+ queue_idle_update ();
+ }
+}
+
+/* lifted from ProcessorEntry::Control */
+PluginPinWidget::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 * UIConfiguration::instance ().get_ui_scale ())))
+ , _slider_persistant_tooltip (&_slider)
+ , _ignore_ui_adjustment (false)
+ , _name (n)
+{
+ _slider.set_controllable (c);
+ box.set_padding (0, 0, 4, 4);
+
+ _slider.set_name ("ProcessorControlSlider");
+ _slider.set_text (_name);
+
+ box.add (_slider);
+ _slider.show ();
+
+ 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 (smallstep);
+ _adjustment.set_page_increment (largestep);
+ _slider.set_default_value (normal);
+
+ _adjustment.signal_value_changed ().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
+ // dup. currently timers are used :(
+ //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
+
+ // 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 ();
+
+ /* We're providing our own PersistentTooltip */
+ set_no_tooltip_whatsoever (_slider);
+}
+
+PluginPinWidget::Control::~Control ()
+{
+ timer_connection.disconnect ();
+}
+
+void
+PluginPinWidget::Control::set_tooltip ()
+{
+ boost::shared_ptr<AutomationControl> c = _control.lock ();
+ if (!c) {
+ return;
+ }
+ char tmp[256];
+ snprintf (tmp, sizeof (tmp), "%s: %.2f", _name.c_str (), c->internal_to_user (c->get_value ()));
+
+ string sm = Gtkmm2ext::markup_escape_text (tmp);
+ _slider_persistant_tooltip.set_tip (sm);
+}
+
+void
+PluginPinWidget::Control::slider_adjusted ()
+{
+ if (_ignore_ui_adjustment) {
+ return;
+ }
+ boost::shared_ptr<AutomationControl> c = _control.lock ();
+ if (!c) {
+ return;
+ }
+ c->set_value ( c->interface_to_internal (_adjustment.get_value ()) , Controllable::NoGroup);
+ set_tooltip ();
+}
+
+
+void
+PluginPinWidget::Control::control_changed ()
+{
+ boost::shared_ptr<AutomationControl> c = _control.lock ();
+ if (!c) {
+ return;
+ }
+
+ _ignore_ui_adjustment = true;
+
+ // 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;
+}
+
+
+
+PluginPinDialog::PluginPinDialog (boost::shared_ptr<ARDOUR::PluginInsert> pi)
+ : ArdourWindow (string_compose (_("Pin Configuration: %1"), pi->name ()))
+{
+ ppw.push_back (PluginPinWidgetPtr(new PluginPinWidget (pi)));
+ add (*ppw.back());
+}
+
+
+PluginPinDialog::PluginPinDialog (boost::shared_ptr<ARDOUR::Route> r)
+ : ArdourWindow (string_compose (_("Pin Configuration: %1"), r->name ()))
+ , _route (r)
+ , _height_mapped (false)
+{
+ vbox = manage (new VBox ());
+ vbox->signal_size_allocate().connect (sigc::mem_fun (*this, &PluginPinDialog::map_height));
+ scroller = manage (new ScrolledWindow);
+ scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
+ scroller->set_shadow_type (Gtk::SHADOW_NONE);
+ scroller->show ();
+ vbox->show ();
+ scroller->add (*vbox);
+ add (*scroller);
+
+
+ _route->foreach_processor (sigc::mem_fun (*this, &PluginPinDialog::add_processor));
+
+ _route->processors_changed.connect (
+ _route_connections, invalidator (*this), boost::bind (&PluginPinDialog::route_processors_changed, this, _1), gui_context()
+ );
+
+ _route->DropReferences.connect (
+ _route_connections, invalidator (*this), boost::bind (&PluginPinDialog::route_going_away, this), gui_context()
+ );
+}
+void
+PluginPinDialog::set_session (ARDOUR::Session *s)
+{
+ SessionHandlePtr::set_session (s);
+ for (PluginPinWidgetList::iterator i = ppw.begin(); i != ppw.end(); ++i) {
+ (*i)->set_session (s);
+ }
+}
+
+void
+PluginPinDialog::map_height (Gtk::Allocation&)
+{
+ if (!_height_mapped) {
+ scroller->set_size_request (-1, std::min (600, 2 + vbox->get_height()));
+ _height_mapped = true;
+ }
+}
+
+void
+PluginPinDialog::route_processors_changed (ARDOUR::RouteProcessorChange)
+{
+ ppw.clear ();
+ _height_mapped = false;
+ scroller->remove ();
+ vbox = manage (new VBox ());
+ vbox->signal_size_allocate().connect (sigc::mem_fun (*this, &PluginPinDialog::map_height));
+ scroller->add (*vbox);
+ _route->foreach_processor (sigc::mem_fun (*this, &PluginPinDialog::add_processor));
+ vbox->show ();
+}
+
+void
+PluginPinDialog::route_going_away ()
+{
+ ppw.clear ();
+ _route.reset ();
+ remove ();
+}
+
+void
+PluginPinDialog::add_processor (boost::weak_ptr<Processor> p)
+{
+ boost::shared_ptr<Processor> proc = p.lock ();
+ if (!proc || !proc->display_to_user ()) {
+ return;
+ }
+ boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (proc);
+#ifdef MIXBUS
+ if (pi && pi->is_channelstrip ()) {
+ pi.reset ();
+ }
+#endif
+ if (pi) {
+ ppw.push_back (PluginPinWidgetPtr(new PluginPinWidget (pi)));
+ vbox->pack_start (*ppw.back());
+ } else {
+ HBox* hbox = manage (new HBox ());
+ hbox->pack_start (*manage (new HSeparator ()));
+ hbox->pack_start (*manage (new Label (proc->display_name ())));
+ hbox->pack_start (*manage (new HSeparator ()));
+ vbox->pack_start (*hbox, false, false);
+ hbox->show_all ();