diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-06-27 10:49:05 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-06-27 10:49:05 -0400 |
commit | c706b1c4bb172fb3622ada9da879e5c684f94a74 (patch) | |
tree | 470567146b627a9e3d90973bb46c65d014fae0ac /gtk2_ardour/editor_canvas.cc | |
parent | 242181dc104ffc8e77ccf5b777e39f2fbccd8d91 (diff) |
replace old implementation of Editor::_ensure_time_axis_view_is_visible() with the guts of Editor::ensure_track_is_visible(), then remove the latter.
Also change all users of ensure_track_is_visible() to use _ensure_time_axis_view_is_visible()
Diffstat (limited to 'gtk2_ardour/editor_canvas.cc')
-rw-r--r-- | gtk2_ardour/editor_canvas.cc | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index d0107c789e..cae0199673 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -805,26 +805,39 @@ Editor::entered_track_canvas (GdkEventCrossing */*ev*/) } void -Editor::_ensure_time_axis_view_is_visible (const TimeAxisView& tav, bool at_top) +Editor::_ensure_time_axis_view_is_visible (TimeAxisView const & track, bool at_top) { - double begin = tav.y_position(); - double v = vertical_adjustment.get_value (); - - if (!at_top && (begin < v || begin + tav.current_height() > v + _visible_canvas_height)) { - /* try to put the TimeAxisView roughly central */ - if (begin >= _visible_canvas_height/2.0) { - begin -= _visible_canvas_height/2.0; - } + if (track.hidden()) { + return; } - /* Clamp the y pos so that we do not extend beyond the canvas full - * height. + /* compute visible area of trackview group, as offsets from top of + * trackview group. */ - if (_full_canvas_height - begin < _visible_canvas_height){ - begin = _full_canvas_height - _visible_canvas_height; + + double const current_view_min_y = vertical_adjustment.get_value(); + double const current_view_max_y = current_view_min_y + vertical_adjustment.get_page_size(); + + double const track_min_y = track.y_position (); + 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)) { + return; + } + + double new_value; + + if (track_min_y < current_view_min_y) { + // Track is above the current view + 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(); } - vertical_adjustment.set_value (begin); + vertical_adjustment.set_value(new_value); } /** Called when the main vertical_adjustment has changed */ |