Fix percentual margin.

This commit is contained in:
Dave Davenport 2017-01-06 20:36:06 +01:00
parent 06c5f51e7d
commit 02dafeeccc
2 changed files with 9 additions and 8 deletions

View File

@ -173,6 +173,7 @@ static void listview_draw ( widget *wid, cairo_t *draw )
int spacing_hori = distance_get_pixel ( lv->spacing, ORIENTATION_HORIZONTAL );
int left_offset = widget_padding_get_left ( wid );
int top_offset = widget_padding_get_top ( wid );
if ( lv->scrollbar->widget.index == 0 ) {
left_offset += spacing_hori + lv->scrollbar->widget.w;
}
@ -193,7 +194,7 @@ static void listview_draw ( widget *wid, cairo_t *draw )
unsigned int ey = wid->h-(widget_padding_get_bottom ( wid ) + ( ( i ) % lv->max_rows ) * ( lv->element_height + spacing_vert ))-lv->element_height;
textbox_moveresize ( lv->boxes[i], ex, ey, element_width, lv->element_height );
} else {
unsigned int ey = widget_padding_get_top ( wid ) + ( ( i ) % lv->max_rows ) * ( lv->element_height + spacing_vert );
unsigned int ey = top_offset + ( ( i ) % lv->max_rows ) * ( lv->element_height + spacing_vert );
textbox_moveresize ( lv->boxes[i], ex, ey, element_width, lv->element_height );
}

View File

@ -100,10 +100,10 @@ void widget_draw ( widget *widget, cairo_t *d )
}
// Store current state.
cairo_save ( d );
int margin_left = distance_get_pixel ( widget->margin.left, ORIENTATION_HORIZONTAL );
int margin_top = distance_get_pixel ( widget->margin.top, ORIENTATION_HORIZONTAL );
int margin_right = distance_get_pixel ( widget->margin.right, ORIENTATION_VERTICAL );
int margin_bottom = distance_get_pixel ( widget->margin.bottom, ORIENTATION_VERTICAL );
int margin_left = distance_get_pixel ( widget->margin.left, ORIENTATION_HORIZONTAL);
int margin_top = distance_get_pixel ( widget->margin.top, ORIENTATION_VERTICAL);
int margin_right = distance_get_pixel ( widget->margin.right, ORIENTATION_HORIZONTAL);
int margin_bottom = distance_get_pixel ( widget->margin.bottom, ORIENTATION_VERTICAL);
// Define a clipmask so we won't draw outside out widget.
cairo_rectangle ( d,
widget->x+margin_left,
@ -119,9 +119,9 @@ void widget_draw ( widget *widget, cairo_t *d )
// Set new x/y possition.
cairo_translate ( d, widget->x, widget->y);
int left = distance_get_pixel ( widget->border.left, ORIENTATION_HORIZONTAL );
int top = distance_get_pixel ( widget->border.top, ORIENTATION_HORIZONTAL );
int right = distance_get_pixel ( widget->border.right, ORIENTATION_VERTICAL );
int left = distance_get_pixel ( widget->border.left, ORIENTATION_HORIZONTAL );
int right = distance_get_pixel ( widget->border.right, ORIENTATION_HORIZONTAL);
int top = distance_get_pixel ( widget->border.top, ORIENTATION_VERTICAL);
int bottom = distance_get_pixel ( widget->border.bottom, ORIENTATION_VERTICAL );
if ( left || top || right || bottom ) {
cairo_save ( d );