diff options
author | André Nusser <andre.nusser@googlemail.com> | 2018-06-08 16:40:01 +0200 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2018-06-08 16:40:01 +0200 |
commit | 42003bd802d868182bf040e86f2cf2773b8ee851 (patch) | |
tree | 86c345b86d0d7567ee1301fb28f20bcc11e80f97 /plugingui | |
parent | c00110f801ae9de05a7f4c250918e4c05588b1d9 (diff) |
Add reset on double click for all the knobs.
Diffstat (limited to 'plugingui')
-rw-r--r-- | plugingui/humanizerframecontent.cc | 19 | ||||
-rw-r--r-- | plugingui/humanizerframecontent.h | 3 | ||||
-rw-r--r-- | plugingui/knob.cc | 12 | ||||
-rw-r--r-- | plugingui/knob.h | 2 | ||||
-rw-r--r-- | plugingui/timingframecontent.cc | 59 | ||||
-rw-r--r-- | plugingui/timingframecontent.h | 9 |
6 files changed, 85 insertions, 19 deletions
diff --git a/plugingui/humanizerframecontent.cc b/plugingui/humanizerframecontent.cc index dbb6007..51725d6 100644 --- a/plugingui/humanizerframecontent.cc +++ b/plugingui/humanizerframecontent.cc @@ -45,18 +45,21 @@ HumanizerframeContent::HumanizerframeContent(Widget* parent, attack.resize(80, 80); attack_knob.resize(30, 30); attack_knob.showValue(false); + attack_knob.setDefaultValue(Settings::velocity_modifier_weight_default); attack.setControl(&attack_knob); layout.addItem(&attack); falloff.resize(80, 80); falloff_knob.resize(30, 30); falloff_knob.showValue(false); + falloff_knob.setDefaultValue(Settings::velocity_modifier_falloff_default); falloff.setControl(&falloff_knob); layout.addItem(&falloff); stddev.resize(80, 80); stddev_knob.resize(30, 30); stddev_knob.showValue(false); + stddev_knob.setDefaultValue(stddevSettingsToKnob(Settings::velocity_stddev_default)); stddev.setControl(&stddev_knob); layout.addItem(&stddev); @@ -79,6 +82,16 @@ HumanizerframeContent::HumanizerframeContent(Widget* parent, this, &HumanizerframeContent::stddevKnobValueChanged); } +float HumanizerframeContent::stddevSettingsToKnob(float value) +{ + return (value - 0.5f) / 3.0f; +} + +float HumanizerframeContent::stddevKnobToSettings(float value) +{ + return value * 3.0f + 0.5f; +} + void HumanizerframeContent::attackValueChanged(float value) { settings.velocity_modifier_weight.store(value); @@ -91,12 +104,14 @@ void HumanizerframeContent::falloffValueChanged(float value) void HumanizerframeContent::stddevKnobValueChanged(float value) { - settings.velocity_stddev.store(value * 3.0f + 0.5f ); + auto settings_value = stddevKnobToSettings(value); + settings.velocity_stddev.store(settings_value); } void HumanizerframeContent::stddevSettingsValueChanged(float value) { - stddev_knob.setValue((value - 0.5f) / 3.0f); + auto knob_value = stddevSettingsToKnob(value); + stddev_knob.setValue(knob_value); } } // GUI:: diff --git a/plugingui/humanizerframecontent.h b/plugingui/humanizerframecontent.h index 8286116..1fdc83c 100644 --- a/plugingui/humanizerframecontent.h +++ b/plugingui/humanizerframecontent.h @@ -46,6 +46,9 @@ public: SettingsNotifier& settings_notifier); private: + float stddevSettingsToKnob(float value); + float stddevKnobToSettings(float value); + void attackValueChanged(float value); void falloffValueChanged(float value); void stddevKnobValueChanged(float value); 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; } } diff --git a/plugingui/knob.h b/plugingui/knob.h index d8771d8..fc71511 100644 --- a/plugingui/knob.h +++ b/plugingui/knob.h @@ -44,6 +44,7 @@ public: bool isFocusable() override { return true; } void setValue(float value); + void setDefaultValue(float value); void setRange(float minimum, float maximum); float value(); void showValue(bool show_value); @@ -72,6 +73,7 @@ private: state_t state; float current_value; + float default_value = 0.0; float maximum; float minimum; diff --git a/plugingui/timingframecontent.cc b/plugingui/timingframecontent.cc index fef4d33..3a29c6b 100644 --- a/plugingui/timingframecontent.cc +++ b/plugingui/timingframecontent.cc @@ -28,8 +28,6 @@ #include <cmath> -#include <settings.h> - #include "painter.h" namespace GUI @@ -47,18 +45,21 @@ TimingframeContent::TimingframeContent(Widget* parent, tightness.resize(80, 80); tightness_knob.resize(30, 30); tightness_knob.showValue(false); + tightness_knob.setDefaultValue(tightnessSettingsToKnob(Settings::latency_stddev_default)); tightness.setControl(&tightness_knob); layout.addItem(&tightness); regain.resize(80, 80); regain_knob.resize(30, 30); regain_knob.showValue(false); + regain_knob.setDefaultValue(Settings::latency_regain_default); regain.setControl(®ain_knob); layout.addItem(®ain); laidback.resize(80, 80); laidback_knob.resize(30, 30); laidback_knob.showValue(false); + laidback_knob.setDefaultValue(laidbackSettingsToKnob(Settings::latency_laid_back_default)); laidback.setControl(&laidback_knob); layout.addItem(&laidback); // set range to [-1, 1] @@ -85,20 +86,53 @@ TimingframeContent::TimingframeContent(Widget* parent, } -void TimingframeContent::tightnessKnobValueChanged(float value) +float TimingframeContent::thightnessKnobToSettings(float value) { value -= 1.0f; value *= -1.0f; value *= 500.0f; - settings.latency_stddev.store(value); + + return value; } -void TimingframeContent::tightnessSettingsValueChanged(float value) +float TimingframeContent::tightnessSettingsToKnob(float value) { value /= 500.0f; value *= -1.0f; value += 1.0f; - tightness_knob.setValue(value); + + return value; +} + +float TimingframeContent::laidbackKnobToSettings(float value) +{ + value -= 0.5f; + value *= 2.0f; + value *= settings.latency_max.load(); + + return std::lround(value); +} + +float TimingframeContent::laidbackSettingsToKnob(int int_value) +{ + float value = int_value; + value /= (float)settings.latency_max.load(); + value *= 0.5; + value += 0.5; + + return value; +} + +void TimingframeContent::tightnessKnobValueChanged(float value) +{ + auto settings_value = thightnessKnobToSettings(value); + settings.latency_stddev.store(settings_value); +} + +void TimingframeContent::tightnessSettingsValueChanged(float value) +{ + auto knob_value = tightnessSettingsToKnob(value); + tightness_knob.setValue(knob_value); } void TimingframeContent::regainKnobValueChanged(float value) @@ -113,19 +147,14 @@ void TimingframeContent::regainSettingsValueChanged(float value) void TimingframeContent::laidbackKnobValueChanged(float value) { - value -= 0.5f; - value *= 2.0f; - value *= settings.latency_max.load(); - settings.latency_laid_back.store(std::lround(value)); + auto settings_value = laidbackKnobToSettings(value); + settings.latency_laid_back.store(settings_value); } void TimingframeContent::laidbackSettingsValueChanged(int int_value) { - float value = int_value; - value /= (float)settings.latency_max.load(); - value *= 0.5; - value += 0.5; - laidback_knob.setValue(value); + auto knob_value = laidbackSettingsToKnob(int_value); + laidback_knob.setValue(knob_value); } } // GUI:: diff --git a/plugingui/timingframecontent.h b/plugingui/timingframecontent.h index 6feeabe..dc2ad8b 100644 --- a/plugingui/timingframecontent.h +++ b/plugingui/timingframecontent.h @@ -28,15 +28,15 @@ #include "knob.h" #include "label.h" +#include "labeledcontrol.h" #include "layout.h" #include "widget.h" -#include "labeledcontrol.h" +#include <settings.h> #include <iomanip> #include <sstream> -struct Settings; class SettingsNotifier; namespace GUI @@ -51,6 +51,11 @@ public: SettingsNotifier& settings_notifier); private: + float thightnessKnobToSettings(float value); + float tightnessSettingsToKnob(float value); + float laidbackKnobToSettings(float value); + float laidbackSettingsToKnob(int int_value); + void tightnessKnobValueChanged(float value); void tightnessSettingsValueChanged(float value); void regainKnobValueChanged(float value); |