From f2d5d172ff5f0ff02e6dfe0d0bd472b068192244 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 6 Oct 2007 23:12:15 +0000 Subject: Access to object properties window via context menu (most importantly the port one, for control ranges). git-svn-id: http://svn.drobilla.net/lad/ingen@833 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/gui/ControlGroups.cpp | 7 +++---- src/libs/gui/ControlGroups.hpp | 3 --- src/libs/gui/DSSIController.hpp | 2 +- src/libs/gui/NodeMenu.hpp | 5 ----- src/libs/gui/ObjectMenu.cpp | 26 +++++++++++++++++++------- src/libs/gui/ObjectMenu.hpp | 2 ++ src/libs/gui/PortMenu.hpp | 5 ----- src/libs/gui/PortPropertiesWindow.cpp | 32 ++++++++++++++++++-------------- src/libs/gui/PortPropertiesWindow.hpp | 18 ++++++++---------- src/libs/gui/WindowFactory.cpp | 35 +++++++++++++++++++++++++---------- src/libs/gui/WindowFactory.hpp | 8 +++++--- src/libs/gui/ingen_gui.glade | 26 ++++++++++++++++++++------ 12 files changed, 101 insertions(+), 68 deletions(-) (limited to 'src/libs/gui') diff --git a/src/libs/gui/ControlGroups.cpp b/src/libs/gui/ControlGroups.cpp index 46052d72..b7828a48 100644 --- a/src/libs/gui/ControlGroups.cpp +++ b/src/libs/gui/ControlGroups.cpp @@ -156,10 +156,9 @@ SliderControlGroup::menu_properties() { Glib::RefPtr xml = GladeFactory::new_glade_reference(); - PortPropertiesWindow* dialog; - xml->get_widget_derived("port_properties_win", dialog); - dialog->init(this, _port_model); - dialog->run(); + PortPropertiesWindow* window; + xml->get_widget_derived("port_properties_win", window); + window->present(_port_model); } diff --git a/src/libs/gui/ControlGroups.hpp b/src/libs/gui/ControlGroups.hpp index 232b1b56..15e5a6ea 100644 --- a/src/libs/gui/ControlGroups.hpp +++ b/src/libs/gui/ControlGroups.hpp @@ -32,7 +32,6 @@ namespace Ingen { namespace GUI { class ControlPanel; -class PortPropertiesWindow; /** A group of controls (for a single Port) in a NodeControlWindow. @@ -50,8 +49,6 @@ public: inline const SharedPtr port_model() const { return _port_model; } protected: - friend class PortPropertiesWindow; - virtual void set_value(float value) = 0; virtual void set_range(float min, float max) {} diff --git a/src/libs/gui/DSSIController.hpp b/src/libs/gui/DSSIController.hpp index 0d7073ea..7d6e0c97 100644 --- a/src/libs/gui/DSSIController.hpp +++ b/src/libs/gui/DSSIController.hpp @@ -36,7 +36,7 @@ namespace Ingen { namespace GUI { class NodeControlWindow; -class NodePropertiesWindow; + /* Controller for a DSSI node. * diff --git a/src/libs/gui/NodeMenu.hpp b/src/libs/gui/NodeMenu.hpp index 715cf6b9..05457b8f 100644 --- a/src/libs/gui/NodeMenu.hpp +++ b/src/libs/gui/NodeMenu.hpp @@ -30,11 +30,6 @@ using Ingen::Client::NodeModel; namespace Ingen { namespace GUI { -class Controller; -class NodeControlWindow; -class NodePropertiesWindow; -class PatchCanvas; - /** Menu for a Node. * diff --git a/src/libs/gui/ObjectMenu.cpp b/src/libs/gui/ObjectMenu.cpp index ca000cfa..73d01389 100644 --- a/src/libs/gui/ObjectMenu.cpp +++ b/src/libs/gui/ObjectMenu.cpp @@ -33,11 +33,13 @@ ObjectMenu::ObjectMenu(BaseObjectType* cobject, const Glib::RefPtrget_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); + xml->get_widget("object_properties_menuitem", _properties_menuitem); } @@ -62,6 +64,9 @@ ObjectMenu::init(SharedPtr object) _destroy_menuitem->signal_activate().connect( sigc::mem_fun(this, &ObjectMenu::on_menu_destroy)); + + _properties_menuitem->signal_activate().connect( + sigc::mem_fun(this, &ObjectMenu::on_menu_properties)); object->signal_polyphonic.connect(sigc::mem_fun(this, &ObjectMenu::polyphonic_changed)); @@ -69,13 +74,6 @@ ObjectMenu::init(SharedPtr object) } -void -ObjectMenu::on_menu_destroy() -{ - App::instance().engine()->destroy(_object->path()); -} - - void ObjectMenu::on_menu_polyphonic() { @@ -99,6 +97,20 @@ ObjectMenu::on_menu_disconnect() App::instance().engine()->disconnect_all(_object->path()); } + +void +ObjectMenu::on_menu_destroy() +{ + App::instance().engine()->destroy(_object->path()); +} + + +void +ObjectMenu::on_menu_properties() +{ + App::instance().window_factory()->present_properties(_object); +} + } // namespace GUI } // namespace Ingen diff --git a/src/libs/gui/ObjectMenu.hpp b/src/libs/gui/ObjectMenu.hpp index b65c78ef..1acc278f 100644 --- a/src/libs/gui/ObjectMenu.hpp +++ b/src/libs/gui/ObjectMenu.hpp @@ -50,6 +50,7 @@ protected: void on_menu_polyphonic(); void on_menu_disconnect(); void on_menu_destroy(); + void on_menu_properties(); void polyphonic_changed(bool polyphonic); @@ -59,6 +60,7 @@ protected: Gtk::MenuItem* _disconnect_menuitem; Gtk::MenuItem* _rename_menuitem; Gtk::MenuItem* _destroy_menuitem; + Gtk::MenuItem* _properties_menuitem; }; diff --git a/src/libs/gui/PortMenu.hpp b/src/libs/gui/PortMenu.hpp index e1079f0d..06e8ac7d 100644 --- a/src/libs/gui/PortMenu.hpp +++ b/src/libs/gui/PortMenu.hpp @@ -30,11 +30,6 @@ using Ingen::Client::PortModel; namespace Ingen { namespace GUI { -class Controller; -class PortControlWindow; -class PortPropertiesWindow; -class PatchCanvas; - /** Menu for a Port. * diff --git a/src/libs/gui/PortPropertiesWindow.cpp b/src/libs/gui/PortPropertiesWindow.cpp index cf8dbd98..a715a114 100644 --- a/src/libs/gui/PortPropertiesWindow.cpp +++ b/src/libs/gui/PortPropertiesWindow.cpp @@ -31,9 +31,8 @@ namespace GUI { PortPropertiesWindow::PortPropertiesWindow(BaseObjectType* cobject, const Glib::RefPtr& xml) - : Gtk::Dialog(cobject) + : Gtk::Window(cobject) , _enable_signal(false) - , _control(NULL) { xml->get_widget("port_properties_min_spinner", _min_spinner); xml->get_widget("port_properties_max_spinner", _max_spinner); @@ -52,13 +51,16 @@ PortPropertiesWindow::PortPropertiesWindow(BaseObjectType* cobject, const Glib:: * This function MUST be called before using this object in any way. */ void -PortPropertiesWindow::init(ControlGroup* control, SharedPtr pm) +PortPropertiesWindow::present(SharedPtr pm) { assert(pm); - assert(control); + for (list::iterator i = _connections.begin(); i != _connections.end(); ++i) + (*i).disconnect(); + + _connections.clear(); + _port_model = pm; - _control = control; set_title(pm->path() + " Properties"); @@ -71,13 +73,19 @@ PortPropertiesWindow::init(ControlGroup* control, SharedPtr pm) _initial_max = max; _min_spinner->set_value(min); - _min_spinner->signal_value_changed().connect(sigc::mem_fun(*this, &PortPropertiesWindow::min_changed)); + _connections.push_back(_min_spinner->signal_value_changed().connect( + sigc::mem_fun(*this, &PortPropertiesWindow::min_changed))); + _max_spinner->set_value(max); - _max_spinner->signal_value_changed().connect(sigc::mem_fun(*this, &PortPropertiesWindow::max_changed)); + _connections.push_back(_max_spinner->signal_value_changed().connect( + sigc::mem_fun(*this, &PortPropertiesWindow::max_changed))); - pm->signal_metadata.connect(sigc::mem_fun(this, &PortPropertiesWindow::metadata_update)); + _connections.push_back(pm->signal_metadata.connect( + sigc::mem_fun(this, &PortPropertiesWindow::metadata_update))); _enable_signal = true; + + Gtk::Window::present(); } @@ -106,8 +114,6 @@ PortPropertiesWindow::min_changed() _max_spinner->set_value(max); } - _control->set_range(min, max); - if (_enable_signal) App::instance().engine()->set_metadata(_port_model->path(), "ingen:minimum", min); } @@ -124,8 +130,6 @@ PortPropertiesWindow::max_changed() _min_spinner->set_value(min); } - _control->set_range(min, max); - if (_enable_signal) App::instance().engine()->set_metadata(_port_model->path(), "ingen:maximum", max); } @@ -136,14 +140,14 @@ PortPropertiesWindow::cancel() { App::instance().engine()->set_metadata(_port_model->path(), "ingen:minimum", _initial_min); App::instance().engine()->set_metadata(_port_model->path(), "ingen:maximum", _initial_max); - delete this; + hide(); } void PortPropertiesWindow::ok() { - delete this; + hide(); } diff --git a/src/libs/gui/PortPropertiesWindow.hpp b/src/libs/gui/PortPropertiesWindow.hpp index 8c8f1c96..5d10960d 100644 --- a/src/libs/gui/PortPropertiesWindow.hpp +++ b/src/libs/gui/PortPropertiesWindow.hpp @@ -27,8 +27,6 @@ using namespace Ingen::Client; namespace Ingen { namespace GUI { -class ControlGroup; - /** Port properties window. * @@ -36,12 +34,12 @@ class ControlGroup; * * \ingroup GUI */ -class PortPropertiesWindow : public Gtk::Dialog +class PortPropertiesWindow : public Gtk::Window { public: PortPropertiesWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); - void init(ControlGroup* control, SharedPtr port_model); + void present(SharedPtr port_model); private: void metadata_update(const string& key, const Atom& value); @@ -56,12 +54,12 @@ private: float _initial_min; float _initial_max; - ControlGroup* _control; - SharedPtr _port_model; - Gtk::SpinButton* _min_spinner; - Gtk::SpinButton* _max_spinner; - Gtk::Button* _cancel_button; - Gtk::Button* _ok_button; + SharedPtr _port_model; + Gtk::SpinButton* _min_spinner; + Gtk::SpinButton* _max_spinner; + Gtk::Button* _cancel_button; + Gtk::Button* _ok_button; + std::list _connections; }; } // namespace GUI diff --git a/src/libs/gui/WindowFactory.cpp b/src/libs/gui/WindowFactory.cpp index 096bb9df..caa02390 100644 --- a/src/libs/gui/WindowFactory.cpp +++ b/src/libs/gui/WindowFactory.cpp @@ -20,8 +20,9 @@ #include "App.hpp" #include "PatchWindow.hpp" #include "GladeFactory.hpp" -#include "NodePropertiesWindow.hpp" #include "PatchPropertiesWindow.hpp" +#include "NodePropertiesWindow.hpp" +#include "PortPropertiesWindow.hpp" #include "NodeControlWindow.hpp" #include "LoadPluginWindow.hpp" #include "LoadPatchWindow.hpp" @@ -44,8 +45,9 @@ WindowFactory::WindowFactory() , _upload_patch_win(NULL) , _new_subpatch_win(NULL) , _load_subpatch_win(NULL) - , _node_properties_win(NULL) , _patch_properties_win(NULL) + , _node_properties_win(NULL) + , _port_properties_win(NULL) { Glib::RefPtr xml = GladeFactory::new_glade_reference(); @@ -54,8 +56,9 @@ WindowFactory::WindowFactory() xml->get_widget_derived("load_remote_patch_win", _load_remote_patch_win); xml->get_widget_derived("new_subpatch_win", _new_subpatch_win); xml->get_widget_derived("load_subpatch_win", _load_subpatch_win); - xml->get_widget_derived("node_properties_win", _node_properties_win); xml->get_widget_derived("patch_properties_win", _patch_properties_win); + xml->get_widget_derived("node_properties_win", _node_properties_win); + xml->get_widget_derived("port_properties_win", _port_properties_win); xml->get_widget_derived("rename_win", _rename_win); #ifdef HAVE_CURL @@ -340,24 +343,36 @@ WindowFactory::present_rename(SharedPtr object) void -WindowFactory::present_properties(SharedPtr node) +WindowFactory::present_properties(SharedPtr object) { - SharedPtr patch = PtrCast(node); + SharedPtr patch = PtrCast(object); if (patch) { - PatchWindowMap::iterator w = _patch_windows.find(patch->path()); if (w != _patch_windows.end()) _patch_properties_win->set_transient_for(*w->second); _patch_properties_win->present(patch); + return; + } - } else { - - PatchWindowMap::iterator w = _patch_windows.find(node->parent()->path()); + SharedPtr node = PtrCast(object); + if (node) { + PatchWindowMap::iterator w = _patch_windows.find(node->path().parent()); if (w != _patch_windows.end()) _node_properties_win->set_transient_for(*w->second); - + _node_properties_win->present(node); + return; + } + + SharedPtr port = PtrCast(object); + if (port) { + PatchWindowMap::iterator w = _patch_windows.find(port->path().parent().parent()); + if (w != _patch_windows.end()) + _patch_properties_win->set_transient_for(*w->second); + + _port_properties_win->present(port); + return; } } diff --git a/src/libs/gui/WindowFactory.hpp b/src/libs/gui/WindowFactory.hpp index 0227f728..91fb27ab 100644 --- a/src/libs/gui/WindowFactory.hpp +++ b/src/libs/gui/WindowFactory.hpp @@ -31,8 +31,9 @@ namespace GUI { class PatchWindow; class NodeControlWindow; -class NodePropertiesWindow; class PatchPropertiesWindow; +class NodePropertiesWindow; +class PortPropertiesWindow; class LoadPatchWindow; class LoadRemotePatchWindow; class UploadPatchWindow; @@ -68,7 +69,7 @@ public: void present_new_subpatch(SharedPtr patch, MetadataMap data = MetadataMap()); void present_load_subpatch(SharedPtr patch, MetadataMap data = MetadataMap()); void present_rename(SharedPtr object); - void present_properties(SharedPtr node); + void present_properties(SharedPtr object); bool remove_patch_window(PatchWindow* win, GdkEventAny* ignored = NULL); @@ -93,8 +94,9 @@ private: UploadPatchWindow* _upload_patch_win; NewSubpatchWindow* _new_subpatch_win; LoadSubpatchWindow* _load_subpatch_win; - NodePropertiesWindow* _node_properties_win; PatchPropertiesWindow* _patch_properties_win; + NodePropertiesWindow* _node_properties_win; + PortPropertiesWindow* _port_properties_win; RenameWindow* _rename_win; }; diff --git a/src/libs/gui/ingen_gui.glade b/src/libs/gui/ingen_gui.glade index e2e9d093..1ef92b53 100644 --- a/src/libs/gui/ingen_gui.glade +++ b/src/libs/gui/ingen_gui.glade @@ -2030,9 +2030,10 @@ Hold <Ctrl> to play controls in either mode. - 6 + 8 Node Properties - Ingen ingen.svg + GTK_WIN_POS_MOUSE True @@ -2985,15 +2986,13 @@ Thank you for contributing. - + 8 GTK_WINDOW_POPUP Port Properties - Ingen False GTK_WIN_POS_MOUSE - True - GDK_WINDOW_TYPE_HINT_DIALOG - + True 8 @@ -3065,7 +3064,7 @@ Thank you for contributing. 2 - + True GTK_BUTTONBOX_END @@ -3150,6 +3149,21 @@ Thank you for contributing. True + + + True + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + View and edit properties + gtk-properties + True + True + + True -- cgit v1.2.1