scroll up/down by tracks uses top edge as "focal point"; fix some other nasty code details

This commit is contained in:
Paul Davis 2014-07-14 12:36:44 -04:00
parent acc1977cbd
commit d0bc4b55fa
5 changed files with 39 additions and 40 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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 ();
}
}