summaryrefslogtreecommitdiff
path: root/plugingui/plugingui.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-04-08 00:15:32 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-04-08 00:15:32 +0200
commit057ef1d83ba263fb2adf1aa86f8e281ab0065c43 (patch)
tree31c1f237e3a9df9fc241d87527f7dd4245665d43 /plugingui/plugingui.cc
parentb530ac02af61e320e137a392decef1b3cc5af2c4 (diff)
Refactoring to finally get rid of MessageHandler/Receiver in favor of the new Settings mechanism.
Diffstat (limited to 'plugingui/plugingui.cc')
-rw-r--r--plugingui/plugingui.cc183
1 files changed, 36 insertions, 147 deletions
diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc
index 9bac007..2802c44 100644
--- a/plugingui/plugingui.cc
+++ b/plugingui/plugingui.cc
@@ -26,18 +26,17 @@
*/
#include "plugingui.h"
+#include <iostream>
+
#include <hugin.hpp>
#include "pluginconfig.h"
-#include "messagehandler.h"
-
-#include <iostream>
namespace GUI {
-PluginGUI::PluginGUI(void* native_window)
- : MessageReceiver(MSGRCV_UI)
- , native_window(native_window)
+PluginGUI::PluginGUI(Settings& settings, void* native_window)
+ : native_window(native_window)
+ , settings(settings)
{
init();
}
@@ -46,70 +45,6 @@ PluginGUI::~PluginGUI()
{
}
-void PluginGUI::handleMessage(Message *msg)
-{
- Painter p(*window);// Make sure we only redraw buffer once (set refcount to 1)
-
- switch(msg->type()) {
- case Message::LoadStatus:
- {
- LoadStatusMessage *ls = (LoadStatusMessage*)msg;
- window->drumkitFileProgress->setProgress((float)ls->numer_of_files_loaded /
- (float)ls->number_of_files);
- if(ls->numer_of_files_loaded == ls->number_of_files)
- {
- window->drumkitFileProgress->setState(ProgressBarState::Green);
- }
- }
- break;
- case Message::LoadStatusMidimap:
- {
- LoadStatusMessageMidimap *ls = (LoadStatusMessageMidimap*)msg;
- window->midimapFileProgress->setProgress(1);
- if(ls->success)
- {
- window->midimapFileProgress->setState(ProgressBarState::Green);
- }
- else
- {
- window->midimapFileProgress->setState(ProgressBarState::Red);
- }
- }
- break;
- case Message::EngineSettingsMessage:
- {
- EngineSettingsMessage *settings = (EngineSettingsMessage *)msg;
- window->lineedit->setText(settings->drumkitfile);
- if(settings->drumkit_loaded)
- {
- window->drumkitFileProgress->setProgress(1);
- window->drumkitFileProgress->setState(ProgressBarState::Green);
- }
- else
- {
- window->drumkitFileProgress->setProgress(0);
- window->drumkitFileProgress->setState(ProgressBarState::Blue);
- }
- window->lineedit2->setText(settings->midimapfile);
- if(settings->midimap_loaded)
- {
- window->midimapFileProgress->setProgress(1);
- window->midimapFileProgress->setState(ProgressBarState::Green);
- }
- else
- {
- window->midimapFileProgress->setProgress(0);
- window->midimapFileProgress->setState(ProgressBarState::Blue);
- }
- window->velocityCheck->setChecked(settings->enable_velocity_modifier);
- window->attackKnob->setValue(settings->velocity_modifier_weight);
- window->falloffKnob->setValue(settings->velocity_modifier_falloff);
- }
- default:
- break;
- }
-}
-
bool PluginGUI::processEvents()
{
if(!initialised)
@@ -118,69 +53,13 @@ bool PluginGUI::processEvents()
}
window->eventHandler()->processEvents();
- //handleMessages();
-
- static bool foo = false;
- static int t = 0;
- if(t != time(nullptr))
- {
- t = time(nullptr);
- foo = !foo;
- float v = settings.velocity_modifier_falloff.load();
- v += 0.1f;
- settings.velocity_modifier_falloff.store(v);
- }
-
- Painter p(*window);
-
- // Run through all settings one at a time propagate changes to the UI.
- if(getter.enable_velocity_modifier.hasChanged())
- {
- enable_velocity_modifier_notifier(getter.enable_velocity_modifier.getValue());
- }
- if(getter.velocity_modifier_falloff.hasChanged())
{
- velocity_modifier_falloff_notifier(getter.velocity_modifier_falloff.getValue());
- }
+ Painter p(*window);
- if(getter.velocity_modifier_weight.hasChanged())
- {
- velocity_modifier_weight_notifier(getter.velocity_modifier_weight.getValue());
- }
-
- if(getter.enable_velocity_randomiser.hasChanged())
- {
- enable_velocity_randomiser_notifier(getter.enable_velocity_randomiser.getValue());
+ settings_notifier.evaluate();
}
- if(getter.velocity_randomiser_weight.hasChanged())
- {
- velocity_randomiser_weight_notifier(getter.velocity_randomiser_weight.getValue());
- }
-
- if(getter.samplerate.hasChanged())
- {
- samplerate_notifier(getter.samplerate.getValue());
- }
-
- if(getter.enable_resampling.hasChanged())
- {
- enable_resampling_notifier(getter.enable_resampling.getValue());
- }
-
- if(getter.number_of_files.hasChanged() ||
- getter.number_of_files_loaded.hasChanged())
- {
- drumkit_file_progress_notifier((float)getter.number_of_files_loaded.getValue() /
- (float)getter.number_of_files.getValue());
- }
-
- //if(getter.current_file.hasChanged())
- //{
- // current_file_notifier(getter.current_file.getValue());
- //}
-
if(closing)
{
closeNotifier();
@@ -198,41 +77,51 @@ void PluginGUI::init()
config = new Config();
config->load();
- window = new DGWindow(native_window, msghandler, *config, settings);
+ window = new DGWindow(native_window, *config, settings);
+
+
+ CONNECT(this, settings_notifier.drumkit_file,
+ window->lineedit, &LineEdit::setText);
+ CONNECT(this, settings_notifier.drumkit_load_status,
+ window, &DGWindow::setDrumKitLoadStatus);
- CONNECT(this, enable_velocity_modifier_notifier,
+ CONNECT(this, settings_notifier.midimap_file,
+ window->lineedit2, &LineEdit::setText);
+ CONNECT(this, settings_notifier.midimap_load_status,
+ window, &DGWindow::setMidiMapLoadStatus);
+
+ CONNECT(this, settings_notifier.enable_velocity_modifier,
window->velocityCheck, &CheckBox::setChecked);
- CONNECT(this, velocity_modifier_falloff_notifier,
+ CONNECT(this, settings_notifier.velocity_modifier_falloff,
window->falloffKnob, &Knob::setValue);
- CONNECT(this, velocity_modifier_weight_notifier,
+ CONNECT(this, settings_notifier.velocity_modifier_weight,
window->attackKnob, &Knob::setValue);
- //CONNECT(this, enable_velocity_randomiser_notifier,
- // window->velocityCheck, &CheckBox::setChecked);
- //CONNECT(this, velocity_randomiser_weight_notifier,
- // window->velocityCheck, &CheckBox::setChecked);
+ // TODO:
+ //CONNECT(this, settings_notifier.enable_velocity_randomiser,
+ // window->, &CheckBox::setChecked);
+ //CONNECT(this, settings_notifier.velocity_randomiser_weight,
+ // window->, &Knob::setValue);
+
+ //CONNECT(this, settings_notifier.samplerate,
+ // window->, &Knob::setValue);
- //CONNECT(this, samplerate_notifier,
- // window->velocityCheck, &CheckBox::setChecked);
+ //CONNECT(this, settings_notifier.enable_resampling,
+ // window->, &CheckBox::setChecked);
- //CONNECT(this, enable_resampling_notifier,
- // window->velocityCheck, &CheckBox::setChecked);
+ CONNECT(this, settings_notifier.number_of_files,
+ window->drumkitFileProgress, &ProgressBar::setTotal);
- CONNECT(this, drumkit_file_progress_notifier,
- window->drumkitFileProgress, &ProgressBar::setProgress);
+ CONNECT(this, settings_notifier.number_of_files_loaded,
+ window->drumkitFileProgress, &ProgressBar::setValue);
auto eventHandler = window->eventHandler();
CONNECT(eventHandler, closeNotifier, this, &PluginGUI::closeEventHandler);
window->show();
- { // Request all engine settings
- EngineSettingsMessage *msg = new EngineSettingsMessage();
- msghandler.sendMessage(MSGRCV_ENGINE, msg);
- }
-
initialised = true;
}