diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2015-09-03 15:54:10 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2015-09-03 15:54:10 +0200 |
commit | 1b5859154efb69e212f4d627e761fbed76c50aa3 (patch) | |
tree | 17cbb3bd1bf01711845b67d7ed8d9c81a60f825c /plugingui/knob.h | |
parent | 36faa43c90023297377d56662d310743d93b938f (diff) |
Introduce new Notifier and use it in the Knob class.
Diffstat (limited to 'plugingui/knob.h')
-rw-r--r-- | plugingui/knob.h | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/plugingui/knob.h b/plugingui/knob.h index a6af499..d14a5b3 100644 --- a/plugingui/knob.h +++ b/plugingui/knob.h @@ -24,13 +24,14 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __DRUMGIZMO_KNOB_H__ -#define __DRUMGIZMO_KNOB_H__ +#pragma once #include "widget.h" #include "image.h" +#include "notifier.h" + namespace GUI { class Knob : public Widget { @@ -43,38 +44,37 @@ public: void setValue(float value); float value(); - void registerClickHandler(void (*handler)(void *), void *ptr); + Notifier<float> valueChangedNotifier; // (float newValue) - //protected: +protected: virtual void clicked() {} - virtual void repaintEvent(RepaintEvent *e); - virtual void buttonEvent(ButtonEvent *e); - virtual void mouseMoveEvent(MouseMoveEvent *e); - virtual void scrollEvent(ScrollEvent *e); - virtual void keyEvent(KeyEvent *e); + // From Widget: + virtual void repaintEvent(RepaintEvent *e) override; + virtual void buttonEvent(ButtonEvent *e) override; + virtual void mouseMoveEvent(MouseMoveEvent *e) override; + virtual void scrollEvent(ScrollEvent *e) override; + virtual void keyEvent(KeyEvent *e) override; private: + //! Sets the internal value and sends out the changed notification. + void internalSetValue(float value); + typedef enum { up, down } state_t; - float val; - float maximum; - float minimum; - state_t state; - GUI::Image img_knob; + float currentValue; + float maximum; + float minimum; - void (*handler)(void *); - void *ptr; + Image img_knob; int mouse_offset_x; - }; -}; +} // GUI:: -#endif/*__DRUMGIZMO_KNOB_H__*/ |