From 7dd94e3415b1d65c251c80d012f16ad183b38e7d Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 9 Mar 2013 13:52:47 +0100 Subject: Add scollwheel support for knob widget. --- plugingui/knob.cc | 11 +++++++++++ plugingui/knob.h | 1 + 2 files changed, 12 insertions(+) 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 { -- cgit v1.2.3