From 42003bd802d868182bf040e86f2cf2773b8ee851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Fri, 8 Jun 2018 16:40:01 +0200 Subject: Add reset on double click for all the knobs. --- plugingui/knob.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'plugingui/knob.cc') diff --git a/plugingui/knob.cc b/plugingui/knob.cc index 4082aa3..8e60056 100644 --- a/plugingui/knob.cc +++ b/plugingui/knob.cc @@ -61,6 +61,11 @@ void Knob::setValue(float value) internalSetValue(value); } +void Knob::setDefaultValue(float value) +{ + default_value = value; +} + void Knob::setRange(float minimum, float maximum) { this->minimum = minimum; @@ -145,10 +150,16 @@ void Knob::buttonEvent(ButtonEvent* buttonEvent) return; } + if (buttonEvent->doubleClick) { + internalSetValue(default_value); + return; + } + if(buttonEvent->direction == Direction::down) { state = down; mouse_offset_x = buttonEvent->x + (-1 * buttonEvent->y); + return; } if(buttonEvent->direction == Direction::up) @@ -156,6 +167,7 @@ void Knob::buttonEvent(ButtonEvent* buttonEvent) state = up; mouse_offset_x = buttonEvent->x + (-1 * buttonEvent->y); clicked(); + return; } } -- cgit v1.2.3