From ad91f9a1241ade8cfaf9bb54a6df6cacffb77315 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Thu, 8 Jun 2017 08:46:16 +0200 Subject: [PATCH] [TextBox] Calculate yalign based on actual side, not estimated size. --- source/dialogs/drun.c | 6 +++--- source/widgets/textbox.c | 13 ++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index 2840a16c..a9d6bd5c 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -459,14 +459,14 @@ static gpointer drun_icon_fetch ( gpointer data ) // this should be fine running in another thread. DRunModePrivateData *pd = (DRunModePrivateData *) data; DRunModeEntry *dr; - gsize i = 0; - const gchar *themes[4]; + gsize i = 0; + const gchar *themes[4]; if ( config.drun_icon_theme != NULL ) { themes[i++] = config.drun_icon_theme; } themes[i++] = "Adwaita"; themes[i++] = "gnome"; - themes[i] = NULL; + themes[i] = NULL; while ( ( dr = g_async_queue_pop ( pd->icon_fetch_queue ) ) != &( pd->quit_entry ) ) { if ( dr->icon_name == NULL ) { diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index c247b388..9a084499 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -413,14 +413,16 @@ static void textbox_draw ( widget *wid, cairo_t *draw ) } // Skip the side MARGIN on the X axis. - int x = widget_padding_get_left ( WIDGET ( tb ) ); + int x = widget_padding_get_left ( WIDGET ( tb ) ); int top = widget_padding_get_top ( WIDGET ( tb ) ); - int y = ( pango_font_metrics_get_ascent ( tb->metrics ) - pango_layout_get_baseline ( tb->layout ) ) / PANGO_SCALE; + int y = ( pango_font_metrics_get_ascent ( tb->metrics ) - pango_layout_get_baseline ( tb->layout ) ) / PANGO_SCALE; + int line_width = 0, line_height = 0; + // Get actual width. + pango_layout_get_pixel_size ( tb->layout, &line_width, &line_height ); if ( tb->yalign > 0.001 ) { - int height = ( pango_font_metrics_get_ascent ( tb->metrics ) + pango_font_metrics_get_descent ( tb->metrics ) ) / PANGO_SCALE; int bottom = widget_padding_get_bottom ( WIDGET ( tb ) ); - top = ( tb->widget.h - bottom - height - top ) * tb->yalign + top; + top = ( tb->widget.h - bottom - line_height - top ) * tb->yalign + top; } y += top; @@ -442,9 +444,6 @@ static void textbox_draw ( widget *wid, cairo_t *draw ) x += offset; if ( tb->xalign > 0.001 ) { - int line_width = 0; - // Get actual width. - pango_layout_get_pixel_size ( tb->layout, &line_width, NULL ); int rem = MAX ( 0, tb->widget.w - widget_padding_get_padding_width ( WIDGET ( tb ) ) - line_width ); x = tb->xalign * rem + widget_padding_get_left ( WIDGET ( tb ) ); }