diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-07-14 12:36:44 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-07-14 12:36:51 -0400 |
commit | d0bc4b55faa25e754d1f15eab4656434aba1a568 (patch) | |
tree | 3a07c0fd68ae69b774657c97bb1e8454c4705ee4 /gtk2_ardour | |
parent | acc1977cbd6699f25a2081184f9fc63e7714f2b9 (diff) |
scroll up/down by tracks uses top edge as "focal point"; fix some other nasty code details
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/editor.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/editor_canvas.cc | 23 | ||||
-rw-r--r-- | gtk2_ardour/editor_ops.cc | 37 | ||||
-rw-r--r-- | gtk2_ardour/public_editor.h | 13 | ||||
-rw-r--r-- | gtk2_ardour/time_axis_view.cc | 4 |
5 files changed, 39 insertions, 40 deletions
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index ac8976c033..83f38b40c9 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -180,7 +180,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void set_internal_edit (bool yn); bool toggle_internal_editing_from_double_click (GdkEvent*); - void _ensure_time_axis_view_is_visible (TimeAxisView const & tav, bool at_top); void foreach_time_axis_view (sigc::slot<void,TimeAxisView&>); void add_to_idle_resize (TimeAxisView*, int32_t); @@ -285,6 +284,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD framecnt_t get_current_zoom () const { return samples_per_pixel; } void cycle_zoom_focus (); void temporal_zoom_step (bool coarser); + void ensure_time_axis_view_is_visible (TimeAxisView const & tav, bool at_top); void tav_zoom_step (bool coarser); void tav_zoom_smooth (bool coarser, bool force_all); diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index c64ee7ccc2..c518472f0c 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -805,7 +805,7 @@ Editor::entered_track_canvas (GdkEventCrossing */*ev*/) } void -Editor::_ensure_time_axis_view_is_visible (TimeAxisView const & track, bool at_top) +Editor::ensure_time_axis_view_is_visible (TimeAxisView const & track, bool at_top) { if (track.hidden()) { return; @@ -822,19 +822,28 @@ Editor::_ensure_time_axis_view_is_visible (TimeAxisView const & track, bool at_t double const track_max_y = track.y_position () + track.effective_height (); if (!at_top && - (track_min_y > current_view_min_y && - track_max_y <= current_view_max_y)) { + (track_min_y >= current_view_min_y && + track_max_y < current_view_max_y)) { + /* already visible, and caller did not ask to place it at the + * top of the track canvas + */ return; } double new_value; - if (track_min_y < current_view_min_y) { - // Track is above the current view + if (at_top) { new_value = track_min_y; } else { - // Track is below the current view - new_value = track.y_position () + track.effective_height() - vertical_adjustment.get_page_size(); + if (track_min_y < current_view_min_y) { + // Track is above the current view + new_value = track_min_y; + } else if (track_max_y > current_view_max_y) { + // Track is below the current view + new_value = track.y_position () + track.effective_height() - vertical_adjustment.get_page_size(); + } else { + new_value = track_min_y; + } } vertical_adjustment.set_value(new_value); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index f4582704d8..083763b2b0 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -1364,32 +1364,35 @@ Editor::scroll_tracks_up_line () bool Editor::scroll_down_one_track () { - TrackViewList::reverse_iterator next = track_views.rend(); + TrackViewList::reverse_iterator next = track_views.rbegin(); std::pair<TimeAxisView*,double> res; - const double bottom_of_trackviews = vertical_adjustment.get_value() + vertical_adjustment.get_page_size() - 1; + const double top_of_trackviews = vertical_adjustment.get_value(); for (TrackViewList::reverse_iterator t = track_views.rbegin(); t != track_views.rend(); ++t) { if ((*t)->hidden()) { continue; } - - /* If this is the bottom visible trackview, we want to display - the next one. + + next = t; + if (next != track_views.rbegin()) { + --next; // moves "next" towards the lower/later tracks since it is a reverse iterator + } + + /* If this is the upper-most visible trackview, we want to display + the one above it (next) */ - res = (*t)->covers_y_position (bottom_of_trackviews); + res = (*t)->covers_y_position (top_of_trackviews); if (res.first) { break; } - - ++next; // moves "next" towards the "front" since it is a reverse iterator } /* move to the track below the first one that covers the */ - if (next != track_views.rend()) { - ensure_time_axis_view_is_visible (**next); + if (next != track_views.rbegin()) { + ensure_time_axis_view_is_visible (**next, true); return true; } @@ -1399,11 +1402,10 @@ Editor::scroll_down_one_track () bool Editor::scroll_up_one_track () { - double vertical_pos = vertical_adjustment.get_value (); - TrackViewList::iterator prev = track_views.end(); std::pair<TimeAxisView*,double> res; - + double top_of_trackviews = vertical_adjustment.get_value (); + for (TrackViewList::iterator t = track_views.begin(); t != track_views.end(); ++t) { if ((*t)->hidden()) { @@ -1411,10 +1413,9 @@ Editor::scroll_up_one_track () } /* find the trackview at the top of the trackview group */ - res = (*t)->covers_y_position (vertical_pos); + res = (*t)->covers_y_position (top_of_trackviews); if (res.first) { - cerr << res.first->name() << " covers the top\n"; break; } @@ -1422,7 +1423,7 @@ Editor::scroll_up_one_track () } if (prev != track_views.end()) { - ensure_time_axis_view_is_visible (**prev); + ensure_time_axis_view_is_visible (**prev, true); return true; } @@ -5637,7 +5638,7 @@ Editor::select_next_route() selection->set(current); - ensure_time_axis_view_is_visible (*current); + ensure_time_axis_view_is_visible (*current, false); } void @@ -5668,7 +5669,7 @@ Editor::select_prev_route() selection->set (current); - ensure_time_axis_view_is_visible (*current); + ensure_time_axis_view_is_visible (*current, false); } void diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 9e971eb5d8..17d43e0bf4 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -276,11 +276,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi virtual framecnt_t current_page_samples() const = 0; virtual double visible_canvas_height () const = 0; virtual void temporal_zoom_step (bool coarser) = 0; - /* The virtual version, without a default argument, is protected below. - */ - void ensure_time_axis_view_is_visible (TimeAxisView const & tav, bool at_top = false) { - _ensure_time_axis_view_is_visible (tav, at_top); - } + virtual void ensure_time_axis_view_is_visible (TimeAxisView const & tav, bool at_top = false) = 0; virtual void override_visible_track_count () = 0; virtual void scroll_tracks_down_line () = 0; virtual void scroll_tracks_up_line () = 0; @@ -429,13 +425,6 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi PBD::Signal0<void> MouseModeChanged; protected: - /* This _ variant of ensure_time_axis_view_is_visible exists because - C++ doesn't really like default values for virtual methods. So the - public version is non-virtual, with a default value; the virtual - (and protected) method here does not have a default value. - */ - virtual void _ensure_time_axis_view_is_visible (TimeAxisView const & tav, bool at_top) = 0; - friend class DisplaySuspender; virtual void suspend_route_redisplay () = 0; virtual void resume_route_redisplay () = 0; diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index 9cc691ad08..a5d91c7bc2 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -675,7 +675,7 @@ TimeAxisView::end_name_edit (int response) } if ((i != allviews.end()) && (*i != this) && !(*i)->hidden()) { - _editor.ensure_time_axis_view_is_visible (**i); + _editor.ensure_time_axis_view_is_visible (**i, false); (*i)->begin_name_edit (); } @@ -706,7 +706,7 @@ TimeAxisView::end_name_edit (int response) } if ((i != allviews.end()) && (*i != this) && !(*i)->hidden()) { - _editor.ensure_time_axis_view_is_visible (**i); + _editor.ensure_time_axis_view_is_visible (**i, false); (*i)->begin_name_edit (); } } |