favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
+ favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
favorite_plugins_scroller.add (favorite_plugins_display);
favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
if (_selection.routes.empty()) {
items.push_back (MenuElem (_("No Track/Bus is selected.")));
} else {
-
items.push_back (MenuElem (_("Add at the top"),
sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
items.push_back (MenuElem (_("Add Pre-Fader"),
items.push_back (MenuElem (_("Add at the end"),
sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
}
+
items.push_back (SeparatorElem());
+
items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
+
+ ARDOUR::PluginPresetPtr ppp = selected_plugin();
+ if (ppp && ppp->_preset.valid) {
+ items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
+ }
+
m->popup (ev->button, ev->time);
}
Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
{
if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3) ) {
- popup_note_context_menu (ev);
+ TreeModel::Path path;
+ TreeViewColumn* column;
+ int cellx, celly;
+ if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
+ Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
+ if (selection) {
+ selection->unselect_all();
+ selection->select(path);
+ }
+ }
+ ARDOUR::PluginPresetPtr ppp = selected_plugin();
+ if (ppp) {
+ popup_note_context_menu (ev);
+ }
}
return false;
}
-void
-Mixer_UI::add_selected_processor (ProcessorPosition pos)
+
+PluginPresetPtr
+Mixer_UI::selected_plugin ()
{
Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
if (!selection) {
- return;
+ return PluginPresetPtr();
}
Gtk::TreeModel::iterator iter = selection->get_selected();
if (!iter) {
- return;
+ return PluginPresetPtr();
}
- ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
- add_favorite_processor (ppp, pos);
+ return (*iter)[favorite_plugins_columns.plugin];
}
void
-Mixer_UI::remove_selected_from_favorites ()
+Mixer_UI::add_selected_processor (ProcessorPosition pos)
{
- Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
- if (!selection) {
+ ARDOUR::PluginPresetPtr ppp = selected_plugin();
+ if (ppp) {
+ add_favorite_processor (ppp, pos);
+ }
+}
+
+void
+Mixer_UI::delete_selected_preset ()
+{
+ if (!_session) {
return;
}
- Gtk::TreeModel::iterator iter = selection->get_selected();
- if (!iter) {
+ ARDOUR::PluginPresetPtr ppp = selected_plugin();
+ if (!ppp || !ppp->_preset.valid) {
+ return;
+ }
+ PluginPtr plugin = ppp->_pip->load (*_session);
+ plugin->get_presets();
+ plugin->remove_preset (ppp->_preset.label);
+}
+
+void
+Mixer_UI::remove_selected_from_favorites ()
+{
+ ARDOUR::PluginPresetPtr ppp = selected_plugin();
+ if (!ppp) {
return;
}
- ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
PluginManager::PluginStatusType status = PluginManager::Normal;
PluginManager& manager (PluginManager::instance());
manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
manager.save_statuses ();
- sync_treeview_from_favorite_order ();
}
void
}
return false;
}
+
+void
+Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
+{
+ if (data.get_target() != "PluginPresetPtr") {
+ return;
+ }
+ if (data.get_length() != sizeof (PluginPresetPtr)) {
+ return;
+ }
+ const void *d = data.get_data();
+ const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
+
+ PluginManager::PluginStatusType status = PluginManager::Favorite;
+ PluginManager& manager (PluginManager::instance());
+
+ manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
+ manager.save_statuses ();
+}