diff options
author | Stijn Buys <ingar@osirion.org> | 2012-01-29 16:17:52 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2012-01-29 16:17:52 +0000 |
commit | 77c5c34cc13b2033afdce8ee87559cfc826fa101 (patch) | |
tree | e2492728c7043c12685bb53186fb059240543741 | |
parent | 144b5123e3b7ef2e511e8906c1cfbcd33024a1fc (diff) |
Improved scrollbar handling in ui::ListView
-rw-r--r-- | src/ui/listview.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ui/listview.cc b/src/ui/listview.cc index cd87639..9fe9b4e 100644 --- a/src/ui/listview.cc +++ b/src/ui/listview.cc @@ -65,7 +65,7 @@ void ListView::resize() if (total_height - listview_scroll < 0) { // child widget is invisible (*it)->hide(); - } else if ((total_height - listview_scroll) >= height()) { + } else if ((total_height - listview_scroll + (*it)->height()) > height()) { // child widget is invisible (*it)->hide(); } else { @@ -77,9 +77,13 @@ void ListView::resize() } } - listview_scrollbar->set_range(0.0f, total_height); - listview_scrollbar->set_value(listview_scroll); - + if (total_height > height()) { + listview_scrollbar->set_range(0.0f, total_height - height()); + listview_scrollbar->set_value(listview_scroll); + listview_scrollbar->show(); + } else { + listview_scrollbar->hide(); + } } void ListView::deselect() @@ -96,6 +100,7 @@ void ListView::select(ListItem *item) void ListView::clear() { + listview_scroll = 0; listview_selecteditem = 0; remove_children(); @@ -103,6 +108,7 @@ void ListView::clear() listview_scrollbar->set_background(false); listview_scrollbar->set_border(false); listview_scrollbar->set_range(0.0f, 0.0f); + listview_scrollbar->set_value(listview_scroll); } bool ListView::on_emit(Widget *sender, const Event event, void *data) |