From ca067234ff70ffc17b820233dd958fd6ec699587 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 29 Mar 2020 16:31:47 +0200 Subject: [PATCH] [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 --- source/widgets/listview.c | 7 +++++++ source/widgets/textbox.c | 4 ++-- 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; }