Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-01-29 16:17:52 +0000
committerStijn Buys <ingar@osirion.org>2012-01-29 16:17:52 +0000
commit77c5c34cc13b2033afdce8ee87559cfc826fa101 (patch)
treee2492728c7043c12685bb53186fb059240543741 /src
parent144b5123e3b7ef2e511e8906c1cfbcd33024a1fc (diff)
Improved scrollbar handling in ui::ListView
Diffstat (limited to 'src')
-rw-r--r--src/ui/listview.cc14
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)