From 02dafeeccca16870a25a11fc6edbaaed8270700b Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 6 Jan 2017 20:36:06 +0100 Subject: [PATCH] Fix percentual margin. --- source/widgets/listview.c | 3 ++- source/widgets/widget.c | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/source/widgets/listview.c b/source/widgets/listview.c index a09e7526..a3015b5d 100644 --- a/source/widgets/listview.c +++ b/source/widgets/listview.c @@ -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 ); } diff --git a/source/widgets/widget.c b/source/widgets/widget.c index 2c227855..fa11506c 100644 --- a/source/widgets/widget.c +++ b/source/widgets/widget.c @@ -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 );