From 119af67b5139e40eb3f21dde42882765e917efcb Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 2 Jan 2008 04:14:26 +0000 Subject: Minor Patchage code cleanups. git-svn-id: http://svn.drobilla.net/lad/patchage@1001 a436a847-0d15-0410-975c-d299462d15a1 --- src/AlsaDriver.hpp | 21 +++++++++------------ src/GladeFile.hpp | 6 ++---- src/JackSettingsDialog.hpp | 5 ++--- src/LashDriver.hpp | 3 +-- src/Patchage.hpp | 4 +--- src/PatchageCanvas.hpp | 3 +-- src/PatchageModule.hpp | 30 ++++-------------------------- src/PatchagePort.hpp | 15 ++++++--------- src/StateManager.hpp | 36 +++++++++++++++--------------------- 9 files changed, 41 insertions(+), 82 deletions(-) (limited to 'src') diff --git a/src/AlsaDriver.hpp b/src/AlsaDriver.hpp index 11adac7..9e9f2ea 100644 --- a/src/AlsaDriver.hpp +++ b/src/AlsaDriver.hpp @@ -21,14 +21,10 @@ #include #include #include -#include #include #include "Driver.hpp" class Patchage; class PatchagePort; -class PatchageFlowCanvas; - -using std::queue; using std::string; /** Handles all externally driven functionality, registering ports etc. @@ -60,18 +56,19 @@ private: void add_connections(boost::shared_ptr port); - bool create_refresh_port(); + bool create_refresh_port(); static void* refresh_main(void* me); - void _refresh_main(); + void _refresh_main(); - boost::shared_ptr create_port(boost::shared_ptr parent, - const string& name, bool is_input, snd_seq_addr_t addr); + boost::shared_ptr create_port( + boost::shared_ptr parent, + const std::string& name, + bool is_input, + snd_seq_addr_t addr); - Patchage* _app; - + Patchage* _app; snd_seq_t* _seq; - - pthread_t _refresh_thread; + pthread_t _refresh_thread; }; #endif // ALSADRIVER_H diff --git a/src/GladeFile.hpp b/src/GladeFile.hpp index fb4c474..cc0954c 100644 --- a/src/GladeFile.hpp +++ b/src/GladeFile.hpp @@ -24,9 +24,7 @@ #include #include - -class GladeFile -{ +class GladeFile { public: static Glib::RefPtr open(const std::string& base_name) { Glib::RefPtr xml; @@ -52,4 +50,4 @@ public: } }; -#endif //GLADEFILE_HPP +#endif // GLADEFILE_HPP diff --git a/src/JackSettingsDialog.hpp b/src/JackSettingsDialog.hpp index 1acb191..b419d89 100644 --- a/src/JackSettingsDialog.hpp +++ b/src/JackSettingsDialog.hpp @@ -45,7 +45,7 @@ public: private: void on_cancel() { hide(); } - string current_jack_command() { + std::string current_jack_command() { std::string result; const char* const home = getenv("HOME"); @@ -65,7 +65,7 @@ private: hide(); const char* const home = getenv("HOME"); if (home) { - string jackdrc_path(home); + std::string jackdrc_path(home); jackdrc_path += "/.jackdrc"; std::ofstream jackdrc(jackdrc_path.c_str()); @@ -74,7 +74,6 @@ private: } } - Gtk::Entry* _command_entry; Gtk::Button* _cancel_but; Gtk::Button* _ok_but; diff --git a/src/LashDriver.hpp b/src/LashDriver.hpp index 225c72f..4cca58d 100644 --- a/src/LashDriver.hpp +++ b/src/LashDriver.hpp @@ -24,8 +24,7 @@ class Patchage; -class LashDriver : public Driver -{ +class LashDriver : public Driver { public: LashDriver(Patchage* app, int argc, char** argv); ~LashDriver(); diff --git a/src/Patchage.hpp b/src/Patchage.hpp index 752510b..bbf6854 100644 --- a/src/Patchage.hpp +++ b/src/Patchage.hpp @@ -32,9 +32,7 @@ class LashDriver; class StateManager; class JackSettingsDialog; - -class Patchage -{ +class Patchage { public: Patchage(int argc, char** argv); ~Patchage(); diff --git a/src/PatchageCanvas.hpp b/src/PatchageCanvas.hpp index 9661666..d904581 100644 --- a/src/PatchageCanvas.hpp +++ b/src/PatchageCanvas.hpp @@ -33,8 +33,7 @@ class PatchagePort; using std::string; using namespace FlowCanvas; -class PatchageCanvas : public Canvas -{ +class PatchageCanvas : public Canvas { public: PatchageCanvas(Patchage* _app, int width, int height); diff --git a/src/PatchageModule.hpp b/src/PatchageModule.hpp index fc314c1..f046267 100644 --- a/src/PatchageModule.hpp +++ b/src/PatchageModule.hpp @@ -29,17 +29,15 @@ #include "StateManager.hpp" #include "PatchagePort.hpp" -using std::string; using std::list; - using namespace FlowCanvas; class PatchageModule : public Module { public: - PatchageModule(Patchage* app, const string& title, ModuleType type, double x=0, double y=0) - : Module(app->canvas(), title, x, y), - _app(app), - _type(type) + PatchageModule(Patchage* app, const std::string& title, ModuleType type, double x=0, double y=0) + : Module(app->canvas(), title, x, y) + , _app(app) + , _type(type) { _menu = new Gtk::Menu(); Gtk::Menu::MenuList& items = _menu->items(); @@ -56,24 +54,6 @@ public: virtual ~PatchageModule() { delete _menu; } - /*virtual void add_patchage_port(const string& port_name, bool is_input, PortType type) - { - new PatchagePort(this, type, port_name, is_input, _app->state_manager()->get_port_color(type)); - - resize(); - } - - virtual void add_patchage_port(const string& port_name, bool is_input, PortType type, const snd_seq_addr_t addr) - { - PatchagePort* port = new PatchagePort(this, type, port_name, is_input, - _app->state_manager()->get_port_color(type)); - - port->alsa_addr(addr); - - resize(); - }*/ - - virtual void load_location() { boost::shared_ptr canvas = _canvas.lock(); if (!canvas) @@ -81,8 +61,6 @@ public: Coord loc = _app->state_manager()->get_module_location(_name, _type); - //cerr << "******" << _name << " MOVING TO (" << loc.x << "," << loc.y << ")" << endl; - if (loc.x != -1) move_to(loc.x, loc.y); else diff --git a/src/PatchagePort.hpp b/src/PatchagePort.hpp index 1fabe65..82efe3e 100644 --- a/src/PatchagePort.hpp +++ b/src/PatchagePort.hpp @@ -20,18 +20,15 @@ #include CONFIG_H_PATH #include -#include #include #include #include - #ifdef HAVE_ALSA #include #endif using namespace FlowCanvas; -using std::string; using std::list; enum PortType { JACK_AUDIO, JACK_MIDI, ALSA_MIDI }; @@ -43,9 +40,9 @@ enum PortType { JACK_AUDIO, JACK_MIDI, ALSA_MIDI }; class PatchagePort : public FlowCanvas::Port { public: - PatchagePort(boost::shared_ptr module, PortType type, const string& name, bool is_input, int color) - : Port(module, name, is_input, color), - _type(type) + PatchagePort(boost::shared_ptr module, PortType type, const std::string& name, bool is_input, int color) + : Port(module, name, is_input, color) + , _type(type) { #ifdef HAVE_ALSA _alsa_addr.client = '\0'; @@ -58,11 +55,11 @@ public: #ifdef HAVE_ALSA // FIXME: This driver specific crap really needs to go void alsa_addr(const snd_seq_addr_t addr) { _alsa_addr = addr; } - const snd_seq_addr_t* alsa_addr() const - { return (_type == ALSA_MIDI) ? &_alsa_addr : NULL; } + const snd_seq_addr_t* alsa_addr() const { return (_type == ALSA_MIDI) ? &_alsa_addr : NULL; } #endif + /** Returns the full name of this port, as "modulename:portname" */ - string full_name() const { return _module.lock()->name() + ":" + _name; } + std::string full_name() const { return _module.lock()->name() + ":" + _name; } PortType type() const { return _type; } diff --git a/src/StateManager.hpp b/src/StateManager.hpp index 71d6bdd..63b47ec 100644 --- a/src/StateManager.hpp +++ b/src/StateManager.hpp @@ -24,34 +24,22 @@ #include #include "PatchagePort.hpp" -using std::string; using std::list; using std::map; - - enum ModuleType { Input, Output, InputOutput }; struct Coord { double x; double y; }; -// This should probably be moved out in to a seperate class/file.... -typedef struct ModuleLocation -{ - string name; - ModuleType type; // for distinguishing terminal modules (input or output) - Coord loc; -}; - - class StateManager { public: StateManager(); - void load(const string& filename); - void save(const string& filename); + void load(const std::string& filename); + void save(const std::string& filename); - Coord get_module_location(const string& name, ModuleType type); - void set_module_location(const string& name, ModuleType type, Coord loc); + Coord get_module_location(const std::string& name, ModuleType type); + void set_module_location(const std::string& name, ModuleType type, Coord loc); - void set_module_split(const string& name, bool split); - bool get_module_split(const string& name, bool default_val) const; + void set_module_split(const std::string& name, bool split); + bool get_module_split(const std::string& name, bool default_val) const; float get_zoom(); void set_zoom(float zoom); @@ -59,9 +47,15 @@ public: int get_port_color(PortType type); private: - list _module_locations; - map _module_splits; - float _zoom; + struct ModuleLocation { + std::string name; + ModuleType type; // for distinguishing terminal modules (input or output) + Coord loc; + }; + + std::list _module_locations; + std::map _module_splits; + float _zoom; }; -- cgit v1.2.1