hand over automationlist undo state ownership (mem-leak)
[ardour.git] / gtk2_ardour / processor_box.cc
index 97c9024766e77716c6db6d0714cb3535168f442a..ac3dc96bac3e1f4593e5eea8554719e6bbaf8e15 100644 (file)
@@ -513,8 +513,14 @@ ProcessorEntry::setup_tooltip ()
                                        string_compose (_("<b>%1</b>\nThe Plugin is not available on this system\nand has been replaced by a stub."), name (Wide)));
                        return;
                }
-               if (boost::dynamic_pointer_cast<Send> (_processor) && !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
-                       ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>&gt; %1</b>", _processor->name()));
+               boost::shared_ptr<Send> send;
+               if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
+                               !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
+                       if (send->remove_on_disconnect ()) {
+                               ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>&gt; %1</b>\nThis (sidechain) send will be removed when disconnected.", _processor->name()));
+                       } else {
+                               ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>&gt; %1</b>", _processor->name()));
+                       }
                        return;
                }
        }
@@ -1034,17 +1040,10 @@ ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
        cairo_fill (cr);
 
        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) {
-                       set_routing_color (cr, i < _ports.n_midi());
-                       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) {
-               set_routing_color (cr, _ports.n_midi() == 1);
-               const float x = rintf(width * .5);
-               cairo_rectangle (cr, x-dx * .5, 0, 1+dx, height);
+       for (uint32_t i = 0; i < _ports.n_total(); ++i) {
+               set_routing_color (cr, i < _ports.n_midi());
+               const double x = ProcessorEntry::RoutingIcon::pin_x_pos (i, width, _ports.n_total(), 0 , false);
+               cairo_rectangle (cr, x - .5 - dx * .5, 0, 1 + dx, height);
                cairo_fill(cr);
        }
 
@@ -1167,7 +1166,7 @@ ProcessorEntry::RoutingIcon::pin_x_pos (uint32_t i, double width, uint32_t n_tot
                assert (i == 0);
                return rint (width * .5) +.5;
        }
-       return rint (width * (.2 + .6 * i / (n_total - 1))) + .5;
+       return rint (width * (.15 + .7 * i / (n_total - 1))) + .5;
 }
 
 void
@@ -1210,47 +1209,29 @@ ProcessorEntry::RoutingIcon::draw_sidechain (cairo_t* cr, double x0, double y0,
 void
 ProcessorEntry::RoutingIcon::draw_thru_src (cairo_t* cr, double x0, double y0, double height, bool midi)
 {
-       const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale()));
-       const double y1 = rint (height * .5) + .5;
-
-       cairo_save (cr);
-       cairo_translate (cr, x0, y0);
-       cairo_move_to (cr, 0 - dx - .5, y1);
-       cairo_line_to (cr, 0 + dx + .5, y1 - 2);
-
-       cairo_move_to (cr, 0 - dx - .5, y1 + 2);
-       cairo_line_to (cr, 0 + dx + .5, y1);
-
-       cairo_move_to (cr, 0, y1 + 1);
-       cairo_line_to (cr, 0, height);
+       const double rad = 1;
+       const double y1 = height - rad - 1.5;
 
+       cairo_arc (cr, x0, y0 + y1, rad, 0, 2. * M_PI);
+       cairo_move_to (cr, x0, y0 + height - 1.5);
+       cairo_line_to (cr, x0, y0 + height);
        set_routing_color (cr, midi);
        cairo_set_line_width  (cr, 1.0);
        cairo_stroke (cr);
-       cairo_restore (cr);
 }
 
 void
 ProcessorEntry::RoutingIcon::draw_thru_sink (cairo_t* cr, double x0, double y0, double height, bool midi)
 {
-       const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale()));
-       const double y1 = rint (height * .5) - .5;
-
-       cairo_save (cr);
-       cairo_translate (cr, x0, y0);
-       cairo_move_to (cr, 0 - dx - .5, y1);
-       cairo_line_to (cr, 0 + dx + .5, y1 - 2);
-
-       cairo_move_to (cr, 0 - dx - .5, y1 + 2);
-       cairo_line_to (cr, 0 + dx + .5, y1);
-
-       cairo_move_to (cr, 0, y1 - 1);
-       cairo_line_to (cr, 0, 0);
+       const double rad = 1;
+       const double y1 = rad + 1;
 
+       cairo_arc (cr, x0, y0 + y1, rad, 0, 2. * M_PI);
+       cairo_move_to (cr, x0, y0);
+       cairo_line_to (cr, x0, y0 + 1);
        set_routing_color (cr, midi);
        cairo_set_line_width  (cr, 1.0);
        cairo_stroke (cr);
-       cairo_restore (cr);
 }
 
 void
@@ -1440,7 +1421,9 @@ ProcessorEntry::RoutingIcon::expose_output_map (cairo_t* cr, const double width,
                        _i_in_map.get_src (dt, idx, &valid_sink);
                        _i_thru_map.get_src (dt, idx, &valid_thru);
                        if (!valid_thru && !valid_sink) {
-                               continue;
+                               if (!is_midi || i != 0) { // special case midi-bypass
+                                       continue;
+                               }
                        }
                }
                double c_x0 = pin_x_pos (i, width, pc_out, 0, false);
