From a96587e4737ea617188f13370331072322adb0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Fri, 21 Apr 2017 16:35:08 +0200 Subject: Introduce first content of status frame. This is just an initial version and not the final one. --- plugingui/maintab.cc | 1 + plugingui/maintab.h | 2 +- plugingui/statusframecontent.cc | 93 ++++++++++++++++++++++++++++++++++++++++- plugingui/statusframecontent.h | 21 +++++++++- 4 files changed, 113 insertions(+), 4 deletions(-) (limited to 'plugingui') diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc index 7680bcd..d93fd5f 100644 --- a/plugingui/maintab.cc +++ b/plugingui/maintab.cc @@ -35,6 +35,7 @@ MainTab::MainTab(Widget* parent, Config& config) : Widget(parent) , drumkitframe_content{this, settings, settings_notifier, config} + , statusframe_content{this, settings_notifier} , humanizerframe_content{this, settings, settings_notifier} , diskstreamingframe_content{this, settings, settings_notifier} , settings(settings) diff --git a/plugingui/maintab.h b/plugingui/maintab.h index 941932f..abb7e8d 100644 --- a/plugingui/maintab.h +++ b/plugingui/maintab.h @@ -62,7 +62,7 @@ private: FrameWidget diskstreaming_frame{this, false}; DrumkitframeContent drumkitframe_content; - StatusframeContent statusframe_content{this}; + StatusframeContent statusframe_content; HumanizerframeContent humanizerframe_content; DiskstreamingframeContent diskstreamingframe_content; diff --git a/plugingui/statusframecontent.cc b/plugingui/statusframecontent.cc index 33a1367..196c0d3 100644 --- a/plugingui/statusframecontent.cc +++ b/plugingui/statusframecontent.cc @@ -29,11 +29,25 @@ namespace GUI { -StatusframeContent::StatusframeContent(Widget* parent) : Widget(parent) +StatusframeContent::StatusframeContent( + Widget* parent, SettingsNotifier& settings_notifier) + : Widget(parent), settings_notifier(settings_notifier) { + CONNECT(this, settings_notifier.drumkit_load_status, + this, &StatusframeContent::updateDrumkitLoadStatus); + CONNECT(this, settings_notifier.midimap_load_status, + this, &StatusframeContent::updateMidimapLoadStatus); + CONNECT(this, settings_notifier.samplerate, + this, &StatusframeContent::updateSamplerate); + CONNECT(this, settings_notifier.enable_resampling, + this, &StatusframeContent::updateResamplingEnabled); + CONNECT(this, settings_notifier.number_of_underruns, + this, &StatusframeContent::updateNumberOfUnderruns); + text_field.move(0, 0); - text_field.setText("This is a status message."); text_field.setReadOnly(true); + + updateContent(); text_field.show(); } @@ -43,4 +57,79 @@ void StatusframeContent::resize(std::size_t width, std::size_t height) text_field.resize(width, height); } +void StatusframeContent::updateContent() +{ + text_field.setText( + "Drumkit load status: " + drumkit_load_status + "\n" + "Midimap load status: " + midimap_load_status + "\n" + "Samplerate: " + samplerate + "\n" + "Resampling enabled: " + resampling_enabled + "\n" + "Number of underruns: " + number_of_underruns + "\n" + ); +} + +void StatusframeContent::updateDrumkitLoadStatus(LoadStatus load_status) +{ + switch(load_status) + { + case LoadStatus::Idle: + drumkit_load_status = "idle"; + break; + case LoadStatus::Loading: + drumkit_load_status = "loading"; + break; + case LoadStatus::Done: + drumkit_load_status = "done"; + break; + case LoadStatus::Error: + drumkit_load_status = "error"; + break; + } + + updateContent(); +} + +void StatusframeContent::updateMidimapLoadStatus(LoadStatus load_status) +{ + switch(load_status) + { + case LoadStatus::Idle: + midimap_load_status = "idle"; + break; + case LoadStatus::Loading: + midimap_load_status = "loading"; + break; + case LoadStatus::Done: + midimap_load_status = "done"; + break; + case LoadStatus::Error: + midimap_load_status = "error"; + break; + } + + updateContent(); +} + +void StatusframeContent::updateSamplerate(double samplerate) +{ + this->samplerate = std::to_string((std::size_t)samplerate); + + updateContent(); +} + +void StatusframeContent::updateResamplingEnabled(bool enable_resampling) +{ + this->resampling_enabled = enable_resampling ? "yes" : "no"; + + updateContent(); +} + +void StatusframeContent::updateNumberOfUnderruns( + std::size_t number_of_underruns) +{ + this->number_of_underruns = std::to_string(number_of_underruns); + + updateContent(); +} + } // GUI:: diff --git a/plugingui/statusframecontent.h b/plugingui/statusframecontent.h index 020855c..0ca5bfe 100644 --- a/plugingui/statusframecontent.h +++ b/plugingui/statusframecontent.h @@ -26,22 +26,41 @@ */ #pragma once +#include "settings.h" #include "textedit.h" #include "widget.h" +class SettingsNotifier; + namespace GUI { class StatusframeContent : public Widget { public: - StatusframeContent(Widget* parent); + StatusframeContent(Widget* parent, SettingsNotifier& settings_notifier); // From Widget virtual void resize(std::size_t width, std::size_t height) override; + void updateContent(); + + void updateDrumkitLoadStatus(LoadStatus load_status); + void updateMidimapLoadStatus(LoadStatus load_status); + void updateSamplerate(double samplerate); + void updateResamplingEnabled(bool enable_resampling); + void updateNumberOfUnderruns(std::size_t number_of_underruns); + private: TextEdit text_field{this}; + + SettingsNotifier& settings_notifier; + + std::string drumkit_load_status; + std::string midimap_load_status; + std::string samplerate; + std::string resampling_enabled; + std::string number_of_underruns; }; } // GUI:: -- cgit v1.2.3