provisional processor control-box tweaks - possible fix for #6519
[ardour.git] / gtk2_ardour / processor_box.cc
index 81bb5e42c356770c84a8dba855502eff2cd9ef78..f6ce27a0c91115f16f7bbf2fd741854240cdb4ab 100644 (file)
@@ -17,8 +17,6 @@
 
 */
 
-//#define ALWAYS_DISPLAY_WIRES
-
 #ifdef WAF_BUILD
 #include "gtk2ardour-config.h"
 #endif
 #include <gtkmm2ext/choice.h>
 #include <gtkmm2ext/utils.h>
 #include <gtkmm2ext/doi.h>
+#include <gtkmm2ext/rgb_macros.h>
 
 #include "ardour/amp.h"
 #include "ardour/audio_track.h"
 #include "ardour/audioengine.h"
 #include "ardour/internal_return.h"
 #include "ardour/internal_send.h"
+#include "ardour/meter.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"
@@ -71,7 +73,7 @@
 #include "return_ui.h"
 #include "route_processor_selection.h"
 #include "send_ui.h"
-#include "utils.h"
+#include "timers.h"
 
 #include "i18n.h"
 
@@ -89,28 +91,42 @@ using namespace Gtkmm2ext;
 ProcessorBox* ProcessorBox::_current_processor_box = 0;
 RefPtr<Action> ProcessorBox::paste_action;
 RefPtr<Action> ProcessorBox::cut_action;
+RefPtr<Action> ProcessorBox::copy_action;
 RefPtr<Action> ProcessorBox::rename_action;
+RefPtr<Action> ProcessorBox::delete_action;
 RefPtr<Action> ProcessorBox::edit_action;
 RefPtr<Action> ProcessorBox::edit_generic_action;
 
+static const uint32_t audio_port_color = 0x4A8A0EFF; // Green
+static const uint32_t midi_port_color = 0x960909FF; //Red
+
 ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processor> p, Width w)
        : _button (ArdourButton::led_default_elements)
        , _position (PreFader)
+       , _position_num(0)
+       , _selectable(true)
+       , _unknown_processor(false)
        , _parent (parent)
        , _processor (p)
        , _width (w)
-       , _visual_state (Gtk::STATE_NORMAL)
        , _input_icon(true)
        , _output_icon(false)
 {
        _vbox.show ();
        
-       _button.set_diameter (3);
        _button.set_distinct_led_click (true);
+       _button.set_fallthrough_to_parent(true);
        _button.set_led_left (true);
        _button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
        _button.set_text (name (_width));
 
+       if (boost::dynamic_pointer_cast<PeakMeter> (_processor)) {
+               _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
+       }
+       if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
+               _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
+               _unknown_processor = true;
+       }
        if (_processor) {
 
                _vbox.pack_start (_routing_icon);
@@ -120,11 +136,12 @@ 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 ();
-#ifdef ALWAYS_DISPLAY_WIRES
-               _routing_icon.show();
-#endif
-               _input_icon.show();
+               _routing_icon.set_visible(false);
+               _input_icon.hide();
                _output_icon.show();
 
                _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
@@ -134,7 +151,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 +167,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());
@@ -188,9 +208,17 @@ ProcessorEntry::drag_text () const
 }
 
 void
-ProcessorEntry::set_position (Position p)
+ProcessorEntry::set_position (Position p, uint32_t num)
 {
        _position = p;
+       _position_num = num;
+
+       if (_position_num == 0 || _routing_icon.get_visible()) {
+               _input_icon.show();
+       } else {
+               _input_icon.hide();
+       }
+
        setup_visuals ();
 }
 
@@ -207,20 +235,22 @@ ProcessorEntry::set_visual_state (Gtkmm2ext::VisualState s, bool yn)
 void
 ProcessorEntry::setup_visuals ()
 {
+       if (_unknown_processor) {
+               _button.set_name ("processor stub");
+               return;
+       }
+
        switch (_position) {
        case PreFader:
                _button.set_name ("processor prefader");
-               _routing_icon.set_name ("ProcessorPreFader");
                break;
 
        case Fader:
                _button.set_name ("processor fader");
-               _routing_icon.set_name ("ProcessorFader");
                break;
 
        case PostFader:
                _button.set_name ("processor postfader");
-               _routing_icon.set_name ("ProcessorPostFader");
                break;
        }
 }
@@ -271,12 +301,6 @@ ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
 void
 ProcessorEntry::processor_configuration_changed (const ChanCount in, const ChanCount out)
 {
-#if 0 // debug, devel information
-       printf("ProcessorEntry::processor_config_changed %s %d %d\n",
-                       name(Wide).c_str(),
-                       in.n_audio(), out.n_audio());
-#endif
-
        _input_icon.set_ports(in);
        _output_icon.set_ports(out);
        _routing_icon.set_sources(in);
@@ -292,15 +316,25 @@ 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;
                }
