From 04c7158a415e9daa76a60a296891217eb0fb6c0c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 13 Dec 2009 21:27:19 +0000 Subject: Remove confusing track / group members in TimeSelection struct; time selection 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 | 10 ++-------- gtk2_ardour/editor_drag.cc | 19 +++++++++++++------ gtk2_ardour/editor_keys.cc | 2 +- gtk2_ardour/editor_mouse.cc | 10 +++------- gtk2_ardour/editor_ops.cc | 16 +++------------- gtk2_ardour/editor_selection.cc | 17 +++++------------ gtk2_ardour/selection.cc | 17 ++++------------- gtk2_ardour/selection.h | 2 +- gtk2_ardour/time_axis_view.cc | 6 ------ gtk2_ardour/time_selection.cc | 1 - gtk2_ardour/time_selection.h | 34 ++++++++++------------------------ 11 files changed, 42 insertions(+), 92 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 9ca44992c4..dd9cdf9582 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -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); } } diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 0e9b62aeb4..5ec2cb0439 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -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: diff --git a/gtk2_ardour/editor_keys.cc b/gtk2_ardour/editor_keys.cc index cbbe11f37b..b9df06d358 100644 --- a/gtk2_ardour/editor_keys.cc +++ b/gtk2_ardour/editor_keys.cc @@ -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; diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 78e5e9a145..cecddd092a 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -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; diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index be9538df68..4ed0354491 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -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")); diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index 8852271f11..59c020feae 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -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 diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index 1a0b1305c7..da706a34d7 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -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& 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 (); diff --git a/gtk2_ardour/selection.h b/gtk2_ardour/selection.h index 279b8df59b..f95b1dbfbe 100644 --- a/gtk2_ardour/selection.h +++ b/gtk2_ardour/selection.h @@ -117,7 +117,7 @@ class Selection : public sigc::trackable void set (RegionView*, bool also_clear_tracks = true); void set (MidiRegionView*); void set (std::vector&); - long set (TimeAxisView*, nframes_t, nframes_t); + long set (nframes_t, nframes_t); void set (boost::shared_ptr); void set (boost::shared_ptr); void set (const std::list >&); diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index 51dfb81ec0..b8d7b3b9e0 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -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); diff --git a/gtk2_ardour/time_selection.cc b/gtk2_ardour/time_selection.cc index 19fc321f78..185c7e1eea 100644 --- a/gtk2_ardour/time_selection.cc +++ b/gtk2_ardour/time_selection.cc @@ -105,4 +105,3 @@ TimeSelection::length() { return end_frame() - start() + 1; } - diff --git a/gtk2_ardour/time_selection.h b/gtk2_ardour/time_selection.h index 819a85e809..f93f40c21e 100644 --- a/gtk2_ardour/time_selection.h +++ b/gtk2_ardour/time_selection.h @@ -27,30 +27,16 @@ namespace ARDOUR { class RouteGroup; } -class TimeAxisView; - -struct TimeSelection : public std::list { - - /* 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 +{ +public: + ARDOUR::AudioRange& operator[](uint32_t); + + nframes_t start(); + nframes_t end_frame(); + nframes_t length(); + + bool consolidate (); }; -- cgit v1.2.3