summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-03-09 13:52:47 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2013-03-09 13:52:47 +0100
commit7dd94e3415b1d65c251c80d012f16ad183b38e7d (patch)
tree5de7d2a4189bc7a377eb7454ca5e867a9800bdc5
parent9d3ca6da69096d5904cbe16d0f8778e6c14537e8 (diff)
Add scollwheel support for knob widget.
-rw-r--r--plugingui/knob.cc11
-rw-r--r--plugingui/knob.h1
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 {