Remove unused methods in ARDOUR_UI for starting/stopping engine
[ardour.git] / gtk2_ardour / processor_box.cc
index 536d5f26f91cf9fd5448541cd86c557407df3579..b72fcbe276f605967e149ad648ebc1ea9814f37e 100644 (file)
@@ -74,6 +74,7 @@
 #include "route_processor_selection.h"
 #include "send_ui.h"
 #include "timers.h"
+#include "tooltips.h"
 
 #include "i18n.h"
 
 class AUPluginUI;
 #endif
 
+#ifndef NDEBUG
+bool ProcessorBox::show_all_processors = false;
+#endif
+
 using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
@@ -113,7 +118,7 @@ ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processo
        , _output_icon(false)
 {
        _vbox.show ();
-       
+
        _button.set_distinct_led_click (true);
        _button.set_fallthrough_to_parent(true);
        _button.set_led_left (true);
@@ -150,7 +155,7 @@ 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) {
-                       
+
                        std::string label = _processor->describe_parameter (*i);
 
                        if (boost::dynamic_pointer_cast<Send> (_processor)) {
@@ -160,11 +165,11 @@ ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processo
                        }
 
                        Control* c = new Control (_processor->automation_control (*i), label);
-                       
+
                        _controls.push_back (c);
 
                        if (boost::dynamic_pointer_cast<Amp> (_processor) == 0) {
-                               /* Add non-Amp controls to the processor box */
+                               /* Add non-Amp (Fader & Trim) controls to the processor box */
                                _vbox.pack_start (c->box);
                        }
                }
@@ -322,10 +327,10 @@ ProcessorEntry::setup_tooltip ()
                                postfix = string_compose(_("\nThis mono plugin has been replicated %1 times."), replicated);
                        }
                        if (pi->plugin()->has_editor()) {
-                               ARDOUR_UI::instance()->set_tip (_button,
+                               ARDOUR_UI_UTILS::set_tooltip (_button,
                                                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,
+                               ARDOUR_UI_UTILS::set_tooltip (_button,
                                                string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), name (Wide), postfix));
                        }
                        return;
@@ -336,7 +341,7 @@ ProcessorEntry::setup_tooltip ()
                        return;
                }
        }
-       ARDOUR_UI::instance()->set_tip (_button, string_compose ("<b>%1</b>", name (Wide)));
+       ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>%1</b>", name (Wide)));
 }
 
 string
@@ -453,7 +458,7 @@ ProcessorEntry::build_controls_menu ()
        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))
                );
@@ -461,7 +466,7 @@ ProcessorEntry::build_controls_menu ()
        if (!_controls.empty ()) {
                items.push_back (SeparatorElem ());
        }
-       
+
        for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
                items.push_back (CheckMenuElem ((*i)->name ()));
                Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
@@ -510,7 +515,7 @@ ProcessorEntry::toggle_panner_link ()
 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)
-       , _slider (&_adjustment, boost::shared_ptr<PBD::Controllable>(), 0, max(13.f, rintf(13.f * ARDOUR_UI::ui_scale)))
+       , _slider (&_adjustment, boost::shared_ptr<PBD::Controllable>(), 0, max(13.f, rintf(13.f * UIConfiguration::instance().get_ui_scale())))
        , _slider_persistant_tooltip (&_slider)
        , _button (ArdourButton::led_default_elements)
        , _ignore_ui_adjustment (false)
@@ -529,10 +534,11 @@ ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string
 
                _button.signal_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
                _button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
-               c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
+               // dup. currently timers are used :(
+               //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
 
        } else {
-               
+
                _slider.set_name ("ProcessorControlSlider");
                _slider.set_text (_name);
 
@@ -563,13 +569,16 @@ ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string
                _adjustment.set_step_increment (smallstep);
                _adjustment.set_page_increment (largestep);
                _slider.set_default_value (normal);
-               
+
                _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
-               c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
+               // dup. currently timers are used :(
+               //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
        }
 
-       Timers::rapid_connect (sigc::mem_fun (*this, &Control::control_changed));
-       
+       // yuck, do we really need to do this?
+       // according to c404374 this is only needed for send automation
+       timer_connection = Timers::rapid_connect (sigc::mem_fun (*this, &Control::control_changed));
+
        control_changed ();
        set_tooltip ();
 
