diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-09-29 02:01:35 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-09-29 02:01:35 +0000 |
commit | 5f128910e1f271200d38e1df20f01e86fe788a35 (patch) | |
tree | 827cc28235e88372dbc8e640eb00675f0b984aad | |
parent | 03fe5aa56d28e1158eb92c0ee163d2a1b3a20a97 (diff) |
more route + region list navigation/editing changes. not sure we actually want this functionality for the region list
git-svn-id: svn://localhost/ardour2/branches/3.0@7858 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/editor_regions.cc | 80 | ||||
-rw-r--r-- | gtk2_ardour/editor_regions.h | 8 | ||||
-rw-r--r-- | gtk2_ardour/editor_routes.cc | 6 |
3 files changed, 91 insertions, 3 deletions
diff --git a/gtk2_ardour/editor_regions.cc b/gtk2_ardour/editor_regions.cc index 426ee2b544..3d03a65ab5 100644 --- a/gtk2_ardour/editor_regions.cc +++ b/gtk2_ardour/editor_regions.cc @@ -59,6 +59,8 @@ using Gtkmm2ext::Keyboard; EditorRegions::EditorRegions (Editor* e) : EditorComponent (e) + , old_focus (0) + , name_editable (0) , _menu (0) , _show_automatic_regions (true) , _sort_type ((Editing::RegionListSortType) 0) @@ -104,6 +106,7 @@ EditorRegions::EditorRegions (Editor* e) CellRendererText* region_name_cell = dynamic_cast<CellRendererText*>(_display.get_column_cell_renderer (0)); region_name_cell->property_editable() = true; region_name_cell->signal_edited().connect (sigc::mem_fun (*this, &EditorRegions::name_edit)); + region_name_cell->signal_editing_started().connect (sigc::mem_fun (*this, &EditorRegions::name_editing_started)); _display.get_selection()->set_select_function (sigc::mem_fun (*this, &EditorRegions::selection_filter)); @@ -153,9 +156,16 @@ EditorRegions::EditorRegions (Editor* e) _scroller.add (_display); _scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC); - _display.signal_key_press_event().connect (sigc::mem_fun(*this, &EditorRegions::key_press), false); _display.signal_button_press_event().connect (sigc::mem_fun(*this, &EditorRegions::button_press), false); _change_connection = _display.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &EditorRegions::selection_changed)); + + _scroller.signal_key_press_event().connect (sigc::mem_fun(*this, &EditorRegions::key_press), false); + _scroller.signal_focus_in_event().connect (sigc::mem_fun (*this, &EditorRegions::focus_in), false); + _scroller.signal_focus_out_event().connect (sigc::mem_fun (*this, &EditorRegions::focus_out)); + + _display.signal_enter_notify_event().connect (sigc::mem_fun (*this, &EditorRegions::enter_notify), false); + _display.signal_leave_notify_event().connect (sigc::mem_fun (*this, &EditorRegions::leave_notify), false); + // _display.signal_popup_menu().connect (sigc::bind (sigc::mem_fun (*this, &Editor::show__display_context_menu), 1, 0)); //ARDOUR_UI::instance()->secondary_clock.mode_changed.connect (sigc::mem_fun(*this, &Editor::redisplay_regions)); @@ -164,6 +174,60 @@ EditorRegions::EditorRegions (Editor* e) ARDOUR::RegionFactory::CheckNewRegion.connect (check_new_region_connection, MISSING_INVALIDATOR, ui_bind (&EditorRegions::add_region, this, _1), gui_context()); } +bool +EditorRegions::focus_in (GdkEventFocus*) +{ + Window* win = dynamic_cast<Window*> (_scroller.get_toplevel ()); + + if (win) { + old_focus = win->get_focus (); + } else { + old_focus = 0; + } + + name_editable = 0; + + /* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */ + return true; +} + +bool +EditorRegions::focus_out (GdkEventFocus*) +{ + if (old_focus) { + old_focus->grab_focus (); + old_focus = 0; + } + + name_editable = 0; + + return false; +} + +bool +EditorRegions::enter_notify (GdkEventCrossing* ev) +{ + /* arm counter so that ::selection_filter() will deny selecting anything for the + next two attempts to change selection status. + */ + _scroller.grab_focus (); + Keyboard::magic_widget_grab_focus (); + return false; +} + +bool +EditorRegions::leave_notify (GdkEventCrossing*) +{ + if (old_focus) { + old_focus->grab_focus (); + old_focus = 0; + } + + name_editable = 0; + Keyboard::magic_widget_drop_focus (); + return false; +} + void EditorRegions::set_session (ARDOUR::Session* s) { @@ -1056,6 +1120,12 @@ EditorRegions::key_press (GdkEventKey* ev) switch (ev->keyval) { case GDK_Tab: case GDK_ISO_Left_Tab: + + if (name_editable) { + name_editable->editing_done (); + name_editable = 0; + } + col = _display.get_column (0); // select&focus on name column if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { @@ -1292,8 +1362,16 @@ EditorRegions::selection_filter (const RefPtr<TreeModel>& model, const TreeModel } void +EditorRegions::name_editing_started (CellEditable* ce, const Glib::ustring&) +{ + name_editable = ce; +} + +void EditorRegions::name_edit (const std::string& path, const std::string& new_text) { + name_editable = 0; + boost::shared_ptr<Region> region; TreeIter iter; diff --git a/gtk2_ardour/editor_regions.h b/gtk2_ardour/editor_regions.h index de53edc4e3..371122785a 100644 --- a/gtk2_ardour/editor_regions.h +++ b/gtk2_ardour/editor_regions.h @@ -124,6 +124,10 @@ private: bool set_selected_in_subrow (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int); bool selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn); + + Gtk::Widget* old_focus; + Gtk::CellEditable* name_editable; + void name_editing_started (Gtk::CellEditable*, const Glib::ustring&); void name_edit (const std::string&, const std::string&); void locked_changed (std::string const &); @@ -133,6 +137,10 @@ private: bool key_press (GdkEventKey *); bool button_press (GdkEventButton *); + bool focus_in (GdkEventFocus*); + bool focus_out (GdkEventFocus*); + bool enter_notify (GdkEventCrossing*); + bool leave_notify (GdkEventCrossing*); void show_context_menu (int button, int time); int sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator); diff --git a/gtk2_ardour/editor_routes.cc b/gtk2_ardour/editor_routes.cc index edbcefa0f5..4f215d7bb6 100644 --- a/gtk2_ardour/editor_routes.cc +++ b/gtk2_ardour/editor_routes.cc @@ -231,6 +231,8 @@ EditorRoutes::focus_in (GdkEventFocus*) old_focus = 0; } + name_editable = 0; + /* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */ return true; } @@ -243,6 +245,7 @@ EditorRoutes::focus_out (GdkEventFocus*) old_focus = 0; } + name_editable = 0; return false; } @@ -268,6 +271,7 @@ EditorRoutes::leave_notify (GdkEventCrossing*) old_focus = 0; } + name_editable = 0; Keyboard::magic_widget_drop_focus (); return false; } @@ -884,8 +888,6 @@ EditorRoutes::key_press (GdkEventKey* ev) boost::shared_ptr<RouteList> rl (new RouteList); TreePath path; - cerr << "our key press\n"; - switch (ev->keyval) { case GDK_Tab: case GDK_ISO_Left_Tab: |