From d556005df149558e2614b7019ca4b180f9c44fb8 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 7 Mar 2013 21:10:47 +0100 Subject: Add scrollEvent and use it for scrolling on listbox. --- plugingui/listbox.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'plugingui/listbox.cc') diff --git a/plugingui/listbox.cc b/plugingui/listbox.cc index dfb5f07..f917368 100644 --- a/plugingui/listbox.cc +++ b/plugingui/listbox.cc @@ -125,6 +125,15 @@ void GUI::ListBox::repaintEvent(GUI::RepaintEvent *e) width() - 1, height() - 1); } +void GUI::ListBox::scrollEvent(ScrollEvent *e) +{ + scroll_offset += e->delta; + if(scroll_offset < 0) scroll_offset = 0; + if(scroll_offset > (items.size() - 1)) + scroll_offset = (items.size() - 1); + repaintEvent(NULL); +} + void GUI::ListBox::buttonEvent(ButtonEvent *e) { //printf("click %d %d [dc: %d]\n", e->x, e->y, e->doubleclick); -- cgit v1.2.3