+RefPtr<Action> ProcessorBox::cut_action;
+RefPtr<Action> ProcessorBox::rename_action;
+RefPtr<Action> ProcessorBox::edit_action;
+Glib::RefPtr<Gdk::Pixbuf> SendProcessorEntry::_slider;
+
+ProcessorEntry::ProcessorEntry (boost::shared_ptr<Processor> p, Width w)
+ : _position (PreFader)
+ , _processor (p)
+ , _width (w)
+ , _visual_state (Gtk::STATE_NORMAL)
+{
+ _hbox.pack_start (_active, false, false);
+ _event_box.add (_name);
+ _hbox.pack_start (_event_box, true, true);
+ _vbox.pack_start (_hbox);
+ _frame.add (_vbox);
+
+ /* without this, the border is mis-drawn on some systems */
+ _vbox.set_border_width (1);
+
+ _name.set_alignment (0, 0.5);
+ _name.set_text (name ());
+ _name.set_padding (2, 2);
+
+ if (boost::dynamic_pointer_cast<Amp> (p)) {
+ /* Fader processor gets a special look */
+ _event_box.set_name ("ProcessorFader");
+ _frame.set_name ("ProcessorFaderFrame");
+ _name.set_padding (2, 4);
+ }
+
+ _active.set_active (_processor->active ());
+ _active.signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::active_toggled));
+
+ _frame.show ();
+ _vbox.show ();
+ _hbox.show ();
+ _event_box.show ();
+ _name.show ();
+ _active.show ();
+
+ _processor->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
+ _processor->PropertyChanged.connect (name_connection, invalidator (*this), ui_bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
+}
+
+EventBox&
+ProcessorEntry::action_widget ()
+{
+ return _event_box;
+}
+
+Gtk::Widget&
+ProcessorEntry::widget ()
+{
+ return _frame;
+}
+
+string
+ProcessorEntry::drag_text () const
+{
+ return name ();
+}
+
+void
+ProcessorEntry::set_visual_state (Gtk::StateType t)
+{
+ _visual_state = t;
+ setup_visuals ();
+}
+
+void
+ProcessorEntry::set_position (Position p)
+{
+ _position = p;
+ setup_visuals ();
+}
+
+void
+ProcessorEntry::setup_visuals ()
+{
+ switch (_position) {
+ case PreFader:
+ _event_box.set_name ("ProcessorPreFader");
+ if (_visual_state == Gtk::STATE_NORMAL) {
+ _frame.set_name ("ProcessorPreFaderFrame");
+ }
+ break;
+
+ case Fader:
+ _event_box.set_name ("ProcessorFader");
+ if (_visual_state == Gtk::STATE_NORMAL) {
+ _frame.set_name ("ProcessorFaderFrame");
+ }
+ break;
+
+ case PostFader:
+ _event_box.set_name ("ProcessorPostFader");
+ if (_visual_state == Gtk::STATE_NORMAL) {
+ _frame.set_name ("ProcessorPostFaderFrame");
+ }
+ break;
+ }
+
+ switch (_visual_state) {
+ case Gtk::STATE_NORMAL:
+ /* _frame has been set up above */
+ _event_box.set_state (Gtk::STATE_NORMAL);
+ break;
+ case Gtk::STATE_SELECTED:
+ _frame.set_name ("ProcessorFrameSelected");
+ /* don't change the background of the box when it is selected */
+ _event_box.set_state (Gtk::STATE_NORMAL);
+ break;
+ case Gtk::STATE_ACTIVE:
+ _frame.set_name ("ProcessorFrameActiveSend");
+ _event_box.set_state (Gtk::STATE_ACTIVE);
+ break;
+ default:
+ break;
+ }
+}
+
+
+boost::shared_ptr<Processor>
+ProcessorEntry::processor () const
+{
+ return _processor;
+}
+
+void
+ProcessorEntry::set_enum_width (Width w)
+{
+ _width = w;
+}
+
+void
+ProcessorEntry::active_toggled ()
+{
+ if (_active.get_active ()) {
+ if (!_processor->active ()) {
+ _processor->activate ();
+ }
+ } else {
+ if (_processor->active ()) {
+ _processor->deactivate ();
+ }
+ }
+}
+
+void
+ProcessorEntry::processor_active_changed ()
+{
+ if (_active.get_active () != _processor->active ()) {
+ _active.set_active (_processor->active ());
+ }
+}
+
+void
+ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
+{
+ if (what_changed.contains (ARDOUR::Properties::name)) {
+ _name.set_text (name ());
+ }
+}
+
+string
+ProcessorEntry::name () const
+{
+ boost::shared_ptr<Send> send;
+ string name_display;
+
+ if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
+ !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
+
+ name_display += '>';
+
+ /* grab the send name out of its overall name */
+
+ string::size_type lbracket, rbracket;
+ lbracket = send->name().find ('[');
+ rbracket = send->name().find (']');
+
+ switch (_width) {
+ case Wide:
+ name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
+ break;
+ case Narrow:
+ name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
+ break;
+ }
+
+ } else {
+
+ switch (_width) {
+ case Wide:
+ name_display += _processor->display_name();
+ break;
+ case Narrow:
+ name_display += PBD::short_version (_processor->display_name(), 5);
+ break;
+ }
+
+ }
+
+ return name_display;
+}
+
+SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
+ : ProcessorEntry (s, w),
+ _send (s),
+ /* set the adjustment to a gain of 0dB so that the fader's default value is right */
+ _adjustment (0.781787, 0, 1, 0.01, 0.1),
+ _fader (_slider, &_adjustment, 0, false),
+ _ignore_gain_change (false)
+{
+ _fader.set_name ("SendFader");
+ _fader.set_controllable (_send->amp()->gain_control ());
+ _vbox.pack_start (_fader);
+
+ _fader.show ();
+
+ _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SendProcessorEntry::gain_adjusted));
+ _send->amp()->gain_control()->Changed.connect (send_gain_connection, invalidator (*this), boost::bind (&SendProcessorEntry::show_gain, this), gui_context());
+ show_gain ();
+}
+
+void
+SendProcessorEntry::setup_slider_pix ()
+{
+ _slider = ::get_icon ("fader_belt_h_thin");
+ assert (_slider);
+}
+
+void
+SendProcessorEntry::show_gain ()
+{
+ ENSURE_GUI_THREAD (*this, &SendProcessorEntry::show_gain)
+
+ float const value = gain_to_slider_position (_send->amp()->gain ());
+
+ if (_adjustment.get_value() != value) {
+ _ignore_gain_change = true;
+ _adjustment.set_value (value);
+ _ignore_gain_change = false;
+
+ stringstream s;
+ s.precision (1);
+ s.setf (ios::fixed, ios::floatfield);
+ s << accurate_coefficient_to_dB (_send->amp()->gain ()) << _("dB");
+ _fader.set_tooltip_text (s.str ());
+ }
+}
+
+void
+SendProcessorEntry::gain_adjusted ()
+{
+ if (_ignore_gain_change) {
+ return;
+ }
+
+ _send->amp()->set_gain (slider_position_to_gain (_adjustment.get_value()), this);
+}
+
+void
+SendProcessorEntry::set_pixel_width (int p)
+{
+ _fader.set_fader_length (p);
+}
+
+PluginInsertProcessorEntry::PluginInsertProcessorEntry (boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
+ : ProcessorEntry (p, w)
+ , _plugin_insert (p)
+{
+ p->SplittingChanged.connect (
+ _splitting_connection, invalidator (*this), ui_bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context()
+ );
+
+ _splitting_icon.set_size_request (-1, 12);
+
+ _vbox.pack_start (_splitting_icon);
+ _vbox.reorder_child (_splitting_icon, 0);
+
+ plugin_insert_splitting_changed ();
+}
+
+void
+PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
+{
+ if (_plugin_insert->splitting ()) {
+ _splitting_icon.show ();
+ } else {
+ _splitting_icon.hide ();
+ }
+}
+
+void
+PluginInsertProcessorEntry::hide_things ()
+{
+ plugin_insert_splitting_changed ();
+}
+
+void
+PluginInsertProcessorEntry::setup_visuals ()
+{
+ switch (_position) {
+ case PreFader:
+ _splitting_icon.set_name ("ProcessorPreFader");
+ break;
+
+ case Fader:
+ _splitting_icon.set_name ("ProcessorFader");
+ break;
+
+ case PostFader:
+ _splitting_icon.set_name ("ProcessorPostFader");
+ break;
+ }
+
+ ProcessorEntry::setup_visuals ();
+}
+
+bool
+PluginInsertProcessorEntry::SplittingIcon::on_expose_event (GdkEventExpose* ev)
+{
+ cairo_t* cr = gdk_cairo_create (get_window()->gobj());
+
+ cairo_set_line_width (cr, 1);
+
+ double const width = ev->area.width;
+ double const height = ev->area.height;
+
+ Gdk::Color const bg = get_style()->get_bg (STATE_NORMAL);
+ cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
+
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_fill (cr);
+
+ Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL);
+ cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ());
+
+ cairo_move_to (cr, width * 0.3, height);
+ cairo_line_to (cr, width * 0.3, height * 0.5);
+ cairo_line_to (cr, width * 0.7, height * 0.5);
+ cairo_line_to (cr, width * 0.7, height);
+ cairo_move_to (cr, width * 0.5, height * 0.5);
+ cairo_line_to (cr, width * 0.5, 0);
+ cairo_stroke (cr);
+
+ return true;
+}
+
+ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
+ RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
+ : _parent_strip (parent)