mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-15 19:16:40 +01:00
Allow to delete preset from context menu
This commit is contained in:
parent
2e0bfae628
commit
c4b63221d1
2 changed files with 34 additions and 2 deletions
|
|
@ -162,6 +162,7 @@ ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processo
|
|||
, _parent (parent)
|
||||
, _selectable(true)
|
||||
, _unknown_processor(false)
|
||||
, _ignore_preset_select(false)
|
||||
, _processor (p)
|
||||
, _width (w)
|
||||
, input_icon(true)
|
||||
|
|
@ -824,6 +825,9 @@ ProcessorEntry::build_controls_menu ()
|
|||
void
|
||||
ProcessorEntry::plugin_preset_selected (ARDOUR::Plugin::PresetRecord preset)
|
||||
{
|
||||
if (_ignore_preset_select) {
|
||||
return;
|
||||
}
|
||||
boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
|
||||
assert (pi);
|
||||
if (!preset.label.empty()) {
|
||||
|
|
@ -862,6 +866,17 @@ ProcessorEntry::plugin_preset_add ()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
ProcessorEntry::plugin_preset_delete ()
|
||||
{
|
||||
boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
|
||||
boost::shared_ptr<ARDOUR::Plugin> plugin = pi->plugin ();
|
||||
Plugin::PresetRecord pset = plugin->last_preset();
|
||||
if (!pset.uri.empty ()) {
|
||||
plugin->remove_preset (pset.label);
|
||||
}
|
||||
}
|
||||
|
||||
Menu*
|
||||
ProcessorEntry::build_presets_menu ()
|
||||
{
|
||||
|
|
@ -871,20 +886,35 @@ ProcessorEntry::build_presets_menu ()
|
|||
if (!pi) {
|
||||
return NULL;
|
||||
}
|
||||
boost::shared_ptr<ARDOUR::Plugin> plugin = pi->plugin();
|
||||
|
||||
vector<ARDOUR::Plugin::PresetRecord> presets = pi->plugin()->get_presets();
|
||||
vector<ARDOUR::Plugin::PresetRecord> presets = plugin->get_presets();
|
||||
Plugin::PresetRecord pset = plugin->last_preset();
|
||||
|
||||
Menu* menu = manage (new Menu);
|
||||
MenuList& items = menu->items ();
|
||||
if (pi->ui_elements () & PlugInsertBase::PluginPreset) {
|
||||
items.push_back (MenuElem (_("New Preset..."), sigc::mem_fun (*this, &ProcessorEntry::plugin_preset_add)));
|
||||
if (!pset.uri.empty ()) {
|
||||
items.push_back (MenuElem (_("Delete the current preset"), sigc::mem_fun (*this, &ProcessorEntry::plugin_preset_delete)));
|
||||
}
|
||||
if (!presets.empty ()) {
|
||||
items.push_back (SeparatorElem ());
|
||||
}
|
||||
}
|
||||
|
||||
PBD::Unwinder<bool> uw (_ignore_preset_select, true);
|
||||
|
||||
for (auto const& p : presets) {
|
||||
items.push_back (MenuElem (p.label, sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::plugin_preset_selected), p)));
|
||||
items.push_back (CheckMenuElem (p.label, sigc::bind (sigc::mem_fun (*this, &ProcessorEntry::plugin_preset_selected), p)));
|
||||
if (p.uri == pset.uri) {
|
||||
Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
|
||||
if (plugin->parameter_changed_since_last_preset ()) {
|
||||
c->set_inconsistent (true);
|
||||
} else {
|
||||
c->set_active (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return menu;
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ protected:
|
|||
private:
|
||||
bool _selectable;
|
||||
bool _unknown_processor;
|
||||
bool _ignore_preset_select;
|
||||
void led_clicked(GdkEventButton *);
|
||||
void processor_active_changed ();
|
||||
void processor_property_changed (const PBD::PropertyChange&);
|
||||
|
|
@ -259,6 +260,7 @@ private:
|
|||
void toggle_allow_feedback ();
|
||||
void plugin_preset_selected (ARDOUR::Plugin::PresetRecord);
|
||||
void plugin_preset_add ();
|
||||
void plugin_preset_delete ();
|
||||
|
||||
class PluginInlineDisplay : public PluginDisplay {
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue