diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-04-17 16:33:45 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-04-17 16:33:58 +0200 |
commit | cbb0f0f34e71630cb59ac4a831daf445f58a6427 (patch) | |
tree | 1114dd2b50aa4a63832e595bec445170f6ba12fb | |
parent | febd5dec458e9fb066dab218b07d6c42b53ea5b1 (diff) |
Connect humanizer controls to settings.
-rw-r--r-- | plugingui/drumkitframecontent.cc | 12 | ||||
-rw-r--r-- | plugingui/drumkitframecontent.h | 4 | ||||
-rw-r--r-- | plugingui/frame.cc | 13 | ||||
-rw-r--r-- | plugingui/frame.h | 9 | ||||
-rw-r--r-- | plugingui/humanizerframecontent.cc | 51 | ||||
-rw-r--r-- | plugingui/humanizerframecontent.h | 26 | ||||
-rw-r--r-- | plugingui/maintab.cc | 14 | ||||
-rw-r--r-- | plugingui/maintab.h | 7 |
8 files changed, 103 insertions, 33 deletions
diff --git a/plugingui/drumkitframecontent.cc b/plugingui/drumkitframecontent.cc index 47f5381..9a51b11 100644 --- a/plugingui/drumkitframecontent.cc +++ b/plugingui/drumkitframecontent.cc @@ -87,13 +87,13 @@ DrumkitframeContent::DrumkitframeContent(Widget* parent, { layout.setHAlignment(HAlignment::left); - drumkitCaption.setText("Drumkit file:"); - midimapCaption.setText("Midimap file:"); + drumkit_caption.setText("Drumkit file:"); + midimap_caption.setText("Midimap file:"); - layout.addItem(&drumkitCaption); + layout.addItem(&drumkit_caption); layout.addItem(&drumkit_file); layout.addItem(&drumkit_file_progress); - layout.addItem(&midimapCaption); + layout.addItem(&midimap_caption); layout.addItem(&midimap_file); layout.addItem(&midimap_file_progress); @@ -130,11 +130,11 @@ void DrumkitframeContent::resize(std::size_t width, std::size_t height) { Widget::resize(width, height); - drumkitCaption.resize(width, 15); + drumkit_caption.resize(width, 15); drumkit_file.resize(width, 37); drumkit_file_progress.resize(drumkit_file.getLineEditWidth(), 11); - midimapCaption.resize(width, 15); + midimap_caption.resize(width, 15); midimap_file.resize(width, 37); midimap_file_progress.resize(drumkit_file.getLineEditWidth(), 11); diff --git a/plugingui/drumkitframecontent.h b/plugingui/drumkitframecontent.h index 143284c..425898d 100644 --- a/plugingui/drumkitframecontent.h +++ b/plugingui/drumkitframecontent.h @@ -86,8 +86,8 @@ private: VBoxLayout layout{this}; - Label drumkitCaption{this}; - Label midimapCaption{this}; + Label drumkit_caption{this}; + Label midimap_caption{this}; BrowseFile drumkit_file{this}; BrowseFile midimap_file{this}; ProgressBar drumkit_file_progress{this}; diff --git a/plugingui/frame.cc b/plugingui/frame.cc index d0e7dff..ed4a67b 100644 --- a/plugingui/frame.cc +++ b/plugingui/frame.cc @@ -32,7 +32,9 @@ namespace GUI { FrameWidget::FrameWidget(Widget* parent, bool has_switch) - : Widget(parent), is_switched_on(!has_switch), bar_height(24) + : Widget(parent) + , is_switched_on(!has_switch) + , bar_height(24) { if(has_switch) { @@ -82,6 +84,8 @@ void FrameWidget::powerButtonClicked(bool clicked) { is_switched_on = !is_switched_on; + onSwitchChangeNotifier(is_switched_on); + if(content) { content->setVisible(true); @@ -101,6 +105,13 @@ void FrameWidget::setContent(Widget* content) content->setVisible(true); } +void FrameWidget::setOnSwitch(bool on) +{ + is_switched_on = on; + onSwitchChangeNotifier(is_switched_on); + redraw(); +} + void FrameWidget::sizeChanged(int width, int height) { if(content) diff --git a/plugingui/frame.h b/plugingui/frame.h index 1a07db0..04cfeb2 100644 --- a/plugingui/frame.h +++ b/plugingui/frame.h @@ -26,6 +26,8 @@ */ #pragma once +#include <notifier.h> + #include "font.h" #include "powerbutton.h" #include "widget.h" @@ -33,7 +35,8 @@ namespace GUI { -class FrameWidget : public Widget +class FrameWidget + : public Widget { public: FrameWidget(Widget* parent, bool has_switch = false); @@ -48,6 +51,10 @@ public: void setTitle(std::string const& title); void setContent(Widget* content); + void setOnSwitch(bool on); + + Notifier<bool> onSwitchChangeNotifier; // (bool on) + protected: // From Widget: virtual void repaintEvent(RepaintEvent* repaintEvent) override; diff --git a/plugingui/humanizerframecontent.cc b/plugingui/humanizerframecontent.cc index 9795b76..d8363b9 100644 --- a/plugingui/humanizerframecontent.cc +++ b/plugingui/humanizerframecontent.cc @@ -26,38 +26,57 @@ */ #include "humanizerframecontent.h" +#include <settings.h> + #include "painter.h" namespace GUI { -HumanizerframeContent::HumanizerframeContent(Widget* parent) : Widget(parent) +HumanizerframeContent::HumanizerframeContent(Widget* parent, + Settings& settings, + SettingsNotifier& settings_notifier) + : Widget(parent) + , settings(settings) + , settings_notifier(settings_notifier) { // FIXME, is resizeChildren broken? layout.setResizeChildren(true); layout.setVAlignment(VAlignment::center); attack.resize(80, 80); - attackKnob.resize(30, 30); - attackKnob.showValue(false); - attack.setControl(&attackKnob); + attack_knob.resize(30, 30); + attack_knob.showValue(false); + attack.setControl(&attack_knob); layout.addItem(&attack); falloff.resize(80, 80); - falloffKnob.resize(30, 30); - falloffKnob.showValue(false); - falloff.setControl(&falloffKnob); + falloff_knob.resize(30, 30); + falloff_knob.showValue(false); + falloff.setControl(&falloff_knob); layout.addItem(&falloff); - // TODO: connect the knobs to the right functions - // CONNECT(&humanizeControls->velocityCheck, stateChangedNotifier, - // this, &DGWindow::velocityCheckClick); - // - // CONNECT(&humanizeControls->attackKnob, valueChangedNotifier, - // this, &DGWindow::attackValueChanged); - // - // CONNECT(&humanizeControls->falloffKnob, valueChangedNotifier, - // this, &DGWindow::falloffValueChanged); + CONNECT(this, settings_notifier.velocity_modifier_falloff, + &falloff_knob, &Knob::setValue); + CONNECT(this, settings_notifier.velocity_modifier_weight, + &attack_knob, &Knob::setValue); + + CONNECT(&attack_knob, valueChangedNotifier, + this, &HumanizerframeContent::attackValueChanged); + + CONNECT(&falloff_knob, valueChangedNotifier, + this, &HumanizerframeContent::falloffValueChanged); + +} + +void HumanizerframeContent::attackValueChanged(float value) +{ + settings.velocity_modifier_weight.store(value); +} + +void HumanizerframeContent::falloffValueChanged(float value) +{ + settings.velocity_modifier_falloff.store(value); } } // GUI:: diff --git a/plugingui/humanizerframecontent.h b/plugingui/humanizerframecontent.h index 0196ea5..f6895dd 100644 --- a/plugingui/humanizerframecontent.h +++ b/plugingui/humanizerframecontent.h @@ -33,14 +33,19 @@ #include <iomanip> #include <sstream> +struct Settings; +class SettingsNotifier; + namespace GUI { // TODO move this to an own file? -class LabeledControl : public Widget +class LabeledControl + : public Widget { public: - LabeledControl(Widget* parent, const std::string& name) : Widget(parent) + LabeledControl(Widget* parent, const std::string& name) + : Widget(parent) { layout.setResizeChildren(false); layout.setHAlignment(HAlignment::center); @@ -76,19 +81,28 @@ private: } }; -class HumanizerframeContent : public Widget +class HumanizerframeContent + : public Widget { public: - HumanizerframeContent(Widget* parent); + HumanizerframeContent(Widget* parent, + Settings& settings, + SettingsNotifier& settings_notifier); private: + void attackValueChanged(float value); + void falloffValueChanged(float value); + HBoxLayout layout{this}; LabeledControl attack{this, "Attack"}; LabeledControl falloff{this, "Release"}; - Knob attackKnob{&attack}; - Knob falloffKnob{&falloff}; + Knob attack_knob{&attack}; + Knob falloff_knob{&falloff}; + + Settings& settings; + SettingsNotifier& settings_notifier; }; } // GUI:: diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc index bed26ba..3e5a816 100644 --- a/plugingui/maintab.cc +++ b/plugingui/maintab.cc @@ -34,6 +34,9 @@ MainTab::MainTab(Widget* parent, SettingsNotifier& settings_notifier) : Widget(parent) , drumkitframe_content{this, settings, settings_notifier} + , humanizerframe_content{this, settings, settings_notifier} + , settings(settings) + , settings_notifier(settings_notifier) { layout.setSpacing(0); layout.setResizeChildren(true); @@ -65,6 +68,17 @@ MainTab::MainTab(Widget* parent, status_frame.setContent(&statusframe_content); humanizer_frame.setContent(&humanizerframe_content); diskstreaming_frame.setContent(&diskstreamingframe_content); + + CONNECT(this, settings_notifier.enable_velocity_modifier, + &humanizer_frame, &FrameWidget::setOnSwitch); + + CONNECT(&humanizer_frame, onSwitchChangeNotifier, + this, &MainTab::humanizerOnChange); +} + +void MainTab::humanizerOnChange(bool on) +{ + settings.enable_velocity_modifier.store(on); } } // GUI:: diff --git a/plugingui/maintab.h b/plugingui/maintab.h index 144b075..6f8b7b2 100644 --- a/plugingui/maintab.h +++ b/plugingui/maintab.h @@ -49,6 +49,8 @@ public: SettingsNotifier& settings_notifier); private: + void humanizerOnChange(bool on); + GridLayout layout{this, 2, 40}; FrameWidget drumkit_frame{this, false}; @@ -58,8 +60,11 @@ private: DrumkitframeContent drumkitframe_content; StatusframeContent statusframe_content{this}; - HumanizerframeContent humanizerframe_content{this}; + HumanizerframeContent humanizerframe_content; DiskstreamingframeContent diskstreamingframe_content{this}; + + Settings& settings; + SettingsNotifier& settings_notifier; }; } // GUI:: |