[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
This commit is contained in:
Dave Davenport 2020-03-29 16:31:47 +02:00
parent cca9fa3372
commit ca067234ff
2 changed files with 9 additions and 2 deletions

View File

@ -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 ) );

View File

@ -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;
}