diff options
Diffstat (limited to 'plugingui')
| -rw-r--r-- | plugingui/Makefile.am | 5 | ||||
| -rw-r--r-- | plugingui/Makefile.mingw32 | 4 | ||||
| -rw-r--r-- | plugingui/button.h | 3 | ||||
| -rw-r--r-- | plugingui/checkbox.h | 3 | ||||
| -rw-r--r-- | plugingui/dgwindow.cc | 116 | ||||
| -rw-r--r-- | plugingui/dgwindow.h | 13 | ||||
| -rw-r--r-- | plugingui/eventhandler.h | 3 | ||||
| -rw-r--r-- | plugingui/filebrowser.h | 4 | ||||
| -rw-r--r-- | plugingui/knob.h | 3 | ||||
| -rw-r--r-- | plugingui/layout.h | 2 | ||||
| -rw-r--r-- | plugingui/listboxbasic.h | 3 | ||||
| -rw-r--r-- | plugingui/listboxthin.h | 3 | ||||
| -rw-r--r-- | plugingui/notifier.h | 163 | ||||
| -rw-r--r-- | plugingui/plugingui.cc | 125 | ||||
| -rw-r--r-- | plugingui/plugingui.h | 24 | ||||
| -rw-r--r-- | plugingui/progressbar.cc | 26 | ||||
| -rw-r--r-- | plugingui/progressbar.h | 11 | ||||
| -rw-r--r-- | plugingui/testmain.cc | 17 | 
18 files changed, 193 insertions, 335 deletions
| diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am index 3dee864..4176c07 100644 --- a/plugingui/Makefile.am +++ b/plugingui/Makefile.am @@ -16,9 +16,7 @@ plugingui_SOURCES = \  	$(top_srcdir)/src/configfile.cc \  	$(top_srcdir)/src/thread.cc \  	$(top_srcdir)/src/semaphore.cc \ -	$(top_srcdir)/src/mutex.cc \ -	$(top_srcdir)/src/messagehandler.cc \ -	$(top_srcdir)/src/messagereceiver.cc +	$(top_srcdir)/src/mutex.cc  rcgen_SOURCES = rcgen.cc @@ -46,7 +44,6 @@ EXTRA_DIST = \  	nativewindow.h \  	nativewindow_win32.h \  	nativewindow_x11.h \ -	notifier.h \  	painter.h \  	pixelbuffer.h \  	pluginconfig.h \ diff --git a/plugingui/Makefile.mingw32 b/plugingui/Makefile.mingw32 index 3f52e8a..9820d1a 100644 --- a/plugingui/Makefile.mingw32 +++ b/plugingui/Makefile.mingw32 @@ -2,9 +2,7 @@ DG_SRC = \  	../src/configfile.cc \  	../src/thread.cc \  	../src/semaphore.cc \ -	../src/mutex.cc \ -	../src/messagehandler.cc \ -	../src/messagereceiver.cc +	../src/mutex.cc  DG_CFLAGS = -I.. -I../include -I../src -DSSE -msse -msse2 -DDISABLE_HUGIN diff --git a/plugingui/button.h b/plugingui/button.h index 7e3e168..1bfeb2d 100644 --- a/plugingui/button.h +++ b/plugingui/button.h @@ -28,9 +28,10 @@  #include <string> +#include <notifier.h> +  #include "widget.h"  #include "painter.h" -#include "notifier.h"  #include "font.h"  namespace GUI { diff --git a/plugingui/checkbox.h b/plugingui/checkbox.h index 3da5511..5c658a5 100644 --- a/plugingui/checkbox.h +++ b/plugingui/checkbox.h @@ -26,9 +26,10 @@   */  #pragma once +#include <notifier.h> +  #include "widget.h"  #include "image.h" -#include "notifier.h"  namespace GUI { diff --git a/plugingui/dgwindow.cc b/plugingui/dgwindow.cc index 86a985d..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,11 +121,10 @@ public:  	Knob falloffKnob{&falloff};  }; -DGWindow::DGWindow(void* native_window, MessageHandler& messageHandler, -                   Config& config) +DGWindow::DGWindow(void* native_window, Config& config, Settings& settings)  	: Window(native_window) -	, messageHandler(messageHandler)  	, config(config) +	, settings(settings)  {  	int vlineSpacing = 16; @@ -179,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); @@ -207,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); @@ -219,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()) @@ -233,42 +279,42 @@ void DGWindow::repaintEvent(RepaintEvent* repaintEvent)  void DGWindow::attackValueChanged(float value)  { -	ChangeSettingMessage *msg = -		new ChangeSettingMessage(ChangeSettingMessage::velocity_modifier_weight, -														 value); +	settings.velocity_modifier_weight.store(value); -	messageHandler.sendMessage(MSGRCV_ENGINE, msg); - -#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);  }  void DGWindow::kitBrowseClick() @@ -318,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) @@ -337,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);  } diff --git a/plugingui/dgwindow.h b/plugingui/dgwindow.h index 605e87a..72e4679 100644 --- a/plugingui/dgwindow.h +++ b/plugingui/dgwindow.h @@ -26,8 +26,9 @@   */  #pragma once -#include "window.h" +#include <settings.h> +#include "window.h"  #include "label.h"  #include "lineedit.h"  #include "checkbox.h" @@ -37,8 +38,6 @@  #include "filebrowser.h"  #include "layout.h" -class MessageHandler; -  namespace GUI {  class Config; @@ -47,7 +46,7 @@ class File;  class DGWindow : public Window {  public: -	DGWindow(void* native_window, MessageHandler& messageHandler, Config& config); +	DGWindow(void* native_window, Config& config, Settings& settings);  	Header* header; @@ -65,6 +64,9 @@ public:  	Knob* falloffKnob;  	FileBrowser* fileBrowser; +	void setDrumKitLoadStatus(LoadStatus load_status); +	void setMidiMapLoadStatus(LoadStatus load_status); +  protected:  	// From Widget:  	void repaintEvent(RepaintEvent* repaintEvent) override; @@ -78,13 +80,14 @@ private:  	void selectKitFile(const std::string& filename);  	void selectMapFile(const std::string& filename); -	MessageHandler& messageHandler;  	Config& config;  	VBoxLayout layout{this};  	Image back{":bg.png"};  	Image logo{":logo.png"}; + +	Settings& settings;  };  } // GUI:: diff --git a/plugingui/eventhandler.h b/plugingui/eventhandler.h index 1fdb1e8..490c515 100644 --- a/plugingui/eventhandler.h +++ b/plugingui/eventhandler.h @@ -26,9 +26,10 @@   */  #pragma once +#include <notifier.h> +  #include "guievent.h"  #include "nativewindow.h" -#include "notifier.h"  namespace GUI { diff --git a/plugingui/filebrowser.h b/plugingui/filebrowser.h index 04b34f6..bc2019f 100644 --- a/plugingui/filebrowser.h +++ b/plugingui/filebrowser.h @@ -26,15 +26,15 @@   */  #pragma once -#include "widget.h" +#include <notifier.h> +#include "widget.h"  #include "button.h"  #include "listbox.h"  #include "lineedit.h"  #include "label.h"  #include "image.h"  #include "directory.h" -#include "notifier.h"  namespace GUI { diff --git a/plugingui/knob.h b/plugingui/knob.h index 10d91d6..d144184 100644 --- a/plugingui/knob.h +++ b/plugingui/knob.h @@ -26,10 +26,11 @@   */  #pragma once +#include <notifier.h> +  #include "widget.h"  #include "image.h"  #include "font.h" -#include "notifier.h"  namespace GUI { diff --git a/plugingui/layout.h b/plugingui/layout.h index 55cc93f..49bf75c 100644 --- a/plugingui/layout.h +++ b/plugingui/layout.h @@ -29,7 +29,7 @@  #include <list>  #include <cstdlib> -#include "notifier.h" +#include <notifier.h>  namespace GUI { diff --git a/plugingui/listboxbasic.h b/plugingui/listboxbasic.h index 7953dc3..2ebe845 100644 --- a/plugingui/listboxbasic.h +++ b/plugingui/listboxbasic.h @@ -29,11 +29,12 @@  #include <string.h>  #include <vector> +#include <notifier.h> +  #include "widget.h"  #include "font.h"  #include "painter.h"  #include "scrollbar.h" -#include "notifier.h"  namespace GUI { diff --git a/plugingui/listboxthin.h b/plugingui/listboxthin.h index 3139ecc..1617234 100644 --- a/plugingui/listboxthin.h +++ b/plugingui/listboxthin.h @@ -29,10 +29,11 @@  #include <string.h>  #include <vector> +#include <notifier.h> +  #include "widget.h"  #include "painter.h"  #include "listboxbasic.h" -#include "notifier.h"  namespace GUI { diff --git a/plugingui/notifier.h b/plugingui/notifier.h deleted file mode 100644 index 9e9f6eb..0000000 --- a/plugingui/notifier.h +++ /dev/null @@ -1,163 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - *            notifier.h - * - *  Thu Sep  3 15:48:39 CEST 2015 - *  Copyright 2015 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. - */ -#pragma once - -#include <functional> -#include <vector> -#include <map> -#include <set> -#include <memory> - -namespace aux -{ -	template<int> -	struct placeholder -	{ -	}; -} - -namespace std -{ -	template<int N> -	struct is_placeholder<aux::placeholder<N>> -		: integral_constant<int, N+1> -	{ -	}; -} - -namespace aux -{ -	// std::integer_sequence introduced in C++14 so remove this once we start requiring that. - -	template<int... Ns> -	struct int_sequence -	{ -	}; - -	template<int N, int... Ns> -	struct gen_int_sequence -		: gen_int_sequence<N-1, N-1, Ns...> -	{ -	}; - -	template<int... Ns> -	struct gen_int_sequence<0, Ns...> -		: int_sequence<Ns...> -	{ -	}; -}; - - -namespace GUI { - -class Listener; -class NotifierBase { -public: -	virtual void disconnect(Listener* object) {} -}; - -class Listener { -public: -	virtual ~Listener() -	{ -		for(auto signal : signals) -		{ -			signal->disconnect(this); -		} -	} - -	void registerNotifier(NotifierBase* signal) -	{ -		signals.insert(signal); -	} - -	void unregisterNotifier(NotifierBase* signal) -	{ -		signals.erase(signal); -	} - -private: -	std::set<NotifierBase*> signals; -}; - -template<typename... Args> -class Notifier : public NotifierBase { -public: -	Notifier() {} - -	//! \brief When dtor is called it will automatically disconnect all its listeners. -	~Notifier() -	{ -		for(auto& slot : slots) -		{ -			slot.first->unregisterNotifier(this); -		} -	} - -	using callback_type = std::function<void(Args...)>; - -	//! \brief Connect object to this Notifier. -	template<typename O, typename F> -	void connect(O* p, const F& fn) -	{ -		slots[p] = std::move(construct_mem_fn(fn, p, aux::gen_int_sequence<sizeof...(Args)>{})); -		if(p && dynamic_cast<Listener*>(p)) -		{ -			dynamic_cast<Listener*>(p)->registerNotifier(this); -		} -	} - -	//! \brief Disconnect object from this Notifier. -	void disconnect(Listener* object) -	{ -		slots.erase(object); -	} - -	//! \brief Activate this notifier by pretending it is a function. -	//! Example: Notifier<int> foo; foo(42); -	void operator()(Args... args) -	{ -		for(auto& slot : slots) -		{ -			slot.second(args...); -		} -	} - -private: -	std::map<Listener*, callback_type> slots; - -	template<typename F, typename O, int... Ns> -	callback_type construct_mem_fn(const F& fn, O* p, aux::int_sequence<Ns...>) const -	{ -		return std::bind(fn, p, aux::placeholder<Ns>{}...); -	} - -}; - -} // GUI:: - -#define CONNECT(SRC, SIG, TAR, SLO) (SRC)->SIG.connect(TAR, SLO) diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index e34c471..2802c44 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -26,16 +26,17 @@   */  #include "plugingui.h" +#include <iostream> +  #include <hugin.hpp>  #include "pluginconfig.h" -#include "messagehandler.h"  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();  } @@ -44,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) @@ -116,7 +53,12 @@ bool PluginGUI::processEvents()  	}  	window->eventHandler()->processEvents(); -	handleMessages(); + +	{ +		Painter p(*window); + +		settings_notifier.evaluate(); +	}  	if(closing)  	{ @@ -135,18 +77,51 @@ void PluginGUI::init()  	config = new Config();  	config->load(); -	window = new DGWindow(native_window, msghandler, *config); +	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);  	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;  } diff --git a/plugingui/plugingui.h b/plugingui/plugingui.h index f441696..04b0a29 100644 --- a/plugingui/plugingui.h +++ b/plugingui/plugingui.h @@ -26,26 +26,20 @@   */  #pragma once +#include <settings.h> +#include <notifier.h> +  #include "dgwindow.h"  #include "eventhandler.h" -  #include "pluginconfig.h" - -#include "thread.h" -#include "semaphore.h" - -#include "messagereceiver.h" -#include "notifier.h" -  namespace GUI {  class PluginGUI -	: public MessageReceiver -	, public Listener +	: public Listener  {  public: -	PluginGUI(void* native_window = nullptr); +	PluginGUI(Settings& settings, void* native_window = nullptr);  	virtual ~PluginGUI();  	//! Process all events and messages in queue @@ -58,9 +52,6 @@ public:  	void show();  	void hide(); - -	void handleMessage(Message* msg); -  	DGWindow* window{nullptr};  	EventHandler* eventhandler{nullptr}; @@ -80,11 +71,12 @@ private:  	volatile bool closing{false};  	volatile bool initialised{false}; -	Semaphore sem{"plugingui"}; -  	// For the old-style notifier.  	void (*windowClosedHandler)(void *){nullptr};  	void *windowClosedPtr{nullptr}; + +	Settings& settings; +	SettingsNotifier settings_notifier{settings};  };  } // GUI:: diff --git a/plugingui/progressbar.cc b/plugingui/progressbar.cc index 932f17c..8a382f5 100644 --- a/plugingui/progressbar.cc +++ b/plugingui/progressbar.cc @@ -26,6 +26,8 @@   */  #include "progressbar.h" +#include <iostream> +  namespace GUI {  ProgressBar::ProgressBar(Widget *parent) @@ -46,9 +48,6 @@ ProgressBar::ProgressBar(Widget *parent)  	bar_green.left    = new Image(":progress_front_green_l.png");  	bar_green.right   = new Image(":progress_front_green_r.png");  	bar_green.center  = new Image(":progress_front_green_c.png"); - -	state = ProgressBarState::Blue; -	_progress = .5;  }  ProgressBar::~ProgressBar() @@ -79,22 +78,31 @@ void ProgressBar::setState(ProgressBarState state)  	}  } -float ProgressBar::progress() +void ProgressBar::setTotal(std::size_t total)  { -	return _progress; +	if(this->total != total) +	{ +		this->total = total; +		repaintEvent(nullptr); +	}  } -void ProgressBar::setProgress(float progress) +void ProgressBar::setValue(std::size_t value)  { -	_progress = progress; -	repaintEvent(nullptr); +	if(this->value != value) +	{ +		this->value = value; +		repaintEvent(nullptr); +	}  }  void ProgressBar::repaintEvent(RepaintEvent* repaintEvent)  {  	Painter p(*this); -	int max = width() * _progress; +	float progress = (float)value / (float)total; + +	int max = width() * progress;  	p.clear(); diff --git a/plugingui/progressbar.h b/plugingui/progressbar.h index d5f6c61..7485e40 100644 --- a/plugingui/progressbar.h +++ b/plugingui/progressbar.h @@ -43,11 +43,11 @@ enum class ProgressBarState  class ProgressBar : public Widget {  public: -	ProgressBar(Widget *parent); +	ProgressBar(Widget* parent);  	~ProgressBar(); -	float progress(); -	void setProgress(float progress); +	void setTotal(std::size_t total); +	void setValue(std::size_t value);  	void setState(ProgressBarState state); @@ -56,7 +56,7 @@ protected:  	virtual void repaintEvent(RepaintEvent* repaintEvent) override;  private: -	ProgressBarState state; +	ProgressBarState state{ProgressBarState::Blue};  	Painter::Bar bar_bg; @@ -64,7 +64,8 @@ private:  	Painter::Bar bar_blue;  	Painter::Bar bar_red; -	float _progress; +	std::size_t total{0}; +	std::size_t value{0};  };  } // GUI:: diff --git a/plugingui/testmain.cc b/plugingui/testmain.cc index 8282bc8..84d813d 100644 --- a/plugingui/testmain.cc +++ b/plugingui/testmain.cc @@ -26,15 +26,17 @@   */  #include "plugingui.h" +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#endif +  #include <hugin.hpp> -// Dummy Engine class. -class Engine : public MessageHandler { -public: -	void handleMessage(Message *msg) {} -}; +#include <notifier.h> +#include <settings.h> -class TestMain : public GUI::Listener { +class TestMain : public Listener {  public:  	TestMain()  	{ @@ -62,7 +64,8 @@ public:  	bool running = true; -	GUI::PluginGUI gui; +	Settings settings; +	GUI::PluginGUI gui{settings};  };  int main() | 
