]> git.tdb.fi Git - libs/gltk.git/commitdiff
Implement mouse wheel scrolling in List
authorMikko Rasa <tdb@tdb.fi>
Fri, 6 Mar 2015 00:02:06 +0000 (02:02 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 6 Mar 2015 00:02:06 +0000 (02:02 +0200)
source/list.cpp

index 10c5af84ab100ef8591a1215b6113868657c8f60..f61d7c26dec8f3ba194058050a4411f423e6e646 100644 (file)
@@ -215,15 +215,32 @@ void List::render_special(const Part &part, GL::Renderer &renderer) const
 
 void List::button_press(int x, int y, unsigned btn)
 {
-       Container::button_press(x, y, btn);
-       if(click_focus && btn==1)
+       if(btn==4 || btn==5)
        {
-               for(unsigned i=first; (i<items.size() && items[i]->is_visible()); ++i)
-                       if(click_focus==items[i])
-                       {
-                               set_selected_index(i);
-                               break;
-                       }
+               unsigned change = 3;
+               if(btn==4)
+               {
+                       change = min(first, change);
+                       slider.set_value(max_scroll-(first-change));
+               }
+               else if(btn==5)
+               {
+                       change = min(max_scroll-first, change);
+                       slider.set_value(max_scroll-(first+change));
+               }
+       }
+       else
+       {
+               Container::button_press(x, y, btn);
+               if(click_focus && btn==1)
+               {
+                       for(unsigned i=first; (i<items.size() && items[i]->is_visible()); ++i)
+                               if(click_focus==items[i])
+                               {
+                                       set_selected_index(i);
+                                       break;
+                               }
+               }
        }
 }