+               if(boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
+                       ARDOUR_UI::instance()->set_tip (_button,
+                                       string_compose (_("<b>%1</b>\nThe Plugin is not available on this system\nand has been replaced by a stub."), name (Wide)));
+                       return;
+               }
        }
        ARDOUR_UI::instance()->set_tip (_button, string_compose ("<b>%1</b>", name (Wide)));
 }
@@ -336,6 +370,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:
@@ -423,7 +464,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));
        }
@@ -438,12 +479,40 @@ 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")));
+               Gtk::CheckMenuItem* c = dynamic_cast<Gtk::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)
-       , _slider (&_adjustment, 0, 13, false)
+       , _slider (&_adjustment, boost::shared_ptr<PBD::Controllable>(), 0, max(13.f, rintf(13.f * ARDOUR_UI::ui_scale)))
        , _slider_persistant_tooltip (&_slider)
-       , _button (ArdourButton::Element (ArdourButton::Text | ArdourButton::Indicator))
+       , _button (ArdourButton::led_default_elements)
        , _ignore_ui_adjustment (false)
        , _visible (false)
        , _name (n)
@@ -460,7 +529,8 @@ 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 {
                
@@ -470,20 +540,39 @@ ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string
                box.add (_slider);
                _slider.show ();
 
-               double const lo = c->internal_to_interface (c->lower ());
-               double const up = c->internal_to_interface (c->upper ());
-               
+               const ARDOUR::ParameterDescriptor& desc = c->desc();
+               double const lo = c->internal_to_interface(desc.lower);
+               double const up = c->internal_to_interface(desc.upper);
+               double const normal = c->internal_to_interface(desc.normal);
+               double smallstep = desc.smallstep;
+               double largestep = desc.largestep;
+
+               if (smallstep == 0.0) {
+                       smallstep = up / 1000.;
+               } else {
+                       smallstep = c->internal_to_interface(desc.lower + smallstep);
+               }
+
+               if (largestep == 0.0) {
+                       largestep = up / 40.;
+               } else {
+                       largestep = c->internal_to_interface(desc.lower + largestep);
+               }
+
                _adjustment.set_lower (lo);
                _adjustment.set_upper (up);
-               _adjustment.set_step_increment ((up - lo) / 100);
-               _adjustment.set_page_increment ((up - lo) / 10);
-               _slider.set_default_value (c->internal_to_interface (c->normal ()));
+               _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 ());
        }
 
-       ARDOUR_UI::RapidScreenUpdate.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 ();
@@ -492,6 +581,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 ()
 {
@@ -500,19 +594,14 @@ ProcessorEntry::Control::set_tooltip ()
        if (!c) {
                return;
        }
-       
-       stringstream s;
-       s << _name << ": ";
+       char tmp[256];
        if (c->toggled ()) {
-               s << (c->get_value() > 0.5 ? _("on") : _("off"));
+               snprintf (tmp, sizeof(tmp), "%s: %s", _name.c_str(), c->get_value() > 0.5 ? _("on") : _("off"));
        } else {
-               s << setprecision(2) << fixed;
-               s << c->internal_to_user (c->get_value ());
+               snprintf (tmp, sizeof(tmp), "%s: %.2f", _name.c_str(), c->internal_to_user (c->get_value ()));
        }
 
-       string sm = Glib::Markup::escape_text (s.str());
-       
-       ARDOUR_UI::instance()->set_tip (_label, sm);
+       string sm = Glib::Markup::escape_text (tmp);
        _slider_persistant_tooltip.set_tip (sm);
        ARDOUR_UI::instance()->set_tip (_button, sm);
 }
@@ -530,7 +619,7 @@ ProcessorEntry::Control::slider_adjusted ()
                return;
        }
 
-       c->set_value (c->interface_to_internal (_adjustment.get_value ()));
+       c->set_value ( c->interface_to_internal(_adjustment.get_value ()) );
        set_tooltip ();
 }
 
@@ -565,13 +654,13 @@ ProcessorEntry::Control::control_changed ()
                _button.set_active (c->get_value() > 0.5);
                
        } else {
-
-               _adjustment.set_value (c->internal_to_interface (c->get_value ()));
-               
-               stringstream s;
-               s.precision (1);
-               s.setf (ios::fixed, ios::floatfield);
-               s << c->internal_to_user (c->get_value ());
+               // 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;
@@ -621,12 +710,6 @@ ProcessorEntry::Control::hide_things ()
        }
 }
 
-void
-ProcessorEntry::Control::hide_label ()
-{
-       _label.hide ();
-}
-
 string
 ProcessorEntry::Control::state_id () const
 {
@@ -636,22 +719,6 @@ ProcessorEntry::Control::state_id () const
        return string_compose (X_("control %1"), c->id().to_s ());
 }
 
