diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-06-09 10:02:38 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-06-09 10:02:38 -0400 |
commit | d36afa6b8bb3815d91e0fe93887a83e4a873f157 (patch) | |
tree | 9df715b20721ea3f0d005b0bfccd05ed611c63ef | |
parent | 95f2b4ba17949ef5d70bc973665e1b9c29f38e4d (diff) |
forward scroll events from track control headers to the canvas, to get consistent scroll behaviour (whatever that behaviour is)
-rw-r--r-- | gtk2_ardour/editor.cc | 32 | ||||
-rw-r--r-- | gtk2_ardour/editor.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/editor_canvas.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/editor_canvas_events.cc | 8 | ||||
-rw-r--r-- | gtk2_ardour/public_editor.h | 1 | ||||
-rw-r--r-- | gtk2_ardour/time_axis_view.cc | 43 |
6 files changed, 25 insertions, 63 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index d63484c899..13f851a8c7 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -495,11 +495,9 @@ Editor::Editor () controls_layout.add (*h); controls_layout.set_name ("EditControlsBase"); - controls_layout.add_events (Gdk::SCROLL_MASK); - controls_layout.signal_scroll_event().connect (sigc::mem_fun(*this, &Editor::control_layout_scroll), false); - - controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK); + controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK|Gdk::SCROLL_MASK); controls_layout.signal_button_release_event().connect (sigc::mem_fun(*this, &Editor::edit_controls_button_release)); + controls_layout.signal_scroll_event().connect (sigc::mem_fun(*this, &Editor::control_layout_scroll), false); _cursors = new MouseCursors; @@ -3878,26 +3876,14 @@ Editor::transport_punch_location() bool Editor::control_layout_scroll (GdkEventScroll* ev) { - if (Keyboard::some_magic_widget_has_focus()) { - return false; - } - - switch (ev->direction) { - case GDK_SCROLL_UP: - scroll_tracks_up_line (); - return true; - break; + /* Just forward to the normal canvas scroll method. The coordinate + systems are different but since the canvas is always larger than the + track headers, and aligned with the trackview area, this will work. - case GDK_SCROLL_DOWN: - scroll_tracks_down_line (); - return true; - - default: - /* no left/right handling yet */ - break; - } - - return false; + In the not too distant future this layout is going away anyway and + headers will be on the canvas. + */ + return canvas_scroll_event (ev); } void diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index b664ac0b84..df01fccc44 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1402,6 +1402,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD /* Canvas event handlers */ + bool canvas_scroll_event (GdkEventScroll* event); bool canvas_control_point_event (GdkEvent* event,ArdourCanvas::Item*, ControlPoint*); bool canvas_line_event (GdkEvent* event,ArdourCanvas::Item*, AutomationLine*); bool canvas_selection_rect_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*); @@ -1458,7 +1459,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD bool canvas_playhead_cursor_event (GdkEvent* event, ArdourCanvas::Item*); bool track_canvas_scroll (GdkEventScroll* event); - bool track_canvas_scroll_event (GdkEventScroll* event); bool track_canvas_button_press_event (GdkEventButton* event); bool track_canvas_button_release_event (GdkEventButton* event); bool track_canvas_motion_notify_event (GdkEventMotion* event); diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 68c7662ec4..a53158cbde 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -236,7 +236,7 @@ Editor::initialize_canvas () handlers. */ - _track_canvas->signal_scroll_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_scroll_event)); + _track_canvas->signal_scroll_event().connect (sigc::mem_fun (*this, &Editor::canvas_scroll_event)); _track_canvas->signal_motion_notify_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_motion_notify_event)); _track_canvas->signal_button_press_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_button_press_event)); _track_canvas->signal_button_release_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_button_release_event)); diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index 04609330ff..34c81597be 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -60,6 +60,10 @@ using Gtkmm2ext::Keyboard; bool Editor::track_canvas_scroll (GdkEventScroll* ev) { + if (Keyboard::some_magic_widget_has_focus()) { + return false; + } + framepos_t xdelta; int direction = ev->direction; @@ -156,7 +160,7 @@ Editor::track_canvas_scroll (GdkEventScroll* ev) } bool -Editor::track_canvas_scroll_event (GdkEventScroll *event) +Editor::canvas_scroll_event (GdkEventScroll *event) { _track_canvas->grab_focus(); return track_canvas_scroll (event); @@ -1010,7 +1014,7 @@ Editor::canvas_note_event (GdkEvent *event, ArdourCanvas::Item* item) } bool -Editor::canvas_drop_zone_event (GdkEvent* event) +Editor::canvas_drop_zone_event (GdkEvent* /*event*/) { return true; } diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index a1643fb188..d37b4d7744 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -318,6 +318,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi virtual void reset_focus () = 0; + virtual bool canvas_scroll_event (GdkEventScroll* event) = 0; virtual bool canvas_control_point_event (GdkEvent* event, ArdourCanvas::Item*, ControlPoint*) = 0; virtual bool canvas_line_event (GdkEvent* event, ArdourCanvas::Item*, AutomationLine*) = 0; virtual bool canvas_selection_rect_event (GdkEvent* event, ArdourCanvas::Item*, SelectionRect*) = 0; diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index e36b78daaf..059776bd92 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -287,43 +287,14 @@ TimeAxisView::show_at (double y, int& nth, VBox *parent) bool TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev) { - switch (ev->direction) { - case GDK_SCROLL_UP: - if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomVerticalModifier)) { - /* See Editor::_stepping_axis_view for notes on this hack */ - Editor& e = dynamic_cast<Editor&> (_editor); - if (!e.stepping_axis_view ()) { - e.set_stepping_axis_view (this); - } - e.stepping_axis_view()->step_height (false); - return true; - } else if (Keyboard::no_modifiers_active (ev->state)) { - _editor.scroll_up_one_track(); - return true; - } - break; + /* Just forward to the normal canvas scroll method. The coordinate + systems are different but since the canvas is always larger than the + track headers, and aligned with the trackview area, this will work. - case GDK_SCROLL_DOWN: - if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomVerticalModifier)) { - /* See Editor::_stepping_axis_view for notes on this hack */ - Editor& e = dynamic_cast<Editor&> (_editor); - if (!e.stepping_axis_view ()) { - e.set_stepping_axis_view (this); - } - e.stepping_axis_view()->step_height (true); - return true; - } else if (Keyboard::no_modifiers_active (ev->state)) { - _editor.scroll_down_one_track(); - return true; - } - break; - - default: - /* no handling for left/right, yet */ - break; - } - - return false; + In the not too distant future this layout is going away anyway and + headers will be on the canvas. + */ + return _editor.canvas_scroll_event (ev); } bool |