From f121d04d6d2eb668edbf7076602d196257bd21c9 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 21 Mar 2015 16:04:56 +0100 Subject: [PATCH] vertical fit: hide tracks in-between --- gtk2_ardour/editor_ops.cc | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 266a6b585e..8d73e5e56c 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -7092,36 +7092,36 @@ Editor::fit_tracks (TrackViewList & tracks) } } - bool prev_was_selected = false; - bool is_selected = tracks.contains (all.front()); - bool next_is_selected; - - for (TrackViewList::iterator t = all.begin(); t != all.end(); ++t) { - - TrackViewList::iterator next; - - next = t; - ++next; - - if (next != all.end()) { - next_is_selected = tracks.contains (*next); - } else { - next_is_selected = false; - } + // find selection range. + // if someone knows how to user TrackViewList::iterator for this + // I'm all ears. + int selected_top = -1; + int selected_bottom = -1; + int i = 0; + for (TrackViewList::iterator t = all.begin(); t != all.end(); ++t, ++i) { if ((*t)->marked_for_display ()) { - if (is_selected) { + if (tracks.contains(*t)) { + if (selected_top == -1) { + selected_top = i; + } + selected_bottom = i; + } + } + } + + i = 0; + for (TrackViewList::iterator t = all.begin(); t != all.end(); ++t, ++i) { + if ((*t)->marked_for_display ()) { + if (tracks.contains(*t)) { (*t)->set_height (h); first_y_pos = std::min ((*t)->y_position (), first_y_pos); } else { - if (prev_was_selected && next_is_selected) { + if (i > selected_top && i < selected_bottom) { hide_track_in_display (*t); } } } - - prev_was_selected = is_selected; - is_selected = next_is_selected; } /*