summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-05-24 19:57:35 +0200
committerDave Davenport <qball@gmpclient.org>2017-05-24 19:57:35 +0200
commite387105091fb9802de474d00035a640bf06dabc3 (patch)
treeada055662a03e97eba2b7c999ae1147c48f7d7b8
parentda092c53ace4ca375d7685d867afc1761e35e377 (diff)
[TextBox] Add 'vertical-align' option
-rw-r--r--include/widgets/textbox.h2
-rw-r--r--source/widgets/textbox.c8
2 files changed, 10 insertions, 0 deletions
diff --git a/include/widgets/textbox.h b/include/widgets/textbox.h
index fc75baa7..8b4c5386 100644
--- a/include/widgets/textbox.h
+++ b/include/widgets/textbox.h
@@ -62,6 +62,8 @@ typedef struct
int blink;
guint blink_timeout;
+ double yalign ;
+
PangoFontMetrics *metrics;
//
const char *theme_name;
diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index c0761f11..150783a1 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -165,6 +165,8 @@ textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType
tb->blink_timeout = g_timeout_add ( 1200, textbox_blink, tb );
}
+ tb->yalign = rofi_theme_get_double ( WIDGET ( tb ), "vertical-align" , 0.0);
+ tb->yalign = MAX ( 0, MIN ( 1.0, tb->yalign));
// Enabled by default
tb->widget.enabled = rofi_theme_get_boolean ( WIDGET ( tb ), "enabled", TRUE );
return tb;
@@ -356,6 +358,11 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
}
int top = widget_padding_get_top ( WIDGET ( tb ) );
+ 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;
+ }
rofi_theme_get_color ( WIDGET ( tb ), "foreground", draw );
// Text
@@ -379,6 +386,7 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
cairo_fill ( draw );
}
+
// Set ARGB
// We need to set over, otherwise subpixel hinting wont work.
cairo_set_operator ( draw, CAIRO_OPERATOR_OVER );