vertical fit: hide tracks in-between
authorRobin Gareus <robin@gareus.org>
Sat, 21 Mar 2015 15:04:56 +0000 (16:04 +0100)
committerRobin Gareus <robin@gareus.org>
Sat, 21 Mar 2015 15:09:35 +0000 (16:09 +0100)
gtk2_ardour/editor_ops.cc

index 266a6b585eb0a3380f373516e04a55f7fbc8a977..8d73e5e56cbe7612aa5472c1440b65ad541a4594 100644 (file)
@@ -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 (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 (is_selected) {
+                       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;
        }
 
        /*