merge (with conflict fixes) with master (even against rgareus' recommendation)
[ardour.git] / gtk2_ardour / processor_box.cc
index becfecffb46e88f6acad1cdbecfe4839c1870857..05a373e9d8a01a6df91f73b96c7ed057e0a56f91 100644 (file)
@@ -45,7 +45,9 @@
 #include "ardour/audioengine.h"
 #include "ardour/internal_return.h"
 #include "ardour/internal_send.h"
+#include "ardour/panner_shell.h"
 #include "ardour/plugin_insert.h"
+#include "ardour/pannable.h"
 #include "ardour/port_insert.h"
 #include "ardour/profile.h"
 #include "ardour/return.h"
@@ -122,6 +124,9 @@ ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processo
 
                _button.set_active (_processor->active());
 
+               _routing_icon.set_no_show_all(true);
+               _input_icon.set_no_show_all(true);
+
                _button.show ();
                _routing_icon.set_visible(false);
                _input_icon.hide();
@@ -134,7 +139,15 @@ ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processo
                set<Evoral::Parameter> p = _processor->what_can_be_automated ();
                for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
                        
-                       Control* c = new Control (_processor->automation_control (*i), _processor->describe_parameter (*i));
+                       std::string label = _processor->describe_parameter (*i);
+
+                       if (boost::dynamic_pointer_cast<Send> (_processor)) {
+                               label = _("Send");
+                       } else if (boost::dynamic_pointer_cast<Return> (_processor)) {
+                               label = _("Return");
+                       }
+
+                       Control* c = new Control (_processor->automation_control (*i), label);
                        
                        _controls.push_back (c);
 
@@ -142,11 +155,6 @@ ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processo
                                /* Add non-Amp controls to the processor box */
                                _vbox.pack_start (c->box);
                        }
-
-                       if (boost::dynamic_pointer_cast<Send> (_processor)) {
-                               /* Don't label send faders */
-                               c->hide_label ();
-                       }
                }
 
                _input_icon.set_ports(_processor->input_streams());
@@ -291,12 +299,17 @@ ProcessorEntry::setup_tooltip ()
        if (_processor) {
                boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
                if (pi) {
+                       std::string postfix = "";
+                       uint32_t replicated;
+                       if ((replicated = pi->get_count()) > 1) {
+                               postfix = string_compose(_("\nThis mono plugin has been replicated %1 times."), replicated);
+                       }
                        if (pi->plugin()->has_editor()) {
                                ARDOUR_UI::instance()->set_tip (_button,
-                                               string_compose (_("<b>%1</b>\nDouble-click to show GUI.\nAlt+double-click to show generic GUI."), name (Wide)));
+                                               string_compose (_("<b>%1</b>\nDouble-click to show GUI.\nAlt+double-click to show generic GUI.%2"), name (Wide), postfix));
                        } else {
                                ARDOUR_UI::instance()->set_tip (_button,
-                                               string_compose (_("<b>%1</b>\nDouble-click to show generic GUI."), name (Wide)));
+                                               string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), name (Wide), postfix));
                        }
                        return;
                }
@@ -335,6 +348,13 @@ ProcessorEntry::name (Width w) const
                }
 
        } else {
+               boost::shared_ptr<ARDOUR::PluginInsert> pi;
+               uint32_t replicated;
+               if ((pi = boost::dynamic_pointer_cast<ARDOUR::PluginInsert> (_processor)) != 0
+                               && (replicated = pi->get_count()) > 1)
+               {
+                       name_display += string_compose(_("(%1x1) "), replicated);
+               }
 
                switch (w) {
                case Wide:
@@ -422,7 +442,7 @@ ProcessorEntry::build_controls_menu ()
        
        for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
                items.push_back (CheckMenuElem ((*i)->name ()));
-               CheckMenuItem* c = dynamic_cast<CheckMenuItem*> (&items.back ());
+               Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
                c->set_active ((*i)->visible ());
                c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::toggle_control_visibility), *i));
        }
@@ -437,6 +457,34 @@ ProcessorEntry::toggle_control_visibility (Control* c)
        _parent->update_gui_object_state (this);
 }
 
+Menu *
+ProcessorEntry::build_send_options_menu ()
+{
+       using namespace Menu_Helpers;
+       Menu* menu = manage (new Menu);
+       MenuList& items = menu->items ();
+
+       boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
+       if (send) {
+
+               items.push_back (CheckMenuElem (_("Link panner controls")));
+               CheckMenuItem* c = dynamic_cast<CheckMenuItem*> (&items.back ());
+               c->set_active (send->panner_shell()->is_linked_to_route());
+               c->signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::toggle_panner_link));
+
+       }
+       return menu;
+}
+
+void
+ProcessorEntry::toggle_panner_link ()
+{
+       boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (_processor);
+       if (send) {
+               send->panner_shell()->set_linked_to_route(!send->panner_shell()->is_linked_to_route());
+       }
+}
+
 ProcessorEntry::Control::Control (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)
@@ -511,7 +559,6 @@ ProcessorEntry::Control::set_tooltip ()
 
        string sm = Glib::Markup::escape_text (s.str());
        