-BlankProcessorEntry::BlankProcessorEntry (ProcessorBox* b, Width w, ChanCount cc)
-       : ProcessorEntry (b, boost::shared_ptr<Processor>(), w)
-{
-#ifdef ALWAYS_DISPLAY_WIRES
-       _vbox.pack_start (_routing_icon);
-       _routing_icon.set_sources(cc);
-       _routing_icon.set_sinks(cc);
-       _routing_icon.show();
-       setup_visuals ();
-       _routing_icon.set_size_request (-1, 8);
-       _vbox.set_size_request (-1, 8);
-#else
-       _vbox.set_size_request (-1, 0);
-#endif
-}
-
 PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
        : ProcessorEntry (b, p, w)
        , _plugin_insert (p)
@@ -666,36 +733,13 @@ PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost::
 void
 PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
 {
-#if 0 // debug, devel information
-       printf("--%s--\n", _plugin_insert->name().c_str());
-       printf("AUDIO src: %d -> in:%d | * cnt %d * | out: %d -> snk: %d\n",
-                       _plugin_insert->input_streams().n_audio(),
-                       _plugin_insert->natural_input_streams().n_audio(),
-                       _plugin_insert->get_count(),
-                       _plugin_insert->natural_output_streams().n_audio(),
-                       _plugin_insert->output_streams().n_audio());
-       printf("MIDI src: %d -> in:%d | * cnt %d * | out: %d -> snk: %d\n",
-                       _plugin_insert->input_streams().n_midi(),
-                       _plugin_insert->natural_input_streams().n_midi(),
-                       _plugin_insert->get_count(),
-                       _plugin_insert->natural_output_streams().n_midi(),
-                       _plugin_insert->output_streams().n_midi());
-       printf("TOTAL src: %d -> in:%d | * cnt %d * | out: %d -> snk: %d\n",
-                       _plugin_insert->input_streams().n_total(),
-                       _plugin_insert->natural_input_streams().n_total(),
-                       _plugin_insert->get_count(),
-                       _plugin_insert->natural_output_streams().n_total(),
-                       _plugin_insert->output_streams().n_total());
-#endif
-
-       _output_icon.set_ports(_plugin_insert->output_streams());
-       _routing_icon.set_splitting(_plugin_insert->splitting ());
+       ChanCount in, out; // actual configured i/o
+       _plugin_insert->configured_io (in, out);
 
-       ChanCount sources = _plugin_insert->input_streams();
+       /* get number of input ports */
        ChanCount sinks = _plugin_insert->natural_input_streams();
-
-       /* replicated instances */
        if (!_plugin_insert->splitting () && _plugin_insert->get_count() > 1) {
+               /* replicated instances */
                for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
                        sinks.set(*t, sinks.get(*t) * _plugin_insert->get_count());
                }
@@ -703,26 +747,59 @@ PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
        /* MIDI bypass */
        if (_plugin_insert->natural_output_streams().n_midi() == 0 &&
                        _plugin_insert->output_streams().n_midi() == 1) {
+               in.set(DataType::MIDI, 1);
+               out.set(DataType::MIDI, 1);
                sinks.set(DataType::MIDI, 1);
-               sources.set(DataType::MIDI, 1);
        }
 
+       /* the Input streams available (*valid* outputs from prev. plugin)
+        * this will be <= sinks. Some input-ports of this processor
+        * may be unconnected.
+        */
+       _routing_icon.set_sources(in);
+
+       /* the actual input ports of this processor */
        _input_icon.set_ports(sinks);
        _routing_icon.set_sinks(sinks);
-       _routing_icon.set_sources(sources);
 
-       if (_plugin_insert->splitting () ||
-                       _plugin_insert->input_streams().n_audio() < _plugin_insert->natural_input_streams().n_audio()
-                )
+       /* set/override plugin-output ports to actual outputs-streams.
+        *
+        * 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 
+        * actual available streams (it cannot know the real outputs
+        * of this plugin).
+        *
+        * There is currently no API to query the ports of the previous (or next)
+        * processor.
+        *
+        * (normally - iff configuration succeeds - this is set during
+        * ProcessorEntry::processor_configuration_changed() and should
+        * equal _plugin_insert->output_streams())
+        */
+       _output_icon.set_ports(out);
+#ifndef NDEBUG
+       if (out != _plugin_insert->output_streams()) {
+               std::cerr << "Processor Wiring: " <<  processor()->name()
+                       << " out-ports: " << _plugin_insert->output_streams() // NB. does not include midi-bypass
+                       << " out-connections: " << out
+                       << endmsg;
+       }
+#endif
+
+       _routing_icon.set_splitting(_plugin_insert->splitting ());
+
+       if (_plugin_insert->splitting () ||  in != sinks)
        {
-               _routing_icon.set_size_request (-1, 8);
-               _routing_icon.show();
+               _routing_icon.set_size_request (-1, std::max (7.f, rintf(7.f * ARDOUR_UI::ui_scale)));
+               _routing_icon.set_visible(true);
+               _input_icon.show();
        } else {
-#ifdef ALWAYS_DISPLAY_WIRES
-               _routing_icon.set_size_request (-1, 4);
-#else
-               _routing_icon.hide();
-#endif
+               _routing_icon.set_visible(false);
+               if (_position_num != 0) {
+                       _input_icon.hide();
+               }
        }
 
        _input_icon.queue_draw();
@@ -737,6 +814,11 @@ PluginInsertProcessorEntry::hide_things ()
        plugin_insert_splitting_changed ();
 }
 
