1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

[TextBox] Calculate yalign based on actual side, not estimated size.

This commit is contained in:
Dave Davenport 2017-06-08 08:46:16 +02:00
parent 47c7518656
commit ad91f9a124
2 changed files with 9 additions and 10 deletions

View file

@ -416,11 +416,13 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
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 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 ) );
}