polish a few blemishes and add some comments

This commit is contained in:
Ben Loftis 2014-07-09 14:45:20 -05:00 committed by Paul Davis
parent 1ed1a23b6c
commit 7b41724c3d

View file

@ -4239,8 +4239,7 @@ SelectionDrag::motion (GdkEvent* event, bool first_move)
} }
/* select all tracks within the rectangle that we've marked out so far */ /* select all tracks within the rectangle that we've marked out so far */
TrackViewList to_be_added_to_selection; TrackViewList new_selection;
TrackViewList to_be_removed_from_selection;
TrackViewList& all_tracks (_editor->track_views); TrackViewList& all_tracks (_editor->track_views);
ArdourCanvas::Coord const top = grab_y(); ArdourCanvas::Coord const top = grab_y();
@ -4248,27 +4247,28 @@ SelectionDrag::motion (GdkEvent* event, bool first_move)
if (top >= 0 && bottom >= 0) { if (top >= 0 && bottom >= 0) {
//first, find the tracks that are covered in the y range selection
for (TrackViewList::const_iterator i = all_tracks.begin(); i != all_tracks.end(); ++i) { for (TrackViewList::const_iterator i = all_tracks.begin(); i != all_tracks.end(); ++i) {
if ((*i)->covered_by_y_range (top, bottom)) { if ((*i)->covered_by_y_range (top, bottom)) {
to_be_added_to_selection.push_back (*i); new_selection.push_back (*i);
} }
} }
//add any tracks that are GROUPED with the tracks we selected //now find any tracks that are GROUPED with the tracks we selected
TrackViewList grouped_add = to_be_added_to_selection; TrackViewList grouped_add = new_selection;
for (TrackViewList::const_iterator i = to_be_added_to_selection.begin(); i != to_be_added_to_selection.end(); ++i) { for (TrackViewList::const_iterator i = new_selection.begin(); i != new_selection.end(); ++i) {
RouteTimeAxisView *add = dynamic_cast<RouteTimeAxisView *>(*i); RouteTimeAxisView *n = dynamic_cast<RouteTimeAxisView *>(*i);
if ( add && add->route()->route_group() && add->route()->route_group()->is_active() ) { if ( n && n->route()->route_group() && n->route()->route_group()->is_active() ) {
for (TrackViewList::const_iterator j = all_tracks.begin(); j != all_tracks.end(); ++j) { for (TrackViewList::const_iterator j = all_tracks.begin(); j != all_tracks.end(); ++j) {
RouteTimeAxisView *rem = dynamic_cast<RouteTimeAxisView *>(*j); RouteTimeAxisView *check = dynamic_cast<RouteTimeAxisView *>(*j);
if ( rem && (add != rem) && (rem->route()->route_group() == add->route()->route_group()) ) if ( check && (n != check) && (check->route()->route_group() == n->route()->route_group()) )
grouped_add.push_back (*j); grouped_add.push_back (*j);
} }
} }
} }
//now compare our list with the current selection, and add or remove as necessary ( most mouse moves don't change the selection so we can't just SET it for every mouse move; it gets clunky ) //now compare our list with the current selection, and add or remove as necessary
//( NOTE: most mouse moves don't change the selection so we can't just SET it for every mouse move; it gets clunky )
TrackViewList tracks_to_add; TrackViewList tracks_to_add;
TrackViewList tracks_to_remove; TrackViewList tracks_to_remove;
for (TrackViewList::const_iterator i = grouped_add.begin(); i != grouped_add.end(); ++i) for (TrackViewList::const_iterator i = grouped_add.begin(); i != grouped_add.end(); ++i)
@ -4277,10 +4277,8 @@ SelectionDrag::motion (GdkEvent* event, bool first_move)
for (TrackViewList::const_iterator i = _editor->selection->tracks.begin(); i != _editor->selection->tracks.end(); ++i) for (TrackViewList::const_iterator i = _editor->selection->tracks.begin(); i != _editor->selection->tracks.end(); ++i)
if ( !grouped_add.contains ( *i ) ) if ( !grouped_add.contains ( *i ) )
tracks_to_remove.push_back ( *i ); tracks_to_remove.push_back ( *i );
_editor->selection->add(tracks_to_add); _editor->selection->add(tracks_to_add);
_editor->selection->remove(tracks_to_remove); _editor->selection->remove(tracks_to_remove);
} }
} }