diff options
author | David Robillard <d@drobilla.net> | 2007-09-21 04:01:33 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-09-21 04:01:33 +0000 |
commit | a1e97211b02cc1cd9509617cd3452d731ad7b512 (patch) | |
tree | 09fc6e10ce01b6975fc69f3f14bf031919264d80 /src | |
parent | 2fd281a285e4b0bc31e0a0dc6f970359440612c8 (diff) | |
download | ingen-a1e97211b02cc1cd9509617cd3452d731ad7b512.tar.gz ingen-a1e97211b02cc1cd9509617cd3452d731ad7b512.tar.bz2 ingen-a1e97211b02cc1cd9509617cd3452d731ad7b512.zip |
Reimplement menu system to be picturey, glade loaded, heirarchial, code reusey, etc.
Patch port polyphony toggling.
git-svn-id: http://svn.drobilla.net/lad/ingen@745 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/engine/Port.cpp | 5 | ||||
-rw-r--r-- | src/libs/engine/Port.hpp | 1 | ||||
-rw-r--r-- | src/libs/gui/Makefile.am | 6 | ||||
-rw-r--r-- | src/libs/gui/NodeMenu.cpp | 103 | ||||
-rw-r--r-- | src/libs/gui/NodeMenu.hpp | 24 | ||||
-rw-r--r-- | src/libs/gui/NodeModule.cpp | 11 | ||||
-rw-r--r-- | src/libs/gui/NodeModule.hpp | 7 | ||||
-rw-r--r-- | src/libs/gui/ObjectMenu.cpp | 105 | ||||
-rw-r--r-- | src/libs/gui/ObjectMenu.hpp | 68 | ||||
-rw-r--r-- | src/libs/gui/PatchPortModule.cpp | 14 | ||||
-rw-r--r-- | src/libs/gui/PatchPortModule.hpp | 5 | ||||
-rw-r--r-- | src/libs/gui/Port.cpp | 32 | ||||
-rw-r--r-- | src/libs/gui/Port.hpp | 3 | ||||
-rw-r--r-- | src/libs/gui/PortMenu.cpp | 54 | ||||
-rw-r--r-- | src/libs/gui/PortMenu.hpp | 54 | ||||
-rw-r--r-- | src/libs/gui/ingen_gui.glade | 67 |
16 files changed, 411 insertions, 148 deletions
diff --git a/src/libs/engine/Port.cpp b/src/libs/engine/Port.cpp index 30ee73f2..8613581d 100644 --- a/src/libs/engine/Port.cpp +++ b/src/libs/engine/Port.cpp @@ -70,8 +70,7 @@ Port::prepare_poly(uint32_t poly) /* FIXME: poly never goes down, harsh on memory.. */ if (poly > _poly) { _prepared_buffers = new Raul::Array<Buffer*>(poly, *_buffers); - _prepared_poly = poly; - for (uint32_t i = _poly; i < _prepared_poly; ++i) + for (uint32_t i = _poly; i < _prepared_buffers->size(); ++i) _prepared_buffers->at(i) = BufferFactory::create(_type, _buffer_size); } @@ -85,7 +84,7 @@ Port::apply_poly(Raul::Maid& maid, uint32_t poly) if (!_polyphonic || !_parent->polyphonic()) return true; - assert(poly <= _prepared_poly); + assert(poly <= _prepared_buffers->size()); // Apply a new set of buffers from a preceding call to prepare_poly if (_prepared_buffers && _buffers != _prepared_buffers) { diff --git a/src/libs/engine/Port.hpp b/src/libs/engine/Port.hpp index 64fde9cc..f0b7ec25 100644 --- a/src/libs/engine/Port.hpp +++ b/src/libs/engine/Port.hpp @@ -101,7 +101,6 @@ protected: Raul::Array<Buffer*>* _buffers; // Dynamic polyphony - uint32_t _prepared_poly; Raul::Array<Buffer*>* _prepared_buffers; }; diff --git a/src/libs/gui/Makefile.am b/src/libs/gui/Makefile.am index 944df91f..fcfb50aa 100644 --- a/src/libs/gui/Makefile.am +++ b/src/libs/gui/Makefile.am @@ -67,8 +67,12 @@ libingen_gui_la_SOURCES = \ NewSubpatchWindow.hpp \ NodeControlWindow.cpp \ NodeControlWindow.hpp \ - NodeMenu.cpp \ + ObjectMenu.hpp \ + ObjectMenu.cpp \ NodeMenu.hpp \ + NodeMenu.cpp \ + PortMenu.hpp \ + PortMenu.cpp \ NodeModule.cpp \ NodeModule.hpp \ NodePropertiesWindow.cpp \ diff --git a/src/libs/gui/NodeMenu.cpp b/src/libs/gui/NodeMenu.cpp index a4f91e95..54966e7e 100644 --- a/src/libs/gui/NodeMenu.cpp +++ b/src/libs/gui/NodeMenu.cpp @@ -23,97 +23,36 @@ #include "NodeMenu.hpp" #include "WindowFactory.hpp" +using namespace std; using std::cerr; using std::endl; namespace Ingen { namespace GUI { -NodeMenu::NodeMenu(SharedPtr<NodeModel> node) - : _enable_signal(false) - , _node(node) +NodeMenu::NodeMenu(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml) + : ObjectMenu(cobject, xml) , _controls_menuitem(NULL) { - App& app = App::instance(); + Gtk::Menu* node_menu = NULL; + xml->get_widget("node_menu", node_menu); + xml->get_widget("node_controls_menuitem", _controls_menuitem); - Gtk::Menu_Helpers::MenuElem controls_elem = Gtk::Menu_Helpers::MenuElem("Controls", - sigc::bind( - sigc::mem_fun(app.window_factory(), &WindowFactory::present_controls), - node)); - _controls_menuitem = controls_elem.get_child(); - items().push_back(controls_elem); - - items().push_back(Gtk::Menu_Helpers::SeparatorElem()); - - items().push_back(Gtk::Menu_Helpers::MenuElem("Rename...", - sigc::bind( - sigc::mem_fun(app.window_factory(), &WindowFactory::present_rename), - node))); - - /*items().push_back(Gtk::Menu_Helpers::MenuElem("Clone", - sigc::bind( - sigc::mem_fun(app.engine(), &EngineInterface::clone), - node)));*/ - - items().push_back(Gtk::Menu_Helpers::MenuElem("Disconnect All", - sigc::mem_fun(this, &NodeMenu::on_menu_disconnect_all))); - - items().push_back(Gtk::Menu_Helpers::MenuElem("Destroy", - sigc::mem_fun(this, &NodeMenu::on_menu_destroy))); - - //m_controls_menuitem->property_sensitive() = false; - - cerr << "FIXME: MIDI learn menu\n"; - /* - if (_node->plugin() && _node->plugin()->type() == PluginModel::Internal - && _node->plugin()->plug_label() == "midi_control_in") { - items().push_back(Gtk::Menu_Helpers::MenuElem("Learn", - sigc::mem_fun(this, &NodeMenu::on_menu_learn))); - } - */ - - items().push_back(Gtk::Menu_Helpers::SeparatorElem()); - - items().push_back(Gtk::Menu_Helpers::MenuElem("Properties", - sigc::bind( - sigc::mem_fun(app.window_factory(), &WindowFactory::present_properties), - node))); - - Gtk::Menu_Helpers::CheckMenuElem poly_elem = Gtk::Menu_Helpers::CheckMenuElem( - "Polyphonic", sigc::mem_fun(this, &NodeMenu::on_menu_polyphonic)); - items().push_back(poly_elem); - _polyphonic_menuitem = static_cast<Gtk::RadioMenuItem*>(&items().back()); - _polyphonic_menuitem->set_active(node->polyphonic()); - - node->signal_polyphonic.connect(sigc::mem_fun(this, &NodeMenu::polyphonic_changed)); - - _enable_signal = true; - - //model->new_port_sig.connect(sigc::mem_fun(this, &NodeMenu::add_port)); - //model->destroyed_sig.connect(sigc::mem_fun(this, &NodeMenu::destroy)); -} - - -void -NodeMenu::on_menu_destroy() -{ - App::instance().engine()->destroy(_node->path()); + node_menu->remove(*_controls_menuitem); + items().push_front(Gtk::Menu_Helpers::SeparatorElem()); + insert(*_controls_menuitem, 0); } void -NodeMenu::on_menu_polyphonic() +NodeMenu::init(SharedPtr<NodeModel> node) { - if (_enable_signal) - App::instance().engine()->set_polyphonic(_node->path(), _polyphonic_menuitem->get_active()); -} - + ObjectMenu::init(node); + + _controls_menuitem->signal_activate().connect(sigc::bind( + sigc::mem_fun(App::instance().window_factory(), &WindowFactory::present_controls), + node)); -void -NodeMenu::polyphonic_changed(bool polyphonic) -{ - _enable_signal = false; - _polyphonic_menuitem->set_active(polyphonic); _enable_signal = true; } @@ -160,21 +99,15 @@ NodeMenu::on_menu_clone() void NodeMenu::on_menu_learn() { - App::instance().engine()->midi_learn(_node->path()); -} - -void -NodeMenu::on_menu_disconnect_all() -{ - App::instance().engine()->disconnect_all(_node->path()); + App::instance().engine()->midi_learn(_object->path()); } bool NodeMenu::has_control_inputs() { - for (PortModelList::const_iterator i = _node->ports().begin(); - i != _node->ports().end(); ++i) + const NodeModel* const nm = (NodeModel*)_object.get(); + for (PortModelList::const_iterator i = nm->ports().begin(); i != nm->ports().end(); ++i) if ((*i)->is_input() && (*i)->is_control()) return true; diff --git a/src/libs/gui/NodeMenu.hpp b/src/libs/gui/NodeMenu.hpp index dd31c4ee..20bc62e7 100644 --- a/src/libs/gui/NodeMenu.hpp +++ b/src/libs/gui/NodeMenu.hpp @@ -23,9 +23,9 @@ #include <raul/Path.hpp> #include <raul/SharedPtr.hpp> #include "client/NodeModel.hpp" -using Ingen::Client::NodeModel; +#include "ObjectMenu.hpp" -using std::string; +using Ingen::Client::NodeModel; namespace Ingen { namespace GUI { @@ -39,14 +39,16 @@ class PatchCanvas; * * \ingroup GUI */ -class NodeMenu : public Gtk::Menu +class NodeMenu : public ObjectMenu { public: - NodeMenu(SharedPtr<NodeModel> node); - - virtual void program_add(int bank, int program, const string& name) {} + NodeMenu(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml); + + virtual void program_add(int bank, int program, const std::string& name) {} virtual void program_remove(int bank, int program) {} + void init(SharedPtr<NodeModel> node); + bool has_control_inputs(); protected: @@ -54,18 +56,10 @@ protected: virtual void enable_controls_menuitem(); virtual void disable_controls_menuitem(); - void on_menu_destroy(); - void on_menu_polyphonic(); void on_menu_clone(); void on_menu_learn(); - void on_menu_disconnect_all(); - - void polyphonic_changed(bool p); - bool _enable_signal; - SharedPtr<NodeModel> _node; - Glib::RefPtr<Gtk::MenuItem> _controls_menuitem; - Gtk::CheckMenuItem* _polyphonic_menuitem; + Gtk::MenuItem* _controls_menuitem; }; diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp index 189f1d2d..fb2fbdab 100644 --- a/src/libs/gui/NodeModule.cpp +++ b/src/libs/gui/NodeModule.cpp @@ -36,11 +36,14 @@ namespace GUI { NodeModule::NodeModule(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeModel> node) -: FlowCanvas::Module(canvas, node->path().name()), - _node(node), - _menu(node) + : FlowCanvas::Module(canvas, node->path().name()) + , _node(node) { assert(_node); + + Glib::RefPtr<Gnome::Glade::Xml> xml = GladeFactory::new_glade_reference(); + xml->get_widget_derived("object_menu", _menu); + _menu->init(node); node->signal_new_port.connect(sigc::bind(sigc::mem_fun(this, &NodeModule::add_port), true)); node->signal_removed_port.connect(sigc::mem_fun(this, &NodeModule::remove_port)); @@ -152,7 +155,7 @@ void NodeModule::on_click(GdkEventButton* event) { if (event->button == 3) - _menu.popup(event->button, event->time); + _menu->popup(event->button, event->time); } diff --git a/src/libs/gui/NodeModule.hpp b/src/libs/gui/NodeModule.hpp index aa77e780..58040989 100644 --- a/src/libs/gui/NodeModule.hpp +++ b/src/libs/gui/NodeModule.hpp @@ -23,7 +23,6 @@ #include <raul/SharedPtr.hpp> #include "Port.hpp" #include "NodeMenu.hpp" -using std::string; class Atom; @@ -55,7 +54,7 @@ public: virtual ~NodeModule(); - boost::shared_ptr<Port> port(const string& port_name) { + boost::shared_ptr<Port> port(const std::string& port_name) { return boost::dynamic_pointer_cast<Ingen::GUI::Port>( Module::get_port(port_name)); } @@ -75,13 +74,13 @@ protected: virtual void on_middle_click(GdkEventButton* ev) { show_control_window(); } void rename(); - void set_metadata(const string& key, const Atom& value); + void set_metadata(const std::string& key, const Atom& value); void add_port(SharedPtr<PortModel> port, bool resize=true); void remove_port(SharedPtr<PortModel> port); SharedPtr<NodeModel> _node; - NodeMenu _menu; + NodeMenu* _menu; }; diff --git a/src/libs/gui/ObjectMenu.cpp b/src/libs/gui/ObjectMenu.cpp new file mode 100644 index 00000000..ca000cfa --- /dev/null +++ b/src/libs/gui/ObjectMenu.cpp @@ -0,0 +1,105 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard <http://drobilla.net> + * + * Ingen 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. + * + * 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 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 + */ + +#include <gtkmm.h> +#include "interface/EngineInterface.hpp" +#include "client/ObjectModel.hpp" +#include "App.hpp" +#include "ObjectMenu.hpp" +#include "WindowFactory.hpp" + +namespace Ingen { +namespace GUI { + + +ObjectMenu::ObjectMenu(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml) + : Gtk::Menu(cobject) + , _enable_signal(false) + , _polyphonic_menuitem(NULL) + , _disconnect_menuitem(NULL) + , _rename_menuitem(NULL) + , _destroy_menuitem(NULL) +{ + xml->get_widget("object_polyphonic_menuitem", _polyphonic_menuitem); + xml->get_widget("object_disconnect_menuitem", _disconnect_menuitem); + xml->get_widget("object_rename_menuitem", _rename_menuitem); + xml->get_widget("object_destroy_menuitem", _destroy_menuitem); +} + + +void +ObjectMenu::init(SharedPtr<ObjectModel> object) +{ + _object = object; + + App& app = App::instance(); + + _polyphonic_menuitem->signal_toggled().connect( + sigc::mem_fun(this, &ObjectMenu::on_menu_polyphonic)); + + _polyphonic_menuitem->set_active(object->polyphonic()); + + _disconnect_menuitem->signal_activate().connect( + sigc::mem_fun(this, &ObjectMenu::on_menu_disconnect)); + + _rename_menuitem->signal_activate().connect(sigc::bind( + sigc::mem_fun(app.window_factory(), &WindowFactory::present_rename), + object)); + + _destroy_menuitem->signal_activate().connect( + sigc::mem_fun(this, &ObjectMenu::on_menu_destroy)); + + object->signal_polyphonic.connect(sigc::mem_fun(this, &ObjectMenu::polyphonic_changed)); + + _enable_signal = true; +} + + +void +ObjectMenu::on_menu_destroy() +{ + App::instance().engine()->destroy(_object->path()); +} + + +void +ObjectMenu::on_menu_polyphonic() +{ + if (_enable_signal) + App::instance().engine()->set_polyphonic(_object->path(), _polyphonic_menuitem->get_active()); +} + + +void +ObjectMenu::polyphonic_changed(bool polyphonic) +{ + _enable_signal = false; + _polyphonic_menuitem->set_active(polyphonic); + _enable_signal = true; +} + + +void +ObjectMenu::on_menu_disconnect() +{ + App::instance().engine()->disconnect_all(_object->path()); +} + + +} // namespace GUI +} // namespace Ingen + diff --git a/src/libs/gui/ObjectMenu.hpp b/src/libs/gui/ObjectMenu.hpp new file mode 100644 index 00000000..b65c78ef --- /dev/null +++ b/src/libs/gui/ObjectMenu.hpp @@ -0,0 +1,68 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard <http://drobilla.net> + * + * Ingen 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. + * + * 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 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 OBJECTMENU_H +#define OBJECTMENU_H + +#include <string> +#include <gtkmm.h> +#include <libglademm/xml.h> +#include <raul/Path.hpp> +#include <raul/SharedPtr.hpp> +#include "client/ObjectModel.hpp" +using Ingen::Client::ObjectModel; + +namespace Ingen { +namespace GUI { + +class Controller; +class ObjectControlWindow; +class ObjectPropertiesWindow; +class PatchCanvas; + +/** Menu for a Object. + * + * \ingroup GUI + */ +class ObjectMenu : public Gtk::Menu +{ +public: + ObjectMenu(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml); + + void init(SharedPtr<ObjectModel> object); + +protected: + + void on_menu_polyphonic(); + void on_menu_disconnect(); + void on_menu_destroy(); + + void polyphonic_changed(bool polyphonic); + + bool _enable_signal; + SharedPtr<ObjectModel> _object; + Gtk::CheckMenuItem* _polyphonic_menuitem; + Gtk::MenuItem* _disconnect_menuitem; + Gtk::MenuItem* _rename_menuitem; + Gtk::MenuItem* _destroy_menuitem; +}; + + +} // namespace GUI +} // namespace Ingen + +#endif // OBJECTMENU_H diff --git a/src/libs/gui/PatchPortModule.cpp b/src/libs/gui/PatchPortModule.cpp index e07f403c..f52785a4 100644 --- a/src/libs/gui/PatchPortModule.cpp +++ b/src/libs/gui/PatchPortModule.cpp @@ -36,11 +36,6 @@ PatchPortModule::PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, SharedPt : FlowCanvas::Module(canvas, port->path().name(), 0, 0, false), // FIXME: coords? _port(port) { - /*if (port_model()->polyphonic() && port_model()->parent() != NULL - && port_model()->parent_patch()->poly() > 1) { - border_width(2.0); - }*/ - assert(canvas); assert(port); @@ -59,8 +54,11 @@ PatchPortModule::PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, SharedPt canvas->get_new_module_location(default_x, default_y); move_to(default_x, default_y); }*/ + + set_stacked_border(port->polyphonic()); port->signal_metadata.connect(sigc::mem_fun(this, &PatchPortModule::metadata_update)); + port->signal_polyphonic.connect(sigc::mem_fun(this, &PatchPortModule::set_stacked_border)); } @@ -71,11 +69,7 @@ PatchPortModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortMod new PatchPortModule(canvas, port)); assert(ret); - ret->_patch_port = boost::shared_ptr<Port>(new Port(ret, port, true, true)); - ret->_patch_port->menu().items().push_back(Gtk::Menu_Helpers::MenuElem("Rename...", - sigc::bind( - sigc::mem_fun(App::instance().window_factory(), &WindowFactory::present_rename), - port))); + ret->_patch_port = boost::shared_ptr<Port>(new Port(ret, port, true)); ret->add_port(ret->_patch_port); diff --git a/src/libs/gui/PatchPortModule.hpp b/src/libs/gui/PatchPortModule.hpp index ceac4954..7a420a44 100644 --- a/src/libs/gui/PatchPortModule.hpp +++ b/src/libs/gui/PatchPortModule.hpp @@ -56,16 +56,11 @@ public: virtual void store_location(); - //void on_right_click(GdkEventButton* event) { _port->show_menu(event); } - SharedPtr<PortModel> port() const { return _port; } protected: PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortModel> port); - //virtual void on_double_click(GdkEventButton* ev) { show_control_window(); } - //virtual void on_middle_click(GdkEventButton* ev) { show_control_window(); } - void metadata_update(const string& key, const Raul::Atom& value); SharedPtr<PortModel> _port; diff --git a/src/libs/gui/Port.cpp b/src/libs/gui/Port.cpp index d5272878..5eae70c7 100644 --- a/src/libs/gui/Port.cpp +++ b/src/libs/gui/Port.cpp @@ -24,7 +24,8 @@ #include "Configuration.hpp" #include "App.hpp" #include "Port.hpp" -using std::cerr; using std::endl; +#include "PortMenu.hpp" +#include "GladeFactory.hpp" using namespace Ingen::Client; @@ -34,20 +35,22 @@ namespace GUI { /** @param flip Make an input port appear as an output port, and vice versa. */ -Port::Port(boost::shared_ptr<FlowCanvas::Module> module, SharedPtr<PortModel> pm, bool flip, bool destroyable) -: FlowCanvas::Port(module, - pm->path().name(), - flip ? (!pm->is_input()) : pm->is_input(), - App::instance().configuration()->get_port_color(pm.get())), - _port_model(pm) +Port::Port(boost::shared_ptr<FlowCanvas::Module> module, SharedPtr<PortModel> pm, bool flip) + : FlowCanvas::Port(module, + pm->path().name(), + flip ? (!pm->is_input()) : pm->is_input(), + App::instance().configuration()->get_port_color(pm.get())) + , _port_model(pm) { assert(module); assert(_port_model); - if (destroyable) - _menu.items().push_back(Gtk::Menu_Helpers::MenuElem("Destroy", - sigc::mem_fun(this, &Port::on_menu_destroy))); - + PortMenu* menu = NULL; + Glib::RefPtr<Gnome::Glade::Xml> xml = GladeFactory::new_glade_reference(); + xml->get_widget_derived("object_menu", menu); + menu->init(pm); + set_menu(menu); + _port_model->signal_renamed.connect(sigc::mem_fun(this, &Port::renamed)); if (pm->is_control()) { @@ -70,13 +73,6 @@ Port::Port(boost::shared_ptr<FlowCanvas::Module> module, SharedPtr<PortModel> pm void -Port::on_menu_destroy() -{ - App::instance().engine()->destroy(_port_model->path()); -} - - -void Port::renamed() { set_name(_port_model->path().name()); diff --git a/src/libs/gui/Port.hpp b/src/libs/gui/Port.hpp index 5925860d..8da6ce49 100644 --- a/src/libs/gui/Port.hpp +++ b/src/libs/gui/Port.hpp @@ -38,7 +38,7 @@ namespace GUI { class Port : public FlowCanvas::Port { public: - Port(boost::shared_ptr<FlowCanvas::Module> module, SharedPtr<PortModel> pm, bool flip = false, bool destroyable = false); + Port(boost::shared_ptr<FlowCanvas::Module> module, SharedPtr<PortModel> pm, bool flip=false); virtual ~Port() {} @@ -51,7 +51,6 @@ private: void metadata_update(const string& key, const Raul::Atom& value); - void on_menu_destroy(); void renamed(); SharedPtr<PortModel> _port_model; diff --git a/src/libs/gui/PortMenu.cpp b/src/libs/gui/PortMenu.cpp new file mode 100644 index 00000000..8bb002c9 --- /dev/null +++ b/src/libs/gui/PortMenu.cpp @@ -0,0 +1,54 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard <http://drobilla.net> + * + * Ingen 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. + * + * 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 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 + */ + +#include <iostream> +#include <gtkmm.h> +#include <raul/SharedPtr.hpp> +#include "interface/EngineInterface.hpp" +#include "client/PortModel.hpp" +#include "App.hpp" +#include "PortMenu.hpp" +#include "WindowFactory.hpp" + +namespace Ingen { +namespace GUI { + + +PortMenu::PortMenu(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml) + : ObjectMenu(cobject, xml) +{ +} + + +void +PortMenu::init(SharedPtr<PortModel> port) +{ + ObjectMenu::init(port); + + if ( ! PtrCast<PatchModel>(port->parent()) ) { + _polyphonic_menuitem->set_sensitive(false); + _rename_menuitem->hide(); + _destroy_menuitem->hide(); + } + + _enable_signal = true; +} + + +} // namespace GUI +} // namespace Ingen + diff --git a/src/libs/gui/PortMenu.hpp b/src/libs/gui/PortMenu.hpp new file mode 100644 index 00000000..aa520ebc --- /dev/null +++ b/src/libs/gui/PortMenu.hpp @@ -0,0 +1,54 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard <http://drobilla.net> + * + * Ingen 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. + * + * 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 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 NODEMENU_H +#define NODEMENU_H + +#include <string> +#include <gtkmm.h> +#include <raul/Path.hpp> +#include <raul/SharedPtr.hpp> +#include "client/PortModel.hpp" +#include "ObjectMenu.hpp" + +using Ingen::Client::PortModel; + +namespace Ingen { +namespace GUI { + +class Controller; +class PortControlWindow; +class PortPropertiesWindow; +class PatchCanvas; + +/** Controller for a Port. + * + * \ingroup GUI + */ +class PortMenu : public ObjectMenu +{ +public: + PortMenu(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml); + + void init(SharedPtr<PortModel> port); +}; + + +} // namespace GUI +} // namespace Ingen + +#endif // NODEMENU_H diff --git a/src/libs/gui/ingen_gui.glade b/src/libs/gui/ingen_gui.glade index 8d1b157e..498faad4 100644 --- a/src/libs/gui/ingen_gui.glade +++ b/src/libs/gui/ingen_gui.glade @@ -3102,4 +3102,71 @@ Thank you for contributing.</property> </widget> </child> </widget> + <widget class="GtkMenu" id="object_menu"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child> + <widget class="GtkCheckMenuItem" id="object_polyphonic_menuitem"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip" translatable="yes">Expose individual voices</property> + <property name="label" translatable="yes">Polyphonic</property> + <property name="use_underline">True</property> + </widget> + </child> + <child> + <widget class="GtkImageMenuItem" id="object_disconnect_menuitem"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip" translatable="yes">Disconnect all connections</property> + <property name="label" translatable="yes">gtk-disconnect</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + </widget> + </child> + <child> + <widget class="GtkImageMenuItem" id="object_rename_menuitem"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip" translatable="yes">Rename this object</property> + <property name="label" translatable="yes">Rename...</property> + <property name="use_underline">True</property> + <child internal-child="image"> + <widget class="GtkImage" id="menu-item-image20"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="stock">gtk-find-and-replace</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkImageMenuItem" id="object_destroy_menuitem"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip" translatable="yes">Destroy this object</property> + <property name="label" translatable="yes">gtk-delete</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + </widget> + </child> + </widget> + <widget class="GtkMenu" id="node_menu"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child> + <widget class="GtkImageMenuItem" id="node_controls_menuitem"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip" translatable="yes">Manipulate controls in a separate window</property> + <property name="label" translatable="yes">Controls...</property> + <property name="use_underline">True</property> + <child internal-child="image"> + <widget class="GtkImage" id="menu-item-image21"> + <property name="stock">gtk-edit</property> + </widget> + </child> + </widget> + </child> + </widget> </glade-interface> |