...use shared backend function instead
[ardour.git] / gtk2_ardour / processor_box.cc
index 1c94d0c054fe96c9f862beff8bf44fe26b4d82fe..641ff9d33e04b3e88ec018f2e336a363a946af7a 100644 (file)
@@ -168,7 +168,7 @@ ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processo
        }
        {
                boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
-               if (pi && pi->plugin() && pi->plugin()->get_info()->type != ARDOUR::Lua) {
+               if (pi && pi->plugin()) {
                        _plugin_preset_pointer = PluginPresetPtr (new PluginPreset (pi->plugin()->get_info()));
                }
        }
@@ -657,7 +657,7 @@ ProcessorEntry::set_control_state (XMLNode const * node)
 
        if (_plugin_display) {
                XMLNode* n = GUIObjectState::get_node (node, X_("InlineDisplay"));
-               XMLProperty* p = n ? n->property (X_("visible")) : NULL;
+               XMLProperty const * p = n ? n->property (X_("visible")) : NULL;
                if (p) {
                        if (string_is_affirmative (p->value ())) {
                                _plugin_display->show();
@@ -947,7 +947,7 @@ ProcessorEntry::Control::set_state (XMLNode const * node)
 {
        XMLNode* n = GUIObjectState::get_node (node, state_id ());
        if (n) {
-               XMLProperty* p = n->property (X_("visible"));
+               XMLProperty const * p = n->property (X_("visible"));
                set_visible (p && string_is_affirmative (p->value ()));
        } else {
                set_visible (false);
@@ -1209,7 +1209,7 @@ 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 rad = 2;
+       const double rad = 1;
        const double y1 = height - rad - 1.5;
 
        cairo_arc (cr, x0, y0 + y1, rad, 0, 2. * M_PI);
@@ -1223,7 +1223,7 @@ ProcessorEntry::RoutingIcon::draw_thru_src (cairo_t* cr, double x0, double y0, d
 void
 ProcessorEntry::RoutingIcon::draw_thru_sink (cairo_t* cr, double x0, double y0, double height, bool midi)
 {
-       const double rad = 2;
+       const double rad = 1;
        const double y1 = rad + 1;
 
        cairo_arc (cr, x0, y0 + y1, rad, 0, 2. * M_PI);
@@ -1421,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);
@@ -1443,7 +1445,9 @@ ProcessorEntry::RoutingIcon::expose_output_map (cairo_t* cr, const double width,
                                _i_in_map.get_src (dt, pn, &valid_sink);
                                _i_thru_map.get_src (dt, pn, &valid_thru_f);
                                if (!valid_thru_f && !valid_sink) {
-                                       continue;
+                                       if (!is_midi || i != 0) { // special case midi-bypass
+                                               continue;
+                                       }
                                }
                        }
 
@@ -1694,7 +1698,7 @@ static std::list<Gtk::TargetEntry> drop_targets()
        std::list<Gtk::TargetEntry> tmp;
        tmp.push_back (Gtk::TargetEntry ("processor")); // from processor-box to processor-box
        tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr")); // from plugin-manager
-       tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // from sidebar
+       tmp.push_back (Gtk::TargetEntry ("PluginFavoritePtr")); // from sidebar
        return tmp;
 }
 
@@ -1906,7 +1910,7 @@ ProcessorBox::plugin_drop (Gtk::SelectionData const &data, ProcessorEntry* posit
        if (data.get_target() == "PluginInfoPtr") {
                _drop_plugin (data, pl);
        }
-       else if (data.get_target() == "PluginPresetPtr") {
+       else if (data.get_target() == "PluginFavoritePtr") {
                _drop_plugin_preset (data, pl);
        }
        else {
@@ -2085,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);
                }
        }
 
@@ -2365,49 +2372,6 @@ ProcessorBox::choose_plugin ()
        _get_plugin_selector()->set_interested_object (*this);
 }
 
-/** @return true if an error occurred, otherwise false */
-bool
-ProcessorBox::choose_lua ()
-{
-       LuaScriptInfoPtr spi;
-
-       ScriptSelector ss (_("Add Lua DSP Processor"), LuaScriptInfo::DSP);
-       switch (ss.run ()) {
-               case Gtk::RESPONSE_ACCEPT:
-                       spi = ss.script();
-                       break;
-               default:
-                       return true;
-       }
-       ss.hide ();
-
-       PluginPtr p;
-       try {
-               LuaPluginInfoPtr lpi (new LuaPluginInfo(spi));
-               p = (lpi->load (*_session));
-       } catch (...) {
-               string msg = _(
-                               "Failed to instantiate Lua DSP Processor,\n"
-                               "probably because the script is invalid (no dsp function).");
-               MessageDialog am (msg);
-               am.run ();
-               return true;
-       }
-
-       boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
-
-       Route::ProcessorStreams err_streams;
-       if (_route->add_processor_by_index (processor, _placement, &err_streams, Config->get_new_plugins_active ())) {
-               string msg = _(
-                               "Failed to add Lua DSP Processor at the given position,\n"
-                               "probably because the I/O configuration of the plugins\n"
-                               "could not match the configuration of this track.");
-               MessageDialog am (msg);
-               am.run ();
-       }
-       return false;
-}
-
 /** @return true if an error occurred, otherwise false */
 bool
 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
@@ -2702,12 +2666,6 @@ ProcessorBox::maybe_add_processor_pin_mgr (boost::weak_ptr<Processor> w)
                wp->set_state (*ui_xml, 0);
        }
 
-       void* existing_ui = p->get_ui ();
-
-       if (existing_ui) {
-               wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
-       }
-
        p->set_pingmgr_proxy (wp);
        WM::Manager::instance().register_window (wp);
 }
@@ -3648,8 +3606,6 @@ ProcessorBox::register_actions ()
        myactions.register_action (processor_box_actions, X_("newplugin"), _("New Plugin"),
                        sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
 
-       act = myactions.register_action (processor_box_actions, X_("newlua"), _("New Lua DSP"),
-                       sigc::ptr_fun (ProcessorBox::rb_choose_lua));
        act = myactions.register_action (processor_box_actions, X_("newinsert"), _("New Insert"),
                        sigc::ptr_fun (ProcessorBox::rb_choose_insert));
        ActionManager::engine_sensitive_actions.push_back (act);
@@ -3754,15 +3710,6 @@ ProcessorBox::rb_choose_plugin ()
        _current_processor_box->choose_plugin ();
 }
 
-void
-ProcessorBox::rb_choose_lua ()
-{
-       if (_current_processor_box == 0) {
-               return;
-       }
-       _current_processor_box->choose_lua ();
-}
-
 void
 ProcessorBox::rb_choose_insert ()
 {
@@ -4207,7 +4154,7 @@ ProcessorWindowProxy::set_state (const XMLNode& node, int /*version*/)
        XMLNodeList children = node.children ();
        XMLNodeList::const_iterator i = children.begin ();
        while (i != children.end()) {
-               XMLProperty* prop = (*i)->property (X_("name"));
+               XMLProperty const * prop = (*i)->property (X_("name"));
                if ((*i)->name() == X_("Window") && prop && prop->value() == _name) {
                        break;
                }
@@ -4215,7 +4162,7 @@ ProcessorWindowProxy::set_state (const XMLNode& node, int /*version*/)
        }
 
        if (i != children.end()) {
-               XMLProperty* prop;
+               XMLProperty const * prop;
                if ((prop = (*i)->property (X_("custom-ui"))) != 0) {
                        want_custom = PBD::string_is_affirmative (prop->value ());
                }
@@ -4248,8 +4195,8 @@ ProcessorWindowProxy::get (bool create)
                if (_window) {
                        setup ();
                }
+               _window->show_all ();
        }
-       _window->show_all ();
        return _window;
 }
 
@@ -4311,9 +4258,8 @@ PluginPinWindowProxy::get (bool create)
                if (aw) {
                        aw->set_session (_session);
                }
+               _window->show_all ();
        }
-
-       _window->show_all ();
        return _window;
 }