-       ARDOUR_UI::instance()->set_tip (_label, sm);
        _slider_persistant_tooltip.set_tip (sm);
        ARDOUR_UI::instance()->set_tip (_button, sm);
 }
@@ -620,12 +667,6 @@ ProcessorEntry::Control::hide_things ()
        }
 }
 
-void
-ProcessorEntry::Control::hide_label ()
-{
-       _label.hide ();
-}
-
 string
 ProcessorEntry::Control::state_id () const
 {
@@ -707,9 +748,6 @@ ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
        cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
        cairo_clip (cr);
 
-       cairo_set_line_width (cr, 5.0);
-       cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
-
        Gtk::Allocation a = get_allocation();
        double const width = a.get_width();
        double const height = a.get_height();
@@ -720,8 +758,6 @@ ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
        cairo_rectangle (cr, 0, 0, width, height);
        cairo_fill (cr);
 
-       const double y0 = _input ? height-.5 : .5;
-
        if (_ports.n_total() > 1) {
                for (uint32_t i = 0; i < _ports.n_total(); ++i) {
                        if (i < _ports.n_midi()) {
@@ -735,10 +771,9 @@ ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
                                                UINT_RGBA_G_FLT(audio_port_color),
                                                UINT_RGBA_B_FLT(audio_port_color));
                        }
-                       const float x = rintf(width * (.2f + .6f * i / (_ports.n_total() - 1.f))) + .5f;
-                       cairo_move_to (cr, x, y0);
-                       cairo_close_path(cr);
-                       cairo_stroke(cr);
+                       const float x = rintf(width * (.2f + .6f * i / (_ports.n_total() - 1.f)));
+                       cairo_rectangle (cr, x-1, 0, 3, height);
+                       cairo_fill(cr);
                }
        } else if (_ports.n_total() == 1) {
                if (_ports.n_midi() == 1) {
@@ -752,8 +787,9 @@ ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
                                        UINT_RGBA_G_FLT(audio_port_color),
                                        UINT_RGBA_B_FLT(audio_port_color));
                }
-               cairo_move_to (cr, rintf(width * .5) + .5f, y0);
-               cairo_close_path(cr);
+               const float x = rintf(width * .5);
+               cairo_rectangle (cr, x-1, 0, 3, height);
+               cairo_fill(cr);
                cairo_stroke(cr);
        }
 
@@ -798,7 +834,7 @@ ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
                        UINT_RGBA_B_FLT(midi_port_color));
        if (midi_sources > 0 && midi_sinks > 0 && sinks > 1 && sources > 1) {
                for (uint32_t i = 0 ; i < midi_sources; ++i) {
-                       const float si_x = rintf(width * (.2f + .6f * i  / (sinks - 1.f))) + .5f;
+                       const float si_x  = rintf(width * (.2f + .6f * i  / (sinks - 1.f))) + .5f;
                        const float si_x0 = rintf(width * (.2f + .6f * i / (sources - 1.f))) + .5f;
                        cairo_move_to (cr, si_x, height);
                        cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
@@ -1085,6 +1121,20 @@ ProcessorBox::show_processor_menu (int arg)
                }
        }
 
+       Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
+       if (send_menu_item) {
+               if (single_selection) {
+                       Menu* m = single_selection->build_send_options_menu ();
+                       if (m && !m->items().empty()) {
+                               send_menu_item->set_submenu (*m);
+                               send_menu_item->set_sensitive (true);
+                       } else {
+                               gtk_menu_item_set_submenu (send_menu_item->gobj(), 0);
+                               send_menu_item->set_sensitive (false);
+                       }
+               }
+       }
+
        /* Sensitise actions as approprioate */
 
         cut_action->set_sensitive (can_cut());
@@ -1396,7 +1446,8 @@ ProcessorBox::choose_insert ()
 void
 ProcessorBox::choose_send ()
 {
-       boost::shared_ptr<Send> send (new Send (*_session, _route->pannable(), _route->mute_master()));
+       boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
+       boost::shared_ptr<Send> send (new Send (*_session, sendpan, _route->mute_master()));
 
        /* make an educated guess at the initial number of outputs for the send */
        ChanCount outs = (_session->master_out())
@@ -2045,8 +2096,9 @@ ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr
                                        continue;
                                }
 
+                               boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
                                XMLNode n (**niter);
-                                InternalSend* s = new InternalSend (*_session, _route->pannable(), _route->mute_master(),
+                                InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
                                                                    boost::shared_ptr<Route>(), Delivery::Aux); 
 
                                IOProcessor::prepare_for_reset (n, s->name());
@@ -2060,8 +2112,10 @@ ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr
 
                        } else if (type->value() == "send") {
 
+                               boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
                                XMLNode n (**niter);
-                                Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
+
+                               Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
 
                                IOProcessor::prepare_for_reset (n, s->name());
                                
@@ -2394,6 +2448,7 @@ ProcessorBox::register_actions ()
        ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
 
        ActionManager::register_action (popup_act_grp, X_("controls"), _("Controls"));
+       ActionManager::register_action (popup_act_grp, X_("send_options"), _("Send Options"));
 
        ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
                        sigc::ptr_fun (ProcessorBox::rb_clear));