@@ -577,6 +586,11 @@ ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string
        set_no_tooltip_whatsoever (_slider);
 }
 
+ProcessorEntry::Control::~Control ()
+{
+       timer_connection.disconnect ();
+}
+
 void
 ProcessorEntry::Control::set_tooltip ()
 {
@@ -594,7 +608,7 @@ ProcessorEntry::Control::set_tooltip ()
 
        string sm = Glib::Markup::escape_text (tmp);
        _slider_persistant_tooltip.set_tip (sm);
-       ARDOUR_UI::instance()->set_tip (_button, sm);
+       ARDOUR_UI_UTILS::set_tooltip (_button, sm);
 }
 
 void
@@ -603,7 +617,7 @@ ProcessorEntry::Control::slider_adjusted ()
        if (_ignore_ui_adjustment) {
                return;
        }
-       
+
        boost::shared_ptr<AutomationControl> c = _control.lock ();
 
        if (!c) {
@@ -643,13 +657,17 @@ ProcessorEntry::Control::control_changed ()
        if (c->toggled ()) {
 
                _button.set_active (c->get_value() > 0.5);
-               
-       } else {
 
-               _adjustment.set_value (c->internal_to_interface(c->get_value ()));
-               set_tooltip ();
+       } else {
+               // as long as rapid timers are used, only update the tooltip
+               // if the value has changed.
+               const double nval = c->internal_to_interface (c->get_value ());
+               if (_adjustment.get_value() != nval) {
+                       _adjustment.set_value (nval);
+                       set_tooltip ();
+               }
        }
-       
+
        _ignore_ui_adjustment = false;
 }
 
@@ -682,7 +700,7 @@ ProcessorEntry::Control::set_visible (bool v)
        } else {
                box.hide ();
        }
-       
+
        _visible = v;
 }
 
@@ -754,7 +772,7 @@ PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
         * This plugin may have unconnected output-ports (currently only in Mixbus,
         * e.g channelstrip-EQ at the top of a MIDI-channel before the synth).
         *
-        * The *next* processor below this one will only see the 
+        * The *next* processor below this one will only see the
         * actual available streams (it cannot know the real outputs
         * of this plugin).
         *
@@ -779,7 +797,7 @@ PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
 
        if (_plugin_insert->splitting () ||  in != sinks)
        {
-               _routing_icon.set_size_request (-1, std::max (7.f, rintf(7.f * ARDOUR_UI::ui_scale)));
+               _routing_icon.set_size_request (-1, std::max (7.f, rintf(7.f * UIConfiguration::instance().get_ui_scale())));
                _routing_icon.set_visible(true);
                _input_icon.show();
        } else {
@@ -804,7 +822,7 @@ PluginInsertProcessorEntry::hide_things ()
 ProcessorEntry::PortIcon::PortIcon(bool input) {
        _input = input;
        _ports = ARDOUR::ChanCount(ARDOUR::DataType::AUDIO, 1);
-       set_size_request (-1, std::max (2.f, rintf(2.f * ARDOUR_UI::ui_scale)));
+       set_size_request (-1, std::max (2.f, rintf(2.f * UIConfiguration::instance().get_ui_scale())));
 }
 
 bool
@@ -825,7 +843,7 @@ ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
        cairo_rectangle (cr, 0, 0, width, height);
        cairo_fill (cr);
 
-       const double dx = rint(max(2., 2. * ARDOUR_UI::ui_scale));
+       const double dx = rint(max(2., 2. * UIConfiguration::instance().get_ui_scale()));
        if (_ports.n_total() > 1) {
                for (uint32_t i = 0; i < _ports.n_total(); ++i) {
                        if (i < _ports.n_midi()) {
@@ -873,7 +891,7 @@ ProcessorEntry::RoutingIcon::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, max (1.f, ARDOUR_UI::ui_scale));
+       cairo_set_line_width (cr, max (1.f, UIConfiguration::instance().get_ui_scale()));
        cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
 
        Gtk::Allocation a = get_allocation();
@@ -923,7 +941,7 @@ ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
                cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
                cairo_stroke (cr);
        } else if (midi_sources == 0 && midi_sinks == 1) {
-               const double dx = 1 + rint(max(2., 2. * ARDOUR_UI::ui_scale));
+               const double dx = 1 + rint(max(2., 2. * UIConfiguration::instance().get_ui_scale()));
                // draw "T"
                //  TODO connect back to track-input of last midi-out if any, otherwise draw "X"
                const float si_x  = rintf(width * .2f) + .5f;
@@ -934,7 +952,7 @@ ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
                cairo_stroke (cr);
 #ifndef NDEBUG
        } else if (midi_sources != 0 && midi_sinks != 0) {
-               PBD::warning << string_compose("Programming error: midi routing display: A %1 -> %2 | M %3 -> %4 | T %5 -> %6", 
+               PBD::warning << string_compose("Programming error: midi routing display: A %1 -> %2 | M %3 -> %4 | T %5 -> %6",
                                audio_sources, audio_sinks, midi_sources, midi_sinks, sources, sinks) << endmsg;
 #endif
        }
@@ -981,7 +999,7 @@ ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
                cairo_stroke (cr);
 #ifndef NDEBUG
        } else if (audio_sources != 0 && audio_sinks != 0) {
-               PBD::warning << string_compose("Programming error: audio routing display: A %1 -> %2 | M %3 -> %4 | T %5 -> %6", 
+               PBD::warning << string_compose("Programming error: audio routing display: A %1 -> %2 | M %3 -> %4 | T %5 -> %6",
                                audio_sources, audio_sinks, midi_sources, midi_sinks, sources, sinks) << endmsg;
 #endif
        }
@@ -1035,7 +1053,7 @@ ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelecto
                        );
        }
 
-       ARDOUR_UI::instance()->set_tip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
+       ARDOUR_UI_UTILS::set_tooltip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
 }
 
 ProcessorBox::~ProcessorBox ()
