move kbd focus reset method into ARDOUR_UI where it (probably) belongs
This commit is contained in:
parent
755010f254
commit
07bb5ff347
@ -5660,3 +5660,55 @@ ARDOUR_UI::cancel_solo ()
|
||||
_session->cancel_all_solo ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::reset_focus (Gtk::Widget* w)
|
||||
{
|
||||
/* this resets focus to the first focusable parent of the given widget,
|
||||
* or, if there is no focusable parent, cancels focus in the toplevel
|
||||
* window that the given widget is packed into (if there is one).
|
||||
*/
|
||||
|
||||
if (!w) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gtk::Widget* top = w->get_toplevel();
|
||||
|
||||
if (!top || !top->is_toplevel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
w = w->get_parent ();
|
||||
|
||||
while (w) {
|
||||
|
||||
if (w->is_toplevel()) {
|
||||
/* Setting the focus widget to a Gtk::Window causes all
|
||||
* subsequent calls to ::has_focus() on the nominal
|
||||
* focus widget in that window to return
|
||||
* false. Workaround: never set focus to the toplevel
|
||||
* itself.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
|
||||
if (w->get_can_focus ()) {
|
||||
Gtk::Window* win = dynamic_cast<Gtk::Window*> (top);
|
||||
win->set_focus (*w);
|
||||
return;
|
||||
}
|
||||
w = w->get_parent ();
|
||||
}
|
||||
|
||||
if (top == &_main_window) {
|
||||
|
||||
}
|
||||
|
||||
/* no focusable parent found, cancel focus in top level window.
|
||||
C++ API cannot be used for this. Thanks, references.
|
||||
*/
|
||||
|
||||
gtk_window_set_focus (GTK_WINDOW(top->gobj()), 0);
|
||||
|
||||
}
|
||||
|
@ -219,6 +219,8 @@ public:
|
||||
void toggle_monitor_section_visibility ();
|
||||
void toggle_keep_tearoffs();
|
||||
|
||||
void reset_focus (Gtk::Widget*);
|
||||
|
||||
static PublicEditor* _instance;
|
||||
|
||||
/** Emitted frequently with the audible frame, false, and the edit point as
|
||||
|
@ -1276,8 +1276,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||
|
||||
void naturalize_region ();
|
||||
|
||||
void reset_focus (Gtk::Widget*);
|
||||
|
||||
void split_region ();
|
||||
|
||||
void delete_ ();
|
||||
|
@ -1726,54 +1726,6 @@ Editor::parameter_changed (std::string p)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::reset_focus (Gtk::Widget* w)
|
||||
{
|
||||
/* this resets focus to the first focusable parent of the given widget,
|
||||
* or, if there is no focusable parent, cancels focus in the toplevel
|
||||
* window that the given widget is packed into (if there is one).
|
||||
*/
|
||||
|
||||
if (!w) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gtk::Widget* top = w->get_toplevel();
|
||||
|
||||
if (!top || !top->is_toplevel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
w = w->get_parent ();
|
||||
|
||||
while (w) {
|
||||
|
||||
if (w->is_toplevel()) {
|
||||
/* Setting the focus widget to a Gtk::Window causes all
|
||||
* subsequent calls to ::has_focus() on the nominal
|
||||
* focus widget in that window to return
|
||||
* false. Workaround: never set focus to the toplevel
|
||||
* itself.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
|
||||
if (w->get_can_focus ()) {
|
||||
Window* win = dynamic_cast<Window*> (top);
|
||||
win->set_focus (*w);
|
||||
return;
|
||||
}
|
||||
w = w->get_parent ();
|
||||
}
|
||||
|
||||
/* no focusable parent found, cancel focus in top level window.
|
||||
C++ API cannot be used for this. Thanks, references.
|
||||
*/
|
||||
|
||||
gtk_window_set_focus (GTK_WINDOW(top->gobj()), 0);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Editor::reset_canvas_action_sensitivity (bool onoff)
|
||||
{
|
||||
|
@ -325,8 +325,6 @@ class PublicEditor : public Gtkmm2ext::Tabbable {
|
||||
Glib::RefPtr<Gtk::ActionGroup> editor_menu_actions;
|
||||
Glib::RefPtr<Gtk::ActionGroup> _region_actions;
|
||||
|
||||
virtual void reset_focus (Gtk::Widget*) = 0;
|
||||
|
||||
virtual bool canvas_scroll_event (GdkEventScroll* event, bool from_canvas) = 0;
|
||||
virtual bool canvas_control_point_event (GdkEvent* event, ArdourCanvas::Item*, ControlPoint*) = 0;
|
||||
virtual bool canvas_line_event (GdkEvent* event, ArdourCanvas::Item*, AutomationLine*) = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user