summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugingui/diskstreamingframecontent.cc47
-rw-r--r--plugingui/diskstreamingframecontent.h14
-rw-r--r--plugingui/maintab.cc12
-rw-r--r--plugingui/maintab.h3
-rw-r--r--plugingui/slider.cc6
-rw-r--r--plugingui/slider.h1
6 files changed, 77 insertions, 6 deletions
diff --git a/plugingui/diskstreamingframecontent.cc b/plugingui/diskstreamingframecontent.cc
index bb4cfc3..53e2c9d 100644
--- a/plugingui/diskstreamingframecontent.cc
+++ b/plugingui/diskstreamingframecontent.cc
@@ -26,19 +26,41 @@
*/
#include "diskstreamingframecontent.h"
+#include <settings.h>
+
namespace GUI
{
-DiskstreamingframeContent::DiskstreamingframeContent(Widget* parent)
- : Widget(parent), slider_width{250}
+DiskstreamingframeContent::DiskstreamingframeContent(Widget* parent,
+ Settings& settings,
+ SettingsNotifier& settings_notifier)
+ : Widget(parent)
+ , slider_width{250}
+ , settings(settings)
+ , settings_notifier(settings_notifier)
{
label_text.setText("Cache limit (max memory usage):");
label_text.setAlignment(TextAlignment::center);
button.setText("Apply"); // TODO connect
- label_size.setText("600 MB"); // TODO connect
+ label_size.setText("0 MB");
label_size.setAlignment(TextAlignment::center);
+
+ CONNECT(this, settings_notifier.disk_cache_upper_limit,
+ this, &DiskstreamingframeContent::limitSettingsValueChanged);
+
+ CONNECT(&slider, valueChangedNotifier,
+ this, &DiskstreamingframeContent::limitValueChanged);
+
+ CONNECT(&button, clickNotifier,
+ this, &DiskstreamingframeContent::reloadClicked);
+
+ // TODO:
+ // CONNECT(this, settings_notifier.disk_cache_chunk_size,
+ // this, &DGWindow::chunkSettingsValueChanged);
+ // CONNECT(this, settings_notifier.number_of_underruns,
+ // this, &DGWindow::underrunsChanged);
}
void DiskstreamingframeContent::resize(std::size_t width, std::size_t height)
@@ -59,4 +81,23 @@ void DiskstreamingframeContent::resize(std::size_t width, std::size_t height)
label_size.resize(slider_width, 15);
}
+void DiskstreamingframeContent::limitSettingsValueChanged(float value)
+{
+ char buf[32];
+ snprintf(buf, sizeof(buf) - 1, "%.2f MB", value / (1024 * 1024));
+ label_size.setText(buf);
+ slider.setValue(value);
+}
+
+void DiskstreamingframeContent::limitValueChanged(float value)
+{
+ settings.disk_cache_upper_limit.store(value);
+}
+
+void DiskstreamingframeContent::reloadClicked()
+{
+ settings.reload_counter++;
+}
+
+
} // GUI::
diff --git a/plugingui/diskstreamingframecontent.h b/plugingui/diskstreamingframecontent.h
index 5c1fad0..bcdbef9 100644
--- a/plugingui/diskstreamingframecontent.h
+++ b/plugingui/diskstreamingframecontent.h
@@ -31,18 +31,27 @@
#include "slider.h"
#include "widget.h"
+struct Settings;
+class SettingsNotifier;
+
namespace GUI
{
class DiskstreamingframeContent : public Widget
{
public:
- DiskstreamingframeContent(Widget* parent);
+ DiskstreamingframeContent(Widget* parent,
+ Settings& settings,
+ SettingsNotifier& settings_notifier);
// From Widget
virtual void resize(std::size_t width, std::size_t height) override;
private:
+ void limitSettingsValueChanged(float value);
+ void limitValueChanged(float value);
+ void reloadClicked();
+
Label label_text{this};
Label label_size{this};
@@ -51,6 +60,9 @@ private:
std::size_t slider_width;
std::size_t button_width;
+
+ Settings& settings;
+ SettingsNotifier& settings_notifier;
};
} // GUI::
diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc
index 3e5a816..571bf20 100644
--- a/plugingui/maintab.cc
+++ b/plugingui/maintab.cc
@@ -35,6 +35,7 @@ MainTab::MainTab(Widget* parent,
: Widget(parent)
, drumkitframe_content{this, settings, settings_notifier}
, humanizerframe_content{this, settings, settings_notifier}
+ , diskstreamingframe_content{this, settings, settings_notifier}
, settings(settings)
, settings_notifier(settings_notifier)
{
@@ -74,6 +75,12 @@ MainTab::MainTab(Widget* parent,
CONNECT(&humanizer_frame, onSwitchChangeNotifier,
this, &MainTab::humanizerOnChange);
+
+ CONNECT(this, settings_notifier.disk_cache_enable,
+ &diskstreaming_frame, &FrameWidget::setOnSwitch);
+
+ CONNECT(&diskstreaming_frame, onSwitchChangeNotifier,
+ this, &MainTab::diskStreamingOnChange);
}
void MainTab::humanizerOnChange(bool on)
@@ -81,4 +88,9 @@ void MainTab::humanizerOnChange(bool on)
settings.enable_velocity_modifier.store(on);
}
+void MainTab::diskStreamingOnChange(bool on)
+{
+ settings.disk_cache_enable.store(on);
+}
+
} // GUI::
diff --git a/plugingui/maintab.h b/plugingui/maintab.h
index 6f8b7b2..f60afcc 100644
--- a/plugingui/maintab.h
+++ b/plugingui/maintab.h
@@ -50,6 +50,7 @@ public:
private:
void humanizerOnChange(bool on);
+ void diskStreamingOnChange(bool on);
GridLayout layout{this, 2, 40};
@@ -61,7 +62,7 @@ private:
DrumkitframeContent drumkitframe_content;
StatusframeContent statusframe_content{this};
HumanizerframeContent humanizerframe_content;
- DiskstreamingframeContent diskstreamingframe_content{this};
+ DiskstreamingframeContent diskstreamingframe_content;
Settings& settings;
SettingsNotifier& settings_notifier;
diff --git a/plugingui/slider.cc b/plugingui/slider.cc
index 7d5cdb4..2a82a54 100644
--- a/plugingui/slider.cc
+++ b/plugingui/slider.cc
@@ -34,6 +34,8 @@
namespace GUI
{
+static constexpr float _4GB = 1024.0 * 1024.0 * 1024.0 * 4.0;
+
Slider::Slider(Widget* parent) : Widget(parent)
{
state = State::up;
@@ -45,9 +47,10 @@ Slider::Slider(Widget* parent) : Widget(parent)
void Slider::setValue(float new_value)
{
- current_value = new_value;
+ current_value = new_value / (float)_4GB; // TODO: Scale to [0, 1] range
redraw();
clickNotifier();
+ valueChangedNotifier(current_value * _4GB); // TODO: Scale up to full range
}
float Slider::value() const
@@ -126,6 +129,7 @@ void Slider::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent)
redraw();
clickNotifier();
+ valueChangedNotifier(current_value * _4GB); // TODO: Scale up to full range
}
}
diff --git a/plugingui/slider.h b/plugingui/slider.h
index ff2db29..3398bb4 100644
--- a/plugingui/slider.h
+++ b/plugingui/slider.h
@@ -58,6 +58,7 @@ public:
void setColour(Colour colour);
Notifier<> clickNotifier;
+ Notifier<float> valueChangedNotifier; // (float value)
protected:
virtual void repaintEvent(RepaintEvent* repaintEvent) override;