From ea41f0f37b709f6d5e0b8fe66dd1335f9a8a0b2f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 12 Feb 2008 19:58:11 +0000 Subject: [PATCH] tidy up AU GUIs, make bypass button work and add preset/automation placeholders git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3043 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/au_pluginui.h | 12 +++++++++ gtk2_ardour/au_pluginui.mm | 47 ++++++++++++++++++++++++--------- gtk2_ardour/generic_pluginui.cc | 2 +- gtk2_ardour/plugin_ui.cc | 31 ++++++++++++++-------- gtk2_ardour/plugin_ui.h | 3 ++- 5 files changed, 70 insertions(+), 25 deletions(-) diff --git a/gtk2_ardour/au_pluginui.h b/gtk2_ardour/au_pluginui.h index a1ee63be77..93a446b7a2 100644 --- a/gtk2_ardour/au_pluginui.h +++ b/gtk2_ardour/au_pluginui.h @@ -1,6 +1,9 @@ #ifndef __gtk2_ardour_auplugin_ui_h__ #define __gtk2_ardour_auplugin_ui_h__ +#include +#include + #include #include #include @@ -13,6 +16,10 @@ #undef verify #include +#include +#include +#include + #include "plugin_ui.h" namespace ARDOUR { @@ -53,6 +60,11 @@ class AUPluginUI : public PlugUIBase, public Gtk::VBox Gtk::HBox top_box; Gtk::EventBox low_box; Gtk::VBox vpacker; + Gtk::Label automation_mode_label; + Gtk::ComboBoxText automation_mode_selector; + Gtk::Label preset_label; + + static std::vector automation_mode_strings; /* Cocoa */ diff --git a/gtk2_ardour/au_pluginui.mm b/gtk2_ardour/au_pluginui.mm index 988701a925..ba54a75ccd 100644 --- a/gtk2_ardour/au_pluginui.mm +++ b/gtk2_ardour/au_pluginui.mm @@ -7,6 +7,8 @@ #include #include +#include + #include "au_pluginui.h" #include "gui_thread.h" @@ -20,16 +22,34 @@ using namespace ARDOUR; using namespace Gtk; +using namespace Gtkmm2ext; using namespace sigc; using namespace std; using namespace PBD; -static const float kOffsetForAUView_X = 220; -static const float kOffsetForAUView_Y = 90; +vector AUPluginUI::automation_mode_strings; + +static const gchar* _automation_mode_strings[] = { + X_("Manual"), + X_("Play"), + X_("Write"), + X_("Touch"), + 0 +}; AUPluginUI::AUPluginUI (boost::shared_ptr insert) : PlugUIBase (insert) + , automation_mode_label (_("Automation")) + , preset_label (_("Presets")) + { + if (automation_mode_strings.empty()) { + automation_mode_strings = I18N (_automation_mode_strings); + } + + set_popdown_strings (automation_mode_selector, automation_mode_strings); + automation_mode_selector.set_active_text (automation_mode_strings.front()); + if ((au = boost::dynamic_pointer_cast (insert->plugin())) == 0) { error << _("unknown type of editor-supplying plugin (note: no AudioUnit support in this version of ardour)") << endmsg; throw failed_constructor (); @@ -37,20 +57,25 @@ AUPluginUI::AUPluginUI (boost::shared_ptr insert) /* stuff some stuff into the top of the window */ - Gtk::Button* button = manage (new Gtk::Button ("press me")); - Gtk::Label* label = manage (new Gtk::Label ("hello, world!")); - top_box.set_spacing (6); top_box.set_border_width (6); - top_box.pack_start (*button, false, false); - top_box.pack_start (*label, false, true); + + top_box.pack_end (bypass_button, false, true); + top_box.pack_end (automation_mode_selector, false, false); + top_box.pack_end (automation_mode_label, false, false); + top_box.pack_end (save_button, false, false); + top_box.pack_end (preset_combo, false, false); + top_box.pack_end (preset_label, false, false); set_spacing (6); pack_start (top_box, false, false); pack_start (low_box, false, false); - button->show (); - label->show (); + preset_label.show (); + preset_combo.show (); + automation_mode_label.show (); + automation_mode_selector.show (); + bypass_button.show (); top_box.show (); low_box.show (); @@ -350,7 +375,6 @@ AUPluginUI::carbon_event (EventHandlerCallRef nextHandlerRef, EventRef event) UInt32 eventKind = GetEventKind(event); ClickActivationResult howToHandleClick; - Gtk::Container* toplevel = get_toplevel(); NSWindow* win = get_nswindow (); cerr << "window " << win << " carbon event type " << eventKind << endl; @@ -389,8 +413,6 @@ AUPluginUI::parent_carbon_window () { NSWindow* win = get_nswindow (); int x, y; - int tbx, tby; - if (!win) { return -1; @@ -602,3 +624,4 @@ AUPluginUI::on_focus_out_event (GdkEventFocus* ev) cerr << "au plugin focus out\n"; return false; } + diff --git a/gtk2_ardour/generic_pluginui.cc b/gtk2_ardour/generic_pluginui.cc index 6af95eda6d..dfff196a5f 100644 --- a/gtk2_ardour/generic_pluginui.cc +++ b/gtk2_ardour/generic_pluginui.cc @@ -81,7 +81,7 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr pi, bool scrol combo_label->set_use_markup (true); smaller_hbox->pack_start (*combo_label, false, false, 10); - smaller_hbox->pack_start (combo, false, false); + smaller_hbox->pack_start (preset_combo, false, false); smaller_hbox->pack_start (save_button, false, false); constraint_hbox->set_spacing (5); diff --git a/gtk2_ardour/plugin_ui.cc b/gtk2_ardour/plugin_ui.cc index 4a74b39f0d..932c952af1 100644 --- a/gtk2_ardour/plugin_ui.cc +++ b/gtk2_ardour/plugin_ui.cc @@ -245,28 +245,37 @@ PlugUIBase::PlugUIBase (boost::shared_ptr pi) save_button(_("Add")), bypass_button (_("Bypass")) { - //combo.set_use_arrows_always(true); - set_popdown_strings (combo, plugin->get_presets()); - combo.set_size_request (100, -1); - combo.set_active_text (""); - combo.signal_changed().connect(mem_fun(*this, &PlugUIBase::setting_selected)); + //preset_combo.set_use_arrows_always(true); + set_popdown_strings (preset_combo, plugin->get_presets()); + preset_combo.set_size_request (100, -1); + preset_combo.set_active_text (""); + preset_combo.signal_changed().connect(mem_fun(*this, &PlugUIBase::setting_selected)); save_button.set_name ("PluginSaveButton"); save_button.signal_clicked().connect(mem_fun(*this, &PlugUIBase::save_plugin_setting)); + insert->active_changed.connect (mem_fun(*this, &PlugUIBase::redirect_active_changed)); + bypass_button.set_active (!pi->active()); + bypass_button.set_name ("PluginBypassButton"); bypass_button.signal_toggled().connect (mem_fun(*this, &PlugUIBase::bypass_toggled)); } +void +PlugUIBase::redirect_active_changed (Redirect* r, void* src) +{ + ENSURE_GUI_THREAD(bind (mem_fun(*this, &PlugUIBase::redirect_active_changed), r, src)); + bypass_button.set_active (!r->active()); +} + void PlugUIBase::setting_selected() { - if (combo.get_active_text().length() > 0) { - if (!plugin->load_preset(combo.get_active_text())) { - warning << string_compose(_("Plugin preset %1 not found"), combo.get_active_text()) << endmsg; + if (preset_combo.get_active_text().length() > 0) { + if (!plugin->load_preset(preset_combo.get_active_text())) { + warning << string_compose(_("Plugin preset %1 not found"), preset_combo.get_active_text()) << endmsg; } } - } void @@ -288,8 +297,8 @@ PlugUIBase::save_plugin_setting () if (name.length()) { if(plugin->save_preset(name)){ - set_popdown_strings (combo, plugin->get_presets()); - combo.set_active_text (name); + set_popdown_strings (preset_combo, plugin->get_presets()); + preset_combo.set_active_text (name); } } break; diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index 0486109f4c..ff90ce783d 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -80,13 +80,14 @@ class PlugUIBase : public virtual sigc::trackable protected: boost::shared_ptr insert; boost::shared_ptr plugin; - Gtk::ComboBoxText combo; + Gtk::ComboBoxText preset_combo; Gtk::Button save_button; Gtk::ToggleButton bypass_button; void setting_selected(); void save_plugin_setting (void); void bypass_toggled(); + void redirect_active_changed (ARDOUR::Redirect* r, void* src); }; class GenericPluginUI : public PlugUIBase, public Gtk::VBox