From eac552b549126fc69e8a08721c4f46f186d59456 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 21 Jan 2012 20:32:13 +0000 Subject: [PATCH] Allow individual plugin controls to be shown / hidden. git-svn-id: svn://localhost/ardour2/branches/3.0@11294 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/processor_box.cc | 181 +++++++++++++++++------------------ gtk2_ardour/processor_box.h | 29 ++++-- 2 files changed, 108 insertions(+), 102 deletions(-) diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index db5ee835c5..d3ad32bbf5 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -95,9 +95,10 @@ RefPtr ProcessorBox::edit_action; RefPtr ProcessorBox::controls_action; Glib::RefPtr ProcessorEntry::_slider_pixbuf; -ProcessorEntry::ProcessorEntry (boost::shared_ptr p, Width w) +ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr p, Width w) : _button (ArdourButton::led_default_elements) , _position (PreFader) + , _parent (parent) , _processor (p) , _width (w) , _visual_state (Gtk::STATE_NORMAL) @@ -125,20 +126,19 @@ ProcessorEntry::ProcessorEntry (boost::shared_ptr p, Width w) set p = _processor->what_can_be_automated (); for (set::iterator i = p.begin(); i != p.end(); ++i) { - if (boost::dynamic_pointer_cast (_processor)) { - /* Don't give Fader processors separate controls here */ - continue; + + Control* c = new Control (_slider_pixbuf, _processor->automation_control (*i), _processor->describe_parameter (*i)); + _controls.push_back (c); + + if (boost::dynamic_pointer_cast (_processor) == 0) { + /* Add non-Amp controls to the processor box */ + _vbox.pack_start (c->box); } - string d = _processor->describe_parameter (*i); if (boost::dynamic_pointer_cast (_processor)) { - /* Little hack; don't label send level faders */ - d = ""; + /* Don't label send faders */ + c->hide_label (); } - - Control* c = new Control (_slider_pixbuf, _processor->automation_control (*i), d); - _controls.push_back (c); - _vbox.pack_start (c->box); } setup_tooltip (); @@ -325,16 +325,20 @@ void ProcessorEntry::show_all_controls () { for (list::iterator i = _controls.begin(); i != _controls.end(); ++i) { - (*i)->show (); + (*i)->set_visible (true); } + + _parent->update_gui_object_state (this); } void ProcessorEntry::hide_all_controls () { for (list::iterator i = _controls.begin(); i != _controls.end(); ++i) { - (*i)->hide (); + (*i)->set_visible (false); } + + _parent->update_gui_object_state (this); } void @@ -367,23 +371,59 @@ ProcessorEntry::hide_things () } } -ProcessorEntry::Control::Control (Glib::RefPtr s, boost::shared_ptr c, string const & l) + +Menu * +ProcessorEntry::build_controls_menu () +{ + using namespace Menu_Helpers; + Menu* menu = manage (new Menu); + MenuList& items = menu->items (); + + items.push_back ( + MenuElem (_("Show All Controls"), sigc::mem_fun (*this, &ProcessorEntry::show_all_controls)) + ); + + items.push_back ( + MenuElem (_("Hide All Controls"), sigc::mem_fun (*this, &ProcessorEntry::hide_all_controls)) + ); + + if (!_controls.empty ()) { + items.push_back (SeparatorElem ()); + } + + for (list::iterator i = _controls.begin(); i != _controls.end(); ++i) { + items.push_back (CheckMenuElem ((*i)->name ())); + CheckMenuItem* c = dynamic_cast (&items.back ()); + c->set_active ((*i)->visible ()); + c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i)); + } + + return menu; +} + +void +ProcessorEntry::toggle_control_visibility (Control* c) +{ + c->set_visible (!c->visible ()); + _parent->update_gui_object_state (this); +} + +ProcessorEntry::Control::Control (Glib::RefPtr s, boost::shared_ptr c, string const & n) : _control (c) , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1) , _slider (s, &_adjustment, 0, false) , _ignore_slider_adjustment (false) , _visible (false) + , _name (n) { _slider.set_controllable (c); - if (!l.empty ()) { - box.pack_start (_label); - _label.show (); - _label.set_text (l); - } + box.pack_start (_label); + _label.show (); + _label.set_text (_name); - _slider.show (); box.pack_start (_slider); + _slider.show (); double const lo = c->internal_to_interface (c->lower ()); double const up = c->internal_to_interface (c->upper ()); @@ -459,28 +499,22 @@ ProcessorEntry::Control::set_state (XMLNode const * node) XMLNode* n = GUIObjectState::get_node (node, state_id ()); if (n) { XMLProperty* p = n->property (X_("visible")); - if (p && string_is_affirmative (p->value ())) { - show (); - } else { - hide (); - } + set_visible (p && string_is_affirmative (p->value ())); } else { - hide (); + set_visible (false); } } void -ProcessorEntry::Control::show () +ProcessorEntry::Control::set_visible (bool v) { - box.show (); - _visible = true; -} - -void -ProcessorEntry::Control::hide () -{ - box.hide (); - _visible = false; + if (v) { + box.show (); + } else { + box.hide (); + } + + _visible = v; } /** Called when the Editor might have re-shown things that @@ -494,6 +528,12 @@ ProcessorEntry::Control::hide_things () } } +void +ProcessorEntry::Control::hide_label () +{ + _label.hide (); +} + string ProcessorEntry::Control::state_id () const { @@ -503,13 +543,13 @@ ProcessorEntry::Control::state_id () const return string_compose (X_("control %1"), c->id().to_s ()); } -BlankProcessorEntry::BlankProcessorEntry (Width w) - : ProcessorEntry (boost::shared_ptr(), w) +BlankProcessorEntry::BlankProcessorEntry (ProcessorBox* b, Width w) + : ProcessorEntry (b, boost::shared_ptr(), w) { } -PluginInsertProcessorEntry::PluginInsertProcessorEntry (boost::shared_ptr p, Width w) - : ProcessorEntry (p, w) +PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr p, Width w) + : ProcessorEntry (b, p, w) , _plugin_insert (p) { p->SplittingChanged.connect ( @@ -800,9 +840,9 @@ ProcessorBox::show_processor_menu (int arg) } } - boost::shared_ptr single_selection; + ProcessorEntry* single_selection = 0; if (processor_display.selection().size() == 1) { - single_selection = processor_display.selection().front()->processor (); + single_selection = processor_display.selection().front(); } /* And the controls submenu */ @@ -811,7 +851,7 @@ ProcessorBox::show_processor_menu (int arg) if (controls_menu_item) { if (single_selection) { - Menu* m = build_controls_menu (single_selection); + Menu* m = single_selection->build_controls_menu (); if (m && !m->items().empty()) { controls_menu_item->set_submenu (*m); controls_menu_item->set_sensitive (true); @@ -833,11 +873,11 @@ ProcessorBox::show_processor_menu (int arg) boost::shared_ptr pi; if (single_selection) { - pi = boost::dynamic_pointer_cast (single_selection); + pi = boost::dynamic_pointer_cast (single_selection->processor ()); } /* disallow rename for multiple selections, for plugin inserts and for the fader */ - rename_action->set_sensitive (single_selection && !pi && !boost::dynamic_pointer_cast (single_selection)); + rename_action->set_sensitive (single_selection && !pi && !boost::dynamic_pointer_cast (single_selection->processor ())); processor_menu->popup (1, arg); @@ -1250,7 +1290,7 @@ ProcessorBox::redisplay_processors () &_visible_prefader_processors, &fader_seen)); if (_visible_prefader_processors == 0) { // fader only - BlankProcessorEntry* bpe = new BlankProcessorEntry (_width); + BlankProcessorEntry* bpe = new BlankProcessorEntry (this, _width); bpe->set_pixel_width (get_allocation().get_width()); processor_display.add_child (bpe); } @@ -1371,9 +1411,9 @@ ProcessorBox::add_processor_to_display (boost::weak_ptr p) boost::shared_ptr plugin_insert = boost::dynamic_pointer_cast (processor); ProcessorEntry* e = 0; if (plugin_insert) { - e = new PluginInsertProcessorEntry (plugin_insert, _width); + e = new PluginInsertProcessorEntry (this, plugin_insert, _width); } else { - e = new ProcessorEntry (processor, _width); + e = new ProcessorEntry (this, processor, _width); } e->set_pixel_width (get_allocation().get_width()); @@ -2443,51 +2483,6 @@ ProcessorBox::processor_menu_unmapped () processor_display.remove_placeholder (); } -Menu * -ProcessorBox::build_controls_menu (boost::shared_ptr p) -{ - using namespace Menu_Helpers; - Menu* menu = manage (new Menu); - MenuList& items = menu->items (); - - items.push_back ( - MenuElem (_("Show All Controls"), sigc::bind (sigc::mem_fun (*this, &ProcessorBox::show_or_hide_all_controls), boost::weak_ptr (p), true) - )); - - items.push_back ( - MenuElem (_("Hide All Controls"), sigc::bind (sigc::mem_fun (*this, &ProcessorBox::show_or_hide_all_controls), boost::weak_ptr (p), false) - )); - - return menu; -} - -void -ProcessorBox::show_or_hide_all_controls (boost::weak_ptr w, bool show) -{ - boost::shared_ptr p (w.lock ()); - if (!p) { - return; - } - - list processors = processor_display.children (); - list::iterator i = processors.begin(); - while (i != processors.end () && (*i)->processor() != p) { - ++i; - } - - if (i == processors.end ()) { - return; - } - - if (show) { - (*i)->show_all_controls (); - } else { - (*i)->hide_all_controls (); - } - - update_gui_object_state (*i); -} - XMLNode * ProcessorBox::entry_gui_object_state (ProcessorEntry* entry) { diff --git a/gtk2_ardour/processor_box.h b/gtk2_ardour/processor_box.h index 364ab7b116..c4047cdc83 100644 --- a/gtk2_ardour/processor_box.h +++ b/gtk2_ardour/processor_box.h @@ -101,7 +101,7 @@ private: class ProcessorEntry : public Gtkmm2ext::DnDVBoxChild, public sigc::trackable { public: - ProcessorEntry (boost::shared_ptr, Width); + ProcessorEntry (ProcessorBox *, boost::shared_ptr, Width); ~ProcessorEntry (); Gtk::EventBox& action_widget (); @@ -128,6 +128,7 @@ public: void add_control_state (XMLNode *) const; void set_control_state (XMLNode const *); std::string state_id () const; + Gtk::Menu* build_controls_menu (); static void setup_slider_pix (); @@ -147,6 +148,7 @@ private: std::string name (Width) const; void setup_tooltip (); + ProcessorBox* _parent; boost::shared_ptr _processor; Width _width; Gtk::StateType _visual_state; @@ -158,11 +160,19 @@ private: Control (Glib::RefPtr, boost::shared_ptr, std::string const &); void set_pixel_width (int); - void show (); - void hide (); + void set_visible (bool); void add_state (XMLNode *) const; void set_state (XMLNode const *); void hide_things (); + void hide_label (); + + bool visible () const { + return _visible; + } + + std::string name () const { + return _name; + } Gtk::VBox box; @@ -178,21 +188,24 @@ private: bool _ignore_slider_adjustment; PBD::ScopedConnection _connection; bool _visible; + std::string _name; }; std::list _controls; + + void toggle_control_visibility (Control *); }; class BlankProcessorEntry : public ProcessorEntry { public: - BlankProcessorEntry (Width w); + BlankProcessorEntry (ProcessorBox *, Width w); }; class PluginInsertProcessorEntry : public ProcessorEntry { public: - PluginInsertProcessorEntry (boost::shared_ptr, Width); + PluginInsertProcessorEntry (ProcessorBox *, boost::shared_ptr, Width); void hide_things (); @@ -246,6 +259,8 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARD Gtk::Window* get_processor_ui (boost::shared_ptr) const; void toggle_edit_processor (boost::shared_ptr); + void update_gui_object_state (ProcessorEntry *); + sigc::signal > ProcessorSelected; sigc::signal > ProcessorUnselected; @@ -289,9 +304,6 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARD Gtk::Menu * build_processor_menu (); void show_processor_menu (int); Gtk::Menu* build_possible_aux_menu(); - Gtk::Menu* build_controls_menu (boost::shared_ptr); - - void show_or_hide_all_controls (boost::weak_ptr, bool); void choose_aux (boost::weak_ptr); void choose_send (); @@ -393,7 +405,6 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARD void mixer_strip_delivery_changed (boost::weak_ptr); - void update_gui_object_state (ProcessorEntry *); XMLNode* entry_gui_object_state (ProcessorEntry *); }; -- 2.30.2