@@ -1304,7 +1322,7 @@ ProcessorBox::leave_notify (GdkEventCrossing*)
 }
 
 bool
-ProcessorBox::processor_operation (ProcessorOperation op) 
+ProcessorBox::processor_operation (ProcessorOperation op)
 {
        ProcSelection targets;
 
@@ -1325,7 +1343,7 @@ ProcessorBox::processor_operation (ProcessorOperation op)
 
        if ( (op == ProcessorsDelete) && targets.empty() )
                return false;  //nothing to delete.  return false so the editor-mixer, because the user was probably intending to delete something in the editor
-       
+
        switch (op) {
        case ProcessorsSelectAll:
                processor_display.select_all ();
@@ -1344,6 +1362,14 @@ ProcessorBox::processor_operation (ProcessorOperation op)
                break;
 
        case ProcessorsPaste:
+               // some processors are not selectable (e.g fader, meter), target is empty.
+               if (targets.empty() && _placement >= 0) {
+                       assert (_route);
+                       boost::shared_ptr<Processor> proc = _route->before_processor_for_index (_placement);
+                       if (proc) {
+                               targets.push_back (proc);
+                       }
+               }
                if (targets.empty()) {
                        paste_processors ();
                } else {
@@ -1372,11 +1398,11 @@ ProcessorBox::processor_operation (ProcessorOperation op)
        default:
                break;
        }
-       
+
        return true;
 }
 
-ProcessorWindowProxy* 
+ProcessorWindowProxy*
 ProcessorBox::find_window_proxy (boost::shared_ptr<Processor> processor) const
 {
        return  processor->window_proxy();
@@ -1415,7 +1441,7 @@ ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry*
        } else if (Keyboard::is_context_menu_event (ev)) {
 
                show_processor_menu (ev->time);
-               
+
                ret = true;
 
        } else if (processor && ev->button == 1 && selected) {
@@ -1707,7 +1733,7 @@ ProcessorBox::redisplay_processors ()
        _visible_prefader_processors = 0;
        fader_seen = false;
 
-       _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors), 
+       _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors),
                                               &_visible_prefader_processors, &fader_seen));
 
        _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
@@ -1756,7 +1782,7 @@ ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
        if (ui_xml) {
                wp->set_state (*ui_xml);
        }
