summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2020-03-29 16:31:47 +0200
committerDave Davenport <qball@gmpclient.org>2020-03-29 16:31:47 +0200
commitca067234ff70ffc17b820233dd958fd6ec699587 (patch)
tree50b6038fb8e6d83414d0524a838ef55e5834d514
parentcca9fa3372f2a4e7970bf1c81890d2c8037f21d5 (diff)
[Textbox|Listview] Fix sizing of textbox.
- don't get height of layout, but calculate height using metrics. - listview, set string with right number of lines. Issue: #925, #1069
-rw-r--r--source/widgets/listview.c7
-rw-r--r--source/widgets/textbox.c4
2 files changed, 9 insertions, 2 deletions
diff --git a/source/widgets/listview.c b/source/widgets/listview.c
index f1eb4197..09ab718d 100644
--- a/source/widgets/listview.c
+++ b/source/widgets/listview.c
@@ -668,6 +668,13 @@ listview *listview_create ( widget *parent, const char *name, listview_update_ca
//
_listview_row row;
listview_create_row ( lv, &row );
+ // FIXME: hack to scale hight correctly.
+ if ( lv->eh > 1 && row.textbox ) {
+ char buff[lv->eh*2+1] ;
+ memset( buff, '\0', lv->eh*2+1);
+ for ( unsigned int i = 0; i < lv->eh; i++) { buff[i] ='\n'; };
+ textbox_text( row.textbox, buff);
+ }
lv->element_height = widget_get_desired_height ( WIDGET ( row.box ) );
widget_free ( WIDGET ( row.box ) );
diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index aa299113..bab5eb9f 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -97,7 +97,7 @@ static int textbox_get_desired_height ( widget *wid )
if ( tb->changed ) {
__textbox_update_pango_text ( tb );
}
- int height = textbox_get_height ( tb );
+ int height = textbox_get_estimated_height ( tb, pango_layout_get_line_count ( tb->layout ) );
return height;
}
@@ -852,7 +852,7 @@ int _textbox_get_height ( widget *wid )
{
textbox *tb = (textbox *) wid;
if ( tb->flags & TB_AUTOHEIGHT ) {
- return textbox_get_height ( tb );
+ return textbox_get_estimated_height ( tb, pango_layout_get_line_count ( tb->layout ) );
}
return tb->widget.h;
}