+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)));
+}
 
 bool
 ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
@@ -746,9 +828,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();
@@ -759,28 +838,39 @@ ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
        cairo_rectangle (cr, 0, 0, width, height);
        cairo_fill (cr);
 
-       const double y0 = _input ? height-.5 : .5;
-
+       const double dx = rint(max(2., 2. * ARDOUR_UI::ui_scale));
        if (_ports.n_total() > 1) {
                for (uint32_t i = 0; i < _ports.n_total(); ++i) {
                        if (i < _ports.n_midi()) {
-                               cairo_set_source_rgb (cr, .8, .3, .3);
+                               cairo_set_source_rgb (cr,
+                                               UINT_RGBA_R_FLT(midi_port_color),
+                                               UINT_RGBA_G_FLT(midi_port_color),
+                                               UINT_RGBA_B_FLT(midi_port_color));
                        } else {
-                               cairo_set_source_rgb (cr, .4, .4, .8);
+                               cairo_set_source_rgb (cr,
+                                               UINT_RGBA_R_FLT(audio_port_color),
+                                               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-dx * .5, 0, 1+dx, height);
+                       cairo_fill(cr);
                }
        } else if (_ports.n_total() == 1) {
                if (_ports.n_midi() == 1) {
-                       cairo_set_source_rgb (cr, .8, .3, .3);
+                       cairo_set_source_rgb (cr,
+                                       UINT_RGBA_R_FLT(midi_port_color),
+                                       UINT_RGBA_G_FLT(midi_port_color),
+                                       UINT_RGBA_B_FLT(midi_port_color));
                } else {
-                       cairo_set_source_rgb (cr, .4, .4, .8);
+                       cairo_set_source_rgb (cr,
+                                       UINT_RGBA_R_FLT(audio_port_color),
+                                       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-dx * .5, 0, 1+dx, height);
+               cairo_fill(cr);
                cairo_stroke(cr);
        }
 
@@ -796,7 +886,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, 1.5);
+       cairo_set_line_width (cr, max (1.f, ARDOUR_UI::ui_scale));
        cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
 
        Gtk::Allocation a = get_allocation();
@@ -815,14 +905,19 @@ ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
        const uint32_t sources = _sources.n_total();
        const uint32_t sinks = _sinks.n_total();
 
-       /* MIDI */
-       cairo_set_source_rgb (cr, .6, .2, .2);
        const uint32_t midi_sources = _sources.n_midi();
        const uint32_t midi_sinks = _sinks.n_midi();
+       const uint32_t audio_sources = _sources.n_audio();
+       const uint32_t audio_sinks = _sinks.n_audio();
 
+       /* MIDI */
+       cairo_set_source_rgb (cr,
+                       UINT_RGBA_R_FLT(midi_port_color),
+                       UINT_RGBA_G_FLT(midi_port_color),
+                       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);
@@ -833,23 +928,48 @@ ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
                cairo_move_to (cr, si_x, height);
                cairo_line_to (cr, si_x, 0);
                cairo_stroke (cr);
+       } else if (midi_sources == 1 && midi_sinks == 1) {
+               /* unusual cases -- removed synth, midi-track w/audio plugins */
+               const float si_x  = rintf(width * (sinks   > 1 ? .2f : .5f)) + .5f;
+               const float si_x0 = rintf(width * (sources > 1 ? .2f : .5f)) + .5f;
+               cairo_move_to (cr, si_x, height);
+               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));
+               // 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;
+               cairo_move_to (cr, si_x, height);
+               cairo_line_to (cr, si_x, height * .66);
+               cairo_move_to (cr, si_x - dx, height * .66);
+               cairo_line_to (cr, si_x + dx, height * .66);
+               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", 
+                               audio_sources, audio_sinks, midi_sources, midi_sinks, sources, sinks) << endmsg;
+#endif
        }
 
        /* AUDIO */
