tidy up AU GUIs, make bypass button work and add preset/automation placeholders
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 12 Feb 2008 19:58:11 +0000 (19:58 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 12 Feb 2008 19:58:11 +0000 (19:58 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3043 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/au_pluginui.h
gtk2_ardour/au_pluginui.mm
gtk2_ardour/generic_pluginui.cc
gtk2_ardour/plugin_ui.cc
gtk2_ardour/plugin_ui.h

index a1ee63be77a4a103863ba7d1f6ef7a19acf6d99a..93a446b7a2607a937bdeb2b3d12b0545db612f5f 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef __gtk2_ardour_auplugin_ui_h__
 #define __gtk2_ardour_auplugin_ui_h__
 
+#include <vector>
+#include <string>
+
 #include <AppKit/AppKit.h>
 #include <Carbon/Carbon.h>
 #include <AudioUnit/AudioUnitCarbonView.h>
 #undef verify
 
 #include <gtkmm/box.h>
+#include <gtkmm/combobox.h>
+#include <gtkmm/button.h>
+#include <gtkmm/label.h>
+
 #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<std::string> automation_mode_strings;
 
        /* Cocoa */
 
index 988701a92568f357cd4b2a78814421b5f008db7c..ba54a75ccd56d3c9b0671978be58ecce8e845e76 100644 (file)
@@ -7,6 +7,8 @@
 #include <gtkmm/button.h>
 #include <gdk/gdkquartz.h>
 
+#include <gtkmm2ext/utils.h>
+
 #include "au_pluginui.h"
 #include "gui_thread.h"
 
 
 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<string> AUPluginUI::automation_mode_strings;
+
+static const gchar* _automation_mode_strings[] = {
+       X_("Manual"),
+       X_("Play"),
+       X_("Write"),
+       X_("Touch"),
+       0
+};
 
 AUPluginUI::AUPluginUI (boost::shared_ptr<PluginInsert> 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<AUPlugin> (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<PluginInsert> 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;
 }
+
index 6af95eda6d8544276ce30cabef0539023cfb05d3..dfff196a5f2d285344836a56466c131451ac2483 100644 (file)
@@ -81,7 +81,7 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr<PluginInsert> 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);
index 4a74b39f0d393b3990fd144189ef44b5538085d6..932c952af1561d7ecb86e90bfa96ea7e93301c29 100644 (file)
@@ -245,28 +245,37 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> 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;
index 0486109f4cf25d4c987150663b4f97454a313059..ff90ce783d571d71733acab3a74eb4551ecd0d1c 100644 (file)
@@ -80,13 +80,14 @@ class PlugUIBase : public virtual sigc::trackable
   protected:
        boost::shared_ptr<ARDOUR::PluginInsert> insert;
        boost::shared_ptr<ARDOUR::Plugin> 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