Plugin selector keyboard focus should now stay in the plugin list. More
authorSampo Savolainen <v2@iki.fi>
Thu, 10 Aug 2006 14:41:53 +0000 (14:41 +0000)
committerSampo Savolainen <v2@iki.fi>
Thu, 10 Aug 2006 14:41:53 +0000 (14:41 +0000)
sensible defaults for the NSD and accelerators will work in plugin
windows (plus keyboard will not affect the plugin window itself).

git-svn-id: svn://localhost/ardour2/trunk@783 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/new_session_dialog.cc
gtk2_ardour/plugin_selector.cc
gtk2_ardour/plugin_selector.h
gtk2_ardour/plugin_ui.cc
gtk2_ardour/plugin_ui.h
gtk2_ardour/public_editor.h

index 47a2b2b6d3d9960054b952d1ce23072dd7e9f93f..993db62d59bd2940da001a668f3991d90d850d6d 100644 (file)
@@ -141,15 +141,17 @@ NewSessionDialog::NewSessionDialog()
        advanced_table->attach(*m_control_bus_channel_count, 1, 2, 2, 3, Gtk::AttachOptions(), Gtk::AttachOptions(), 0, 0);
        advanced_table->attach(*m_master_bus_channel_count, 1, 2, 1, 2, Gtk::AttachOptions(), Gtk::AttachOptions(), 0, 0);
        advanced_table->attach(*m_create_master_bus, 0, 1, 1, 2, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
+
        m_connect_inputs->set_flags(Gtk::CAN_FOCUS);
        m_connect_inputs->set_relief(Gtk::RELIEF_NORMAL);
        m_connect_inputs->set_mode(true);
-       m_connect_inputs->set_active(false);
+       m_connect_inputs->set_active(true);
        m_connect_inputs->set_border_width(0);
+
        m_limit_input_ports->set_flags(Gtk::CAN_FOCUS);
        m_limit_input_ports->set_relief(Gtk::RELIEF_NORMAL);
        m_limit_input_ports->set_mode(true);
-       m_limit_input_ports->set_sensitive(false);
+       m_limit_input_ports->set_sensitive(true);
        m_limit_input_ports->set_border_width(0);
        m_input_limit_count->set_flags(Gtk::CAN_FOCUS);
        m_input_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS);
@@ -157,6 +159,7 @@ NewSessionDialog::NewSessionDialog()
        m_input_limit_count->set_digits(0);
        m_input_limit_count->set_wrap(false);
        m_input_limit_count->set_sensitive(false);
+
        input_port_limit_hbox->pack_start(*m_limit_input_ports, Gtk::PACK_SHRINK, 6);
        input_port_limit_hbox->pack_start(*m_input_limit_count, Gtk::PACK_EXPAND_PADDING, 0);
        input_port_vbox->pack_start(*m_connect_inputs, Gtk::PACK_SHRINK, 0);
@@ -177,12 +180,12 @@ NewSessionDialog::NewSessionDialog()
        m_connect_outputs->set_flags(Gtk::CAN_FOCUS);
        m_connect_outputs->set_relief(Gtk::RELIEF_NORMAL);
        m_connect_outputs->set_mode(true);
-       m_connect_outputs->set_active(false);
+       m_connect_outputs->set_active(true);
        m_connect_outputs->set_border_width(0);
        m_limit_output_ports->set_flags(Gtk::CAN_FOCUS);
        m_limit_output_ports->set_relief(Gtk::RELIEF_NORMAL);
        m_limit_output_ports->set_mode(true);
-       m_limit_output_ports->set_sensitive(false);
+       m_limit_output_ports->set_sensitive(true);
        m_limit_output_ports->set_border_width(0);
        m_output_limit_count->set_flags(Gtk::CAN_FOCUS);
        m_output_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS);
@@ -597,12 +600,24 @@ void
 NewSessionDialog::connect_inputs_clicked ()
 {
         m_limit_input_ports->set_sensitive(m_connect_inputs->get_active());
+
+               if (m_connect_inputs->get_active() && m_limit_input_ports->get_active()) {
+               m_input_limit_count->set_sensitive(true);
+               } else {
+               m_input_limit_count->set_sensitive(false);
+               }
 }
 
 void
 NewSessionDialog::connect_outputs_clicked ()
 {
         m_limit_output_ports->set_sensitive(m_connect_outputs->get_active());
+
+               if (m_connect_outputs->get_active() && m_limit_output_ports->get_active()) {
+               m_output_limit_count->set_sensitive(true);
+               } else {
+               m_output_limit_count->set_sensitive(false);
+               }
 }
 
 void
index 20db1b394478d0944e916352524d439432fbf602..2ebaaae100572efd0ed2ccd54e8b77993e0531a8 100644 (file)
@@ -141,6 +141,7 @@ PluginSelector::PluginSelector (PluginManager *mgr)
        set_response_sensitive (RESPONSE_APPLY, false);
        get_vbox()->pack_start (*table);
 
