summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-03-12 17:39:28 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2017-03-23 20:17:52 +0100
commit7860651ee543385bb6d1c229312b20e78150f118 (patch)
tree013bac8986d1753f470db68cfdcbe4c92d00ace8
parent54d0e5d4b13b18668b1c044f197fe528bb43d4a2 (diff)
Preliminary plugin gui for disktreaming control.
-rw-r--r--plugin/drumgizmo_plugin.cc4
-rw-r--r--plugingui/Makefile.am1
-rw-r--r--plugingui/dgwindow.cc148
-rw-r--r--plugingui/dgwindow.h58
-rw-r--r--plugingui/plugingui.cc40
-rw-r--r--plugingui/tests/Makefile.am13
-rw-r--r--plugingui/tests/dgwindowtest.cc65
7 files changed, 247 insertions, 82 deletions
diff --git a/plugin/drumgizmo_plugin.cc b/plugin/drumgizmo_plugin.cc
index f31db98..d6dd371 100644
--- a/plugin/drumgizmo_plugin.cc
+++ b/plugin/drumgizmo_plugin.cc
@@ -62,7 +62,7 @@ DrumGizmoPlugin::DrumGizmoPlugin()
init();
drumgizmo = std::make_shared<DrumGizmo>(settings, output, input);
- resizeWindow(370, 330);
+ resizeWindow(370, 430);
drumgizmo->setFreeWheel(true);
drumgizmo->setSamplerate(44100);
drumgizmo->setFrameSize(2048);
@@ -261,7 +261,7 @@ bool DrumGizmoPlugin::hasGUI()
void DrumGizmoPlugin::createWindow(void *parent)
{
plugin_gui = std::make_shared<GUI::PluginGUI>(settings, parent);
- resizeWindow(370, 330);
+ resizeWindow(370, 430);
onShowWindow();
}
diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am
index 1e90c89..8180788 100644
--- a/plugingui/Makefile.am
+++ b/plugingui/Makefile.am
@@ -8,6 +8,7 @@ libdggui_la_CPPFLAGS = \
$(GUI_CPPFLAGS) \
-I$(top_srcdir)/hugin \
-I$(top_srcdir)/src \
+ -I$(top_srcdir)/include \
-DWITH_HUG_MUTEX $(PTHREAD_CFLAGS) \
-DLODEPNG_NO_COMPILE_ENCODER \
-DLODEPNG_NO_COMPILE_DISK \
diff --git a/plugingui/dgwindow.cc b/plugingui/dgwindow.cc
index 5ff92d6..dc1f7f6 100644
--- a/plugingui/dgwindow.cc
+++ b/plugingui/dgwindow.cc
@@ -31,6 +31,8 @@
#include "../version.h"
#include "pluginconfig.h"
+#include <memchecker.h>
+#include <cpp11fix.h>
namespace GUI {
@@ -121,15 +123,58 @@ public:
Knob falloffKnob{&falloff};
};
-DGWindow::DGWindow(void* native_window, Config& config, Settings& settings)
+class DiskStreamingControls
+ : public Widget
+ , private MemChecker
+{
+public:
+ DiskStreamingControls(Widget* parent)
+ : Widget(parent)
+ {
+ layout.setResizeChildren(false);
+ layout.setVAlignment(VAlignment::center);
+
+ streamer.resize(80, 80);
+ streamerCheck.resize(59, 38);
+ streamer.setControl(&streamerCheck);
+ layout.addItem(&streamer);
+
+ limit.resize(80, 80);
+ float free_mem = calcFreeMemory() / (1024.0 * 1024.0);
+ limitKnob.setRange(std::min(500.0, free_mem / 2.0), free_mem);
+ limitKnob.resize(60, 60);
+ limit.setControl(&limitKnob);
+ layout.addItem(&limit);
+
+ reload_button.setText("Reload");
+ reload_button.resize(100, 50);
+ layout.addItem(&reload_button);
+ }
+
+ HBoxLayout layout{this};
+
+ LabeledControl streamer{this, "Streaming"};
+ LabeledControl limit{this, "MB Limit"};
+
+ CheckBox streamerCheck{&streamer};
+ Knob limitKnob{&limit};
+ Button reload_button{this};
+};
+
+DGWindow::DGWindow(void* native_window, Config& config, Settings& settings,
+ SettingsNotifier& settings_notifier)
: Window(native_window)
, config(config)
, settings(settings)
+ , settings_notifier(settings_notifier)
{
-
int vlineSpacing = 16;
- resize(370, 330);
+ constexpr std::size_t width = 370 + 40;
+ constexpr std::size_t height = 440;
+ constexpr std::size_t border = 60;
+
+ resize(width, height);
setCaption("DrumGizmo v" VERSION);
layout.setResizeChildren(false);
@@ -139,52 +184,52 @@ DGWindow::DGWindow(void* native_window, Config& config, Settings& settings)
auto headerCaption = new Label(this);
headerCaption->setText("DrumGizmo");
headerCaption->setAlignment(TextAlignment::center);
- headerCaption->resize(370 - 40, 32);
+ headerCaption->resize(width - border, 32);
layout.addItem(headerCaption);
auto headerLine = new VerticalLine(this);
- headerLine->resize(370 - 40, vlineSpacing);
+ headerLine->resize(width - border, vlineSpacing);
layout.addItem(headerLine);
auto drumkitCaption = new Label(this);
drumkitCaption->setText("Drumkit file:");
- drumkitCaption->resize(370 - 40, 15);
+ drumkitCaption->resize(width - border, 15);
layout.addItem(drumkitCaption);
auto drumkitFile = new File(this);
- drumkitFile->resize(370 - 40, 37);
+ drumkitFile->resize(width - border, 37);
lineedit = &drumkitFile->lineedit;
CONNECT(&drumkitFile->browseButton, clickNotifier,
this, &DGWindow::kitBrowseClick);
layout.addItem(drumkitFile);
drumkitFileProgress = new ProgressBar(this);
- drumkitFileProgress->resize(370 - 40, 11);
+ drumkitFileProgress->resize(width - border, 11);
layout.addItem(drumkitFileProgress);
VerticalLine *l = new VerticalLine(this);
- l->resize(370 - 40, vlineSpacing);
+ l->resize(width - border, vlineSpacing);
layout.addItem(l);
auto midimapCaption = new Label(this);
midimapCaption->setText("Midimap file:");
- midimapCaption->resize(370 - 40, 15);
+ midimapCaption->resize(width - border, 15);
layout.addItem(midimapCaption);
auto midimapFile = new File(this);
- midimapFile->resize(370 - 40, 37);
+ midimapFile->resize(width - border, 37);
lineedit2 = &midimapFile->lineedit;
CONNECT(&midimapFile->browseButton, clickNotifier,
this, &DGWindow::midimapBrowseClick);
layout.addItem(midimapFile);
midimapFileProgress = new ProgressBar(this);
- midimapFileProgress->resize(370 - 40, 11);
+ midimapFileProgress->resize(width - border, 11);
midimapFileProgress->setTotal(2);
layout.addItem(midimapFileProgress);
VerticalLine *l2 = new VerticalLine(this);
- l2->resize(370 - 40, vlineSpacing);
+ l2->resize(width - border, vlineSpacing);
layout.addItem(l2);
HumanizeControls* humanizeControls = new HumanizeControls(this);
@@ -205,20 +250,70 @@ DGWindow::DGWindow(void* native_window, Config& config, Settings& settings)
falloffKnob = &humanizeControls->falloffKnob;
VerticalLine *l3 = new VerticalLine(this);
- l3->resize(370 - 40, vlineSpacing);
+ l3->resize(width - border, vlineSpacing);
layout.addItem(l3);
+ disk_streaming_controls = new DiskStreamingControls(this);
+ disk_streaming_controls->resize(80 * 3, 80);
+ layout.addItem(disk_streaming_controls);
+ CONNECT(&disk_streaming_controls->streamerCheck, stateChangedNotifier,
+ this, &DGWindow::streamerCheckClick);
+
+ CONNECT(&disk_streaming_controls->limitKnob, valueChangedNotifier,
+ this, &DGWindow::limitValueChanged);
+
+ CONNECT(&disk_streaming_controls->reload_button, clickNotifier,
+ this, &DGWindow::reloadClicked);
+
+ VerticalLine *l4 = new VerticalLine(this);
+ l4->resize(width - border, vlineSpacing);
+ layout.addItem(l4);
+
Label *lbl_version = new Label(this);
lbl_version->setText(".::. v" VERSION " .::. http://www.drumgizmo.org .::. LGPLv3 .::.");
- lbl_version->resize(370, 20);
+ lbl_version->resize(width, 20);
lbl_version->setAlignment(TextAlignment::center);
layout.addItem(lbl_version);
// Create file browser
fileBrowser = new FileBrowser(this);
fileBrowser->move(0, 0);
- fileBrowser->resize(370, 330);
+ fileBrowser->resize(width, height);
fileBrowser->hide();
+
+ CONNECT(this, settings_notifier.drumkit_file,
+ lineedit, &LineEdit::setText);
+ CONNECT(this, settings_notifier.drumkit_load_status,
+ this, &DGWindow::setDrumKitLoadStatus);
+
+ CONNECT(this, settings_notifier.midimap_file,
+ lineedit2, &LineEdit::setText);
+ CONNECT(this, settings_notifier.midimap_load_status,
+ this, &DGWindow::setMidiMapLoadStatus);
+
+ CONNECT(this, settings_notifier.enable_velocity_modifier,
+ velocityCheck, &CheckBox::setChecked);
+
+ CONNECT(this, settings_notifier.velocity_modifier_falloff,
+ falloffKnob, &Knob::setValue);
+ CONNECT(this, settings_notifier.velocity_modifier_weight,
+ attackKnob, &Knob::setValue);
+
+ CONNECT(this, settings_notifier.number_of_files,
+ drumkitFileProgress, &ProgressBar::setTotal);
+
+ CONNECT(this, settings_notifier.number_of_files_loaded,
+ drumkitFileProgress, &ProgressBar::setValue);
+
+ CONNECT(this, settings_notifier.disk_cache_enable,
+ &disk_streaming_controls->streamerCheck, &CheckBox::setChecked);
+ CONNECT(this, settings_notifier.disk_cache_upper_limit,
+ this, &DGWindow::limitSettingsValueChanged);
+}
+
+DGWindow::~DGWindow()
+{
+ delete disk_streaming_controls;
}
void DGWindow::setDrumKitLoadStatus(LoadStatus load_status)
@@ -280,6 +375,27 @@ void DGWindow::repaintEvent(RepaintEvent* repaintEvent)
p.drawImage(width() - 16, 0, sidebar);
}
+void DGWindow::streamerCheckClick(bool value)
+{
+ settings.disk_cache_enable.store(value);
+}
+
+void DGWindow::limitValueChanged(float value)
+{
+ // value is in MB
+ settings.disk_cache_upper_limit.store(value * 1024 * 1024);
+}
+
+void DGWindow::limitSettingsValueChanged(float value)
+{
+ disk_streaming_controls->limitKnob.setValue(value / (1024 * 1024));
+}
+
+void DGWindow::reloadClicked()
+{
+ settings.reload_counter++;
+}
+
void DGWindow::attackValueChanged(float value)
{
settings.velocity_modifier_weight.store(value);
diff --git a/plugingui/dgwindow.h b/plugingui/dgwindow.h
index 5323a12..f6fdb46 100644
--- a/plugingui/dgwindow.h
+++ b/plugingui/dgwindow.h
@@ -40,31 +40,21 @@
#include "texturedbox.h"
#include "imagecache.h"
-namespace GUI {
+namespace GUI
+{
class Config;
class Header;
class File;
+class DiskStreamingControls;
-class DGWindow : public Window {
+class DGWindow
+ : public Window
+{
public:
- DGWindow(void* native_window, Config& config, Settings& settings);
-
- Header* header;
-
- File* drumkitFile;
- LineEdit* lineedit;
- ProgressBar* drumkitFileProgress;
-
- File* midimapFile;
- LineEdit* lineedit2;
- ProgressBar* midimapFileProgress;
-
- // Humanized velocity controls:
- CheckBox* velocityCheck;
- Knob* attackKnob;
- Knob* falloffKnob;
- FileBrowser* fileBrowser;
+ DGWindow(void* native_window, Config& config, Settings& settings,
+ SettingsNotifier& settings_notifier);
+ ~DGWindow();
void setDrumKitLoadStatus(LoadStatus load_status);
void setMidiMapLoadStatus(LoadStatus load_status);
@@ -74,6 +64,11 @@ protected:
void repaintEvent(RepaintEvent* repaintEvent) override;
private:
+ void streamerCheckClick(bool value);
+ void limitValueChanged(float value);
+ void limitSettingsValueChanged(float value);
+ void reloadClicked();
+
void attackValueChanged(float value);
void falloffValueChanged(float value);
void velocityCheckClick(bool checked);
@@ -82,6 +77,20 @@ private:
void selectKitFile(const std::string& filename);
void selectMapFile(const std::string& filename);
+ LineEdit* lineedit;
+ ProgressBar* drumkitFileProgress;
+
+ LineEdit* lineedit2;
+ ProgressBar* midimapFileProgress;
+
+ // Humanized velocity controls:
+ CheckBox* velocityCheck;
+ Knob* attackKnob;
+ Knob* falloffKnob;
+ FileBrowser* fileBrowser;
+
+ DiskStreamingControls* disk_streaming_controls{nullptr};
+
Config& config;
VBoxLayout layout{this};
@@ -89,12 +98,13 @@ private:
Image back{":bg.png"};
Image logo{":logo.png"};
- ImageCache image_cache;
- TexturedBox sidebar{image_cache, ":sidebar.png", 0, 0,
- 16, 0, 0,
- 14, 1, 14};
-
+ ImageCache image_cache;
+ TexturedBox sidebar{image_cache, ":sidebar.png", 0, 0,
+ 16, 0, 0,
+ 14, 1, 14};
+
Settings& settings;
+ SettingsNotifier& settings_notifier;
};
} // GUI::
diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc
index be59cd1..3fc8111 100644
--- a/plugingui/plugingui.cc
+++ b/plugingui/plugingui.cc
@@ -78,45 +78,7 @@ void PluginGUI::init()
config = new Config();
config->load();
- 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, 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, settings_notifier.velocity_modifier_falloff,
- window->falloffKnob, &Knob::setValue);
- CONNECT(this, settings_notifier.velocity_modifier_weight,
- window->attackKnob, &Knob::setValue);
-
-
- // 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, settings_notifier.enable_resampling,
- // window->, &CheckBox::setChecked);
-
- CONNECT(this, settings_notifier.number_of_files,
- window->drumkitFileProgress, &ProgressBar::setTotal);
-
- CONNECT(this, settings_notifier.number_of_files_loaded,
- window->drumkitFileProgress, &ProgressBar::setValue);
+ window = new DGWindow(native_window, *config, settings, settings_notifier);
auto eventHandler = window->eventHandler();
CONNECT(eventHandler, closeNotifier, this, &PluginGUI::closeEventHandler);
diff --git a/plugingui/tests/Makefile.am b/plugingui/tests/Makefile.am
index acc5d96..8af96ee 100644
--- a/plugingui/tests/Makefile.am
+++ b/plugingui/tests/Makefile.am
@@ -1,4 +1,4 @@
-noinst_PROGRAMS = resizetest tabwidgettest
+noinst_PROGRAMS = resizetest tabwidgettest dgwindowtest
resizetest_LDADD = $(top_srcdir)/plugingui/libdggui.la
resizetest_CXXFLAGS = \
@@ -17,3 +17,14 @@ tabwidgettest_CXXFLAGS = \
tabwidgettest_SOURCES = \
tabwidgettest.cc \
$(top_srcdir)/hugin/hugin.c
+
+dgwindowtest_LDADD = \
+ $(top_srcdir)/plugingui/libdggui.la \
+ $(top_srcdir)/src/libdg.la
+dgwindowtest_CXXFLAGS = \
+ -I$(top_srcdir)/plugingui \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/hugin
+dgwindowtest_SOURCES = \
+ dgwindowtest.cc \
+ $(top_srcdir)/hugin/hugin.c
diff --git a/plugingui/tests/dgwindowtest.cc b/plugingui/tests/dgwindowtest.cc
new file mode 100644
index 0000000..fb42797
--- /dev/null
+++ b/plugingui/tests/dgwindowtest.cc
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * dgwindowtest.cc
+ *
+ * Fri Feb 17 16:25:32 CET 2017
+ * Copyright 2017 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of DrumGizmo.
+ *
+ * DrumGizmo is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DrumGizmo is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with DrumGizmo; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include <platform.h>
+
+#if DG_PLATFORM == DG_PLATFORM_WINDOWS
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+#include <unistd.h>
+
+#include <hugin.hpp>
+#include <settings.h>
+
+#include <dgwindow.h>
+#include <eventhandler.h>
+#include <pluginconfig.h>
+
+int main()
+{
+ INFO(example, "We are up and running");
+
+ Settings settings;
+ SettingsNotifier settings_notifier{settings};
+ GUI::Config config;
+ GUI::DGWindow main_window(nullptr, config, settings, settings_notifier);
+ main_window.show();
+
+ bool running = true;
+ while(running)
+ {
+ settings_notifier.evaluate();
+ main_window.eventHandler()->processEvents();
+#if DG_PLATFORM == DG_PLATFORM_WINDOWS
+ SleepEx(50, FALSE);
+#else
+ usleep(50000);
+#endif
+ }
+
+ return 0;
+}