remove all trace of SAE from source code.
[ardour.git] / gtk2_ardour / processor_box.cc
index 73abc02c43ea00d1097392b9623f779c869203cf..fec73f8d63d99199d121e1932f3bc3a998cef09c 100644 (file)
@@ -94,7 +94,7 @@ using namespace Gtk;
 using namespace Glib;
 using namespace Gtkmm2ext;
 
-ProcessorBox* ProcessorBox::_current_processor_box = 0;
+ProcessorBox*  ProcessorBox::_current_processor_box = 0;
 RefPtr<Action> ProcessorBox::paste_action;
 RefPtr<Action> ProcessorBox::cut_action;
 RefPtr<Action> ProcessorBox::copy_action;
@@ -102,6 +102,7 @@ RefPtr<Action> ProcessorBox::rename_action;
 RefPtr<Action> ProcessorBox::delete_action;
 RefPtr<Action> ProcessorBox::edit_action;
 RefPtr<Action> ProcessorBox::edit_generic_action;
+ActionMap      ProcessorBox::processor_box_actions (X_("processor box"));
 
 static const uint32_t audio_port_color = 0x4A8A0EFF; // Green
 static const uint32_t midi_port_color = 0x960909FF; //Red
@@ -221,8 +222,14 @@ ProcessorEntry::drag_text () const
 bool
 ProcessorEntry::drag_data_get (Glib::RefPtr<Gdk::DragContext> const, Gtk::SelectionData &data)
 {
-       if (data.get_target() == "PluginPresetPtr" && _plugin_preset_pointer) {
+       if (data.get_target() == "PluginPresetPtr") {
                boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
+
+               if (!_plugin_preset_pointer || !pi) {
+                       data.set (data.get_target(), 8, NULL, 0);
+                       return true;
+               }
+
                boost::shared_ptr<ARDOUR::Plugin> plugin = pi->plugin();
                assert (plugin);
 
@@ -705,7 +712,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 ()) , Controllable::NoGroup);
        set_tooltip ();
 }
 
@@ -720,7 +727,7 @@ ProcessorEntry::Control::button_clicked ()
 
        bool const n = _button.get_active ();
 
-       c->set_value (n ? 0 : 1);
+       c->set_value (n ? 0 : 1, Controllable::NoGroup);
        _button.set_active (!n);
        set_tooltip ();
 }
@@ -1099,9 +1106,24 @@ ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
 static std::list<Gtk::TargetEntry> drop_targets()
 {
        std::list<Gtk::TargetEntry> tmp;
-       tmp.push_back (Gtk::TargetEntry ("processor"));
-       tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr"));
-       tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr"));
+       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
+       return tmp;
+}
+
+static std::list<Gtk::TargetEntry> drag_targets()
+{
+       std::list<Gtk::TargetEntry> tmp;
+       tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // to sidebar (optional preset)
+       tmp.push_back (Gtk::TargetEntry ("processor")); // to processor-box (copy)
+       return tmp;
+}
+
+static std::list<Gtk::TargetEntry> drag_targets_noplugin()
+{
+       std::list<Gtk::TargetEntry> tmp;
+       tmp.push_back (Gtk::TargetEntry ("processor")); // to processor box (sends, faders re-order)
        return tmp;
 }
 
@@ -1855,9 +1877,6 @@ ProcessorBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Processor>
 
        case IOSelector::Accepted:
                _route->add_processor_by_index (processor, _placement);
-               if (Profile->get_sae()) {
-                       processor->activate ();
-               }
                break;
        }
 
@@ -1883,9 +1902,6 @@ ProcessorBox::return_io_finished (IOSelector::Result r, boost::weak_ptr<Processo
 
        case IOSelector::Accepted:
                _route->add_processor_by_index (processor, _placement);
-               if (Profile->get_sae()) {
-                       processor->activate ();
-               }
                break;
        }
 
@@ -1981,7 +1997,7 @@ ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
        const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
 
        if (ui_xml) {
-               wp->set_state (*ui_xml);
+               wp->set_state (*ui_xml, 0);
        }
 
         void* existing_ui = p->get_ui ();
