From ad3752a9029796b95230b323af138c075c9be93f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 21 Nov 2012 22:11:28 +0000 Subject: GUI::Configuration => GUI::Style. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4844 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/App.cpp | 14 +++--- src/gui/App.hpp | 12 ++--- src/gui/Configuration.cpp | 106 -------------------------------------------- src/gui/Configuration.hpp | 74 ------------------------------- src/gui/GraphBox.cpp | 16 +++---- src/gui/GraphPortModule.cpp | 2 +- src/gui/LoadGraphWindow.cpp | 8 ++-- src/gui/NodeModule.cpp | 6 +-- src/gui/Port.cpp | 4 +- src/gui/Style.cpp | 106 ++++++++++++++++++++++++++++++++++++++++++++ src/gui/Style.hpp | 67 ++++++++++++++++++++++++++++ src/gui/wscript | 2 +- 12 files changed, 205 insertions(+), 212 deletions(-) delete mode 100644 src/gui/Configuration.cpp delete mode 100644 src/gui/Configuration.hpp create mode 100644 src/gui/Style.cpp create mode 100644 src/gui/Style.hpp (limited to 'src/gui') diff --git a/src/gui/App.cpp b/src/gui/App.cpp index ec7321b7..30c31f64 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -36,14 +36,14 @@ #include "raul/Path.hpp" #include "App.hpp" -#include "Configuration.hpp" #include "ConnectWindow.hpp" +#include "GraphTreeWindow.hpp" +#include "GraphWindow.hpp" #include "LoadPluginWindow.hpp" #include "MessagesWindow.hpp" #include "NodeModule.hpp" -#include "GraphTreeWindow.hpp" -#include "GraphWindow.hpp" #include "Port.hpp" +#include "Style.hpp" #include "SubgraphModule.hpp" #include "ThreadedLoader.hpp" #include "WidgetFactory.hpp" @@ -66,7 +66,7 @@ class Port; Gtk::Main* App::_main = 0; App::App(Ingen::World* world) - : _configuration(new Configuration(*this)) + : _style(new Style(*this)) , _about_dialog(NULL) , _window_factory(new WindowFactory(*this)) , _world(world) @@ -90,7 +90,7 @@ App::App(Ingen::World* world) App::~App() { - delete _configuration; + delete _style; delete _window_factory; } @@ -107,8 +107,8 @@ App::create(Ingen::World* world) App* app = new App(world); // Load configuration settings - app->configuration()->load_settings(); - app->configuration()->apply_settings(); + app->style()->load_settings(); + app->style()->apply_settings(); // Set default window icon app->_about_dialog->property_program_name() = "Ingen"; diff --git a/src/gui/App.hpp b/src/gui/App.hpp index 8cf2b61e..2b27de25 100644 --- a/src/gui/App.hpp +++ b/src/gui/App.hpp @@ -54,15 +54,15 @@ namespace Ingen { namespace GUI { -class MessagesWindow; +class ConnectWindow; class GraphCanvas; class GraphTreeView; class GraphTreeWindow; -class ConnectWindow; -class Configuration; +class MessagesWindow; +class Port; +class Style; class ThreadedLoader; class WindowFactory; -class Port; /** Ingen Gtk Application. * \ingroup GUI @@ -103,7 +103,7 @@ public: ConnectWindow* connect_window() const { return _connect_window; } MessagesWindow* messages_dialog() const { return _messages_window; } GraphTreeWindow* graph_tree() const { return _graph_tree_window; } - Configuration* configuration() const { return _configuration; } + Style* style() const { return _style; } WindowFactory* window_factory() const { return _window_factory; } Glib::RefPtr icon_from_path(const std::string& path, int size); @@ -156,7 +156,7 @@ protected: SharedPtr _store; SharedPtr _loader; - Configuration* _configuration; + Style* _style; ConnectWindow* _connect_window; MessagesWindow* _messages_window; diff --git a/src/gui/Configuration.cpp b/src/gui/Configuration.cpp deleted file mode 100644 index 0932c2ee..00000000 --- a/src/gui/Configuration.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or any later version. - - Ingen 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 Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see . -*/ - -#include -#include -#include -#include -#include - -#include "ganv/Port.hpp" -#include "ingen/Log.hpp" -#include "ingen/client/PluginModel.hpp" -#include "ingen/client/PortModel.hpp" -#include "ingen/serialisation/Parser.hpp" - -#include "App.hpp" -#include "Configuration.hpp" -#include "Port.hpp" - -using namespace std; - -namespace Ingen { -namespace GUI { - -using namespace Ingen::Client; - -Configuration::Configuration(App& app) - // Colours from the Tango palette with modified V - : _app(app) - , _audio_port_color(0x4A8A0EFF) // Green - , _control_port_color(0x244678FF) // Blue - , _cv_port_color(0x248780FF) // Teal (between audio and control) - , _event_port_color(0x960909FF) // Red - , _string_port_color(0x5C3566FF) // Plum -{ -} - -Configuration::~Configuration() -{ -} - -/** Loads settings from the rc file. Passing no parameter will load from - * the default location. - */ -void -Configuration::load_settings(string filename) -{ - /* ... */ -} - -/** Saves settings to rc file. Passing no parameter will save to the - * default location. - */ -void -Configuration::save_settings(string filename) -{ - /* ... */ -} - -/** Applies the current loaded settings to whichever parts of the app - * need updating. - */ -void -Configuration::apply_settings() -{ - /* ... */ -} - -uint32_t -Configuration::get_port_color(const Client::PortModel* p) -{ - assert(p != NULL); - const URIs& uris = _app.uris(); - if (p->is_a(uris.lv2_AudioPort)) { - return _audio_port_color; - } else if (p->is_a(uris.lv2_ControlPort)) { - return _control_port_color; - } else if (p->is_a(uris.lv2_CVPort)) { - return _cv_port_color; - } else if (p->supports(uris.atom_String)) { - return _string_port_color; - } else if (_app.can_control(p)) { - return _control_port_color; - } else if (p->is_a(uris.atom_AtomPort)) { - return _event_port_color; - } - - _app.log().warn(Raul::fmt("No known port type for %1%\n") % p->path()); - return 0x666666FF; -} - -} // namespace GUI -} // namespace Ingen diff --git a/src/gui/Configuration.hpp b/src/gui/Configuration.hpp deleted file mode 100644 index 0a9a81f7..00000000 --- a/src/gui/Configuration.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or any later version. - - Ingen 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 Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see . -*/ - -#ifndef INGEN_GUI_CONFIGURATION_HPP -#define INGEN_GUI_CONFIGURATION_HPP - -#include - -#include - -#include "raul/SharedPtr.hpp" - -namespace Ingen { namespace Client { class PortModel; } } - -namespace Ingen { -namespace GUI { - -class App; -class Port; - -/** Singleton state manager for the entire app. - * - * Stores settings like color preferences, search paths, etc. - * (ie any user-defined preferences to be stoed in the rc file). - * - * \ingroup GUI - */ -class Configuration -{ -public: - explicit Configuration(App& app); - ~Configuration(); - - void load_settings(std::string filename = ""); - void save_settings(std::string filename = ""); - - void apply_settings(); - - const std::string& graph_folder() { return _graph_folder; } - void set_graph_folder(const std::string& f) { _graph_folder = f; } - - uint32_t get_port_color(const Client::PortModel* p); - -private: - App& _app; - - /** Most recent graph folder shown in open dialog */ - std::string _graph_folder; - - uint32_t _audio_port_color; - uint32_t _control_port_color; - uint32_t _cv_port_color; - uint32_t _event_port_color; - uint32_t _string_port_color; -}; - -} // namespace GUI -} // namespace Ingen - -#endif // INGEN_GUI_CONFIGURATION_HPP - diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index 2fd796d8..a2f76100 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -30,16 +30,16 @@ #include "App.hpp" #include "BreadCrumbs.hpp" -#include "Configuration.hpp" #include "ConnectWindow.hpp" -#include "LoadGraphWindow.hpp" -#include "LoadPluginWindow.hpp" -#include "MessagesWindow.hpp" -#include "NewSubgraphWindow.hpp" #include "GraphCanvas.hpp" #include "GraphTreeWindow.hpp" #include "GraphView.hpp" #include "GraphWindow.hpp" +#include "LoadGraphWindow.hpp" +#include "LoadPluginWindow.hpp" +#include "MessagesWindow.hpp" +#include "NewSubgraphWindow.hpp" +#include "Style.hpp" #include "ThreadedLoader.hpp" #include "WidgetFactory.hpp" #include "WindowFactory.hpp" @@ -477,8 +477,8 @@ GraphBox::event_save_as() const Raul::Atom& document = _graph->get_property(uris.ingen_document); if (document.type() == uris.forge.URI) dialog.set_uri(document.get_uri()); - else if (_app->configuration()->graph_folder().length() > 0) - dialog.set_current_folder(_app->configuration()->graph_folder()); + else if (_app->style()->graph_folder().length() > 0) + dialog.set_current_folder(_app->style()->graph_folder()); if (dialog.run() != Gtk::RESPONSE_OK) break; @@ -552,7 +552,7 @@ GraphBox::event_save_as() STATUS_CONTEXT_GRAPH); } - _app->configuration()->set_graph_folder(dialog.get_current_folder()); + _app->style()->set_graph_folder(dialog.get_current_folder()); break; } } diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp index c3c3bda3..d819a68a 100644 --- a/src/gui/GraphPortModule.cpp +++ b/src/gui/GraphPortModule.cpp @@ -24,7 +24,7 @@ #include "ingen/client/GraphModel.hpp" #include "App.hpp" -#include "Configuration.hpp" +#include "Style.hpp" #include "GraphCanvas.hpp" #include "GraphPortModule.hpp" #include "GraphWindow.hpp" diff --git a/src/gui/LoadGraphWindow.cpp b/src/gui/LoadGraphWindow.cpp index b5297c86..a7daf90f 100644 --- a/src/gui/LoadGraphWindow.cpp +++ b/src/gui/LoadGraphWindow.cpp @@ -28,9 +28,9 @@ #include "ingen/runtime_paths.hpp" #include "App.hpp" -#include "Configuration.hpp" -#include "LoadGraphWindow.hpp" #include "GraphView.hpp" +#include "LoadGraphWindow.hpp" +#include "Style.hpp" #include "ThreadedLoader.hpp" using namespace std; @@ -125,8 +125,8 @@ LoadGraphWindow::set_graph(SharedPtr graph) void LoadGraphWindow::on_show() { - if (_app->configuration()->graph_folder().length() > 0) - set_current_folder(_app->configuration()->graph_folder()); + if (_app->style()->graph_folder().length() > 0) + set_current_folder(_app->style()->graph_folder()); Gtk::FileChooserDialog::on_show(); } diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index 144bd1be..d70e4fe1 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -31,13 +31,13 @@ #include "raul/Atom.hpp" #include "App.hpp" -#include "Configuration.hpp" -#include "NodeMenu.hpp" -#include "NodeModule.hpp" #include "GraphCanvas.hpp" #include "GraphWindow.hpp" +#include "NodeMenu.hpp" +#include "NodeModule.hpp" #include "Port.hpp" #include "RenameWindow.hpp" +#include "Style.hpp" #include "SubgraphModule.hpp" #include "WidgetFactory.hpp" #include "WindowFactory.hpp" diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 843f0816..0027e480 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -25,10 +25,10 @@ #include "ingen/client/PortModel.hpp" #include "App.hpp" -#include "Configuration.hpp" #include "GraphWindow.hpp" #include "Port.hpp" #include "PortMenu.hpp" +#include "Style.hpp" #include "WidgetFactory.hpp" #include "WindowFactory.hpp" @@ -72,7 +72,7 @@ Port::Port(App& app, bool flip) : Ganv::Port(module, name, flip ? (!pm->is_input()) : pm->is_input(), - app.configuration()->get_port_color(pm.get())) + app.style()->get_port_color(pm.get())) , _app(app) , _port_model(pm) , _pressed(false) diff --git a/src/gui/Style.cpp b/src/gui/Style.cpp new file mode 100644 index 00000000..3c004a20 --- /dev/null +++ b/src/gui/Style.cpp @@ -0,0 +1,106 @@ +/* + This file is part of Ingen. + Copyright 2007-2012 David Robillard + + Ingen is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or any later version. + + Ingen 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 Affero General Public License for details. + + You should have received a copy of the GNU Affero General Public License + along with Ingen. If not, see . +*/ + +#include +#include +#include +#include +#include + +#include "ganv/Port.hpp" +#include "ingen/Log.hpp" +#include "ingen/client/PluginModel.hpp" +#include "ingen/client/PortModel.hpp" +#include "ingen/serialisation/Parser.hpp" + +#include "App.hpp" +#include "Style.hpp" +#include "Port.hpp" + +using namespace std; + +namespace Ingen { +namespace GUI { + +using namespace Ingen::Client; + +Style::Style(App& app) + // Colours from the Tango palette with modified V + : _app(app) + , _audio_port_color(0x4A8A0EFF) // Green + , _control_port_color(0x244678FF) // Blue + , _cv_port_color(0x248780FF) // Teal (between audio and control) + , _event_port_color(0x960909FF) // Red + , _string_port_color(0x5C3566FF) // Plum +{ +} + +Style::~Style() +{ +} + +/** Loads settings from the rc file. Passing no parameter will load from + * the default location. + */ +void +Style::load_settings(string filename) +{ + /* ... */ +} + +/** Saves settings to rc file. Passing no parameter will save to the + * default location. + */ +void +Style::save_settings(string filename) +{ + /* ... */ +} + +/** Applies the current loaded settings to whichever parts of the app + * need updating. + */ +void +Style::apply_settings() +{ + /* ... */ +} + +uint32_t +Style::get_port_color(const Client::PortModel* p) +{ + assert(p != NULL); + const URIs& uris = _app.uris(); + if (p->is_a(uris.lv2_AudioPort)) { + return _audio_port_color; + } else if (p->is_a(uris.lv2_ControlPort)) { + return _control_port_color; + } else if (p->is_a(uris.lv2_CVPort)) { + return _cv_port_color; + } else if (p->supports(uris.atom_String)) { + return _string_port_color; + } else if (_app.can_control(p)) { + return _control_port_color; + } else if (p->is_a(uris.atom_AtomPort)) { + return _event_port_color; + } + + _app.log().warn(Raul::fmt("No known port type for %1%\n") % p->path()); + return 0x666666FF; +} + +} // namespace GUI +} // namespace Ingen diff --git a/src/gui/Style.hpp b/src/gui/Style.hpp new file mode 100644 index 00000000..e1bfaeb1 --- /dev/null +++ b/src/gui/Style.hpp @@ -0,0 +1,67 @@ +/* + This file is part of Ingen. + Copyright 2007-2012 David Robillard + + Ingen is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or any later version. + + Ingen 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 Affero General Public License for details. + + You should have received a copy of the GNU Affero General Public License + along with Ingen. If not, see . +*/ + +#ifndef INGEN_GUI_STYLE_HPP +#define INGEN_GUI_STYLE_HPP + +#include + +#include + +#include "raul/SharedPtr.hpp" + +namespace Ingen { namespace Client { class PortModel; } } + +namespace Ingen { +namespace GUI { + +class App; +class Port; + +class Style +{ +public: + explicit Style(App& app); + ~Style(); + + void load_settings(std::string filename = ""); + void save_settings(std::string filename = ""); + + void apply_settings(); + + const std::string& graph_folder() { return _graph_folder; } + void set_graph_folder(const std::string& f) { _graph_folder = f; } + + uint32_t get_port_color(const Client::PortModel* p); + +private: + App& _app; + + /** Most recent graph folder shown in open dialog */ + std::string _graph_folder; + + uint32_t _audio_port_color; + uint32_t _control_port_color; + uint32_t _cv_port_color; + uint32_t _event_port_color; + uint32_t _string_port_color; +}; + +} // namespace GUI +} // namespace Ingen + +#endif // INGEN_GUI_STYLE_HPP + diff --git a/src/gui/wscript b/src/gui/wscript index 7d022b27..4732e56f 100644 --- a/src/gui/wscript +++ b/src/gui/wscript @@ -29,7 +29,6 @@ def build(bld): obj.source = ''' App.cpp BreadCrumbs.cpp - Configuration.cpp ConnectWindow.cpp Edge.cpp GraphBox.cpp @@ -50,6 +49,7 @@ def build(bld): PortPropertiesWindow.cpp PropertiesWindow.cpp RenameWindow.cpp + Style.cpp SubgraphModule.cpp ThreadedLoader.cpp WidgetFactory.cpp -- cgit v1.2.1