summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-06-03 14:10:07 +0200
committerDave Davenport <qball@gmpclient.org>2017-06-03 14:10:07 +0200
commit044c55dd2fb8add891298891fc91a2cc89b345d6 (patch)
tree28a4fa106408e5a2f40f0dec2601c9a2bfb94df4 /source
parent21615ccacd630176f6af12e39696f97a89ec68fe (diff)
Fix icon offset.
- Always add more ()
Diffstat (limited to 'source')
-rw-r--r--source/widgets/textbox.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index 244903b6..9cdc89a3 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -327,7 +327,7 @@ void textbox_icon ( textbox *tb, cairo_surface_t *icon )
// within the parent handled auto width/height modes
void textbox_moveresize ( textbox *tb, int x, int y, int w, int h )
{
- unsigned int offset = tb->left_offset + ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0;
+ unsigned int offset = tb->left_offset + (( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0);
if ( tb->flags & TB_AUTOWIDTH ) {
pango_layout_set_width ( tb->layout, -1 );
w = textbox_get_font_width ( tb ) + widget_padding_get_padding_width ( WIDGET ( tb ) ) + offset;
@@ -862,9 +862,9 @@ int textbox_get_font_height ( const textbox *tb )
int textbox_get_font_width ( const textbox *tb )
{
- int width;
- pango_layout_get_pixel_size ( tb->layout, &width, NULL );
- return width;
+ PangoRectangle rect;
+ pango_layout_get_pixel_extents ( tb->layout, NULL, &rect );
+ return rect.width+rect.x;
}
/** Caching for the expected character height. */
@@ -897,7 +897,7 @@ int textbox_get_estimated_height ( const textbox *tb, int eh )
int textbox_get_desired_width ( widget *wid )
{
textbox *tb = (textbox *) wid;
- unsigned int offset = tb->left_offset + ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0;
+ unsigned int offset = tb->left_offset + (( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0);
if ( wid->expand && tb->flags & TB_AUTOWIDTH ) {
return textbox_get_font_width ( tb ) + widget_padding_get_padding_width ( wid ) + offset;
}
@@ -907,12 +907,12 @@ int textbox_get_desired_width ( widget *wid )
{
return wi;
}
- int width = 0;
+ int padding = widget_padding_get_left ( WIDGET ( tb ) );
+ padding += widget_padding_get_right ( WIDGET ( tb ) );
+ int old_width = pango_layout_get_width ( tb->layout );
pango_layout_set_width ( tb->layout, -1 );
- width = textbox_get_font_width ( tb );
+ int width = textbox_get_font_width ( tb );
// Restore.
- pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tb->widget.w - widget_padding_get_padding_width ( WIDGET ( tb ) ) - offset ) );
- width = width + widget_padding_get_padding_width ( wid ) + offset;
-
- return width;
+ pango_layout_set_width ( tb->layout, old_width );
+ return width + padding + offset;
}