13
0

add Editor::trackviews_height() convenience function to determine height of trackview area of canvas; use to help fix set_visible_track_count(); don't consider hidden tracks in that function; add "Selected" to that selector menu

This commit is contained in:
Paul Davis 2014-07-15 18:09:04 -04:00
parent bb69a55784
commit b69870dfe6
4 changed files with 26 additions and 5 deletions

View File

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

View File

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

View File

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

View File

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