+       // Notebook tab order must be the same in here as in set_correct_focus()
        using namespace Gtk::Notebook_Helpers;
        notebook.pages().push_back (TabElem (lscroller, _("LADSPA")));
 
@@ -161,6 +162,7 @@ PluginSelector::PluginSelector (PluginManager *mgr)
 
        ladspa_display.signal_button_press_event().connect_notify (mem_fun(*this, &PluginSelector::row_clicked));
        ladspa_display.get_selection()->signal_changed().connect (mem_fun(*this, &PluginSelector::ladspa_display_selection_changed));
+       ladspa_display.grab_focus();
        
 #ifdef VST_SUPPORT
        if (Config->get_use_vst()) {
@@ -188,6 +190,43 @@ PluginSelector::PluginSelector (PluginManager *mgr)
 #ifdef HAVE_COREAUDIO
        au_refiller ();
 #endif
+
+       signal_show().connect (mem_fun (*this, &PluginSelector::set_correct_focus));
+}
+
+/**
+ * Makes sure keyboard focus is always in the plugin list
+ * of the selected notebook tab.
+ **/
+void
+PluginSelector::set_correct_focus()
+{
+       int cp = notebook.get_current_page();
+
+       if (cp == 0) {
+               ladspa_display.grab_focus();
+               return;
+       }
+
+#ifdef VST_SUPPORT
+       if (Config->get_use_vst()) {
+               cp--;
+       
+               if (cp == 0) {
+                       vst_display.grab_focus();
+                       return;
+               }
+       }
+#endif
+
+#ifdef HAVE_COREAUDIO
+       cp--;
+
+       if (cp == 0) {
+               au_display.grab_focus();
+               return;
+       }
+#endif;
 }
 
 void
index 654088e3d85416a0f7ea911835c3c41cb4d2f44c..d71203131c3a7bb647cb6d9d3491b45c8e0b5fa2 100644 (file)
@@ -147,6 +147,8 @@ class PluginSelector : public ArdourDialog
        void btn_apply_clicked();
        void use_plugin (ARDOUR::PluginInfoPtr);
        void cleanup ();
+
+       void set_correct_focus();
 };
 
 #endif // __ardour_plugin_selector_h__
index 350240cb1e40079857e9598b88dcb15826a0334b..f9db649737b9f931a954b33f5f6cc569bbaea14f 100644 (file)
@@ -27,6 +27,7 @@
 #include <pbd/xml++.h>
 #include <pbd/failed_constructor.h>
 
+#include <gtkmm/widget.h>
 #include <gtkmm2ext/click_box.h>
 #include <gtkmm2ext/fastmeter.h>
 #include <gtkmm2ext/barcontroller.h>
@@ -51,6 +52,7 @@
 #include "plugin_ui.h"
 #include "utils.h"
 #include "gui_thread.h"
+#include "public_editor.h"
 
 #include "i18n.h"
 
@@ -111,11 +113,23 @@ PluginUIWindow::PluginUIWindow (AudioEngine &engine, boost::shared_ptr<PluginIns
                if (h > 600) h = 600;
                set_default_size (450, h); 
        }
+
 }
 
 PluginUIWindow::~PluginUIWindow ()
 {
 }
+bool
+PluginUIWindow::on_key_press_event (GdkEventKey* event)
+{
+       return PublicEditor::instance().on_key_press_event(event);
+}
+
+bool
+PluginUIWindow::on_key_release_event (GdkEventKey* event)
+{
+       return PublicEditor::instance().on_key_release_event(event);
+}
 
 void
 PluginUIWindow::plugin_going_away (ARDOUR::Redirect* ignored)
index 5b1fd89178972c36546f7c22de2803d96b1a7208..acd22294dd42cd34435e44bbb8047952de2ed90d 100644 (file)
@@ -203,6 +203,9 @@ class PluginUIWindow : public ArdourDialog
        PlugUIBase& pluginui() { return *_pluginui; }
 
        void resize_preferred();
+
+       virtual bool on_key_press_event (GdkEventKey*);
+       virtual bool on_key_release_event (GdkEventKey*);
        
   private:
        PlugUIBase* _pluginui;
index f70e4c20bd5ee163f2bbf7ea2ccfe581d21194bc..f85210327c38860687b6326a155a7959a66e7cfb 100644 (file)
@@ -31,6 +31,7 @@ namespace Gtk {
 class Editor;
 class TimeAxisViewItem;
 class TimeAxisView;
+class PluginUIWindow;
 class PluginSelector;
 class PlaylistSelector;
 class XMLNode;
@@ -171,6 +172,8 @@ class PublicEditor : public Gtk::Window, public Stateful {
        virtual bool canvas_markerview_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*) = 0;
 
        static PublicEditor* _instance;
+
+       friend class PluginUIWindow;
 };
 
 #endif // __gtk_ardour_public_editor_h__