Remove confusing track / group members in TimeSelection struct; time selection
authorCarl Hetherington <carl@carlh.net>
Sun, 13 Dec 2009 21:27:19 +0000 (21:27 +0000)
committerCarl Hetherington <carl@carlh.net>
Sun, 13 Dec 2009 21:27:19 +0000 (21:27 +0000)
applies to the selected tracks.  Some tinkering with how tracks are selected
during time selections.

git-svn-id: svn://localhost/ardour2/branches/3.0@6360 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.cc
gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_keys.cc
gtk2_ardour/editor_mouse.cc
gtk2_ardour/editor_ops.cc
gtk2_ardour/editor_selection.cc
gtk2_ardour/selection.cc
gtk2_ardour/selection.h
gtk2_ardour/time_axis_view.cc
gtk2_ardour/time_selection.cc
gtk2_ardour/time_selection.h

index 9ca44992c414d728f8a0291e88f1c54ebbcbce07..dd9cdf9582bc35122d348b6dd2e2ed81a648a06f 100644 (file)
@@ -4230,14 +4230,8 @@ Editor::post_zoom ()
        }
 
        if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
-               if (!selection->tracks.empty()) {
-                       for (TrackViewList::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
-                               (*i)->reshow_selection (selection->time);
-                       }
-               } else {
-                       for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
-                               (*i)->reshow_selection (selection->time);
-                       }
+               for (TrackViewList::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
+                       (*i)->reshow_selection (selection->time);
                }
        }
 
index 0e9b62aeb48cb4baf9e65c99e35e5223a4813f64..5ec2cb0439793d51becf0b24f749a60f09cc6550 100644 (file)
@@ -2933,7 +2933,6 @@ SelectionDrag::motion (GdkEvent* event, bool first_move)
        nframes64_t end = 0;
        nframes64_t length;
 
-
        nframes64_t const pending_position = adjusted_current_frame (event);
 
        /* only alter selection if the current frame is
@@ -2960,7 +2959,7 @@ SelectionDrag::motion (GdkEvent* event, bool first_move)
                }
 
                /* first drag: Either add to the selection
-                  or create a new selection->
+                  or create a new selection
                */
 
                if (first_move) {
@@ -2970,11 +2969,17 @@ SelectionDrag::motion (GdkEvent* event, bool first_move)
 
                        if (_copy) {
                                /* adding to the selection */
+                               _editor->selection->add (_editor->clicked_axisview);
                                _editor->clicked_selection = _editor->selection->add (start, end);
                                _copy = false;
                        } else {
-                               /* new selection-> */
-                               _editor->clicked_selection = _editor->selection->set (_editor->clicked_axisview, start, end);
+                               /* new selection */
+
+                               if (!_editor->selection->selected (_editor->clicked_axisview)) {
+                                       _editor->selection->set (_editor->clicked_axisview);
+                               }
+                               
+                               _editor->clicked_selection = _editor->selection->set (start, end);
                        }
                }
                break;
@@ -3077,9 +3082,11 @@ SelectionDrag::finished (GdkEvent* event, bool movement_occurred)
                /* just a click, no pointer movement.*/
 
                if (Keyboard::no_modifier_keys_pressed (&event->button)) {
-
                        _editor->selection->clear_time();
+               }
 
+               if (!_editor->selection->selected (_editor->clicked_axisview)) {
+                       _editor->selection->set (_editor->clicked_axisview);
                }
                
                if (s && s->get_play_range () && s->transport_rolling()) {
@@ -3288,7 +3295,7 @@ RangeMarkerBarDrag::finished (GdkEvent* event, bool movement_occurred)
 
                        case MouseRange:
                                /* find the two markers on either side of the click and make the range out of it */
-                               _editor->selection->set (0, start, end);
+                               _editor->selection->set (start, end);
                                break;
 
                        default:
index cbbe11f37b76948b215eb91a026fd22d9e0d54fe..b9df06d3580697521cba85b6b95b12e232362416 100644 (file)
@@ -57,7 +57,7 @@ Editor::keyboard_selection_finish (bool add)
                if (add) {
                        selection->add (pending_keyboard_selection_start, end);
                } else {
-                       selection->set (0, pending_keyboard_selection_start, end);
+                       selection->set (pending_keyboard_selection_start, end);
                }
 
                have_pending_keyboard_selection = false;
index 78e5e9a1452259b58da78012c9d16d05920f56b7..cecddd092a5c0a3cde51b451930b292d9af21395 100644 (file)
@@ -331,13 +331,11 @@ Editor::mouse_mode_toggled (MouseMode m)
        } else {
 
                /*
-                  in range mode,show the range selection.
+                  in range mode, show the range selection.
                */
 
                for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
-                       if ((*i)->get_selected()) {
-                               (*i)->show_selection (selection->time);
-                       }
+                       (*i)->show_selection (selection->time);
                }
        }
 