@@ -2006,7 +2022,8 @@ ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor>
                         )
           ) {
 
-               if (boost::dynamic_pointer_cast<Amp>(processor) && boost::dynamic_pointer_cast<Amp>(processor)->type() == X_("amp")) {
+               if (boost::dynamic_pointer_cast<Amp>(processor) && 
+                   boost::dynamic_pointer_cast<Amp>(processor)->gain_control()->parameter().type() == GainAutomation) {
                        *amp_seen = true;
                } else {
                        if (!*amp_seen) {
@@ -2069,7 +2086,16 @@ ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
                e->show_all_controls ();
        }
 
-       processor_display.add_child (e);
+       if (plugin_insert
+#ifdef MIXBUS
+                       && !plugin_insert->plugin(0)->is_channelstrip()
+#endif
+                )
+       {
+               processor_display.add_child (e, drag_targets());
+       } else {
+               processor_display.add_child (e, drag_targets_noplugin());
+       }
 }
 
 void
@@ -2087,7 +2113,8 @@ ProcessorBox::setup_entry_positions ()
 
        uint32_t num = 0;
        for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
-               if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) && boost::dynamic_pointer_cast<Amp>((*i)->processor())->type() == X_("amp")) {
+               if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) && 
+                   boost::dynamic_pointer_cast<Amp>((*i)->processor())->gain_control()->parameter().type() == GainAutomation) {
                        pre_fader = false;
                        (*i)->set_position (ProcessorEntry::Fader, num++);
                } else {
@@ -2659,7 +2686,7 @@ ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool us
                }
        }
 
-       if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->type() == X_("amp")) {
+       if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->gain_control()->parameter().type() == GainAutomation) {
 
                if (_parent_strip) {
                        _parent_strip->revert_to_default_display ();
@@ -2768,68 +2795,71 @@ ProcessorBox::get_generic_editor_window (boost::shared_ptr<Processor> processor)
 void
 ProcessorBox::register_actions ()
 {
-       Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("ProcessorMenu"));
+       Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = processor_box_actions.create_action_group (X_("ProcessorMenu"));
        Glib::RefPtr<Action> act;
 
        /* new stuff */
-       ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
+       processor_box_actions.register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
                        sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
 
-       act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
+       act = processor_box_actions.register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
                        sigc::ptr_fun (ProcessorBox::rb_choose_insert));
        ActionManager::engine_sensitive_actions.push_back (act);
-       act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New External Send ..."),
+       act = processor_box_actions.register_action (popup_act_grp, X_("newsend"), _("New External Send ..."),
                        sigc::ptr_fun (ProcessorBox::rb_choose_send));
        ActionManager::engine_sensitive_actions.push_back (act);
 
-       ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
+       processor_box_actions.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"));
+       processor_box_actions.register_action (popup_act_grp, X_("controls"), _("Controls"));
+       processor_box_actions.register_action (popup_act_grp, X_("send_options"), _("Send Options"));
 
-       ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
+       processor_box_actions.register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
                        sigc::ptr_fun (ProcessorBox::rb_clear));
-       ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
+       processor_box_actions.register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
                        sigc::ptr_fun (ProcessorBox::rb_clear_pre));
-       ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
+       processor_box_actions.register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
                        sigc::ptr_fun (ProcessorBox::rb_clear_post));
 
        /* standard editing stuff */
-       cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
-                                                     sigc::ptr_fun (ProcessorBox::rb_cut));
-       copy_action = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
-                       sigc::ptr_fun (ProcessorBox::rb_copy));
-       delete_action = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
-                       sigc::ptr_fun (ProcessorBox::rb_delete));
-
-       paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
+
+       cut_action = processor_box_actions.register_action (popup_act_grp, X_("cut"), _("Cut"),
+                                                           sigc::ptr_fun (ProcessorBox::rb_cut));
+       copy_action = processor_box_actions.register_action (popup_act_grp, X_("copy"), _("Copy"),
+                                                            sigc::ptr_fun (ProcessorBox::rb_copy));
+       delete_action = processor_box_actions.register_action (popup_act_grp, X_("delete"), _("Delete"),
+                                                              sigc::ptr_fun (ProcessorBox::rb_delete));
+
+       ActionManager::plugin_selection_sensitive_actions.push_back (cut_action);
+       ActionManager::plugin_selection_sensitive_actions.push_back (copy_action);
+       ActionManager::plugin_selection_sensitive_actions.push_back (delete_action);
+
+       paste_action = processor_box_actions.register_action (popup_act_grp, X_("paste"), _("Paste"),
                        sigc::ptr_fun (ProcessorBox::rb_paste));
