summaryrefslogtreecommitdiff
path: root/gtk2_ardour/processor_box.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2012-01-21 20:32:13 +0000
committerCarl Hetherington <carl@carlh.net>2012-01-21 20:32:13 +0000
commiteac552b549126fc69e8a08721c4f46f186d59456 (patch)
treea47d55eee76ce0bc04e203286f163d81617a6a15 /gtk2_ardour/processor_box.cc
parent4381b590bbc6e5e6c3f8d5b4e8d88d8a085280b1 (diff)
Allow individual plugin controls to be shown / hidden.
git-svn-id: svn://localhost/ardour2/branches/3.0@11294 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/processor_box.cc')
-rw-r--r--gtk2_ardour/processor_box.cc181
1 files changed, 88 insertions, 93 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<Action> ProcessorBox::edit_action;
RefPtr<Action> ProcessorBox::controls_action;
Glib::RefPtr<Gdk::Pixbuf> ProcessorEntry::_slider_pixbuf;
-ProcessorEntry::ProcessorEntry (boost::shared_ptr<Processor> p, Width w)
+ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processor> 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<Processor> p, Width w)
set<Evoral::Parameter> p = _processor->what_can_be_automated ();
for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
- if (boost::dynamic_pointer_cast<Amp> (_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<Amp> (_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<Send> (_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<Control*>::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<Control*>::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<Gdk::Pixbuf> s, boost::shared_ptr<AutomationControl> 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<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
+ items.push_back (CheckMenuElem ((*i)->name ()));
+ CheckMenuItem* c = dynamic_cast<CheckMenuItem*> (&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<Gdk::Pixbuf> s, boost::shared_ptr<AutomationControl> 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<Processor>(), w)
+BlankProcessorEntry::BlankProcessorEntry (ProcessorBox* b, Width w)
+ : ProcessorEntry (b, boost::shared_ptr<Processor>(), w)
{
}
-PluginInsertProcessorEntry::PluginInsertProcessorEntry (boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
- : ProcessorEntry (p, w)
+PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> 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<Processor> 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<PluginInsert> pi;
if (single_selection) {
- pi = boost::dynamic_pointer_cast<PluginInsert> (single_selection);
+ pi = boost::dynamic_pointer_cast<PluginInsert> (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<Amp> (single_selection));
+ rename_action->set_sensitive (single_selection && !pi && !boost::dynamic_pointer_cast<Amp> (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<Processor> p)
boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (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<Processor> 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<Processor> (p), true)
- ));
-
- items.push_back (
- MenuElem (_("Hide All Controls"), sigc::bind (sigc::mem_fun (*this, &ProcessorBox::show_or_hide_all_controls), boost::weak_ptr<Processor> (p), false)
- ));
-
- return menu;
-}
-
-void
-ProcessorBox::show_or_hide_all_controls (boost::weak_ptr<Processor> w, bool show)
-{
- boost::shared_ptr<Processor> p (w.lock ());
- if (!p) {
- return;
- }
-
- list<ProcessorEntry*> processors = processor_display.children ();
- list<ProcessorEntry*>::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)
{