@@ -483,11 +481,9 @@ Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemTyp
                break;
 
        case StreamItem:
-               /* for context click or range selection, select track */
+               /* for context click, select track */
                if (event->button.button == 3) {
                        set_selected_track_as_side_effect ();
-               } else if (event->type == GDK_BUTTON_PRESS && mouse_mode == MouseRange) {
-                       set_selected_track_as_side_effect ();
                }
                break;
 
index be9538df68c65f179ffde55ab7dd96cd212dd683..4ed0354491f126e4f1663bb42f3251ca389236b0 100644 (file)
@@ -247,14 +247,8 @@ Editor::extend_selection_to_end_of_region (bool next)
                start = selection->time.start ();
        }
 
-       /* Try to leave the selection with the same route if possible */
-
-       if ((tv = selection->time.track) == 0) {
-               return;
-       }
-
        begin_reversible_command (_("extend selection"));
-       selection->set (tv, start, region->position() + region->length());
+       selection->set (start, region->position() + region->length());
        commit_reversible_command ();
 }
 
@@ -277,12 +271,8 @@ Editor::extend_selection_to_start_of_region (bool previous)
 
        /* Try to leave the selection with the same route if possible */
 
-       if ((tv = selection->time.track) == 0) {
-               return;
-       }
-
        begin_reversible_command (_("extend selection"));
-       selection->set (tv, region->position(), end);
+       selection->set (region->position(), end);
        commit_reversible_command ();
 }
 
@@ -3921,7 +3911,7 @@ Editor::cut_copy (CutCopyOp op)
                                if (!get_edit_op_range (start, end)) {
                                        return;
                                }
-                               selection->set ((TimeAxisView*) 0, start, end);
+                               selection->set (start, end);
                        }
 
                        begin_reversible_command (opname + _(" range"));
index 8852271f11b65fd01caa0f48fd043a29a9acd328..59c020feae18bd47c0b7e30336408594ccd1e523 100644 (file)
@@ -808,14 +808,8 @@ Editor::time_selection_changed ()
                (*i)->hide_selection ();
        }
 
-       if (selection->tracks.empty()) {
-               for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
-                       (*i)->show_selection (selection->time);
-               }
-       } else {
-               for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
-                       (*i)->show_selection (selection->time);
-               }
+       for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
+               (*i)->show_selection (selection->time);
        }
 
        if (selection->time.empty()) {
@@ -823,7 +817,6 @@ Editor::time_selection_changed ()
        } else {
                ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, true);
        }
-
 }
 
 void
@@ -1033,7 +1026,7 @@ Editor::set_selection_from_region ()
                return;
        }
 
-       selection->set (0, selection->regions.start(), selection->regions.end_frame());
+       selection->set (selection->regions.start(), selection->regions.end_frame());
        if (!Profile->get_sae()) {
                set_mouse_mode (Editing::MouseRange, false);
        }
@@ -1066,7 +1059,7 @@ void
 Editor::set_selection_from_range (Location& loc)
 {
        begin_reversible_command (_("set selection from range"));
-       selection->set (0, loc.start(), loc.end());
+       selection->set (loc.start(), loc.end());
        commit_reversible_command ();
 
        if (!Profile->get_sae()) {
@@ -1293,7 +1286,7 @@ Editor::select_range_between ()
        }
 
        set_mouse_mode (MouseRange);
-       selection->set ((TimeAxisView*) 0, start, end);
+       selection->set (start, end);
 }
 
 bool