-       rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
+       rename_action = processor_box_actions.register_action (popup_act_grp, X_("rename"), _("Rename"),
                        sigc::ptr_fun (ProcessorBox::rb_rename));
-       ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
+       processor_box_actions.register_action (popup_act_grp, X_("selectall"), _("Select All"),
                        sigc::ptr_fun (ProcessorBox::rb_select_all));
-       ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
+       processor_box_actions.register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
                        sigc::ptr_fun (ProcessorBox::rb_deselect_all));
 
        /* activation etc. */
 
-       ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate All"),
+       processor_box_actions.register_action (popup_act_grp, X_("activate_all"), _("Activate All"),
                        sigc::ptr_fun (ProcessorBox::rb_activate_all));
-       ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate All"),
+       processor_box_actions.register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate All"),
                        sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
-       ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
+       processor_box_actions.register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
                        sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
 
        /* show editors */
-       edit_action = ActionManager::register_action (
+       edit_action = processor_box_actions.register_action (
                popup_act_grp, X_("edit"), _("Edit..."),
                sigc::ptr_fun (ProcessorBox::rb_edit));
 
-       edit_generic_action = ActionManager::register_action (
+       edit_generic_action = processor_box_actions.register_action (
                popup_act_grp, X_("edit-generic"), _("Edit with generic controls..."),
                sigc::ptr_fun (ProcessorBox::rb_edit_generic));
-
-       ActionManager::add_action_group (popup_act_grp);
 }
 
 void
@@ -3050,7 +3080,7 @@ ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
 
        if (proxy) {
                proxy->set_custom_ui_mode (true);
-               proxy->toggle ();
+               proxy->show_the_right_window ();
        }
 }
 
@@ -3068,7 +3098,7 @@ ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
 
        if (proxy) {
                proxy->set_custom_ui_mode (false);
-               proxy->toggle ();
+               proxy->show_the_right_window ();
        }
 }
 
@@ -3273,7 +3303,7 @@ ProcessorWindowProxy::session_handle()
 }
 
 XMLNode&
-ProcessorWindowProxy::get_state () const
+ProcessorWindowProxy::get_state ()
 {
        XMLNode *node;
        node = &ProxyBase::get_state();
@@ -3281,8 +3311,8 @@ ProcessorWindowProxy::get_state () const
        return *node;
 }
 
-void
-ProcessorWindowProxy::set_state (const XMLNode& node)
+int
+ProcessorWindowProxy::set_state (const XMLNode& node, int /*version*/)
 {
        XMLNodeList children = node.children ();
        XMLNodeList::const_iterator i = children.begin ();
@@ -3301,7 +3331,7 @@ ProcessorWindowProxy::set_state (const XMLNode& node)
                }
        }
 
-       ProxyBase::set_state(node);
+       return ProxyBase::set_state (node, 0);
 }
 
 Gtk::Window*
@@ -3334,13 +3364,16 @@ ProcessorWindowProxy::get (bool create)
 }
 
 void
-ProcessorWindowProxy::toggle ()
+ProcessorWindowProxy::show_the_right_window ()
 {
        if (_window && (is_custom != want_custom)) {
                /* drop existing window - wrong type */
                drop_window ();
+               get (true);
+               setup ();
+               assert (_window);
+               is_custom = want_custom;
        }
-       is_custom = want_custom;
 
-       WM::ProxyBase::toggle ();
+       toggle ();
 }