step 2 of keyboard focus work for plugin windows

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4026 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2008-10-29 07:35:40 +00:00
parent 01c2be0bab
commit deeef0a263
12 changed files with 101 additions and 5 deletions

View file

@ -1307,6 +1307,21 @@ if not conf.CheckFunc('posix_memalign'):
env = conf.Finish()
# Which GTK tooltips API
gtktestenv = env.Clone ()
gtktestenv.Merge ([
libraries['gtk2']
])
conf = gtktestenv.Configure ()
if conf.CheckFunc('gtk_widget_set_tooltip_text'):
env.Append (CXXFLAGS='-DGTK_NEW_TOOLTIP_API')
conf.Finish ()
# generate the per-user and system rc files from the same source
sysrcbuild = env.SubstInFile ('ardour_system.rc','ardour.rc.in', SUBST_DICT = subst_dict)

View file

@ -1476,6 +1476,8 @@ widget "*HWMonitorButton" style:highest "red_when_active"
widget "*HWMonitorButton*" style:highest "red_when_active"
widget "*BypassButton" style:highest "red_when_active"
widget "*BypassButton*" style:highest "red_when_active"
widget "*FocusButton" style:highest "red_when_active"
widget "*FocusButton*" style:highest "red_when_active"
widget "*TransportSoloAlert" style:highest "flashing_alert"
widget "*TransportSoloAlert.*" style:highest "flashing_alert"
widget "*TransportAuditioningAlert" style:highest "flashing_alert"

View file

@ -1479,6 +1479,8 @@ widget "*HWMonitorButton" style:highest "red_when_active"
widget "*HWMonitorButton*" style:highest "red_when_active"
widget "*BypassButton" style:highest "red_when_active"
widget "*BypassButton*" style:highest "red_when_active"
widget "*FocusButton" style:highest "red_when_active"
widget "*FocusButton*" style:highest "red_when_active"
widget "*TransportSoloAlert" style:highest "flashing_alert"
widget "*TransportSoloAlert.*" style:highest "flashing_alert"
widget "*TransportAuditioningAlert" style:highest "flashing_alert"

View file

@ -67,6 +67,7 @@ AUPluginUI::AUPluginUI (boost::shared_ptr<PluginInsert> insert)
top_box.set_spacing (6);
top_box.set_border_width (6);
top_box.pack_end (focus_button, 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);
@ -624,16 +625,16 @@ create_au_gui (boost::shared_ptr<PluginInsert> plugin_insert, VBox** box)
bool
AUPluginUI::on_focus_in_event (GdkEventFocus* ev)
{
cerr << "au plugin focus in\n";
Keyboard::magic_widget_grab_focus ();
//cerr << "au plugin focus in\n";
//Keyboard::magic_widget_grab_focus ();
return false;
}
bool
AUPluginUI::on_focus_out_event (GdkEventFocus* ev)
{
cerr << "au plugin focus out\n";
Keyboard::magic_widget_drop_focus ();
//cerr << "au plugin focus out\n";
//Keyboard::magic_widget_drop_focus ();
return false;
}

View file

@ -86,6 +86,7 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr<PluginInsert> pi, bool scrol
constraint_hbox->set_spacing (5);
constraint_hbox->pack_start (*smaller_hbox, true, false);
constraint_hbox->pack_end (focus_button, false, false);
constraint_hbox->pack_end (bypass_button, false, false);
settings_box.pack_end (*constraint_hbox, false, false);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -89,12 +89,14 @@ void
Keyboard::magic_widget_grab_focus ()
{
_some_magic_widget_has_focus = true;
cerr << "Grabbed magic widget docus\n";
}
void
Keyboard::magic_widget_drop_focus ()
{
_some_magic_widget_has_focus = false;
cerr << "Dropped magic widget docus\n";
}
bool

View file