-       
+
         void* existing_ui = p->get_ui ();
 
         if (existing_ui) {
@@ -1772,9 +1798,14 @@ ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor>
 {
        boost::shared_ptr<Processor> processor (p.lock ());
 
-       if (processor && processor->display_to_user()) {
+       if (processor && ( processor->display_to_user()
+#ifndef NDEBUG
+                           || show_all_processors
+#endif
+                        )
+          ) {
 
-               if (boost::dynamic_pointer_cast<Amp>(processor)) {
+               if (boost::dynamic_pointer_cast<Amp>(processor) && boost::dynamic_pointer_cast<Amp>(processor)->type() == X_("amp")) {
                        *amp_seen = true;
                } else {
                        if (!*amp_seen) {
@@ -1789,12 +1820,17 @@ ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
 {
        boost::shared_ptr<Processor> processor (p.lock ());
 
-       if (!processor || !processor->display_to_user()) {
+       if (!processor || ( !processor->display_to_user()
+#ifndef NDEBUG
+                           && !show_all_processors
+#endif
+                         )
+          ) {
                return;
        }
 
        boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
-       
+
        ProcessorEntry* e = 0;
        if (plugin_insert) {
                e = new PluginInsertProcessorEntry (this, plugin_insert, _width);
@@ -1805,7 +1841,7 @@ ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
        boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
        boost::shared_ptr<PortInsert> ext = boost::dynamic_pointer_cast<PortInsert> (processor);
        boost::shared_ptr<UnknownProcessor> stub = boost::dynamic_pointer_cast<UnknownProcessor> (processor);
-       
+
        //faders and meters are not deletable, copy/paste-able, so they shouldn't be selectable
        if (!send && !plugin_insert && !ext && !stub)
                e->set_selectable(false);
@@ -1850,7 +1886,7 @@ ProcessorBox::setup_entry_positions ()
 
        uint32_t num = 0;
        for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
-               if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
+               if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) && boost::dynamic_pointer_cast<Amp>((*i)->processor())->type() == X_("amp")) {
                        pre_fader = false;
                        (*i)->set_position (ProcessorEntry::Fader, num++);
                } else {
@@ -2184,11 +2220,11 @@ ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr
                                continue;
 
                        } else if (type->value() == "intsend") {
-                               
+
                                /* aux sends are OK, but those used for
                                 * other purposes, are not.
                                 */
-                               
+
                                assert (role);
 
                                if (role->value() != "Aux") {
@@ -2217,7 +2253,7 @@ ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr
                                Send* s = new Send (*_session, _route->pannable(), _route->mute_master());
 
                                IOProcessor::prepare_for_reset (n, s->name());
-                               
+
                                 if (s->set_state (n, Stateful::loading_state_version)) {
                                         delete s;
                                         return;
@@ -2243,13 +2279,13 @@ ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr
 
                                XMLNode n (**niter);
                                PortInsert* pi = new PortInsert (*_session, _route->pannable (), _route->mute_master ());
-                               
+
                                IOProcessor::prepare_for_reset (n, pi->name());
-                               
+
                                if (pi->set_state (n, Stateful::loading_state_version)) {
                                        return;
                                }
-                               
+
                                p.reset (pi);
 
                        } else {
@@ -2411,7 +2447,7 @@ ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool us
         * will be forced back into a model where the fader controls the main gain.
         * If the processor is a send, then we map the send controls onto the
         * strip.
-        * 
+        *
         * Plugins and others will return a window for control.
         */
 
@@ -2422,7 +2458,7 @@ ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool us
                }
        }
 
-       if (boost::dynamic_pointer_cast<Amp> (processor)) {
+       if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->type() == X_("amp")) {
 
                if (_parent_strip) {
                        _parent_strip->revert_to_default_display ();
@@ -2968,7 +3004,7 @@ ProcessorBox::entry_gui_object_state (ProcessorEntry* entry)
        }
 
        GUIObjectState& st = _parent_strip->gui_object_state ();
-       
+
        XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
        assert (strip);
        return st.get_or_add_node (strip, entry->state_id());
@@ -3029,7 +3065,7 @@ ProcessorWindowProxy::processor_going_away ()
 }
 
 ARDOUR::SessionHandlePtr*
-ProcessorWindowProxy::session_handle() 
+ProcessorWindowProxy::session_handle()
 {
        /* we don't care */
        return 0;
@@ -3084,7 +3120,7 @@ ProcessorWindowProxy::get (bool create)
                if (!create) {
                        return 0;
                }
-               
+
                is_custom = want_custom;
                _window = _processor_box->get_editor_window (p, is_custom);