@@ -1455,29 +1438,36 @@ ProcessorEntry::RoutingIcon::expose_output_map (cairo_t* cr, const double width,
                double x = pin_x_pos (i, width, n_out, 0, is_midi);
 
                if (!_terminal) {
-                       // only check thru (gnd is part of input)
-                       bool valid_thru;
-                       uint32_t idx = _thru_map.get (dt, pn, &valid_thru);
-                       if (!valid_thru) {
-                               continue;
-                       }
-
-                       // skip connections that are not used in the next's input :(
+                       bool valid_thru_f = false;
+                       // skip connections that are not used in the next's input
                        if (_feeding) {
                                bool valid_sink;
                                _i_in_map.get_src (dt, pn, &valid_sink);
-                               _i_thru_map.get_src (dt, pn, &valid_thru);
-                               if (!valid_thru && !valid_sink) {
-                                       continue;
+                               _i_thru_map.get_src (dt, pn, &valid_thru_f);
+                               if (!valid_thru_f && !valid_sink) {
+                                       if (!is_midi || i != 0) { // special case midi-bypass
+                                               continue;
+                                       }
                                }
                        }
 
-                       if (idx >= _in.get (dt)) {
-                               draw_sidechain (cr, x, 0, ht, is_midi);
-                       } else {
-                               draw_thru_src (cr, x, 0, ht, is_midi);
+                       bool valid_src;
+                       _out_map.get_src (dt, pn, &valid_src);
+                       if (!valid_src) {
+                               bool valid_thru;
+                               uint32_t idx = _thru_map.get (dt, pn, &valid_thru);
+                               if (valid_thru) {
+                                       if (idx >= _in.get (dt)) {
+                                               draw_sidechain (cr, x, 0, height, is_midi);
+                                       } else {
+                                               draw_thru_src (cr, x, 0, height, is_midi);
+                                       }
+                               } else if (valid_thru_f){
+                                       // gnd is part of input, unless it's a thru input
+                                       // (also only true if !coalesced into one small display)
+                                       draw_gnd (cr, x, 0, height, is_midi);
+                               }
                        }
-
                } else {
                        // terminal node, add arrows
                        bool valid_src;
@@ -2099,19 +2089,22 @@ ProcessorBox::show_processor_menu (int arg)
                }
        }
 
-       Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
-       if (send_menu_item) {
-               if (single_selection && !_route->is_monitor()) {
-                       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);
+
+       if (!ARDOUR::Profile->get_mixbus()) {
+               Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
+               if (send_menu_item) {
+                       if (single_selection && !_route->is_monitor()) {
+                               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 {
-                               gtk_menu_item_set_submenu (send_menu_item->gobj(), 0);
                                send_menu_item->set_sensitive (false);
                        }
-               } else {
-                       send_menu_item->set_sensitive (false);
                }
        }
 
@@ -2508,8 +2501,7 @@ ProcessorBox::choose_insert ()
 void
 ProcessorBox::choose_send ()
 {
-       boost::shared_ptr<Pannable> sendpan(new Pannable (*_session));
-       boost::shared_ptr<Send> send (new Send (*_session, sendpan, _route->mute_master()));
+       boost::shared_ptr<Send> send (new Send (*_session, _route->pannable (), _route->mute_master()));
 
        /* make an educated guess at the initial number of outputs for the send */
        ChanCount outs = (_session->master_out())
@@ -2905,6 +2897,7 @@ ProcessorBox::setup_routing_feeds ()
                        (*i)->routing_icon.unset_fed_by ();
                }
                prev = i;
+               (*i)->input_icon.hide();
        }
 
        /* now set which icons need to be displayed */
@@ -2915,8 +2908,6 @@ ProcessorBox::setup_routing_feeds ()
                        (*i)->routing_icon.hide();
                        if (i == children.begin()) {
                                (*i)->input_icon.show();
-                       } else {
-                               (*i)->input_icon.hide();
                        }
                } else {
                        (*i)->routing_icon.show();
@@ -2944,6 +2935,7 @@ ProcessorBox::setup_routing_feeds ()
                        } else if (!(*i)->routing_icon.out_identity ()) {
                                (*i)->output_routing_icon.show();
                                (*i)->output_routing_icon.queue_draw();
+                               (*next)->input_icon.show();
                        } else {
                                (*i)->output_routing_icon.hide();
                        }
@@ -4263,8 +4255,8 @@ ProcessorWindowProxy::get (bool create)
                if (_window) {
                        setup ();
                }
+               _window->show_all ();
        }
-       _window->show_all ();
        return _window;
 }
 
@@ -4326,9 +4318,8 @@ PluginPinWindowProxy::get (bool create)
                if (aw) {
                        aw->set_session (_session);
                }
+               _window->show_all ();
        }
-
-       _window->show_all ();
        return _window;
 }