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:
parent
47c7518656
commit
ad91f9a124
2 changed files with 9 additions and 10 deletions
|
@ -459,14 +459,14 @@ static gpointer drun_icon_fetch ( gpointer data )
|
||||||
// this should be fine running in another thread.
|
// this should be fine running in another thread.
|
||||||
DRunModePrivateData *pd = (DRunModePrivateData *) data;
|
DRunModePrivateData *pd = (DRunModePrivateData *) data;
|
||||||
DRunModeEntry *dr;
|
DRunModeEntry *dr;
|
||||||
gsize i = 0;
|
gsize i = 0;
|
||||||
const gchar *themes[4];
|
const gchar *themes[4];
|
||||||
if ( config.drun_icon_theme != NULL ) {
|
if ( config.drun_icon_theme != NULL ) {
|
||||||
themes[i++] = config.drun_icon_theme;
|
themes[i++] = config.drun_icon_theme;
|
||||||
}
|
}
|
||||||
themes[i++] = "Adwaita";
|
themes[i++] = "Adwaita";
|
||||||
themes[i++] = "gnome";
|
themes[i++] = "gnome";
|
||||||
themes[i] = NULL;
|
themes[i] = NULL;
|
||||||
|
|
||||||
while ( ( dr = g_async_queue_pop ( pd->icon_fetch_queue ) ) != &( pd->quit_entry ) ) {
|
while ( ( dr = g_async_queue_pop ( pd->icon_fetch_queue ) ) != &( pd->quit_entry ) ) {
|
||||||
if ( dr->icon_name == NULL ) {
|
if ( dr->icon_name == NULL ) {
|
||||||
|
|
|
@ -413,14 +413,16 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip the side MARGIN on the X axis.
|
// 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 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 ) {
|
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 ) );
|
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;
|
y += top;
|
||||||
|
|
||||||
|
@ -442,9 +444,6 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
|
||||||
x += offset;
|
x += offset;
|
||||||
|
|
||||||
if ( tb->xalign > 0.001 ) {
|
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 );
|
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 ) );
|
x = tb->xalign * rem + widget_padding_get_left ( WIDGET ( tb ) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue