13
0

implement scroll-wheel support for ClickBoxes

This commit is contained in:
Robin Gareus 2015-07-13 15:33:15 +02:00
parent f4229968d9
commit 56ba08b7cb
4 changed files with 32 additions and 0 deletions

View File

@ -143,6 +143,29 @@ AutoSpin::button_press (GdkEventButton *ev)
return TRUE;
}
gint
AutoSpin::scroll_event (GdkEventScroll *ev)
{
stop_spinning (0);
gfloat increment = step_increment;
if (ev->state & Keyboard::TertiaryModifier) {
increment = page_increment;
}
switch (ev->direction) {
case GDK_SCROLL_DOWN:
case GDK_SCROLL_LEFT:
adjust_value (-increment);
break;
case GDK_SCROLL_RIGHT:
case GDK_SCROLL_UP:
adjust_value (increment);
break;
}
}
void
AutoSpin::start_spinning (bool decrement, bool page)
{

View File

@ -62,6 +62,13 @@ ClickBox::button_press_handler (GdkEventButton* ev)
return true;
}
bool
ClickBox::on_scroll_event (GdkEventScroll* ev)
{
AutoSpin::scroll_event (ev);
return true;
}
bool
ClickBox::button_release_handler (GdkEventButton* ev)
{

View File

@ -47,6 +47,7 @@ class LIBGTKMM2EXT_API AutoSpin
gint button_press (GdkEventButton *);
gint stop_spinning (GdkEventButton *ignored_but_here_for_clicked);
void start_spinning (bool decrementing, bool use_page);
gint scroll_event (GdkEventScroll *);
private:
Gtk::Adjustment &adjustment;

View File

@ -57,6 +57,7 @@ class LIBGTKMM2EXT_API ClickBox : public Gtk::DrawingArea, public AutoSpin
void style_changed (const Glib::RefPtr<Gtk::Style> &);
bool button_press_handler (GdkEventButton *);
bool button_release_handler (GdkEventButton *);
bool on_scroll_event (GdkEventScroll*);
sigc::slot<bool, char *, Gtk::Adjustment &> _printer;
};