Optimize automation-event process splitting
[ardour.git] / gtk2_ardour / editor_selection.cc
index a060f93d04e47af53abd9c87c7f6455c9ffabad8..227eaa4a63247da4d083976930b16885bdbd7850 100644 (file)
@@ -399,7 +399,7 @@ Editor::mapover_tracks (sigc::slot<void, RouteTimeAxisView&, uint32_t> sl, TimeA
 
        RouteGroup* group = route_basis->route()->route_group();
 
-       if (group && group->enabled_property(prop) && group->enabled_property (Properties::active.property_id) ) {
+       if (group && group->enabled_property(prop) && group->enabled_property (Properties::active.property_id)) {
 
                /* the basis is a member of an active route group, with the appropriate
                   properties; find other members */
@@ -443,7 +443,7 @@ Editor::mapover_tracks_with_unique_playlists (sigc::slot<void, RouteTimeAxisView
 
        RouteGroup* group = route_basis->route()->route_group(); // could be null, not a problem
 
-       if (group && group->enabled_property(prop) && group->enabled_property (Properties::active.property_id) ) {
+       if (group && group->enabled_property(prop) && group->enabled_property (Properties::active.property_id)) {
 
                /* the basis is a member of an active route group, with the appropriate
                   properties; find other members */
@@ -983,23 +983,6 @@ Editor::set_selected_regionview_from_map_event (GdkEventAny* /*ev*/, StreamView*
        return true;
 }
 
-struct SelectionOrderSorter {
-       bool operator() (TimeAxisView const * const a, TimeAxisView const * const b) const  {
-               boost::shared_ptr<Stripable> sa = a->stripable ();
-               boost::shared_ptr<Stripable> sb = b->stripable ();
-               if (!sa && !sb) {
-                       return a < b;
-               }
-               if (!sa) {
-                       return false;
-               }
-               if (!sb) {
-                       return true;
-               }
-               return sa->presentation_info().selection_cnt() < sb->presentation_info().selection_cnt();
-       }
-};
-
 void
 Editor::presentation_info_changed (PropertyChange const & what_changed)
 {
@@ -1155,6 +1138,17 @@ Editor::presentation_info_changed (PropertyChange const & what_changed)
        }
 }
 
+void
+Editor::track_selection_changed ()
+{
+       /* reset paste count, so the plaste location doesn't get incremented
+        * if we want to paste in the same place, but different track. */
+       paste_count = 0;
+
+       if ( _session->solo_selection_active() )
+               play_solo_selection(false);
+}
+
 void
 Editor::time_selection_changed ()
 {
@@ -1577,6 +1571,20 @@ Editor::region_selection_changed ()
                }
        }
 
+       if (_session->solo_selection_active()) {
+               play_solo_selection(false);
+       }
+
+       /* set nudge button color */
+       if (! get_regions_from_selection_and_entered().empty()) {
+               /* nudge regions */
+               nudge_forward_button.set_name ("nudge button");
+               nudge_backward_button.set_name ("nudge button");
+       } else {
+               /* nudge marker or playhead */
+               nudge_forward_button.set_name ("generic button");
+               nudge_backward_button.set_name ("generic button");
+       }
 }
 
 void
@@ -1700,7 +1708,6 @@ Editor::invert_selection_in_track ()
 void
 Editor::invert_selection ()
 {
-       list<Selectable *> touched;
 
        if (internal_editing()) {
                for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
@@ -1712,16 +1719,35 @@ Editor::invert_selection ()
                return;
        }
 
-       for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
-               if ((*iter)->hidden()) {
-                       continue;
+       if (!selection->tracks.empty()) {
+
+               TrackViewList inverted;
+
+               for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
+                       if (!(*iter)->selected()) {
+                               inverted.push_back (*iter);
+                       }
                }
-               (*iter)->get_inverted_selectables (*selection, touched);
-       }
 
-       begin_reversible_selection_op (X_("Invert Selection"));
-       selection->set (touched);
-       commit_reversible_selection_op ();
+               begin_reversible_selection_op (X_("Invert Track Selection"));
+               selection->set (inverted);
+               commit_reversible_selection_op ();
+
+       } else {
+
+               list<Selectable *> touched;
+
+               for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
+                       if ((*iter)->hidden()) {
+                               continue;
+                       }
+                       (*iter)->get_inverted_selectables (*selection, touched);
+               }
+
+               begin_reversible_selection_op (X_("Invert ObjectSelection"));
+               selection->set (touched);
+               commit_reversible_selection_op ();
+       }
 }
 
 /** @param start Start time in session samples.
@@ -1807,7 +1833,7 @@ Editor::set_selection_from_region ()
 
        selection->set (tvl);
 
-       if (!get_smart_mode () || !mouse_mode == Editing::MouseObject) {
+       if (!get_smart_mode () || !(mouse_mode == Editing::MouseObject) ) {
                set_mouse_mode (Editing::MouseRange, false);
        }
 }
@@ -1844,7 +1870,7 @@ Editor::set_selection_from_range (Location& loc)
 
        // if no tracks are selected, enable all tracks
        // (_something_ has to be selected for any range selection, otherwise the user won't see anything)
-       if ( selection->tracks.empty() ) {
+       if (selection->tracks.empty()) {
                select_all_tracks();
        }
 
@@ -2103,7 +2129,7 @@ Editor::select_range_between ()
        samplepos_t start;
        samplepos_t end;
 
-       if ( !selection->time.empty() ) {
+       if (!selection->time.empty()) {
                selection->clear_time ();
        }
 
@@ -2128,7 +2154,7 @@ Editor::get_edit_op_range (samplepos_t& start, samplepos_t& end) const
 
        /* if an explicit range exists, use it */
 
-       if ( (mouse_mode == MouseRange || get_smart_mode() ) &&  !selection->time.empty()) {
+       if ((mouse_mode == MouseRange || get_smart_mode()) &&  !selection->time.empty()) {
                /* we know that these are ordered */
                start = selection->time.start();
                end = selection->time.end_sample();