summaryrefslogtreecommitdiff
path: root/plugingui/dgwindow.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/dgwindow.cc
parentb530ac02af61e320e137a392decef1b3cc5af2c4 (diff)
Refactoring to finally get rid of MessageHandler/Receiver in favor of the new Settings mechanism.
Diffstat (limited to 'plugingui/dgwindow.cc')
-rw-r--r--plugingui/dgwindow.cc113
1 files changed, 73 insertions, 40 deletions
diff --git a/plugingui/dgwindow.cc b/plugingui/dgwindow.cc
index 25cbdf0..c325703 100644
--- a/plugingui/dgwindow.cc
+++ b/plugingui/dgwindow.cc
@@ -30,12 +30,12 @@
#include "verticalline.h"
#include "../version.h"
-#include "messagehandler.h"
#include "pluginconfig.h"
namespace GUI {
-class LabeledControl : public Widget
+class LabeledControl
+ : public Widget
{
public:
LabeledControl(Widget* parent, const std::string& name)
@@ -60,7 +60,8 @@ public:
Label caption{this};
};
-class File : public Widget
+class File
+ : public Widget
{
public:
File(Widget* parent)
@@ -83,7 +84,8 @@ public:
Button browseButton{this};
};
-class HumanizeControls : public Widget
+class HumanizeControls
+ : public Widget
{
public:
HumanizeControls(Widget* parent)
@@ -119,10 +121,8 @@ public:
Knob falloffKnob{&falloff};
};
-DGWindow::DGWindow(void* native_window, MessageHandler& messageHandler,
- Config& config, Settings& settings)
+DGWindow::DGWindow(void* native_window, Config& config, Settings& settings)
: Window(native_window)
- , messageHandler(messageHandler)
, config(config)
, settings(settings)
{
@@ -180,6 +180,7 @@ DGWindow::DGWindow(void* native_window, MessageHandler& messageHandler,
midimapFileProgress = new ProgressBar(this);
midimapFileProgress->resize(width() - 40, 11);
+ midimapFileProgress->setTotal(2);
layout.addItem(midimapFileProgress);
VerticalLine *l2 = new VerticalLine(this);
@@ -208,7 +209,7 @@ DGWindow::DGWindow(void* native_window, MessageHandler& messageHandler,
layout.addItem(l3);
Label *lbl_version = new Label(this);
- lbl_version->setText(".::. v" VERSION " .::. http://www.drumgizmo.org .::. LGPLv3 .::.");
+ lbl_version->setText(".::. v" VERSION " .::. http://www.drumgizmo.org .::. LGPLv3 .::.");
lbl_version->resize(width(), 20);
lbl_version->setAlignment(TextAlignment::center);
layout.addItem(lbl_version);
@@ -220,6 +221,50 @@ DGWindow::DGWindow(void* native_window, MessageHandler& messageHandler,
fileBrowser->hide();
}
+void DGWindow::setDrumKitLoadStatus(LoadStatus load_status)
+{
+ ProgressBarState state = ProgressBarState::Blue;
+ switch(load_status)
+ {
+ case LoadStatus::Idle:
+ case LoadStatus::Loading:
+ state = ProgressBarState::Blue;
+ break;
+ case LoadStatus::Done:
+ state = ProgressBarState::Green;
+ break;
+ case LoadStatus::Error:
+ state = ProgressBarState::Red;
+ break;
+ }
+ drumkitFileProgress->setState(state);
+}
+
+void DGWindow::setMidiMapLoadStatus(LoadStatus load_status)
+{
+ ProgressBarState state = ProgressBarState::Blue;
+ switch(load_status)
+ {
+ case LoadStatus::Idle:
+ midimapFileProgress->setValue(0);
+ break;
+ case LoadStatus::Loading:
+ midimapFileProgress->setValue(1);
+ state = ProgressBarState::Blue;
+ break;
+ case LoadStatus::Done:
+ midimapFileProgress->setValue(2);
+ state = ProgressBarState::Green;
+ break;
+ case LoadStatus::Error:
+ midimapFileProgress->setValue(2);
+ state = ProgressBarState::Red;
+ break;
+ }
+
+ midimapFileProgress->setState(state);
+}
+
void DGWindow::repaintEvent(RepaintEvent* repaintEvent)
{
if(!visible())
@@ -234,45 +279,41 @@ void DGWindow::repaintEvent(RepaintEvent* repaintEvent)
void DGWindow::attackValueChanged(float value)
{
- //ChangeSettingMessage *msg =
- // new ChangeSettingMessage(ChangeSettingMessage::velocity_modifier_weight,
- // value);
- //messageHandler.sendMessage(MSGRCV_ENGINE, msg);
-
settings.velocity_modifier_weight.store(value);
-#ifdef STANDALONE
+#ifdef STANDALONE // For GUI debugging
int i = value * 4;
switch(i) {
- case 0: drumkitFileProgress->setState(ProgressBarState::Off); break;
- case 1: drumkitFileProgress->setState(ProgressBarState::Blue); break;
- case 2: drumkitFileProgress->setState(ProgressBarState::Green); break;
- case 3: drumkitFileProgress->setState(ProgressBarState::Red); break;
- default: break;
+ case 0:
+ drumkitFileProgress->setState(ProgressBarState::Off);
+ break;
+ case 1:
+ drumkitFileProgress->setState(ProgressBarState::Blue);
+ break;
+ case 2:
+ drumkitFileProgress->setState(ProgressBarState::Green);
+ break;
+ case 3:
+ drumkitFileProgress->setState(ProgressBarState::Red);
+ break;
+ default:
+ break;
}
#endif
}
void DGWindow::falloffValueChanged(float value)
{
- //ChangeSettingMessage *msg =
- // new ChangeSettingMessage(ChangeSettingMessage::velocity_modifier_falloff,
- // value);
- //messageHandler.sendMessage(MSGRCV_ENGINE, msg);
-
settings.velocity_modifier_falloff.store(value);
-#ifdef STANDALONE
- drumkitFileProgress->setProgress(value);
+#ifdef STANDALONE // For GUI debugging
+ drumkitFileProgress->setTotal(100);
+ drumkitFileProgress->setValue(value * 100);
#endif
}
void DGWindow::velocityCheckClick(bool checked)
{
-// ChangeSettingMessage *msg =
-// new ChangeSettingMessage(ChangeSettingMessage::enable_velocity_modifier,
-// checked);
-// messageHandler.sendMessage(MSGRCV_ENGINE, msg);
settings.enable_velocity_modifier.store(checked);
}
@@ -323,13 +364,7 @@ void DGWindow::selectKitFile(const std::string& filename)
config.lastkit = drumkit;
config.save();
- drumkitFileProgress->setProgress(0);
- drumkitFileProgress->setState(ProgressBarState::Blue);
-
- LoadDrumKitMessage *msg = new LoadDrumKitMessage();
- msg->drumkitfile = drumkit;
-
- messageHandler.sendMessage(MSGRCV_ENGINE, msg);
+ settings.drumkit_file.store(drumkit);
}
void DGWindow::selectMapFile(const std::string& filename)
@@ -342,9 +377,7 @@ void DGWindow::selectMapFile(const std::string& filename)
config.lastmidimap = midimap;
config.save();
- LoadMidimapMessage *msg = new LoadMidimapMessage();
- msg->midimapfile = midimap;
- messageHandler.sendMessage(MSGRCV_ENGINE, msg);
+ settings.midimap_file.store(midimap);
}