-       cairo_set_source_rgb (cr, .6, .6, .8);
-       const uint32_t audio_sources = _sources.n_audio();
-       const uint32_t audio_sinks = _sinks.n_audio();
+       cairo_set_source_rgb (cr,
+                       UINT_RGBA_R_FLT(audio_port_color),
+                       UINT_RGBA_G_FLT(audio_port_color),
+                       UINT_RGBA_B_FLT(audio_port_color));
 
        if (_splitting) {
+               assert(audio_sources < 2);
                assert(audio_sinks > 1);
-               const float si_x0 = rintf(width * .5f) + .5f;
+               /* assume there is only ever one MIDI port */
+               const float si_x0 = rintf(width * (midi_sources > 0 ? .8f : .5f)) + .5f;
                for (uint32_t i = midi_sinks; i < sinks; ++i) {
                        const float si_x = rintf(width * (.2f + .6f * i / (sinks - 1.f))) + .5f;
                        cairo_move_to (cr, si_x, height);
                        cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
                        cairo_stroke (cr);
                }
-       } else if (audio_sources > 1) {
+       } else if (audio_sources > 1 && sinks > 1) {
                for (uint32_t i = 0 ; i < audio_sources; ++i) {
                        const float si_x = rintf(width * (.2f + .6f * (i + midi_sinks) / (sinks - 1.f))) + .5f;
                        const float si_x0 = rintf(width * (.2f + .6f * (i + midi_sources) / (sources - 1.f))) + .5f;
@@ -857,11 +977,26 @@ 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 (audio_sources == 1 && audio_sinks == 1) {
-               const float si_x = rintf(width * .5f) + .5f;
+       } else if (audio_sources == 1 && audio_sinks > 0) {
+               float si_x, si_x0;
+               if (sinks == 1) {
+                       si_x = rintf(width * .5f) + .5f;
+               } else {
+                       si_x = rintf(width * (.2f + .6f * midi_sinks / (sinks - 1.f))) + .5f;
+               }
+               if (sources == 1) {
+                       si_x0 = rintf(width * .5f) + .5f;
+               } else {
+                       si_x0 = rintf(width * (.2f + .6f * midi_sources / (sources - 1.f))) + .5f;
+               }
                cairo_move_to (cr, si_x, height);
-               cairo_line_to (cr, si_x, 0);
+               cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
                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", 
+                               audio_sources, audio_sinks, midi_sources, midi_sinks, sources, sinks) << endmsg;
+#endif
        }
        cairo_destroy(cr);
        return true;
@@ -953,12 +1088,6 @@ ProcessorBox::set_route (boost::shared_ptr<Route> r)
        _route->PropertyChanged.connect (
                _route_connections, invalidator (*this), boost::bind (&ProcessorBox::route_property_changed, this, _1), gui_context()
                );
-#ifdef ALWAYS_DISPLAY_WIRES
-       /* update BlankProcessorEntry wire-count */
-       _route->io_changed.connect (
-               _route_connections, invalidator (*this), boost::bind (&ProcessorBox::io_changed_proxy, this), gui_context ()
-               );
-#endif
 
        redisplay_processors ();
 }
