Add a plugin-preset list/selector GUI
This is currently only used for "Preset only" plugins, generic UI. And also depends on plugin-presets having a description.
This commit is contained in:
parent
a48d6a37b3
commit
9594e12c52
@ -56,6 +56,7 @@
|
||||
#include "widgets/tooltips.h"
|
||||
|
||||
#include "plugin_ui.h"
|
||||
#include "plugin_presets_ui.h"
|
||||
#include "plugin_display.h"
|
||||
#include "gui_thread.h"
|
||||
#include "automation_controller.h"
|
||||
@ -412,7 +413,20 @@ GenericPluginUI::build ()
|
||||
plugin->announce_property_values();
|
||||
}
|
||||
|
||||
if (grid) {
|
||||
if (control_uis.empty ()) {
|
||||
std::vector<Plugin::PresetRecord> presets = insert->plugin()->get_presets();
|
||||
bool show_preset_browser = false;
|
||||
for (std::vector<Plugin::PresetRecord>::const_iterator i = presets.begin(); i != presets.end(); ++i) {
|
||||
if (i->valid && !i->description.empty()) {
|
||||
show_preset_browser = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (show_preset_browser) {
|
||||
preset_gui = new PluginPresetsUI (insert);
|
||||
hpacker.pack_start (*preset_gui, true, true);
|
||||
}
|
||||
} else if (grid) {
|
||||
custom_layout (control_uis);
|
||||
} else {
|
||||
automatic_layout (control_uis);
|
||||
|
164
gtk2_ardour/plugin_presets_ui.cc
Normal file
164
gtk2_ardour/plugin_presets_ui.cc
Normal file
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Robin Gareus <robin@gareus.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "gtkmm2ext/utils.h"
|
||||
|
||||
#include "ardour/plugin.h"
|
||||
#include "gui_thread.h"
|
||||
|
||||
#include "plugin_presets_ui.h"
|
||||
|
||||
#include "pbd/i18n.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
|
||||
PluginPresetsUI::PluginPresetsUI (boost::shared_ptr<PluginInsert> insert)
|
||||
: _insert (insert)
|
||||
, _load_button (_("Load"))
|
||||
{
|
||||
_plugin_preset_model = Gtk::TreeStore::create (_plugin_preset_columns);
|
||||
_plugin_preset_display.set_model (_plugin_preset_model);
|
||||
_plugin_preset_display.set_headers_visible (true);
|
||||
_plugin_preset_display.get_selection ()->set_mode (Gtk::SELECTION_SINGLE);
|
||||
_plugin_preset_display.get_selection ()->signal_changed ().connect (sigc::mem_fun (*this, &PluginPresetsUI::preset_selected));
|
||||
_plugin_preset_display.set_sensitive (true);
|
||||
|
||||
Gtk::CellRendererText* label_render = Gtk::manage (new Gtk::CellRendererText());
|
||||
Gtk::TreeView::Column* label_col = Gtk::manage (new Gtk::TreeView::Column (_("Preset"), *label_render));
|
||||
label_col->add_attribute (label_render->property_markup(), _plugin_preset_columns.name);
|
||||
_plugin_preset_display.append_column (*label_col);
|
||||
|
||||
_preset_desc.set_editable (false);
|
||||
_preset_desc.set_can_focus (false);
|
||||
_preset_desc.set_wrap_mode (Gtk::WRAP_WORD);
|
||||
_preset_desc.set_size_request (400,200);
|
||||
_preset_desc.set_name (X_("TextOnBackground"));
|
||||
_preset_desc.set_border_width (6);
|
||||
|
||||
_preset_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
|
||||
_preset_scroller.add (_plugin_preset_display);
|
||||
|
||||
_load_button.set_name ("generic button");
|
||||
_load_button.signal_clicked.connect (sigc::mem_fun (*this, &PluginPresetsUI::load_preset));
|
||||
_load_button.set_sensitive (false);
|
||||
|
||||
attach (_preset_scroller, 0, 1, 0, 2, Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 2, 0);
|
||||
attach (_preset_desc, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 2, 0);
|
||||
attach (_load_button, 1, 2, 1, 2, Gtk::FILL, Gtk::SHRINK, 2, 0);
|
||||
|
||||
boost::shared_ptr<Plugin> plugin (_insert->plugin ());
|
||||
|
||||
plugin->PresetAdded.connect (_preset_connections, invalidator (*this), boost::bind (&PluginPresetsUI::update_preset_list, this), gui_context ());
|
||||
plugin->PresetRemoved.connect (_preset_connections, invalidator (*this), boost::bind (&PluginPresetsUI::update_preset_list, this), gui_context ());
|
||||
plugin->PresetLoaded.connect (_preset_connections, invalidator (*this), boost::bind (&PluginPresetsUI::update_preset_list, this), gui_context ());
|
||||
|
||||
update_preset_list ();
|
||||
}
|
||||
|
||||
void
|
||||
PluginPresetsUI::update_preset_list ()
|
||||
{
|
||||
boost::shared_ptr<Plugin> plugin (_insert->plugin ());
|
||||
|
||||
Plugin::PresetRecord const& p = plugin->last_preset ();
|
||||
std::vector<Plugin::PresetRecord> presets = plugin->get_presets ();
|
||||
|
||||
|
||||
std::string selected_uri;
|
||||
if (_plugin_preset_display.get_selection ()->count_selected_rows () == 1) {
|
||||
Gtk::TreeIter iter = _plugin_preset_display.get_selection ()->get_selected ();
|
||||
ARDOUR::Plugin::PresetRecord const& ppr ((*iter)[_plugin_preset_columns.plugin_preset]);
|
||||
selected_uri = ppr.uri;
|
||||
}
|
||||
|
||||
_plugin_preset_model->clear ();
|
||||
|
||||
bool found_active = false;
|
||||
|
||||
for (std::vector<Plugin::PresetRecord>::const_iterator i = presets.begin (); i != presets.end (); ++i) {
|
||||
Gtk::TreeModel::Row row = *(_plugin_preset_model->append ());
|
||||
if (p.uri == i->uri) {
|
||||
row[_plugin_preset_columns.name] = string_compose ("<span weight=\"bold\" background=\"green\">%1</span>", i->label);
|
||||
found_active = true;
|
||||
} else {
|
||||
row[_plugin_preset_columns.name] = i->label;
|
||||
}
|
||||
row[_plugin_preset_columns.description] = i->description;
|
||||
row[_plugin_preset_columns.plugin_preset] = *i;
|
||||
}
|
||||
|
||||
{
|
||||
Gtk::TreeModel::Row row = *(_plugin_preset_model->prepend ());
|
||||
if (found_active) {
|
||||
row[_plugin_preset_columns.name] = _("(none)");
|
||||
} else {
|
||||
row[_plugin_preset_columns.name] = string_compose ("<span weight=\"bold\" background=\"green\">%1</span>", _("(none)"));
|
||||
}
|
||||
row[_plugin_preset_columns.description] = "";
|
||||
row[_plugin_preset_columns.plugin_preset] = Plugin::PresetRecord ();
|
||||
}
|
||||
|
||||
Gtk::TreeModel::Children rows = _plugin_preset_model->children ();
|
||||
for (Gtk::TreeModel::Children::iterator i = rows.begin (); i != rows.end (); ++i) {
|
||||
ARDOUR::Plugin::PresetRecord const& ppr ((*i)[_plugin_preset_columns.plugin_preset]);
|
||||
if (ppr.uri == selected_uri) {
|
||||
_plugin_preset_display.get_selection ()->select (*i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
PluginPresetsUI::preset_selected ()
|
||||
{
|
||||
if (_plugin_preset_display.get_selection ()->count_selected_rows () != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gtk::TreeIter iter = _plugin_preset_display.get_selection ()->get_selected ();
|
||||
assert (iter);
|
||||
ARDOUR::Plugin::PresetRecord const& ppr ((*iter)[_plugin_preset_columns.plugin_preset]);
|
||||
|
||||
std::string d;
|
||||
if (!ppr.valid) {
|
||||
d = "-";
|
||||
} else if (ppr.user) {
|
||||
d = _("(user preset)");
|
||||
} else {
|
||||
d = (*iter)[_plugin_preset_columns.description];
|
||||
}
|
||||
_preset_desc.get_buffer ()->set_text (Gtkmm2ext::markup_escape_text (d));
|
||||
|
||||
Plugin::PresetRecord const& p = _insert->plugin ()->last_preset ();
|
||||
_load_button.set_sensitive (ppr.valid && !(p.valid && p.uri == ppr.uri));
|
||||
}
|
||||
|
||||
void
|
||||
PluginPresetsUI::load_preset ()
|
||||
{
|
||||
if (_plugin_preset_display.get_selection ()->count_selected_rows () != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gtk::TreeIter iter = _plugin_preset_display.get_selection ()->get_selected ();
|
||||
ARDOUR::Plugin::PresetRecord const& ppr ((*iter)[_plugin_preset_columns.plugin_preset]);
|
||||
if (ppr.valid) {
|
||||
_insert->load_preset (ppr);
|
||||
}
|
||||
}
|
69
gtk2_ardour/plugin_presets_ui.h
Normal file
69
gtk2_ardour/plugin_presets_ui.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Robin Gareus <robin@gareus.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _gtkardour_plugin_presets_ui_h_
|
||||
#define _gtkardour_plugin_presets_ui_h_
|
||||
|
||||
#include <gtkmm/label.h>
|
||||
#include <gtkmm/liststore.h>
|
||||
#include <gtkmm/scrolledwindow.h>
|
||||
#include <gtkmm/table.h>
|
||||
#include <gtkmm/textview.h>
|
||||
#include <gtkmm/treemodel.h>
|
||||
#include <gtkmm/treestore.h>
|
||||
#include <gtkmm/treeview.h>
|
||||
|
||||
#include "widgets/ardour_button.h"
|
||||
|
||||
#include "ardour/plugin_insert.h"
|
||||
|
||||
class PluginPresetsUI : public Gtk::Table
|
||||
{
|
||||
public:
|
||||
PluginPresetsUI (boost::shared_ptr<ARDOUR::PluginInsert>);
|
||||
|
||||
private:
|
||||
void update_preset_list ();
|
||||
void preset_selected ();
|
||||
void load_preset ();
|
||||
|
||||
boost::shared_ptr<ARDOUR::PluginInsert> _insert;
|
||||
PBD::ScopedConnectionList _preset_connections;
|
||||
|
||||
struct PluginPresetModelColumns : public Gtk::TreeModel::ColumnRecord {
|
||||
PluginPresetModelColumns () {
|
||||
add (name);
|
||||
add (description);
|
||||
add (plugin_preset);
|
||||
}
|
||||
|
||||
Gtk::TreeModelColumn<std::string> name;
|
||||
Gtk::TreeModelColumn<std::string> description;
|
||||
Gtk::TreeModelColumn<ARDOUR::Plugin::PresetRecord> plugin_preset;
|
||||
};
|
||||
|
||||
ArdourWidgets::ArdourButton _load_button;
|
||||
|
||||
PluginPresetModelColumns _plugin_preset_columns;
|
||||
Gtk::TreeView _plugin_preset_display;
|
||||
Glib::RefPtr<Gtk::TreeStore> _plugin_preset_model;
|
||||
Gtk::ScrolledWindow _preset_scroller;
|
||||
Gtk::TextView _preset_desc;
|
||||
};
|
||||
|
||||
#endif
|
@ -72,6 +72,7 @@
|
||||
#include "latency_gui.h"
|
||||
#include "plugin_dspload_ui.h"
|
||||
#include "plugin_eq_gui.h"
|
||||
#include "plugin_presets_ui.h"
|
||||
#include "timers.h"
|
||||
#include "new_plugin_preset_dialog.h"
|
||||
|
||||
@ -468,6 +469,7 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
|
||||
, latency_dialog (0)
|
||||
, eqgui (0)
|
||||
, stats_gui (0)
|
||||
, preset_gui (0)
|
||||
{
|
||||
_preset_modified.set_size_request (16, -1);
|
||||
_preset_combo.set_text("(default)");
|
||||
@ -544,6 +546,7 @@ PlugUIBase::~PlugUIBase()
|
||||
{
|
||||
delete eqgui;
|
||||
delete stats_gui;
|
||||
delete preset_gui;
|
||||
delete latency_gui;
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,7 @@ class LatencyGUI;
|
||||
class ArdourWindow;
|
||||
class PluginEqGui;
|
||||
class PluginLoadStatsGui;
|
||||
class PluginPresetsUI;
|
||||
class VSTPluginUI;
|
||||
|
||||
class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionList
|
||||
@ -159,6 +160,7 @@ protected:
|
||||
|
||||
PluginEqGui* eqgui;
|
||||
PluginLoadStatsGui* stats_gui;
|
||||
PluginPresetsUI* preset_gui;
|
||||
|
||||
Gtk::Image* focus_out_image;
|
||||
Gtk::Image* focus_in_image;
|
||||
|
@ -186,6 +186,7 @@ gtk2_ardour_sources = [
|
||||
'plugin_display.cc',
|
||||
'plugin_eq_gui.cc',
|
||||
'plugin_pin_dialog.cc',
|
||||
'plugin_presets_ui.cc',
|
||||
'plugin_setup_dialog.cc',
|
||||
'plugin_selector.cc',
|
||||
'plugin_ui.cc',
|
||||
|
Loading…
Reference in New Issue
Block a user