+/** Set the x range visible in the editor.
+ * Caller should have checked that Editor::pending_visual_change.idle_handler_id is < 0
+ * @param x new x range in summary coordinates.
+ */
+void
+EditorSummary::set_editor_x (pair<double, double> const & x)
+{
+ _editor->reset_x_origin (x.first / _x_scale + _start);
+
+ double const nx = (
+ ((x.second - x.first) / _x_scale) /
+ _editor->frame_to_unit (_editor->current_page_frames())
+ );
+
+ if (nx != _editor->get_current_zoom ()) {
+ _editor->reset_zoom (nx);
+ }
+}
+
+/** Set the top of the y range visible in the editor.
+ * Caller should have checked that Editor::pending_visual_change.idle_handler_id is < 0
+ * @param y new editor top in summary coodinates.
+ */
+void
+EditorSummary::set_editor_y (double const y)
+{
+ double y1 = summary_y_to_editor (y);
+ double const eh = _editor->canvas_height() - _editor->get_canvas_timebars_vsize ();
+ double y2 = y1 + eh;
+
+ double const full_editor_height = _editor->full_canvas_height - _editor->get_canvas_timebars_vsize();
+
+ if (y2 > full_editor_height) {
+ y1 -= y2 - full_editor_height;
+ }
+
+ if (y1 < 0) {
+ y1 = 0;
+ }
+
+ _editor->reset_y_origin (y1);
+}
+
+/** Set the y range visible in the editor. This is achieved by scaling track heights,
+ * if necessary.
+ * Caller should have checked that Editor::pending_visual_change.idle_handler_id is < 0
+ * @param y new editor range in summary coodinates.
+ */
+void
+EditorSummary::set_editor_y (pair<double, double> const & y)
+{
+ /* Compute current height of tracks between y.first and y.second. We add up
+ the total height into `total_height' and the height of complete tracks into
+ `scale height'.
+ */
+ pair<double, double> yc = y;
+ double total_height = 0;
+ double scale_height = 0;
+
+ _editor->_routes->suspend_redisplay ();
+
+ for (TrackViewList::const_iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
+
+ if ((*i)->hidden()) {
+ continue;
+ }
+
+ double const h = (*i)->effective_height ();
+
+ if (yc.first >= 0 && yc.first < _track_height) {
+ total_height += (_track_height - yc.first) * h / _track_height;
+ } else if (yc.first < 0 && yc.second > _track_height) {
+ total_height += h;
+ scale_height += h;
+ } else if (yc.second >= 0 && yc.second < _track_height) {
+ total_height += yc.second * h / _track_height;
+ break;
+ }
+
+ yc.first -= _track_height;
+ yc.second -= _track_height;
+ }
+
+ /* hence required scale factor of the complete tracks to fit the required y range */
+ double const scale = ((_editor->canvas_height() - _editor->get_canvas_timebars_vsize()) - (total_height - scale_height)) / scale_height;
+
+ yc = y;
+
+ /* Scale complete tracks within the range to make it fit */
+
+ for (TrackViewList::const_iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
+
+ if ((*i)->hidden()) {
+ continue;
+ }
+
+ if (yc.first < 0 && yc.second > _track_height) {
+ (*i)->set_height (max (TimeAxisView::preset_height (HeightSmall), (uint32_t) ((*i)->effective_height() * scale)));