@@ -983,10 +1112,6 @@ ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* posit
                           `dropped on' processor */
                        list<ProcessorEntry*> c = processor_display.children ();
                        list<ProcessorEntry*>::iterator i = c.begin ();
-                       while (dynamic_cast<BlankProcessorEntry*> (*i)) {
-                               assert (i != c.end ());
-                               ++i;
-                       }
 
                        assert (i != c.end ());
                        p = (*i)->processor ();
@@ -998,6 +1123,9 @@ ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* posit
        list<boost::shared_ptr<Processor> > procs;
        for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
                if ((*i)->processor ()) {
+                       if (boost::dynamic_pointer_cast<UnknownProcessor> ((*i)->processor())) {
+                               continue;
+                       }
                        procs.push_back ((*i)->processor ());
                }
        }
@@ -1113,16 +1241,37 @@ ProcessorBox::show_processor_menu (int arg)
                                gtk_menu_item_set_submenu (controls_menu_item->gobj(), 0);
                                controls_menu_item->set_sensitive (false);
                        }
+               } else {
+                       controls_menu_item->set_sensitive (false);
+               }
+       }
+
+       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);
+                       }
+               } else {
+                       send_menu_item->set_sensitive (false);
                }
        }
 
        /* Sensitise actions as approprioate */
 
-        cut_action->set_sensitive (can_cut());
+
+       const bool sensitive = !processor_display.selection().empty() && ! stub_processor_selected ();
+
        paste_action->set_sensitive (!_rr_selection.processors.empty());
+       cut_action->set_sensitive (sensitive && can_cut ());
+       copy_action->set_sensitive (sensitive);
+       delete_action->set_sensitive (sensitive || stub_processor_selected ());
 
-       const bool sensitive = !processor_display.selection().empty();
-       ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
        edit_action->set_sensitive (one_processor_can_be_edited ());
        edit_generic_action->set_sensitive (one_processor_can_be_edited ());
 
@@ -1135,7 +1284,10 @@ ProcessorBox::show_processor_menu (int arg)
        edit_action->set_sensitive (pi && pi->plugin()->has_editor ());
 
        /* 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->processor ()));
+       rename_action->set_sensitive (single_selection
+                       && !pi
+                       && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ())
+                       && !boost::dynamic_pointer_cast<UnknownProcessor> (single_selection->processor ()));
 
        processor_menu->popup (1, arg);
 
@@ -1164,14 +1316,14 @@ ProcessorBox::leave_notify (GdkEventCrossing*)
        return false;
 }
 
-void
+bool
 ProcessorBox::processor_operation (ProcessorOperation op) 
 {
        ProcSelection targets;
 
        get_selected_processors (targets);
 
-       if (targets.empty()) {
+/*     if (targets.empty()) {
 
                int x, y;
                processor_display.get_pointer (x, y);
@@ -1182,12 +1334,20 @@ ProcessorBox::processor_operation (ProcessorOperation op)
                        targets.push_back (pointer.first->processor ());
                }
        }
+*/
 
+       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 ();
                break;
 
+       case ProcessorsSelectNone:
+               processor_display.select_none ();
+               break;
+
        case ProcessorsCopy:
                copy_processors (targets);
                break;
@@ -1225,24 +1385,17 @@ ProcessorBox::processor_operation (ProcessorOperation op)
        default:
                break;
        }
+       
+       return true;
 }
 
 ProcessorWindowProxy* 
 ProcessorBox::find_window_proxy (boost::shared_ptr<Processor> processor) const
 {
-       for (list<ProcessorWindowProxy*>::const_iterator i = _processor_window_info.begin(); i != _processor_window_info.end(); ++i) {
-               boost::shared_ptr<Processor> p = (*i)->processor().lock();
-
-               if (p && p == processor) {
-                       return (*i);
-               }
-       }
-
-       return 0;
+       return  processor->window_proxy();
 }
 
 
-
 bool
 ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry* child)
 {
@@ -1259,7 +1412,9 @@ ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry*
                if (_session->engine().connected()) {
                        /* XXX giving an error message here is hard, because we may be in the midst of a button press */
 
-                       if (!one_processor_can_be_edited ()) return true;
+                       if (!one_processor_can_be_edited ()) {
+                               return true;
+                       }
 
                        if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
                                generic_edit_processor (processor);
@@ -1270,6 +1425,12 @@ ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry*
 
                ret = true;
 
+       } else if (Keyboard::is_context_menu_event (ev)) {
+
+               show_processor_menu (ev->time);
+               
+               ret = true;
+
        } else if (processor && ev->button == 1 && selected) {
 
                // this is purely informational but necessary for route params UI
@@ -1298,10 +1459,6 @@ ProcessorBox::processor_button_release_event (GdkEventButton *ev, ProcessorEntry
                                sigc::mem_fun(*this, &ProcessorBox::idle_delete_processor),
                                boost::weak_ptr<Processor>(processor)));
 
-       } else if (Keyboard::is_context_menu_event (ev)) {
-
-               show_processor_menu (ev->time);
-
        } else if (processor && Keyboard::is_button2_event (ev)
 #ifndef GTKOSX
                   && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))
@@ -1427,7 +1584,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())
@@ -1552,7 +1710,6 @@ ProcessorBox::redisplay_processors ()
 {
        ENSURE_GUI_THREAD (*this, &ProcessorBox::redisplay_processors);
        bool     fader_seen;
-       ChanCount amp_chan_count;
 
        if (no_processor_redisplay) {
                return;
@@ -1564,73 +1721,13 @@ ProcessorBox::redisplay_processors ()
        fader_seen = false;
 
        _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &ProcessorBox::help_count_visible_prefader_processors), 
-                                              &_visible_prefader_processors, &fader_seen, &amp_chan_count));
-
-       if (_visible_prefader_processors == 0) { // fader only
-               BlankProcessorEntry* bpe = new BlankProcessorEntry (this, _width, amp_chan_count);
-               processor_display.add_child (bpe);
-       }
+                                              &_visible_prefader_processors, &fader_seen));
 
        _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::add_processor_to_display));
-
-       for (ProcessorWindowProxies::iterator i = _processor_window_info.begin(); i != _processor_window_info.end(); ++i) {
-               (*i)->marked = false;
-       }
-
        _route->foreach_processor (sigc::mem_fun (*this, &ProcessorBox::maybe_add_processor_to_ui_list));
-
-       /* trim dead wood from the processor window proxy list */
-
-       ProcessorWindowProxies::iterator i = _processor_window_info.begin();
-       while (i != _processor_window_info.end()) {
-               ProcessorWindowProxies::iterator j = i;
-               ++j;
-
-               if (!(*i)->valid()) {
-
-                       WM::Manager::instance().remove (*i);
-                       delete *i;
-                       _processor_window_info.erase (i);
-                       
-               } else if (!(*i)->marked) {
-
-                       /* this processor is no longer part of this processor
-                        * box.
-                        *
-                        * that could be because it was deleted or it could be
-                        * because the route being displayed in the parent
-                        * strip changed.
-                        *
-                        * The latter only happens with the editor mixer strip.
-                        */
-
-                       if (is_editor_mixer_strip()) {
-                               
-                               /* editor mixer strip .. DO NOTHING
-                                *
-                                * note: the processor window stays visible if
-                                * it is already visible
-                                */
-                       } else {
-                               (*i)->hide ();
-                               WM::Manager::instance().remove (*i);
-                               delete *i;
-                               _processor_window_info.erase (i);
-                       } 
-               } 
-
-               i = j;
-       }
-
        setup_entry_positions ();
 }
 
-void
-ProcessorBox::io_changed_proxy ()
-{
-       Glib::signal_idle().connect_once (sigc::mem_fun (*this, &ProcessorBox::redisplay_processors));
-}
-
 /** Add a ProcessorWindowProxy for a processor to our list, if that processor does
  *  not already have one.
  */
@@ -1641,24 +1738,14 @@ ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
        if (!p) {
                return;
        }
-
-       ProcessorWindowProxies::iterator i = _processor_window_info.begin ();
-       while (i != _processor_window_info.end()) {
-
-               boost::shared_ptr<Processor> t = (*i)->processor().lock ();
-
-               if (p == t) {
-                       /* this processor is already on the list; done */
-                       (*i)->marked = true;
-                       return;
-               }
-
-               ++i;
+       if (p->window_proxy()) {
+               return;
        }
 
        /* not on the list; add it */
 
        string loc;
+#if 0 // is this still needed? Why?
        if (_parent_strip) {
                if (_parent_strip->mixer_owned()) {
                        loc = X_("M");
@@ -1668,6 +1755,9 @@ ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
        } else {
                loc = X_("P");
        }
+#else
+       loc = X_("P");
+#endif
 
        ProcessorWindowProxy* wp = new ProcessorWindowProxy (
                string_compose ("%1-%2-%3", loc, _route->id(), p->id()),
@@ -1680,24 +1770,18 @@ ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
                wp->set_state (*ui_xml);
        }
        
-       wp->marked = true;
-
-        /* if the processor already has an existing UI,
-           note that so that we don't recreate it
-        */
-
         void* existing_ui = p->get_ui ();
 
         if (existing_ui) {
                 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
         }
 
-       _processor_window_info.push_back (wp);
+       p->set_window_proxy (wp);
        WM::Manager::instance().register_window (wp);
 }
 
 void
-ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen, ChanCount *cc)
+ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor> p, uint32_t* cnt, bool* amp_seen)
 {
        boost::shared_ptr<Processor> processor (p.lock ());
 
@@ -1705,9 +1789,6 @@ ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor>
 
                if (boost::dynamic_pointer_cast<Amp>(processor)) {
                        *amp_seen = true;
-                       for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
-                               cc->set(*t, processor->input_streams().get(*t));
-                       }
                } else {
                        if (!*amp_seen) {
                                (*cnt)++;
@@ -1726,6 +1807,7 @@ 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 (this, plugin_insert, _width);
@@ -1733,14 +1815,33 @@ ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
                e = new ProcessorEntry (this, processor, _width);
        }
 
+       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);
+
+       bool mark_send_visible = false;
+       if (send && _parent_strip) {
+               /* show controls of new sends by default */
+               GUIObjectState& st = _parent_strip->gui_object_state ();
+               XMLNode* strip = st.get_or_add_node (_parent_strip->state_id ());
+               assert (strip);
+               /* check if state exists, if not it must be a new send */
+               if (!st.get_node(strip, e->state_id())) {
+                       mark_send_visible = true;
+               }
+       }
+
        /* Set up this entry's state from the GUIObjectState */
        XMLNode* proc = entry_gui_object_state (e);
        if (proc) {
                e->set_control_state (proc);
        }
-       
-       if (boost::dynamic_pointer_cast<Send> (processor)) {
-               /* Always show send controls */
+
+       if (mark_send_visible) {
                e->show_all_controls ();
        }
 
@@ -1760,15 +1861,16 @@ ProcessorBox::setup_entry_positions ()
        list<ProcessorEntry*> children = processor_display.children ();
        bool pre_fader = true;
 
+       uint32_t num = 0;
        for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
                if (boost::dynamic_pointer_cast<Amp>((*i)->processor())) {
                        pre_fader = false;
-                       (*i)->set_position (ProcessorEntry::Fader);
+                       (*i)->set_position (ProcessorEntry::Fader, num++);
                } else {
                        if (pre_fader) {
-                               (*i)->set_position (ProcessorEntry::PreFader);
+                               (*i)->set_position (ProcessorEntry::PreFader, num++);
                        } else {
-                               (*i)->set_position (ProcessorEntry::PostFader);
+                               (*i)->set_position (ProcessorEntry::PostFader, num++);
                        }
                }
        }
@@ -1843,22 +1945,38 @@ ProcessorBox::rename_processors ()
 bool
 ProcessorBox::can_cut () const
 {
-        vector<boost::shared_ptr<Processor> > sel;
+       vector<boost::shared_ptr<Processor> > sel;
 
-        get_selected_processors (sel);
+       get_selected_processors (sel);
 
-        /* cut_processors () does not cut inserts */
+       /* cut_processors () does not cut inserts */
 
-        for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
+       for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
 
                if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
                    (boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
                    (boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
-                        return true;
-                }
-        }
+                       return true;
+               }
+       }
+
+       return false;
+}
 
-        return false;
+bool
+ProcessorBox::stub_processor_selected () const
+{
+       vector<boost::shared_ptr<Processor> > sel;
+
+       get_selected_processors (sel);
+
+       for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
+               if (boost::dynamic_pointer_cast<UnknownProcessor>((*i)) != 0) {
+                       return true;
+               }
+       }
+
+       return false;
 }
 
 void
@@ -2090,9 +2208,10 @@ 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(),
-                                                                   boost::shared_ptr<Route>(), Delivery::Aux); 
+                               InternalSend* s = new InternalSend (*_session, sendpan, _route->mute_master(),
+                                               _route, boost::shared_ptr<Route>(), Delivery::Aux);
 
                                IOProcessor::prepare_for_reset (n, s->name());
 
@@ -2105,8 +2224,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());
                                
@@ -2148,9 +2269,10 @@ ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr
                                /* XXX its a bit limiting to assume that everything else
                                   is a plugin.
                                */
-
                                p.reset (new PluginInsert (*_session));
-                                p->set_state (**niter, Stateful::current_state_version);
+                               PBD::ID id = p->id();
+                               p->set_state (**niter, Stateful::current_state_version);
+                               boost::dynamic_pointer_cast<PluginInsert>(p)->update_id (id);
                        }
 
                        copies.push_back (p);
@@ -2439,6 +2561,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));
@@ -2450,14 +2573,10 @@ ProcessorBox::register_actions ()
        /* standard editing stuff */
        cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
                                                      sigc::ptr_fun (ProcessorBox::rb_cut));
-       ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
-       act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
+       copy_action = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
                        sigc::ptr_fun (ProcessorBox::rb_copy));
-       ActionManager::plugin_selection_sensitive_actions.push_back(act);
-
-       act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
+       delete_action = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
                        sigc::ptr_fun (ProcessorBox::rb_delete));
-       ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
 
        paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
                        sigc::ptr_fun (ProcessorBox::rb_paste));
@@ -2798,16 +2917,10 @@ ProcessorBox::generate_processor_title (boost::shared_ptr<PluginInsert> pi)
 Window *
 ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
 {
-       list<ProcessorWindowProxy*>::const_iterator i = _processor_window_info.begin ();
-       while (i != _processor_window_info.end()) {
-               boost::shared_ptr<Processor> t = (*i)->processor().lock ();
-               if (t && t == p) {
-                       return (*i)->get ();
-               }
-
-               ++i;
+       ProcessorWindowProxy* wp = p->window_proxy();
+       if (wp) {
+               return wp->get ();
        }
-
        return 0;
 }
 
@@ -2818,24 +2931,9 @@ ProcessorBox::get_processor_ui (boost::shared_ptr<Processor> p) const
 void
 ProcessorBox::set_processor_ui (boost::shared_ptr<Processor> p, Gtk::Window* w)
 {
-       list<ProcessorWindowProxy*>::iterator i = _processor_window_info.begin ();
-
+       assert (p->window_proxy());
        p->set_ui (w);
-
-       while (i != _processor_window_info.end()) {
-               boost::shared_ptr<Processor> t = (*i)->processor().lock ();
-               if (t && t == p) {
-                       (*i)->use_window (*w);
-                       return;
-               }
-
-               ++i;
-       }
-
-       /* we shouldn't get here, because the ProcessorUIList should always contain
-          an entry for each processor.
-       */
-       assert (false);
+       p->window_proxy()->use_window (*w);
 }
 
 void
@@ -2910,12 +3008,10 @@ ProcessorBox::is_editor_mixer_strip() const
 
 ProcessorWindowProxy::ProcessorWindowProxy (string const & name, ProcessorBox* box, boost::weak_ptr<Processor> processor)
        : WM::ProxyBase (name, string())
-       , marked (false)
        , _processor_box (box)
        , _processor (processor)
        , is_custom (false)
        , want_custom (false)
-       , _valid (true)
 {
        boost::shared_ptr<Processor> p = _processor.lock ();
        if (!p) {
@@ -2938,7 +3034,7 @@ ProcessorWindowProxy::processor_going_away ()
 {
        delete _window;
        _window = 0;
-       _valid = false;
+       WM::Manager::instance().remove (this);
        /* should be no real reason to do this, since the object that would
           send DropReferences is about to be deleted, but lets do it anyway.
        */
@@ -2952,12 +3048,6 @@ ProcessorWindowProxy::session_handle()
        return 0;
 }
 
-bool
-ProcessorWindowProxy::valid() const
-{
-       return _valid;
-}
-
 XMLNode&
 ProcessorWindowProxy::get_state () const
 {