From 560fac6a42644bd7584db5f53db19c936ef50ab0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 24 Jul 2007 19:26:47 +0000 Subject: Consistently rename all C++ files .cpp/.hpp. Fix (some) inclusion guard names to not clash with other libs. git-svn-id: http://svn.drobilla.net/lad/patchage@613 a436a847-0d15-0410-975c-d299462d15a1 --- src/AlsaDriver.cpp | 14 ++-- src/AlsaDriver.h | 75 -------------------- src/AlsaDriver.hpp | 75 ++++++++++++++++++++ src/Driver.h | 58 ---------------- src/Driver.hpp | 58 ++++++++++++++++ src/JackDriver.cpp | 18 +++-- src/JackDriver.h | 119 -------------------------------- src/JackDriver.hpp | 116 +++++++++++++++++++++++++++++++ src/JackSettingsDialog.h | 86 ----------------------- src/JackSettingsDialog.hpp | 86 +++++++++++++++++++++++ src/LashDriver.cpp | 11 ++- src/LashDriver.h | 71 ------------------- src/LashDriver.hpp | 71 +++++++++++++++++++ src/Patchage.cpp | 18 ++--- src/Patchage.h | 166 --------------------------------------------- src/Patchage.hpp | 166 +++++++++++++++++++++++++++++++++++++++++++++ src/PatchageCanvas.cpp | 16 ++--- src/PatchageCanvas.h | 59 ---------------- src/PatchageCanvas.hpp | 59 ++++++++++++++++ src/PatchageEvent.cpp | 12 ++-- src/PatchageEvent.h | 103 ---------------------------- src/PatchageEvent.hpp | 102 ++++++++++++++++++++++++++++ src/PatchageModule.h | 133 ------------------------------------ src/PatchageModule.hpp | 133 ++++++++++++++++++++++++++++++++++++ src/PatchagePort.h | 76 --------------------- src/PatchagePort.hpp | 77 +++++++++++++++++++++ src/StateManager.cpp | 7 +- src/StateManager.h | 76 --------------------- src/StateManager.hpp | 76 +++++++++++++++++++++ src/main.cpp | 6 +- 30 files changed, 1067 insertions(+), 1076 deletions(-) delete mode 100644 src/AlsaDriver.h create mode 100644 src/AlsaDriver.hpp delete mode 100644 src/Driver.h create mode 100644 src/Driver.hpp delete mode 100644 src/JackDriver.h create mode 100644 src/JackDriver.hpp delete mode 100644 src/JackSettingsDialog.h create mode 100644 src/JackSettingsDialog.hpp delete mode 100644 src/LashDriver.h create mode 100644 src/LashDriver.hpp delete mode 100644 src/Patchage.h create mode 100644 src/Patchage.hpp delete mode 100644 src/PatchageCanvas.h create mode 100644 src/PatchageCanvas.hpp delete mode 100644 src/PatchageEvent.h create mode 100644 src/PatchageEvent.hpp delete mode 100644 src/PatchageModule.h create mode 100644 src/PatchageModule.hpp delete mode 100644 src/PatchagePort.h create mode 100644 src/PatchagePort.hpp delete mode 100644 src/StateManager.h create mode 100644 src/StateManager.hpp (limited to 'src') diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp index 6a07487..058b0a1 100644 --- a/src/AlsaDriver.cpp +++ b/src/AlsaDriver.cpp @@ -18,15 +18,13 @@ #include #include #include -#include "PatchageCanvas.h" -#include "AlsaDriver.h" -#include "Patchage.h" -#include "PatchageModule.h" -#include "PatchagePort.h" - -using std::cerr; -using std::string; +#include "PatchageCanvas.hpp" +#include "AlsaDriver.hpp" +#include "Patchage.hpp" +#include "PatchageModule.hpp" +#include "PatchagePort.hpp" +using namespace std; using namespace FlowCanvas; AlsaDriver::AlsaDriver(Patchage* app) diff --git a/src/AlsaDriver.h b/src/AlsaDriver.h deleted file mode 100644 index 2408d9d..0000000 --- a/src/AlsaDriver.h +++ /dev/null @@ -1,75 +0,0 @@ -/* This file is part of Patchage. - * Copyright (C) 2007 Dave Robillard - * - * Patchage is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Patchage 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef ALSADRIVER_H -#define ALSADRIVER_H - -#include -#include -#include -#include -#include -#include "Driver.h" -class Patchage; -class PatchagePort; -class PatchageFlowCanvas; - -using std::queue; using std::string; - - -/** Handles all externally driven functionality, registering ports etc. - */ -class AlsaDriver : public Driver -{ -public: - AlsaDriver(Patchage* app); - ~AlsaDriver(); - - void attach(bool launch_daemon = false); - void detach(); - - bool is_attached() const { return (_seq != NULL); } - - void refresh(); - - bool connect(boost::shared_ptr src_port, - boost::shared_ptr dst_port); - - bool disconnect(boost::shared_ptr src_port, - boost::shared_ptr dst_port); - -private: - void refresh_ports(); - void refresh_connections(); - - void add_connections(boost::shared_ptr port); - - bool create_refresh_port(); - static void* refresh_main(void* me); - void _refresh_main(); - - boost::shared_ptr create_port(boost::shared_ptr parent, - const string& name, bool is_input, snd_seq_addr_t addr); - - Patchage* _app; - - snd_seq_t* _seq; - - pthread_t _refresh_thread; -}; - -#endif // ALSADRIVER_H diff --git a/src/AlsaDriver.hpp b/src/AlsaDriver.hpp new file mode 100644 index 0000000..d251d78 --- /dev/null +++ b/src/AlsaDriver.hpp @@ -0,0 +1,75 @@ +/* This file is part of Patchage. + * Copyright (C) 2007 Dave Robillard + * + * Patchage is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Patchage 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef ALSADRIVER_H +#define ALSADRIVER_H + +#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. + */ +class AlsaDriver : public Driver +{ +public: + AlsaDriver(Patchage* app); + ~AlsaDriver(); + + void attach(bool launch_daemon = false); + void detach(); + + bool is_attached() const { return (_seq != NULL); } + + void refresh(); + + bool connect(boost::shared_ptr src_port, + boost::shared_ptr dst_port); + + bool disconnect(boost::shared_ptr src_port, + boost::shared_ptr dst_port); + +private: + void refresh_ports(); + void refresh_connections(); + + void add_connections(boost::shared_ptr port); + + bool create_refresh_port(); + static void* refresh_main(void* me); + void _refresh_main(); + + boost::shared_ptr create_port(boost::shared_ptr parent, + const string& name, bool is_input, snd_seq_addr_t addr); + + Patchage* _app; + + snd_seq_t* _seq; + + pthread_t _refresh_thread; +}; + +#endif // ALSADRIVER_H diff --git a/src/Driver.h b/src/Driver.h deleted file mode 100644 index 7feb8ca..0000000 --- a/src/Driver.h +++ /dev/null @@ -1,58 +0,0 @@ -/* This file is part of Patchage. - * Copyright (C) 2007 Dave Robillard - * - * Patchage is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Patchage 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef DRIVER_H -#define DRIVER_H - -#include -#include -#include -#include "PatchageEvent.h" - -class PatchagePort; - -/** Trival driver base class */ -class Driver { -public: - virtual ~Driver() {} - - virtual void attach(bool launch_daemon) = 0; - virtual void detach() = 0; - virtual bool is_attached() const = 0; - - virtual void refresh() = 0; - - virtual bool connect(boost::shared_ptr src_port, - boost::shared_ptr dst_port) = 0; - - virtual bool disconnect(boost::shared_ptr src_port, - boost::shared_ptr dst_port) = 0; - - Raul::SRSWQueue& events() { return _events; } - - sigc::signal signal_attached; - sigc::signal signal_detached; - -protected: - Driver(size_t event_queue_size) : _events(event_queue_size) {} - - Raul::SRSWQueue _events; -}; - - -#endif // DRIVER_H - diff --git a/src/Driver.hpp b/src/Driver.hpp new file mode 100644 index 0000000..5d0c59d --- /dev/null +++ b/src/Driver.hpp @@ -0,0 +1,58 @@ +/* This file is part of Patchage. + * Copyright (C) 2007 Dave Robillard + * + * Patchage is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Patchage 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef DRIVER_H +#define DRIVER_H + +#include +#include +#include +#include "PatchageEvent.hpp" + +class PatchagePort; + +/** Trival driver base class */ +class Driver { +public: + virtual ~Driver() {} + + virtual void attach(bool launch_daemon) = 0; + virtual void detach() = 0; + virtual bool is_attached() const = 0; + + virtual void refresh() = 0; + + virtual bool connect(boost::shared_ptr src_port, + boost::shared_ptr dst_port) = 0; + + virtual bool disconnect(boost::shared_ptr src_port, + boost::shared_ptr dst_port) = 0; + + Raul::SRSWQueue& events() { return _events; } + + sigc::signal signal_attached; + sigc::signal signal_detached; + +protected: + Driver(size_t event_queue_size) : _events(event_queue_size) {} + + Raul::SRSWQueue _events; +}; + + +#endif // DRIVER_H + diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index 4513830..e088590 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -23,16 +23,14 @@ #include #include #include -#include -#include "PatchageCanvas.h" -#include "PatchageEvent.h" -#include "JackDriver.h" -#include "Patchage.h" -#include "PatchageModule.h" - -using std::cerr; using std::endl; -using std::string; - +#include +#include "PatchageCanvas.hpp" +#include "PatchageEvent.hpp" +#include "JackDriver.hpp" +#include "Patchage.hpp" +#include "PatchageModule.hpp" + +using namespace std; using namespace FlowCanvas; diff --git a/src/JackDriver.h b/src/JackDriver.h deleted file mode 100644 index 1c03972..0000000 --- a/src/JackDriver.h +++ /dev/null @@ -1,119 +0,0 @@ -/* This file is part of Patchage. - * Copyright (C) 2007 Dave Robillard - * - * Patchage is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Patchage 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef JACKDRIVER_H -#define JACKDRIVER_H - -#include -#include -#include -#include -#include -#include -#include "raul/AtomicPtr.h" -#include "Driver.h" -class Patchage; -class PatchageEvent; -class PatchageFlowCanvas; -class PatchagePort; -class PatchageModule; - -using std::string; - - -/** Handles all externally driven functionality, registering ports etc. - * - * Jack callbacks and connect methods and things like that live here. - * Right now just for jack ports, but that will change... - */ -class JackDriver : public Driver -{ -public: - JackDriver(Patchage* app); - ~JackDriver(); - - void attach(bool launch_daemon); - void detach(); - - bool is_attached() const { return (_client != NULL); } - bool is_realtime() const { return _client && jack_is_realtime(_client); } - - void refresh(); - - bool connect(boost::shared_ptr src, - boost::shared_ptr dst); - - bool disconnect(boost::shared_ptr src, - boost::shared_ptr dst); - - void start_transport() { jack_transport_start(_client); } - void stop_transport() { jack_transport_stop(_client); } - - void reset_xruns(); - void reset_delay() { jack_reset_max_delayed_usecs(_client); } - - void rewind_transport() { - jack_position_t zero; - zero.frame = 0; - zero.valid = (jack_position_bits_t)0; - jack_transport_reposition(_client, &zero); - } - - jack_client_t* client() { return _client; } - - jack_nframes_t buffer_size(); - bool set_buffer_size(jack_nframes_t size); - - inline float sample_rate() { return jack_get_sample_rate(_client); } - - inline size_t xruns() { return _xruns; } - - inline float max_delay() { return jack_get_max_delayed_usecs(_client); } - - boost::shared_ptr create_port(boost::shared_ptr parent, - jack_port_t* port); - -private: - - static void error_cb(const char* msg); - - void destroy_all_ports(); - void shutdown(); - - void update_time(); - - static void jack_port_registration_cb(jack_port_id_t port_id, int registered, void* me); - static void jack_port_connect_cb(jack_port_id_t src, jack_port_id_t dst, int connect, void* me); - static int jack_graph_order_cb(void* me); - static int jack_buffer_size_cb(jack_nframes_t buffer_size, void* me); - static int jack_xrun_cb(void* me); - static void jack_shutdown_cb(void* me); - - Patchage* _app; - jack_client_t* _client; - - Glib::Mutex _mutex; - - bool _is_activated; - jack_position_t _last_pos; - jack_nframes_t _buffer_size; - size_t _xruns; - float _xrun_delay; -}; - - -#endif // JACKDRIVER_H diff --git a/src/JackDriver.hpp b/src/JackDriver.hpp new file mode 100644 index 0000000..b66e4ee --- /dev/null +++ b/src/JackDriver.hpp @@ -0,0 +1,116 @@ +/* This file is part of Patchage. + * Copyright (C) 2007 Dave Robillard + * + * Patchage is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Patchage 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef JACKDRIVER_H +#define JACKDRIVER_H + +#include +#include +#include +#include +#include +#include +#include "Driver.hpp" +class Patchage; +class PatchageEvent; +class PatchageFlowCanvas; +class PatchagePort; +class PatchageModule; + + +/** Handles all externally driven functionality, registering ports etc. + * + * Jack callbacks and connect methods and things like that live here. + * Right now just for jack ports, but that will change... + */ +class JackDriver : public Driver +{ +public: + JackDriver(Patchage* app); + ~JackDriver(); + + void attach(bool launch_daemon); + void detach(); + + bool is_attached() const { return (_client != NULL); } + bool is_realtime() const { return _client && jack_is_realtime(_client); } + + void refresh(); + + bool connect(boost::shared_ptr src, + boost::shared_ptr dst); + + bool disconnect(boost::shared_ptr src, + boost::shared_ptr dst); + + void start_transport() { jack_transport_start(_client); } + void stop_transport() { jack_transport_stop(_client); } + + void reset_xruns(); + void reset_delay() { jack_reset_max_delayed_usecs(_client); } + + void rewind_transport() { + jack_position_t zero; + zero.frame = 0; + zero.valid = (jack_position_bits_t)0; + jack_transport_reposition(_client, &zero); + } + + jack_client_t* client() { return _client; } + + jack_nframes_t buffer_size(); + bool set_buffer_size(jack_nframes_t size); + + inline float sample_rate() { return jack_get_sample_rate(_client); } + + inline size_t xruns() { return _xruns; } + + inline float max_delay() { return jack_get_max_delayed_usecs(_client); } + + boost::shared_ptr create_port(boost::shared_ptr parent, + jack_port_t* port); + +private: + + static void error_cb(const char* msg); + + void destroy_all_ports(); + void shutdown(); + + void update_time(); + + static void jack_port_registration_cb(jack_port_id_t port_id, int registered, void* me); + static void jack_port_connect_cb(jack_port_id_t src, jack_port_id_t dst, int connect, void* me); + static int jack_graph_order_cb(void* me); + static int jack_buffer_size_cb(jack_nframes_t buffer_size, void* me); + static int jack_xrun_cb(void* me); + static void jack_shutdown_cb(void* me); + + Patchage* _app; + jack_client_t* _client; + + Glib::Mutex _mutex; + + bool _is_activated; + jack_position_t _last_pos; + jack_nframes_t _buffer_size; + size_t _xruns; + float _xrun_delay; +}; + + +#endif // JACKDRIVER_H diff --git a/src/JackSettingsDialog.h b/src/JackSettingsDialog.h deleted file mode 100644 index 4900a60..0000000 --- a/src/JackSettingsDialog.h +++ /dev/null @@ -1,86 +0,0 @@ -/* This file is part of Patchage. - * Copyright (C) 2007 Dave Robillard - * - * Patchage is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Patchage 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef JACK_SETTINGS_DIALOG_H -#define JACK_SETTINGS_DIALOG_H - -#include -#include -#include -#include - - -class JackSettingsDialog : public Gtk::Dialog { -public: - JackSettingsDialog(BaseObjectType* cobject, const Glib::RefPtr& xml) - : Gtk::Dialog(cobject) - { - xml->get_widget("jack_settings_command_entry", _command_entry); - xml->get_widget("jack_settings_cancel_button", _cancel_button); - xml->get_widget("jack_settings_ok_button", _ok_button); - - _cancel_button->signal_clicked().connect(sigc::mem_fun(this, &JackSettingsDialog::on_cancel)); - _ok_button->signal_clicked().connect(sigc::mem_fun(this, &JackSettingsDialog::on_ok)); - _command_entry->set_text(current_jack_command()); - } - -private: - void on_cancel() - { - hide(); - } - - string current_jack_command() - { - string result; - - const char* const home = getenv("HOME"); - if (home) { - string jackdrc_path(home); - jackdrc_path += "/.jackdrc"; - - ifstream jackdrc(jackdrc_path.c_str()); - std::getline(jackdrc, result); - jackdrc.close(); - } - - return result; - } - - void on_ok() - { - hide(); - const char* const home = getenv("HOME"); - if (home) { - string jackdrc_path(home); - jackdrc_path += "/.jackdrc"; - - ofstream jackdrc(jackdrc_path.c_str()); - jackdrc << _command_entry->get_text() << endl; - jackdrc.close(); - } - } - - - Gtk::Entry* _command_entry; - Gtk::Button* _cancel_button; - Gtk::Button* _ok_button; -}; - - -#endif // JACK_SETTINGS_DIALOG_H - diff --git a/src/JackSettingsDialog.hpp b/src/JackSettingsDialog.hpp new file mode 100644 index 0000000..4900a60 --- /dev/null +++ b/src/JackSettingsDialog.hpp @@ -0,0 +1,86 @@ +/* This file is part of Patchage. + * Copyright (C) 2007 Dave Robillard + * + * Patchage is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Patchage 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef JACK_SETTINGS_DIALOG_H +#define JACK_SETTINGS_DIALOG_H + +#include +#include +#include +#include + + +class JackSettingsDialog : public Gtk::Dialog { +public: + JackSettingsDialog(BaseObjectType* cobject, const Glib::RefPtr& xml) + : Gtk::Dialog(cobject) + { + xml->get_widget("jack_settings_command_entry", _command_entry); + xml->get_widget("jack_settings_cancel_button", _cancel_button); + xml->get_widget("jack_settings_ok_button", _ok_button); + + _cancel_button->signal_clicked().connect(sigc::mem_fun(this, &JackSettingsDialog::on_cancel)); + _ok_button->signal_clicked().connect(sigc::mem_fun(this, &JackSettingsDialog::on_ok)); + _command_entry->set_text(current_jack_command()); + } + +private: + void on_cancel() + { + hide(); + } + + string current_jack_command() + { + string result; + + const char* const home = getenv("HOME"); + if (home) { + string jackdrc_path(home); + jackdrc_path += "/.jackdrc"; + + ifstream jackdrc(jackdrc_path.c_str()); + std::getline(jackdrc, result); + jackdrc.close(); + } + + return result; + } + + void on_ok() + { + hide(); + const char* const home = getenv("HOME"); + if (home) { + string jackdrc_path(home); + jackdrc_path += "/.jackdrc"; + + ofstream jackdrc(jackdrc_path.c_str()); + jackdrc << _command_entry->get_text() << endl; + jackdrc.close(); + } + } + + + Gtk::Entry* _command_entry; + Gtk::Button* _cancel_button; + Gtk::Button* _ok_button; +}; + + +#endif // JACK_SETTINGS_DIALOG_H + diff --git a/src/LashDriver.cpp b/src/LashDriver.cpp index 114748b..5c58444 100644 --- a/src/LashDriver.cpp +++ b/src/LashDriver.cpp @@ -15,15 +15,14 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "LashDriver.h" -#include "config.h" #include #include -#include "Patchage.h" -#include "StateManager.h" +#include "../../config/config.h" +#include "LashDriver.hpp" +#include "Patchage.hpp" +#include "StateManager.hpp" -using std::cerr; using std::cout; using std::endl; -using std::string; +using namespace std; LashDriver::LashDriver(Patchage* app, int argc, char** argv) diff --git a/src/LashDriver.h b/src/LashDriver.h deleted file mode 100644 index 0121509..0000000 --- a/src/LashDriver.h +++ /dev/null @@ -1,71 +0,0 @@ -/* This file is part of Patchage. - * Copyright (C) 2007 Dave Robillard - * - * Patchage is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Patchage 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef LASHDRIVER_H -#define LASHDRIVER_H - -#include -#include -#include "Driver.h" - -class Patchage; - -class LashDriver : public Driver -{ -public: - LashDriver(Patchage* app, int argc, char** argv); - ~LashDriver(); - - void attach(bool launch_daemon); - void detach(); - - bool is_attached() const - { return _server_interface && _server_interface->enabled(); } - - bool connect(boost::shared_ptr, boost::shared_ptr) - { return false; } - - bool disconnect(boost::shared_ptr, boost::shared_ptr) - { return false; } - - void refresh() {} - - void process_events() { _server_interface->process_events(); } - - void restore_project(const std::string& directory); - void set_project_directory(const std::string& directory); - void save_project(); - void close_project(); - -private: - Patchage* _app; - std::string _project_name; - - lash_args_t* _args; - SharedPtr _server_interface; - - void on_project_add(const SharedPtr project); - void on_save_file(const std::string& directory); - void on_restore_file(const std::string& directory); - void on_quit(); - - void handle_event(lash_event_t* conf); - void handle_config(lash_config_t* conf); -}; - - -#endif // LASHDRIVER_H diff --git a/src/LashDriver.hpp b/src/LashDriver.hpp new file mode 100644 index 0000000..225c72f --- /dev/null +++ b/src/LashDriver.hpp @@ -0,0 +1,71 @@ +/* This file is part of Patchage. + * Copyright (C) 2007 Dave Robillard + * + * Patchage is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Patchage 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef LASHDRIVER_H +#define LASHDRIVER_H + +#include +#include +#include "Driver.hpp" + +class Patchage; + +class LashDriver : public Driver +{ +public: + LashDriver(Patchage* app, int argc, char** argv); + ~LashDriver(); + + void attach(bool launch_daemon); + void detach(); + + bool is_attached() const + { return _server_interface && _server_interface->enabled(); } + + bool connect(boost::shared_ptr, boost::shared_ptr) + { return false; } + + bool disconnect(boost::shared_ptr, boost::shared_ptr) + { return false; } + + void refresh() {} + + void process_events() { _server_interface->process_events(); } + + void restore_project(const std::string& directory); + void set_project_directory(const std::string& directory); + void save_project(); + void close_project(); + +private: + Patchage* _app; + std::string _project_name; + + lash_args_t* _args; + SharedPtr _server_interface; + + void on_project_add(const SharedPtr project); + void on_save_file(const std::string& directory); + void on_restore_file(const std::string& directory); + void on_quit(); + + void handle_event(lash_event_t* conf); + void handle_config(lash_config_t* conf); +}; + + +#endif // LASHDRIVER_H diff --git a/src/Patchage.cpp b/src/Patchage.cpp index b6e7f84..a21e578 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -17,27 +17,27 @@ #include #include -#include "Patchage.h" -#include "PatchageEvent.h" #include "../../config/config.h" #include #include #include #include -#include "StateManager.h" -#include "PatchageCanvas.h" #include -#include "JackDriver.h" -#include "JackSettingsDialog.h" +#include "Patchage.hpp" +#include "PatchageEvent.hpp" +#include "StateManager.hpp" +#include "PatchageCanvas.hpp" +#include "JackDriver.hpp" +#include "JackSettingsDialog.hpp" #ifdef HAVE_LASH -#include "LashDriver.h" +#include "LashDriver.hpp" #endif #ifdef HAVE_ALSA -#include "AlsaDriver.h" +#include "AlsaDriver.hpp" #endif // FIXME: include to avoid undefined reference to boost SP debug hooks stuff -#include +#include diff --git a/src/Patchage.h b/src/Patchage.h deleted file mode 100644 index e4112ff..0000000 --- a/src/Patchage.h +++ /dev/null @@ -1,166 +0,0 @@ -/* This file is part of Patchage. - * Copyright (C) 2007 Dave Robillard - * - * Patchage is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Patchage 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef PATCHAGE_H -#define PATCHAGE_H - -#include "config.h" -#include -#include -#include - -using namespace std; - -class PatchageCanvas; -class JackDriver; -class AlsaDriver; -class LashDriver; -class StateManager; -class JackSettingsDialog; - - -class Patchage -{ -public: - Patchage(int argc, char** argv); - ~Patchage(); - - boost::shared_ptr canvas() const { return _canvas; } - - StateManager* state_manager() const { return _state_manager; } - Gtk::Window* window() const { return _main_window; } - JackDriver* jack_driver() const { return _jack_driver; } -#ifdef HAVE_ALSA - AlsaDriver* alsa_driver() const { return _alsa_driver; } -#endif -#ifdef HAVE_LASH - LashDriver* lash_driver() const { return _lash_driver; } -#endif - - void attach(); - void quit() { _main_window->hide(); } - - void clear_load(); - - void update_state(); - void store_window_location(); - - void status_message(const string& msg); - inline void queue_refresh() { _refresh = true; } - - int max_pane_position() - { return _main_paned->property_max_position() - - _messages_expander->get_label_widget()->get_height() - 10; } - -protected: - void connect_widgets(); - - void menu_store_positions(); - void menu_file_quit(); - void show_messages_toggled(); - void view_toolbar_toggled(); - void menu_view_refresh(); - void menu_view_arrange(); - void menu_help_about(); - void zoom(double z); - void zoom_changed(); - bool idle_callback(); - bool update_load(); - void update_toolbar(); - - //void jack_connect_changed(); - void buffer_size_changed(); - //void sample_rate_changed(); - //void realtime_changed(); - - void on_pane_position_changed(); - void on_messages_expander_changed(); - - bool _pane_closed; - bool _update_pane_position; - int _user_pane_position; - -#ifdef HAVE_LASH - LashDriver* _lash_driver; - Gtk::MenuItem* _menu_open_session; - Gtk::MenuItem* _menu_save_session; - Gtk::MenuItem* _menu_save_session_as; - Gtk::MenuItem* _menu_close_session; - Gtk::MenuItem* _menu_lash_launch; - Gtk::MenuItem* _menu_lash_connect; - Gtk::MenuItem* _menu_lash_disconnect; - void menu_open_session(); - void menu_save_session(); - void menu_save_session_as(); - void menu_close_session(); - void menu_lash_launch(); - void menu_lash_connect(); - void menu_lash_disconnect(); -#endif - -#ifdef HAVE_ALSA - AlsaDriver* _alsa_driver; - Gtk::MenuItem* _menu_alsa_connect; - Gtk::MenuItem* _menu_alsa_disconnect; - void menu_alsa_connect(); - void menu_alsa_disconnect(); -#endif - - boost::shared_ptr _canvas; - - JackDriver* _jack_driver; - StateManager* _state_manager; - - Gtk::Main* _gtk_main; - - string _settings_filename; - bool _refresh; - - Gtk::Window* _main_window; - JackSettingsDialog* _jack_settings_dialog; - Gtk::AboutDialog* _about_window; - Gtk::MenuItem* _menu_jack_settings; - Gtk::MenuItem* _menu_jack_launch; - Gtk::MenuItem* _menu_jack_connect; - Gtk::MenuItem* _menu_jack_disconnect; - Gtk::MenuItem* _menu_store_positions; - Gtk::MenuItem* _menu_file_quit; - Gtk::CheckMenuItem* _menu_view_toolbar; - Gtk::CheckMenuItem* _menu_view_messages; - Gtk::MenuItem* _menu_view_refresh; - Gtk::MenuItem* _menu_view_arrange; - Gtk::MenuItem* _menu_help_about; - Gtk::Toolbar* _toolbar; - Gtk::ScrolledWindow* _canvas_scrolledwindow; - Gtk::HScale* _zoom_slider; - Gtk::TextView* _status_text; - Gtk::Paned* _main_paned; - Gtk::Expander* _messages_expander; - Gtk::Button* _rewind_button; - Gtk::Button* _play_button; - Gtk::Button* _stop_button; - Gtk::ToolButton* _zoom_normal_button; - Gtk::ToolButton* _zoom_full_button; - //Gtk::ProgressBar* _load_progress_bar; - Gtk::ComboBox* _buffer_size_combo; - Gtk::Label* _sample_rate_label; - Gtk::ProgressBar* _xrun_progress_bar; - Gtk::ToolButton* _clear_load_button; - //Gtk::Statusbar* _status_bar; -}; - -#endif // PATCHAGE_H diff --git a/src/Patchage.hpp b/src/Patchage.hpp new file mode 100644 index 0000000..e4112ff --- /dev/null +++ b/src/Patchage.hpp @@ -0,0 +1,166 @@ +/* This file is part of Patchage. + * Copyright (C) 2007 Dave Robillard + * + * Patchage is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Patchage 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef PATCHAGE_H +#define PATCHAGE_H + +#include "config.h" +#include +#include +#include + +using namespace std; + +class PatchageCanvas; +class JackDriver; +class AlsaDriver; +class LashDriver; +class StateManager; +class JackSettingsDialog; + + +class Patchage +{ +public: + Patchage(int argc, char** argv); + ~Patchage(); + + boost::shared_ptr canvas() const { return _canvas; } + + StateManager* state_manager() const { return _state_manager; } + Gtk::Window* window() const { return _main_window; } + JackDriver* jack_driver() const { return _jack_driver; } +#ifdef HAVE_ALSA + AlsaDriver* alsa_driver() const { return _alsa_driver; } +#endif +#ifdef HAVE_LASH + LashDriver* lash_driver() const { return _lash_driver; } +#endif + + void attach(); + void quit() { _main_window->hide(); } + + void clear_load(); + + void update_state(); + void store_window_location(); + + void status_message(const string& msg); + inline void queue_refresh() { _refresh = true; } + + int max_pane_position() + { return _main_paned->property_max_position() + - _messages_expander->get_label_widget()->get_height() - 10; } + +protected: + void connect_widgets(); + + void menu_store_positions(); + void menu_file_quit(); + void show_messages_toggled(); + void view_toolbar_toggled(); + void menu_view_refresh(); + void menu_view_arrange(); + void menu_help_about(); + void zoom(double z); + void zoom_changed(); + bool idle_callback(); + bool update_load(); + void update_toolbar(); + + //void jack_connect_changed(); + void buffer_size_changed(); + //void sample_rate_changed(); + //void realtime_changed(); + + void on_pane_position_changed(); + void on_messages_expander_changed(); + + bool _pane_closed; + bool _update_pane_position; + int _user_pane_position; + +#ifdef HAVE_LASH + LashDriver* _lash_driver; + Gtk::MenuItem* _menu_open_session; + Gtk::MenuItem* _menu_save_session; + Gtk::MenuItem* _menu_save_session_as; + Gtk::MenuItem* _menu_close_session; + Gtk::MenuItem* _menu_lash_launch; + Gtk::MenuItem* _menu_lash_connect; + Gtk::MenuItem* _menu_lash_disconnect; + void menu_open_session(); + void menu_save_session(); + void menu_save_session_as(); + void menu_close_session(); + void menu_lash_launch(); + void menu_lash_connect(); + void menu_lash_disconnect(); +#endif + +#ifdef HAVE_ALSA + AlsaDriver* _alsa_driver; + Gtk::MenuItem* _menu_alsa_connect; + Gtk::MenuItem* _menu_alsa_disconnect; + void menu_alsa_connect(); + void menu_alsa_disconnect(); +#endif + + boost::shared_ptr _canvas; + + JackDriver* _jack_driver; + StateManager* _state_manager; + + Gtk::Main* _gtk_main; + + string _settings_filename; + bool _refresh; + + Gtk::Window* _main_window; + JackSettingsDialog* _jack_settings_dialog; + Gtk::AboutDialog* _about_window; + Gtk::MenuItem* _menu_jack_settings; + Gtk::MenuItem* _menu_jack_launch; + Gtk::MenuItem* _menu_jack_connect; + Gtk::MenuItem* _menu_jack_disconnect; + Gtk::MenuItem* _menu_store_positions; + Gtk::MenuItem* _menu_file_quit; + Gtk::CheckMenuItem* _menu_view_toolbar; + Gtk::CheckMenuItem* _menu_view_messages; + Gtk::MenuItem* _menu_view_refresh; + Gtk::MenuItem* _menu_view_arrange; + Gtk::MenuItem* _menu_help_about; + Gtk::Toolbar* _toolbar; + Gtk::ScrolledWindow* _canvas_scrolledwindow; + Gtk::HScale* _zoom_slider; + Gtk::TextView* _status_text; + Gtk::Paned* _main_paned; + Gtk::Expander* _messages_expander; + Gtk::Button* _rewind_button; + Gtk::Button* _play_button; + Gtk::Button* _stop_button; + Gtk::ToolButton* _zoom_normal_button; + Gtk::ToolButton* _zoom_full_button; + //Gtk::ProgressBar* _load_progress_bar; + Gtk::ComboBox* _buffer_size_combo; + Gtk::Label* _sample_rate_label; + Gtk::ProgressBar* _xrun_progress_bar; + Gtk::ToolButton* _clear_load_button; + //Gtk::Statusbar* _status_bar; +}; + +#endif // PATCHAGE_H diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp index 6c9e2c8..22b4d1f 100644 --- a/src/PatchageCanvas.cpp +++ b/src/PatchageCanvas.cpp @@ -15,15 +15,15 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include "config.h" -#include "PatchageCanvas.h" -#include "Patchage.h" -#include "JackDriver.h" -#include "PatchageModule.h" -#include "PatchagePort.h" +#include +#include "../../config/config.h" +#include "PatchageCanvas.hpp" +#include "Patchage.hpp" +#include "JackDriver.hpp" +#include "PatchageModule.hpp" +#include "PatchagePort.hpp" #ifdef HAVE_ALSA -#include "AlsaDriver.h" +#include "AlsaDriver.hpp" #endif PatchageCanvas::PatchageCanvas(Patchage* app, int width, int height) diff --git a/src/PatchageCanvas.h b/src/PatchageCanvas.h deleted file mode 100644 index 4ac5c62..0000000 --- a/src/PatchageCanvas.h +++ /dev/null @@ -1,59 +0,0 @@ -/* This file is part of Patchage. - * Copyright (C) 2007 Dave Robillard - * - * Patchage is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Patchage 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef PATCHAGECANVAS_H -#define PATCHAGECANVAS_H - -#include "../../config/config.h" -#include -#ifdef HAVE_ALSA -#include -#endif -#include -#include "StateManager.h" - -class Patchage; -class PatchageModule; -class PatchagePort; - -using std::string; -using namespace FlowCanvas; - -class PatchageCanvas : public Canvas -{ -public: - PatchageCanvas(Patchage* _app, int width, int height); - - boost::shared_ptr find_module(const string& name, ModuleType type); -#ifdef HAVE_ALSA - boost::shared_ptr find_port(const snd_seq_addr_t* alsa_addr); -#endif - void connect(boost::shared_ptr port1, boost::shared_ptr port2); - void disconnect(boost::shared_ptr port1, boost::shared_ptr port2); - - void status_message(const string& msg); - - boost::shared_ptr get_item(const string& name); - boost::shared_ptr get_port(const string& module_name, - const string& port_name); - -private: - Patchage* _app; -}; - - -#endif // PATCHAGECANVAS_H diff --git a/src/PatchageCanvas.hpp b/src/PatchageCanvas.hpp new file mode 100644 index 0000000..fd662f1 --- /dev/null +++ b/src/PatchageCanvas.hpp @@ -0,0 +1,59 @@ +/* This file is part of Patchage. + * Copyright (C) 2007 Dave Robillard + * + * Patchage is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Patchage 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef PATCHAGECANVAS_H +#define PATCHAGECANVAS_H + +#include "../../config/config.h" +#include +#ifdef HAVE_ALSA +#include +#endif +#include +#include "StateManager.hpp" + +class Patchage; +class PatchageModule; +class PatchagePort; + +using std::string; +using namespace FlowCanvas; + +class PatchageCanvas : public Canvas +{ +public: + PatchageCanvas(Patchage* _app, int width, int height); + + boost::shared_ptr find_module(const string& name, ModuleType type); +#ifdef HAVE_ALSA + boost::shared_ptr find_port(const snd_seq_addr_t* alsa_addr); +#endif + void connect(boost::shared_ptr port1, boost::shared_ptr port2); + void disconnect(boost::shared_ptr port1, boost::shared_ptr port2); + + void status_message(const string& msg); + + boost::shared_ptr get_item(const string& name); + boost::shared_ptr get_port(const string& module_name, + const string& port_name); + +private: + Patchage* _app; +}; + + +#endif // PATCHAGECANVAS_H diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp index 493050a..f996495 100644 --- a/src/PatchageEvent.cpp +++ b/src/PatchageEvent.cpp @@ -16,12 +16,12 @@ */ #include "../../config/config.h" -#include "raul/SharedPtr.h" -#include "Patchage.h" -#include "PatchageCanvas.h" -#include "PatchageModule.h" -#include "PatchageEvent.h" -#include "JackDriver.h" +#include +#include "Patchage.hpp" +#include "PatchageCanvas.hpp" +#include "PatchageModule.hpp" +#include "PatchageEvent.hpp" +#include "JackDriver.hpp" SharedPtr diff --git a/src/PatchageEvent.h b/src/PatchageEvent.h deleted file mode 100644 index 24dd7ba..0000000 --- a/src/PatchageEvent.h +++ /dev/null @@ -1,103 +0,0 @@ -/* This file is part of Patchage. - * Copyright (C) 2007 Dave Robillard - * - * Patchage is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Patchage 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef PATCHAGEEVENT_H -#define PATCHAGEEVENT_H - -#include -#include -#include "../../config/config.h" -#ifdef HAVE_ALSA -#include -#endif -#include "PatchagePort.h" - -class Patchage; - - -/** A Driver event to be processed by the GUI thread. - */ -class PatchageEvent { -public: - enum Type { - NULL_EVENT = 0, - PORT_CREATION, - PORT_DESTRUCTION, - CONNECTION, - DISCONNECTION - }; - - PatchageEvent() - : _type(NULL_EVENT) - {} - - PatchageEvent(Type type, jack_port_id_t port) - : _type(type) - , _port_1(port) - {} - - PatchageEvent(Type type, jack_port_id_t port_1, jack_port_id_t port_2) - : _type(type) - , _port_1(port_1) - , _port_2(port_2) - {} - -#ifdef HAVE_ALSA - PatchageEvent(Type type, snd_seq_addr_t port_1, snd_seq_addr_t port_2) - : _type(type) - , _port_1(port_1) - , _port_2(port_2) - {} -#endif - - void execute(Patchage* patchage); - - inline Type type() const { return (Type)_type; } - -private: - uint8_t _type; - - struct PortRef { - PortRef() : type(NULL_PORT_REF) { id.jack_id = 0; } - - PortRef(jack_port_id_t jack_id) : type(JACK_ID) { id.jack_id = jack_id; } - PortRef(jack_port_t* jack_port) : type(JACK_PORT) { id.jack_port = jack_port; } - -#ifdef HAVE_ALSA - PortRef(snd_seq_addr_t addr) : type(ALSA_ADDR) { id.alsa_addr = addr; } -#endif - - enum { NULL_PORT_REF, JACK_ID, JACK_PORT, ALSA_ADDR } type; - - union { - jack_port_t* jack_port; - jack_port_id_t jack_id; -#ifdef HAVE_ALSA - snd_seq_addr_t alsa_addr; -#endif - } id; - }; - - PortRef _port_1; - PortRef _port_2; - - boost::shared_ptr find_port(const Patchage* patchage, const PortRef& ref); -}; - - -#endif // PATCHAGEEVENT_H - diff --git a/src/PatchageEvent.hpp b/src/PatchageEvent.hpp new file mode 100644 index 0000000..ada4718 --- /dev/null +++ b/src/PatchageEvent.hpp @@ -0,0 +1,102 @@ +/* This file is part of Patchage. + * Copyright (C) 2007 Dave Robillard + * + * Patchage is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Patchage 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef PATCHAGEEVENT_H +#define PATCHAGEEVENT_H + +#include +#include "../../config/config.h" +#ifdef HAVE_ALSA +#include +#endif +#include "PatchagePort.hpp" + +class Patchage; + + +/** A Driver event to be processed by the GUI thread. + */ +class PatchageEvent { +public: + enum Type { + NULL_EVENT = 0, + PORT_CREATION, + PORT_DESTRUCTION, + CONNECTION, + DISCONNECTION + }; + + PatchageEvent() + : _type(NULL_EVENT) + {} + + PatchageEvent(Type type, jack_port_id_t port) + : _type(type) + , _port_1(port) + {} + + PatchageEvent(Type type, jack_port_id_t port_1, jack_port_id_t port_2) + : _type(type) + , _port_1(port_1) + , _port_2(port_2) + {} + +#ifdef HAVE_ALSA + PatchageEvent(Type type, snd_seq_addr_t port_1, snd_seq_addr_t port_2) + : _type(type) + , _port_1(port_1) + , _port_2(port_2) + {} +#endif + + void execute(Patchage* patchage); + + inline Type type() const { return (Type)_type; } + +private: + uint8_t _type; + + struct PortRef { + PortRef() : type(NULL_PORT_REF) { id.jack_id = 0; } + + PortRef(jack_port_id_t jack_id) : type(JACK_ID) { id.jack_id = jack_id; } + PortRef(jack_port_t* jack_port) : type(JACK_PORT) { id.jack_port = jack_port; } + +#ifdef HAVE_ALSA + PortRef(snd_seq_addr_t addr) : type(ALSA_ADDR) { id.alsa_addr = addr; } +#endif + + enum { NULL_PORT_REF, JACK_ID, JACK_PORT, ALSA_ADDR } type; + + union { + jack_port_t* jack_port; + jack_port_id_t jack_id; +#ifdef HAVE_ALSA + snd_seq_addr_t alsa_addr; +#endif + } id; + }; + + PortRef _port_1; + PortRef _port_2; + + boost::shared_ptr find_port(const Patchage* patchage, const PortRef& ref); +}; + + +#endif // PATCHAGEEVENT_H + diff --git a/src/PatchageModule.h b/src/PatchageModule.h deleted file mode 100644 index 131c86a..0000000 --- a/src/PatchageModule.h +++ /dev/null @@ -1,133 +0,0 @@ -/* This file is part of Patchage. - * Copyright (C) 2007 Dave Robillard - * - * Patchage is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Patchage 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef PATCHAGEMODULE_H -#define PATCHAGEMODULE_H - -#include -#include -#ifdef HAVE_ALSA -#include -#endif -#include -#include -#include "PatchageCanvas.h" -#include "StateManager.h" -#include "PatchagePort.h" - -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) - { - Gtk::Menu::MenuList& items = _menu.items(); - if (type == InputOutput) { - items.push_back(Gtk::Menu_Helpers::MenuElem("Split", - sigc::mem_fun(this, &PatchageModule::split))); - } else { - items.push_back(Gtk::Menu_Helpers::MenuElem("Join", - sigc::mem_fun(this, &PatchageModule::join))); - } - items.push_back(Gtk::Menu_Helpers::MenuElem("Disconnect All", - sigc::mem_fun(this, &PatchageModule::menu_disconnect_all))); - - //signal_clicked.connect(sigc::mem_fun(this, &PatchageModule::on_click)); - } - - virtual ~PatchageModule() { } - - /*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) - return; - - 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 - move_to((canvas->width()/2) - 100 + rand() % 400, - (canvas->height()/2) - 100 + rand() % 400); - } - - void split() { - assert(_type == InputOutput); - _app->state_manager()->set_module_split(_name, true); - _app->queue_refresh(); - } - - void join() { - assert(_type != InputOutput); - _app->state_manager()->set_module_split(_name, false); - _app->queue_refresh(); - } - - virtual void store_location() { - Coord loc = { property_x().get_value(), property_y().get_value() }; - _app->state_manager()->set_module_location(_name, _type, loc); - } - - virtual void show_dialog() {} - - virtual void on_click(GdkEventButton* ev) { - if (ev->button == 3) - _menu.popup(ev->button, ev->time); - FlowCanvas::Item::on_click(ev); - } - - virtual void menu_disconnect_all() { - for (PortVector::iterator p = _ports.begin(); p != _ports.end(); ++p) - (*p)->disconnect_all(); - } - - ModuleType type() { return _type; } - -protected: - Patchage* _app; - Gtk::Menu _menu; - ModuleType _type; -}; - - -#endif // PATCHAGEMODULE_H diff --git a/src/PatchageModule.hpp b/src/PatchageModule.hpp new file mode 100644 index 0000000..244e7bf --- /dev/null +++ b/src/PatchageModule.hpp @@ -0,0 +1,133 @@ +/* This file is part of Patchage. + * Copyright (C) 2007 Dave Robillard + * + * Patchage is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Patchage 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef PATCHAGEMODULE_H +#define PATCHAGEMODULE_H + +#include +#include +#ifdef HAVE_ALSA +#include +#endif +#include +#include +#include "PatchageCanvas.hpp" +#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) + { + Gtk::Menu::MenuList& items = _menu.items(); + if (type == InputOutput) { + items.push_back(Gtk::Menu_Helpers::MenuElem("Split", + sigc::mem_fun(this, &PatchageModule::split))); + } else { + items.push_back(Gtk::Menu_Helpers::MenuElem("Join", + sigc::mem_fun(this, &PatchageModule::join))); + } + items.push_back(Gtk::Menu_Helpers::MenuElem("Disconnect All", + sigc::mem_fun(this, &PatchageModule::menu_disconnect_all))); + + //signal_clicked.connect(sigc::mem_fun(this, &PatchageModule::on_click)); + } + + virtual ~PatchageModule() { } + + /*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) + return; + + 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 + move_to((canvas->width()/2) - 100 + rand() % 400, + (canvas->height()/2) - 100 + rand() % 400); + } + + void split() { + assert(_type == InputOutput); + _app->state_manager()->set_module_split(_name, true); + _app->queue_refresh(); + } + + void join() { + assert(_type != InputOutput); + _app->state_manager()->set_module_split(_name, false); + _app->queue_refresh(); + } + + virtual void store_location() { + Coord loc = { property_x().get_value(), property_y().get_value() }; + _app->state_manager()->set_module_location(_name, _type, loc); + } + + virtual void show_dialog() {} + + virtual void on_click(GdkEventButton* ev) { + if (ev->button == 3) + _menu.popup(ev->button, ev->time); + FlowCanvas::Item::on_click(ev); + } + + virtual void menu_disconnect_all() { + for (PortVector::iterator p = _ports.begin(); p != _ports.end(); ++p) + (*p)->disconnect_all(); + } + + ModuleType type() { return _type; } + +protected: + Patchage* _app; + Gtk::Menu _menu; + ModuleType _type; +}; + + +#endif // PATCHAGEMODULE_H diff --git a/src/PatchagePort.h b/src/PatchagePort.h deleted file mode 100644 index 6109fba..0000000 --- a/src/PatchagePort.h +++ /dev/null @@ -1,76 +0,0 @@ -/* This file is part of Patchage. - * Copyright (C) 2007 Dave Robillard - * - * Patchage is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Patchage 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef PATCHAGEPORT_H -#define PATCHAGEPORT_H - -#include "config.h" -#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 }; - - -/** A Port on a PatchageModule - * - * \ingroup OmGtk - */ -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) - { -#ifdef HAVE_ALSA - _alsa_addr.client = '\0'; - _alsa_addr.port = '\0'; -#endif - } - - virtual ~PatchagePort() {} - -#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; } -#endif - /** Returns the full name of this port, as "modulename:portname" */ - string full_name() const { return _module.lock()->name() + ":" + _name; } - - PortType type() const { return _type; } - -private: -#ifdef HAVE_ALSA - snd_seq_addr_t _alsa_addr; -#endif - PortType _type; -}; - - -#endif // PATCHAGEPORT_H diff --git a/src/PatchagePort.hpp b/src/PatchagePort.hpp new file mode 100644 index 0000000..52fe720 --- /dev/null +++ b/src/PatchagePort.hpp @@ -0,0 +1,77 @@ +/* This file is part of Patchage. + * Copyright (C) 2007 Dave Robillard + * + * Patchage is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Patchage 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef PATCHAGEPORT_H +#define PATCHAGEPORT_H + +#include "../../config/config.h" +#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 }; + + +/** A Port on a PatchageModule + * + * \ingroup OmGtk + */ +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) + { +#ifdef HAVE_ALSA + _alsa_addr.client = '\0'; + _alsa_addr.port = '\0'; +#endif + } + + virtual ~PatchagePort() {} + +#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; } +#endif + /** Returns the full name of this port, as "modulename:portname" */ + string full_name() const { return _module.lock()->name() + ":" + _name; } + + PortType type() const { return _type; } + +private: +#ifdef HAVE_ALSA + snd_seq_addr_t _alsa_addr; +#endif + PortType _type; +}; + + +#endif // PATCHAGEPORT_H diff --git a/src/StateManager.cpp b/src/StateManager.cpp index 8ed3ac8..22fdb9a 100644 --- a/src/StateManager.cpp +++ b/src/StateManager.cpp @@ -15,15 +15,14 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "StateManager.h" #include #include #include #include -#include "Patchage.h" +#include "StateManager.hpp" +#include "Patchage.hpp" -using std::map; using std::list; -using std::cerr; using std::cout; using std::endl; +using namespace std; StateManager::StateManager() diff --git a/src/StateManager.h b/src/StateManager.h deleted file mode 100644 index d7065dd..0000000 --- a/src/StateManager.h +++ /dev/null @@ -1,76 +0,0 @@ -/* This file is part of Patchage. - * Copyright (C) 2007 Dave Robillard - * - * Patchage is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Patchage 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef STATEMANAGER_H -#define STATEMANAGER_H - -#include -#include -#include -#include -#include "PatchagePort.h" - -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); - - Coord get_module_location(const string& name, ModuleType type); - void set_module_location(const 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; - - Coord get_window_location(); - void set_window_location(Coord loc); - - Coord get_window_size(); - void set_window_size(Coord loc); - - float get_zoom(); - void set_zoom(float zoom); - - int get_port_color(PortType type); - -private: - list _module_locations; - map _module_splits; - Coord _window_location; - Coord _window_size; - float _zoom; -}; - - -#endif // STATEMANAGER_H diff --git a/src/StateManager.hpp b/src/StateManager.hpp new file mode 100644 index 0000000..af89944 --- /dev/null +++ b/src/StateManager.hpp @@ -0,0 +1,76 @@ +/* This file is part of Patchage. + * Copyright (C) 2007 Dave Robillard + * + * Patchage is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Patchage 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef STATEMANAGER_H +#define STATEMANAGER_H + +#include +#include +#include +#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); + + Coord get_module_location(const string& name, ModuleType type); + void set_module_location(const 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; + + Coord get_window_location(); + void set_window_location(Coord loc); + + Coord get_window_size(); + void set_window_size(Coord loc); + + float get_zoom(); + void set_zoom(float zoom); + + int get_port_color(PortType type); + +private: + list _module_locations; + map _module_splits; + Coord _window_location; + Coord _window_size; + float _zoom; +}; + + +#endif // STATEMANAGER_H diff --git a/src/main.cpp b/src/main.cpp index c17e3e0..b7bfc36 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,14 +15,14 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" +#include "../../config/config.h" #include #include #include -#include "Patchage.h" -#include "JackDriver.h" +#include "Patchage.hpp" +#include "JackDriver.hpp" #ifdef HAVE_LASH #include -- cgit v1.2.1