diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-09 13:52:47 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-09 13:52:47 +0100 |
commit | 7dd94e3415b1d65c251c80d012f16ad183b38e7d (patch) | |
tree | 5de7d2a4189bc7a377eb7454ca5e867a9800bdc5 /plugingui | |
parent | 9d3ca6da69096d5904cbe16d0f8778e6c14537e8 (diff) |
Add scollwheel support for knob widget.
Diffstat (limited to 'plugingui')
-rw-r--r-- | plugingui/knob.cc | 11 | ||||
-rw-r--r-- | plugingui/knob.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/plugingui/knob.cc b/plugingui/knob.cc index 75a7278..d60ecc4 100644 --- a/plugingui/knob.cc +++ b/plugingui/knob.cc @@ -64,6 +64,17 @@ void GUI::Knob::registerClickHandler(void (*handler)(void *), void *ptr) this->ptr = ptr; } +void GUI::Knob::scrollEvent(ScrollEvent *e) +{ + val -= e->delta / 200.0; + if(val < 0) val = 0; + if(val > 1) val = 1; + + if(handler) handler(ptr); + + repaintEvent(NULL); +} + void GUI::Knob::mouseMoveEvent(MouseMoveEvent *e) { if(state == down) { diff --git a/plugingui/knob.h b/plugingui/knob.h index 98ccf36..a78361b 100644 --- a/plugingui/knob.h +++ b/plugingui/knob.h @@ -48,6 +48,7 @@ public: virtual void repaintEvent(RepaintEvent *e); virtual void buttonEvent(ButtonEvent *e); virtual void mouseMoveEvent(MouseMoveEvent *e); + virtual void scrollEvent(ScrollEvent *e); private: typedef enum { |