diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index d726a43611..f0e375114d 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -3491,6 +3491,7 @@ Editor::build_track_count_menu () visible_tracks_selector.AddMenuElem (MenuElem (X_("24"), sigc::bind (sigc::mem_fun(*this, &Editor::set_visible_track_count), 24))); visible_tracks_selector.AddMenuElem (MenuElem (X_("32"), sigc::bind (sigc::mem_fun(*this, &Editor::set_visible_track_count), 32))); visible_tracks_selector.AddMenuElem (MenuElem (X_("64"), sigc::bind (sigc::mem_fun(*this, &Editor::set_visible_track_count), 64))); + visible_tracks_selector.AddMenuElem (MenuElem (_("Selected"), sigc::mem_fun(*this, &Editor::fit_selected_tracks))); visible_tracks_selector.AddMenuElem (MenuElem (_("All"), sigc::bind (sigc::mem_fun(*this, &Editor::set_visible_track_count), 0))); } else { visible_tracks_selector.AddMenuElem (MenuElem (_("Fit current tracks"), sigc::bind (sigc::mem_fun(*this, &Editor::set_visible_track_count), 0))); @@ -3545,15 +3546,21 @@ Editor::set_visible_track_count (int32_t n) int h; string str; - + if (_visible_track_count > 0) { - h = _visible_canvas_height / _visible_track_count; + h = trackviews_height() / _visible_track_count; std::ostringstream s; s << _visible_track_count; str = s.str(); } else if (_visible_track_count == 0) { - h = _visible_canvas_height / track_views.size(); - str = _("all"); + uint32_t n = 0; + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + if ((*i)->marked_for_display()) { + ++n; + } + } + h = trackviews_height() / n; + str = _("All"); } else { /* negative value means that the visible track count has been overridden by explicit track height changes. diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 83f38b40c9..00fe0e04ea 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -149,6 +149,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD double visible_canvas_height () const { return _visible_canvas_height; } + double trackviews_height() const; void cycle_snap_mode (); void next_snap_choice (); diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index c518472f0c..66caeb7bc6 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -1352,3 +1352,13 @@ Editor::choose_canvas_cursor_on_entry (GdkEventCrossing* /*event*/, ItemType typ set_canvas_cursor (cursor, false); } } + +double +Editor::trackviews_height() const +{ + if (!_trackview_group) { + return 0; + } + + return _visible_canvas_height - _trackview_group->canvas_origin().y; +} diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 083763b2b0..88a76983bb 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -6767,6 +6767,7 @@ Editor::fit_selected_tracks () } } } + } void @@ -6795,7 +6796,7 @@ Editor::fit_tracks (TrackViewList & tracks) height that will be taken by visible children of selected tracks - height of the ruler/hscroll area */ - uint32_t h = (uint32_t) floor ((_visible_canvas_height - (child_heights + _trackview_group->canvas_origin().y)) / visible_tracks); + uint32_t h = (uint32_t) floor ((trackviews_height() - child_heights) / visible_tracks); double first_y_pos = DBL_MAX; if (h < TimeAxisView::preset_height (HeightSmall)) { @@ -6859,6 +6860,8 @@ Editor::fit_tracks (TrackViewList & tracks) vertical_adjustment.set_value (first_y_pos); redo_visual_stack.push_back (current_visual_state (true)); + + visible_tracks_selector.set_text (_("Sel")); } void