@ -170,6 +170,22 @@ PluginUIWindow::on_leave_notify_event (GdkEventCrossing *ev)
return false;
}
bool
PluginUIWindow::on_focus_in_event (GdkEventFocus *ev)
{
Window::on_focus_in_event (ev);
//Keyboard::the_keyboard().magic_widget_grab_focus ();
return false;
}
bool
PluginUIWindow::on_focus_out_event (GdkEventFocus *ev)
{
Window::on_focus_out_event (ev);
//Keyboard::the_keyboard().magic_widget_drop_focus ();
return false;
}
void
PluginUIWindow::on_show ()
{
@ -330,6 +346,17 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
bypass_button.set_name ("PluginBypassButton");
bypass_button.signal_toggled().connect (mem_fun(*this, &PlugUIBase::bypass_toggled));
focus_button.signal_button_release_event().connect (mem_fun(*this, &PlugUIBase::focus_toggled));
focus_button.add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
/* these images are not managed, so that we can remove them at will */
focus_out_image = new Image (get_icon (X_("computer_keyboard")));
focus_in_image = new Image (get_icon (X_("computer_keyboard_active")));
focus_button.add (*focus_out_image);
ARDOUR_UI::instance()->set_tip (&focus_button, _("Click to focus all keyboard events on this plugin window"), "");
}
void
@ -391,6 +418,26 @@ PlugUIBase::bypass_toggled ()
}
}
bool
PlugUIBase::focus_toggled (GdkEventButton* ev)
{
if (Keyboard::the_keyboard().some_magic_widget_has_focus()) {
Keyboard::the_keyboard().magic_widget_drop_focus();
focus_button.remove ();
focus_button.add (*focus_out_image);
focus_out_image->show ();
ARDOUR_UI::instance()->set_tip (&focus_button, _("Click to focus all keyboard events on this plugin window"), "");
} else {
Keyboard::the_keyboard().magic_widget_grab_focus();
focus_button.remove ();
focus_button.add (*focus_in_image);
focus_in_image->show ();
ARDOUR_UI::instance()->set_tip (&focus_button, _("Click to remove keyboard focus from this plugin window"), "");
}
return true;
}
void
PlugUIBase::update_presets ()
{

View file

@ -34,6 +34,7 @@
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/label.h>
#include <gtkmm/menu.h>
#include <gtkmm/image.h>
#include <gtkmm/adjustment.h>
#include <gtkmm/togglebutton.h>
#include <gtkmm/socket.h>
@ -85,10 +86,15 @@ class PlugUIBase : public virtual sigc::trackable
Gtk::ComboBoxText preset_combo;
Gtk::Button save_button;
Gtk::ToggleButton bypass_button;
Gtk::EventBox focus_button;
Gtk::Image* focus_out_image;
Gtk::Image* focus_in_image;
void setting_selected();
void save_plugin_setting (void);
void bypass_toggled();
bool focus_toggled(GdkEventButton*);
void redirect_active_changed (ARDOUR::Redirect* r, void* src);
};
@ -212,6 +218,8 @@ class PluginUIWindow : public Gtk::Window
bool on_enter_notify_event (GdkEventCrossing*);
bool on_leave_notify_event (GdkEventCrossing*);
bool on_focus_in_event (GdkEventFocus*);
bool on_focus_out_event (GdkEventFocus*);
bool on_key_press_event (GdkEventKey*);
bool on_key_release_event (GdkEventKey*);
void on_show ();

View file

@ -65,6 +65,9 @@ UI::UI (string namestr, int *argc, char ***argv)
: AbstractUI<UIRequest> (namestr, true)
{
theMain = new Main (argc, argv);
#ifndef GTK_NEW_TOOLTIP_API
tips = new Tooltips;
#endif
_active = false;
_auto_display_errors = true;
@ -372,7 +375,16 @@ UI::do_request (UIRequest* req)
} else if (req->type == SetTip) {
/* XXX need to figure out how this works */
#ifdef GTK_NEW_TOOLTIP_API
/* even if the installed GTK is up to date,
at present (November 2008) our included
version of gtkmm is not. so use the GTK
API that we've verified has the right function.
*/
gtk_widget_set_tooltip_text (req->widget->gobj(), req->msg);
#else
tips->set_tip (*req->widget, req->msg, "");
#endif
} else {

View file

@ -29,6 +29,9 @@
#include <pthread.h>
#include <gtkmm/widget.h>
#include <gtkmm/style.h>
#ifndef GTK_NEW_TOOLTIP_API
#include <gtkmm/tooltips.h>
#endif
#include <gtkmm/textbuffer.h>
#include <gtkmm/main.h>
#include <gdkmm/color.h>
@ -152,6 +155,9 @@ class UI : public Receiver, public AbstractUI<UIRequest>
static pthread_t gui_thread;
bool _active;
Gtk::Main *theMain;
#ifndef GTK_NEW_TOOLTIP_API
Gtk::Tooltips *tips;
#endif
TextViewer *errors;
Glib::RefPtr<Gtk::TextBuffer::Tag> error_ptag;
Glib::RefPtr<Gtk::TextBuffer::Tag> error_mtag;