diff options
| -rw-r--r-- | plugin/Makefile.mingw32.in | 2 | ||||
| -rw-r--r-- | plugingui/Makefile.am | 4 | ||||
| -rw-r--r-- | plugingui/dgwindow.cc | 541 | ||||
| -rw-r--r-- | plugingui/dgwindow.h | 115 | ||||
| -rw-r--r-- | plugingui/plugingui.cc | 153 | ||||
| -rw-r--r-- | plugingui/plugingui.h | 82 | ||||
| -rw-r--r-- | plugingui/tests/Makefile.am | 13 | ||||
| -rw-r--r-- | plugingui/tests/dgwindowtest.cc | 65 | 
8 files changed, 1 insertions, 974 deletions
| diff --git a/plugin/Makefile.mingw32.in b/plugin/Makefile.mingw32.in index 5f1a607..9614496 100644 --- a/plugin/Makefile.mingw32.in +++ b/plugin/Makefile.mingw32.in @@ -52,7 +52,6 @@ GUI_SRC = \  	@top_srcdir@/plugingui/checkbox.cc \  	@top_srcdir@/plugingui/colour.cc \  	@top_srcdir@/plugingui/combobox.cc \ -	@top_srcdir@/plugingui/dgwindow.cc \  	@top_srcdir@/plugingui/dialog.cc \  	@top_srcdir@/plugingui/directory.cc \  	@top_srcdir@/plugingui/diskstreamingframecontent.cc \ @@ -78,7 +77,6 @@ GUI_SRC = \  	@top_srcdir@/plugingui/painter.cc \  	@top_srcdir@/plugingui/pixelbuffer.cc \  	@top_srcdir@/plugingui/pluginconfig.cc \ -	@top_srcdir@/plugingui/plugingui.cc \  	@top_srcdir@/plugingui/powerbutton.cc \  	@top_srcdir@/plugingui/progressbar.cc \  	@top_srcdir@/plugingui/resource.cc \ diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am index 8795acd..eeeeb34 100644 --- a/plugingui/Makefile.am +++ b/plugingui/Makefile.am @@ -25,7 +25,6 @@ nodist_libdggui_la_SOURCES = \  	checkbox.cc \  	colour.cc \  	combobox.cc \ -	dgwindow.cc \  	dialog.cc \  	directory.cc \  	diskstreamingframecontent.cc \ @@ -50,7 +49,6 @@ nodist_libdggui_la_SOURCES = \  	painter.cc \  	pixelbuffer.cc \  	pluginconfig.cc \ -	plugingui.cc \  	powerbutton.cc \  	progressbar.cc \  	resource.cc \ @@ -112,7 +110,6 @@ EXTRA_DIST = \  	checkbox.h \  	colour.h \  	combobox.h \ -	dgwindow.h \  	drawable.h \  	dialog.h \  	directory.h \ @@ -137,7 +134,6 @@ EXTRA_DIST = \  	painter.h \  	pixelbuffer.h \  	pluginconfig.h \ -	plugingui.h \  	progressbar.h \  	resource.h \  	resource_data.h \ diff --git a/plugingui/dgwindow.cc b/plugingui/dgwindow.cc deleted file mode 100644 index 44f52e7..0000000 --- a/plugingui/dgwindow.cc +++ /dev/null @@ -1,541 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - *            dgwindow.cc - * - *  Mon Nov 23 20:30:45 CET 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. - */ -#include "dgwindow.h" - -#include "knob.h" -#include "verticalline.h" -#include "../version.h" - -#include "pluginconfig.h" -#include <memchecker.h> -#include <cpp11fix.h> - -namespace GUI { - -class LabeledControl -	: public Widget -{ -public: -	LabeledControl(Widget* parent, const std::string& name) -		: Widget(parent) -	{ -		layout.setResizeChildren(false); -		layout.setHAlignment(HAlignment::center); - -		caption.setText(name); -		caption.resize(100, 20); -		caption.setAlignment(TextAlignment::center); -		layout.addItem(&caption); -	} - -	void setControl(Widget* control) -	{ -		layout.addItem(control); -	} - -	VBoxLayout layout{this}; - -	Label caption{this}; -}; - -class File -	: public Widget -{ -public: -	File(Widget* parent) -		: Widget(parent) -	{ -		layout.setResizeChildren(false); -		layout.setVAlignment(VAlignment::center); - -		lineedit.resize(243, 29); -		layout.addItem(&lineedit); - -		browseButton.setText("Browse..."); -		browseButton.resize(85, 41); -		layout.addItem(&browseButton); -	} - -	HBoxLayout layout{this}; - -	LineEdit lineedit{this}; -	Button browseButton{this}; -}; - -class HumanizeControls -	: public Widget -{ -public: -	HumanizeControls(Widget* parent) -		: Widget(parent) -	{ -		layout.setResizeChildren(false); -		layout.setVAlignment(VAlignment::center); - -		velocity.resize(80, 80); -		velocityCheck.resize(59, 38); -		velocity.setControl(&velocityCheck); -		layout.addItem(&velocity); - -		attack.resize(80, 80); -		attackKnob.resize(60, 60); -		attack.setControl(&attackKnob); -		layout.addItem(&attack); - -		falloff.resize(80, 80); -		falloffKnob.resize(60, 60); -		falloff.setControl(&falloffKnob); -		layout.addItem(&falloff); -	} - -	HBoxLayout layout{this}; - -	LabeledControl velocity{this, "Humanizer"}; -	LabeledControl attack{this, "Attack"}; -	LabeledControl falloff{this, "Release"}; - -	CheckBox velocityCheck{&velocity}; -	Knob attackKnob{&attack}; -	Knob falloffKnob{&falloff}; -}; - -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(256.0, free_mem / 2.0), free_mem); -		limitKnob.resize(60, 60); -		limit.setControl(&limitKnob); -		layout.addItem(&limit); - -		chunk.resize(80, 80); -		chunkKnob.setRange(64.0, 4096.0); -		chunkKnob.resize(60, 60); -		chunk.setControl(&chunkKnob); -		layout.addItem(&chunk); - -		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"}; -	LabeledControl chunk{this, "kB Chunk"}; - -	CheckBox streamerCheck{&streamer}; -	Knob limitKnob{&limit}; -	Knob chunkKnob{&chunk}; -	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; - -	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); -	layout.setHAlignment(HAlignment::center); -//	layout.setSpacing(0); - -	auto headerCaption = new Label(this); -	headerCaption->setText("DrumGizmo"); -	headerCaption->setAlignment(TextAlignment::center); -	headerCaption->resize(width - border, 32); -	layout.addItem(headerCaption); - -	auto headerLine = new VerticalLine(this); -	headerLine->resize(width - border, vlineSpacing); -	layout.addItem(headerLine); - -	auto drumkitCaption = new Label(this); -	drumkitCaption->setText("Drumkit file:"); -	drumkitCaption->resize(width - border, 15); -	layout.addItem(drumkitCaption); - -	auto drumkitFile = new File(this); -	drumkitFile->resize(width - border, 37); -	lineedit = &drumkitFile->lineedit; -	CONNECT(&drumkitFile->browseButton, clickNotifier, -	        this, &DGWindow::kitBrowseClick); -	layout.addItem(drumkitFile); - -	drumkitFileProgress = new ProgressBar(this); -	drumkitFileProgress->resize(width - border, 11); -	layout.addItem(drumkitFileProgress); - -	VerticalLine *l = new VerticalLine(this); -	l->resize(width - border, vlineSpacing); -	layout.addItem(l); - -	auto midimapCaption = new Label(this); -	midimapCaption->setText("Midimap file:"); -	midimapCaption->resize(width - border, 15); -	layout.addItem(midimapCaption); - -	auto midimapFile = new File(this); -	midimapFile->resize(width - border, 37); -	lineedit2 = &midimapFile->lineedit; -	CONNECT(&midimapFile->browseButton, clickNotifier, -	        this, &DGWindow::midimapBrowseClick); -	layout.addItem(midimapFile); - -	midimapFileProgress = new ProgressBar(this); -	midimapFileProgress->resize(width - border, 11); -	midimapFileProgress->setTotal(2); -	layout.addItem(midimapFileProgress); - -	VerticalLine *l2 = new VerticalLine(this); -	l2->resize(width - border, vlineSpacing); -	layout.addItem(l2); - -	HumanizeControls* humanizeControls = new HumanizeControls(this); -	humanizeControls->resize(80 * 3, 80); -	layout.addItem(humanizeControls); -	CONNECT(&humanizeControls->velocityCheck, stateChangedNotifier, -	        this, &DGWindow::velocityCheckClick); - -	CONNECT(&humanizeControls->attackKnob, valueChangedNotifier, -	        this, &DGWindow::attackValueChanged); - -	CONNECT(&humanizeControls->falloffKnob, valueChangedNotifier, -	        this, &DGWindow::falloffValueChanged); - -	// Store pointers for PluginGUI access: -	velocityCheck = &humanizeControls->velocityCheck; -	attackKnob = &humanizeControls->attackKnob; -	falloffKnob = &humanizeControls->falloffKnob; - -	VerticalLine *l3 = new VerticalLine(this); -	l3->resize(width - border, vlineSpacing); -	layout.addItem(l3); - -	disk_streaming_controls = new DiskStreamingControls(this); -	disk_streaming_controls->resize(80 * 4, 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->chunkKnob, valueChangedNotifier, -	        this, &DGWindow::chunkValueChanged); - -	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(width, 20); -	lbl_version->setAlignment(TextAlignment::center); -	layout.addItem(lbl_version); - -	lbl_underruns.setText("Underruns: 0"); -	lbl_underruns.resize(width, 20); -	lbl_underruns.setAlignment(TextAlignment::center); -	layout.addItem(&lbl_underruns); - -	// Create file browser -	fileBrowser = new FileBrowser(this); -	fileBrowser->move(0, 0); -	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); -	CONNECT(this, settings_notifier.disk_cache_chunk_size, -	        this, &DGWindow::chunkSettingsValueChanged); -	CONNECT(this, settings_notifier.number_of_underruns, -	        this, &DGWindow::underrunsChanged); -} - -DGWindow::~DGWindow() -{ -	delete disk_streaming_controls; -} - -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()) -	{ -		return; -	} - -	Painter p(*this); -	p.drawImageStretched(0,0, back, width(), height()); -	p.drawImage(width() - logo.width(), height() - logo.height(), logo); -	sidebar.setSize(16, height()); -	p.drawImage(0, 0, sidebar); -	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::chunkValueChanged(float value) -{ -	// value is in MB -	settings.disk_cache_chunk_size.store(value * 1024); -} - -void DGWindow::limitSettingsValueChanged(float value) -{ -	disk_streaming_controls->limitKnob.setValue(value / (1024 * 1024)); -} - -void DGWindow::chunkSettingsValueChanged(float value) -{ -	disk_streaming_controls->chunkKnob.setValue(value / 1024); -} - -void DGWindow::underrunsChanged(int underruns) -{ -	static char buf[256]; -	sprintf(buf, "Underuns: %d", underruns); -	lbl_underruns.setText(buf); -} - -void DGWindow::reloadClicked() -{ -	settings.reload_counter++; -} - -void DGWindow::attackValueChanged(float value) -{ -	settings.velocity_modifier_weight.store(value); - -#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; -	} -#endif -} - -void DGWindow::falloffValueChanged(float value) -{ -	settings.velocity_modifier_falloff.store(value); - -#ifdef STANDALONE // For GUI debugging -	drumkitFileProgress->setTotal(100); -	drumkitFileProgress->setValue(value * 100); -#endif -} - -void DGWindow::velocityCheckClick(bool checked) -{ -	settings.enable_velocity_modifier.store(checked); -} - -void DGWindow::kitBrowseClick() -{ -	std::string path = lineedit->text(); -	if(path == "") -	{ -		path = config.lastkit; -	} - -	if(path == "") -	{ -		path = lineedit2->text(); -	} - -	fileBrowser->setPath(path); -	CONNECT(fileBrowser, fileSelectNotifier, this, &DGWindow::selectKitFile); -	fileBrowser->show(); -} - -void DGWindow::midimapBrowseClick() -{ -	std::string path = lineedit2->text(); -	if(path == "") -	{ -		path = config.lastmidimap; -	} - -	if(path == "") -	{ -		path = lineedit->text(); -	} - -	fileBrowser->setPath(path); -	CONNECT(fileBrowser, fileSelectNotifier, this, &DGWindow::selectMapFile); -	fileBrowser->show(); -} - -void DGWindow::selectKitFile(const std::string& filename) -{ -	lineedit->setText(filename); - -	fileBrowser->hide(); - -	std::string drumkit = lineedit->text(); - -	config.lastkit = drumkit; -	config.save(); - -	settings.drumkit_file.store(drumkit); -} - -void DGWindow::selectMapFile(const std::string& filename) -{ -	lineedit2->setText(filename); -	fileBrowser->hide(); - -	std::string midimap = lineedit2->text(); - -	config.lastmidimap = midimap; -	config.save(); - -	settings.midimap_file.store(midimap); -} - - -} // GUI:: diff --git a/plugingui/dgwindow.h b/plugingui/dgwindow.h deleted file mode 100644 index d35caaa..0000000 --- a/plugingui/dgwindow.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - *            dgwindow.h - * - *  Mon Nov 23 20:30:45 CET 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 <settings.h> - -#include "window.h" -#include "label.h" -#include "lineedit.h" -#include "checkbox.h" -#include "button.h" -#include "knob.h" -#include "progressbar.h" -#include "filebrowser.h" -#include "layout.h" -#include "texturedbox.h" -#include "imagecache.h" - -namespace GUI -{ - -class Config; -class Header; -class File; -class DiskStreamingControls; - -class DGWindow -	: public Window -{ -public: -	DGWindow(void* native_window, Config& config, Settings& settings, -	         SettingsNotifier& settings_notifier); -	~DGWindow(); - -	void setDrumKitLoadStatus(LoadStatus load_status); -	void setMidiMapLoadStatus(LoadStatus load_status); - -protected: -	// From Widget: -	void repaintEvent(RepaintEvent* repaintEvent) override; - -private: -	void streamerCheckClick(bool value); -	void limitValueChanged(float value); -	void chunkValueChanged(float value); -	void limitSettingsValueChanged(float value); -	void chunkSettingsValueChanged(float value); -	void reloadClicked(); - -	void attackValueChanged(float value); -	void falloffValueChanged(float value); -	void velocityCheckClick(bool checked); -	void underrunsChanged(int underruns); -	void kitBrowseClick(); -	void midimapBrowseClick(); -	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}; - -	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}; - -	Settings& settings; -	SettingsNotifier& settings_notifier; - -	Label lbl_underruns{this}; -}; - -} // GUI:: diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc deleted file mode 100644 index 3fc8111..0000000 --- a/plugingui/plugingui.cc +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - *            plugingui.cc - * - *  Mon Oct  3 13:40:49 CEST 2011 - *  Copyright 2011 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 "plugingui.h" - -#include <iostream> - -#include <hugin.hpp> - -#include "pluginconfig.h" - -namespace GUI { - -PluginGUI::PluginGUI(Settings& settings, void* native_window) -	: native_window(native_window) -	, settings(settings) -{ -	init(); -} - -PluginGUI::~PluginGUI() -{ -	deinit(); -} - -bool PluginGUI::processEvents() -{ -	if(!initialised) -	{ -		return running; -	} - -	window->eventHandler()->processEvents(); - -	{ -		Painter p(*window); - -		settings_notifier.evaluate(); -	} - -	if(closing) -	{ -		closeNotifier(); -		closing = false; -		return false; -	} - -	return running; -} - -void PluginGUI::init() -{ -	DEBUG(gui, "init"); - -	config = new Config(); -	config->load(); - -	window = new DGWindow(native_window, *config, settings, settings_notifier); - -	auto eventHandler = window->eventHandler(); -	CONNECT(eventHandler, closeNotifier, this, &PluginGUI::closeEventHandler); - -	window->show(); - -	initialised = true; -} - -void PluginGUI::deinit() -{ -	if(config) -	{ -		config->save(); -		delete config; -	} - -	if(window) -	{ -		delete window; -	} -} - -void PluginGUI::show() -{ -	while(!initialised) -	{ -		usleep(10000); -	} - -	if(!window) -	{ -		init(); -	} - -	if(window) -	{ -		window->show(); -	} -} - -void PluginGUI::hide() -{ -	while(!initialised) -	{ -		usleep(10000); -	} - -	if(window) -	{ -		window->hide(); -	} -} - -void PluginGUI::setWindowClosedCallback(void (*handler)(void *), void* ptr) -{ -	windowClosedHandler = handler; -	windowClosedPtr = ptr; -} - -void PluginGUI::closeEventHandler() -{ -	closing = true; -	closeNotifier(); -	// Call old-style notifier if one is registered. -	if(windowClosedHandler) -	{ -		windowClosedHandler(windowClosedPtr); -	} -} - -} // GUI:: diff --git a/plugingui/plugingui.h b/plugingui/plugingui.h deleted file mode 100644 index 04b0a29..0000000 --- a/plugingui/plugingui.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - *            plugingui.h - * - *  Mon Oct  3 13:40:49 CEST 2011 - *  Copyright 2011 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 <settings.h> -#include <notifier.h> - -#include "dgwindow.h" -#include "eventhandler.h" -#include "pluginconfig.h" - -namespace GUI { - -class PluginGUI -	: public Listener -{ -public: -	PluginGUI(Settings& settings, void* native_window = nullptr); -	virtual ~PluginGUI(); - -	//! Process all events and messages in queue -	//! \return true if not closing, returns false if closing. -	bool processEvents(); - -	void init(); -	void deinit(); - -	void show(); -	void hide(); - -	DGWindow* window{nullptr}; -	EventHandler* eventhandler{nullptr}; - -	Config* config{nullptr}; - -	Notifier<> closeNotifier; - -	// Support old interface a little while longer.. -	void setWindowClosedCallback(void (*handler)(void*), void* ptr); - -private: -	void closeEventHandler(); - -	void* native_window{nullptr}; - -	volatile bool running{true}; -	volatile bool closing{false}; -	volatile bool initialised{false}; - -	// For the old-style notifier. -	void (*windowClosedHandler)(void *){nullptr}; -	void *windowClosedPtr{nullptr}; - -	Settings& settings; -	SettingsNotifier settings_notifier{settings}; -}; - -} // GUI:: diff --git a/plugingui/tests/Makefile.am b/plugingui/tests/Makefile.am index 917c66f..63d8c61 100644 --- a/plugingui/tests/Makefile.am +++ b/plugingui/tests/Makefile.am @@ -1,4 +1,4 @@ -noinst_PROGRAMS = resizetest tabwidgettest dgwindowtest framewidgettest \ +noinst_PROGRAMS = resizetest tabwidgettest framewidgettest \  	filebrowsertest  resizetest_LDADD = $(top_srcdir)/plugingui/libdggui.la @@ -28,17 +28,6 @@ filebrowsertest_SOURCES = \  	filebrowsertest.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 -  framewidgettest_LDADD = $(top_srcdir)/plugingui/libdggui.la  framewidgettest_CXXFLAGS = \  	-I$(top_srcdir)/plugingui \ diff --git a/plugingui/tests/dgwindowtest.cc b/plugingui/tests/dgwindowtest.cc deleted file mode 100644 index fb42797..0000000 --- a/plugingui/tests/dgwindowtest.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- 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; -} | 