index 1a0b1305c738e1ea0e38edff5af1b9e72aa04108..da706a34d7a4b344866ebd98cadb1b716616e1b6 100644 (file)
@@ -64,8 +64,6 @@ operator== (const Selection& a, const Selection& b)
 {
        return a.regions == b.regions &&
                a.tracks == b.tracks &&
-               a.time.track == b.time.track &&
-               a.time.group == b.time.group &&
                a.time == b.time &&
                a.lines == b.lines &&
                a.playlists == b.playlists &&
@@ -139,8 +137,6 @@ Selection::clear_midi_regions ()
 void
 Selection::clear_time ()
 {
-       time.track = 0;
-       time.group = 0;
        time.clear();
 
        TimeChanged ();
@@ -729,8 +725,11 @@ Selection::set (vector<RegionView*>& v)
        add (v);
 }
 
+/** Set the start and end time of the time selection, without changing
+ *  the list of tracks it applies to.
+ */
 long
-Selection::set (TimeAxisView* track, nframes_t start, nframes_t end)
+Selection::set (nframes_t start, nframes_t end)
 {
        if ((start == 0 && end == 0) || end < start) {
                return 0;
@@ -748,14 +747,6 @@ Selection::set (TimeAxisView* track, nframes_t start, nframes_t end)
                time.front().end = end;
        }
 
-       if (track) {
-               time.track = track;
-               time.group = track->route_group();
-       } else {
-               time.track = 0;
-               time.group = 0;
-       }
-
        time.consolidate ();
 
        TimeChanged ();
index 279b8df59b708bc06e131da8d3498081d003aa66..f95b1dbfbea6efea414e332cb0ea81b4398a9a02 100644 (file)
@@ -117,7 +117,7 @@ class Selection : public sigc::trackable
        void set (RegionView*, bool also_clear_tracks = true);
        void set (MidiRegionView*);
        void set (std::vector<RegionView*>&);
-       long set (TimeAxisView*, nframes_t, nframes_t);
+       long set (nframes_t, nframes_t);
        void set (boost::shared_ptr<Evoral::ControlList>);
        void set (boost::shared_ptr<ARDOUR::Playlist>);
        void set (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&);
index 51dfb81ec02a9abddf5fb1d071bff9b8a4c00bb3..b8d7b3b9e02517dc1a567f7bcd4d705d28bfa748 100644 (file)
@@ -619,12 +619,6 @@ TimeAxisView::set_selected (bool yn)
                controls_ebox.set_name (controls_base_selected_name);
                controls_hbox.set_name (controls_base_selected_name);
                controls_vbox.set_name (controls_base_selected_name);
-               /* propagate any existing selection, if the mode is right */
-
-               if (_editor.current_mouse_mode() == Editing::MouseRange && !_editor.get_selection().time.empty()) {
-                       show_selection (_editor.get_selection().time);
-               }
-
        } else {
                controls_ebox.set_name (controls_base_unselected_name);
                controls_hbox.set_name (controls_base_unselected_name);
index 19fc321f785a5378f0899f1d625841cabdd52133..185c7e1eeadf06112e8009df0814b16c48f18dcd 100644 (file)
@@ -105,4 +105,3 @@ TimeSelection::length()
 {
        return end_frame() - start() + 1;
 }
-
index 819a85e80951e9ca13fdd802d6dbd550a482c0ac..f93f40c21e4004eaa583dae58391fd7a5257cafa 100644 (file)
@@ -27,30 +27,16 @@ namespace ARDOUR {
        class RouteGroup;
 }
 
-class TimeAxisView;
-
-struct TimeSelection : public std::list<ARDOUR::AudioRange> {
-
-    /* if (track == 0 && group == 0) then it applies to all
-       tracks.
-
-       if (track != 0 && group == 0) then it applies just to
-       that track.
-
-       if (group != 0) then it applies to all tracks in
-       the group.
-    */
-
-    TimeAxisView*               track;
-    ARDOUR::RouteGroup*         group;
-
-    ARDOUR::AudioRange& operator[](uint32_t);
-
-    nframes_t start();
-    nframes_t end_frame();
-    nframes_t length();
-
-    bool consolidate ();
+class TimeSelection : public std::list<ARDOUR::AudioRange>
+{
+public:
+       ARDOUR::AudioRange& operator[](uint32_t);
+       
+       nframes_t start();
+       nframes_t end_frame();
+       nframes_t length();
+       
+       bool consolidate ();
 };