summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Loftis <ben@harrisonconsoles.com>2014-07-05 20:47:43 -0500
committerBen Loftis <ben@harrisonconsoles.com>2014-07-05 20:47:43 -0500
commit0b38d65dd0d73fb92db3b3b82be5da3eab05afff (patch)
tree5d5d79efb183e029df1ee1d0627e15acc9eec476
parent62c3638a42690fa82c68416294fb9d4be7aac92d (diff)
new approach to selections which will help rationalize Split and similar functions. Object and Track selections are now mutually exclusive. a split will happen at (a) selection->regions (b) the intersection of edit_point and selection->tracks or (c) the region under the mouse, IFF nothing else is selected.
-rw-r--r--gtk2_ardour/editor.cc25
-rw-r--r--gtk2_ardour/editor_ops.cc12
-rw-r--r--gtk2_ardour/selection.cc35
3 files changed, 53 insertions, 19 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 5994305aa1..3c8ce77a15 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -4521,22 +4521,14 @@ Editor::get_regions_after (RegionSelection& rs, framepos_t where, const TrackVie
/** Get regions using the following method:
*
- * Make a region list using the selected regions, unless
- * the edit point is `mouse' and the mouse is over an unselected
- * region. In this case, use just that region.
+ * Make a region list using:
+ * (a) any selected regions
+ * (b) the intersection of any selected tracks and the edit point(*)
+ * (c) if neither exists, and edit_point == mouse, then whatever region is under the mouse
*
- * If the edit point is not 'mouse', and there are no regions selected,
- * search the list of selected tracks and return regions that are under
- * the edit point on these tracks. If there are no selected tracks and
- * 'No Selection = All Tracks' is active, search all tracks,
+ * (*) NOTE: in this case, if 'No Selection = All Tracks' is active, search all tracks
*
- * The rationale here is that the mouse edit point is special in that
- * its position describes both a time and a track; the other edit
- * modes only describe a time. Hence if the edit point is `mouse' we
- * ignore selected tracks, as we assume the user means something by
- * pointing at a particular track. Also in this case we take note of
- * the region directly under the edit point, as there is always just one
- * (rather than possibly several with non-mouse edit points).
+ * Note that we have forced the rule that selected regions and selected tracks are mutually exclusive
*/
RegionSelection
@@ -4544,13 +4536,13 @@ Editor::get_regions_from_selection_and_edit_point ()
{
RegionSelection regions;
- if (_edit_point == EditAtMouse && entered_regionview && !selection->regions.contains (entered_regionview)) {
+ if (_edit_point == EditAtMouse && entered_regionview && selection->tracks.empty() && selection->regions.empty() ) {
regions.add (entered_regionview);
} else {
regions = selection->regions;
}
- if (regions.empty() && _edit_point != EditAtMouse) {
+ if ( regions.empty() ) {
TrackViewList tracks = selection->tracks;
if (_route_groups->all_group_active_button().get_active() && tracks.empty()) {
@@ -4568,6 +4560,7 @@ Editor::get_regions_from_selection_and_edit_point ()
get_regions_at(regions, where, tracks);
}
}
+
return regions;
}
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 5326543567..e4d6c267e9 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -133,6 +133,8 @@ Editor::split_regions_at (framepos_t where, RegionSelection& regions)
{
bool frozen = false;
+ bool operating_on_region_selection = !selection->regions.empty();
+
list<boost::shared_ptr<Playlist> > used_playlists;
list<RouteTimeAxisView*> used_trackviews;
@@ -232,8 +234,12 @@ Editor::split_regions_at (framepos_t where, RegionSelection& regions)
EditorThaw(); /* Emit Signal */
}
- if (!latest_regionviews.empty()) {
- selection->add (latest_regionviews);
+ //IFF we had a selected region, then we should select both sides of the new region after the split.
+ //(if there is no region selection then we are working on a range selection, so no changes to region selection are necessary)
+ if( operating_on_region_selection ) {
+ if (!latest_regionviews.empty()) {
+ selection->add (latest_regionviews);
+ }
}
}
@@ -2788,7 +2794,7 @@ Editor::separate_regions_between (const TimeSelection& ts)
}
if (in_command) {
- selection->set (new_selection);
+// selection->set (new_selection);
commit_reversible_command ();
}
diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc
index 6465bb4d44..c279502d83 100644
--- a/gtk2_ardour/selection.cc
+++ b/gtk2_ardour/selection.cc
@@ -226,6 +226,7 @@ void
Selection::toggle (boost::shared_ptr<Playlist> pl)
{
clear_time(); //enforce object/range exclusivity
+ clear_tracks(); //enforce object/track exclusivity
PlaylistSelection::iterator i;
@@ -269,6 +270,7 @@ void
Selection::toggle (const MidiNoteSelection& midi_note_list)
{
clear_time(); //enforce object/range exclusivity
+ clear_tracks(); //enforce object/track exclusivity
for (MidiNoteSelection::const_iterator i = midi_note_list.begin(); i != midi_note_list.end(); ++i) {
toggle ((*i));
@@ -296,6 +298,7 @@ void
Selection::toggle (RegionView* r)
{
clear_time(); //enforce object/range exclusivity
+ clear_tracks(); //enforce object/track exclusivity
RegionSelection::iterator i;
@@ -312,6 +315,7 @@ void
Selection::toggle (MidiRegionView* mrv)
{
clear_time(); //enforce object/range exclusivity
+ clear_tracks(); //enforce object/track exclusivity
MidiRegionSelection::iterator i;
@@ -328,6 +332,7 @@ void
Selection::toggle (vector<RegionView*>& r)
{
clear_time(); //enforce object/range exclusivity
+ clear_tracks(); //enforce object/track exclusivity
RegionSelection::iterator i;
@@ -364,6 +369,7 @@ void
Selection::add (boost::shared_ptr<Playlist> pl)
{
clear_time(); //enforce object/range exclusivity
+ clear_tracks(); //enforce object/track exclusivity
if (find (playlists.begin(), playlists.end(), pl) == playlists.end()) {
pl->use ();
@@ -376,6 +382,7 @@ void
Selection::add (const list<boost::shared_ptr<Playlist> >& pllist)
{
clear_time(); //enforce object/range exclusivity
+ clear_tracks(); //enforce object/track exclusivity
bool changed = false;
@@ -420,6 +427,7 @@ void
Selection::add (const MidiNoteSelection& midi_list)
{
clear_time(); //enforce object/range exclusivity
+ clear_tracks(); //enforce object/track exclusivity
const MidiNoteSelection::const_iterator b = midi_list.begin();
const MidiNoteSelection::const_iterator e = midi_list.end();
@@ -445,6 +453,7 @@ void
Selection::add (vector<RegionView*>& v)
{
clear_time(); //enforce object/range exclusivity
+ clear_tracks(); //enforce object/track exclusivity
/* XXX This method or the add (const RegionSelection&) needs to go
*/
@@ -469,6 +478,7 @@ void
Selection::add (const RegionSelection& rs)
{
clear_time(); //enforce object/range exclusivity
+ clear_tracks(); //enforce object/track exclusivity
/* XXX This method or the add (const vector<RegionView*>&) needs to go
*/
@@ -493,6 +503,7 @@ void
Selection::add (RegionView* r)
{
clear_time(); //enforce object/range exclusivity
+ clear_tracks(); //enforce object/track exclusivity
if (find (regions.begin(), regions.end(), r) == regions.end()) {
bool changed = regions.add (r);
@@ -509,6 +520,7 @@ void
Selection::add (MidiRegionView* mrv)
{
clear_time(); //enforce object/range exclusivity
+ clear_tracks(); //enforce object/track exclusivity
if (find (midi_regions.begin(), midi_regions.end(), mrv) == midi_regions.end()) {
midi_regions.push_back (mrv);
@@ -581,6 +593,7 @@ void
Selection::add (boost::shared_ptr<Evoral::ControlList> cl)
{
clear_time(); //enforce object/range exclusivity
+ clear_tracks(); //enforce object/track exclusivity
boost::shared_ptr<ARDOUR::AutomationList> al
= boost::dynamic_pointer_cast<ARDOUR::AutomationList>(cl);
@@ -767,6 +780,7 @@ Selection::remove (boost::shared_ptr<ARDOUR::AutomationList> ac)
void
Selection::set (TimeAxisView* track)
{
+ clear_objects(); //enforce object/range exclusivity
clear_tracks ();
add (track);
}
@@ -774,6 +788,7 @@ Selection::set (TimeAxisView* track)
void
Selection::set (const TrackViewList& track_list)
{
+ clear_objects(); //enforce object/range exclusivity
clear_tracks ();
add (track_list);
}
@@ -782,6 +797,7 @@ void
Selection::set (const MidiNoteSelection& midi_list)
{
clear_time (); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
clear_objects ();
add (midi_list);
}
@@ -790,6 +806,7 @@ void
Selection::set (boost::shared_ptr<Playlist> playlist)
{
clear_time (); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
clear_objects ();
add (playlist);
}
@@ -806,6 +823,7 @@ void
Selection::set (const RegionSelection& rs)
{
clear_time(); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
clear_objects();
regions = rs;
RegionsChanged(); /* EMIT SIGNAL */
@@ -815,6 +833,7 @@ void
Selection::set (MidiRegionView* mrv)
{
clear_time(); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
clear_objects ();
add (mrv);
}
@@ -823,6 +842,7 @@ void
Selection::set (RegionView* r, bool also_clear_tracks)
{
clear_time(); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
clear_objects ();
if (also_clear_tracks && !Config->get_link_region_and_track_selection()) {
/* clear_regions() will have done this if the link preference
@@ -839,6 +859,7 @@ Selection::set (vector<RegionView*>& v)
bool had_regions = !regions.empty();
clear_time(); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
clear_objects();
if (Config->get_link_region_and_track_selection()) {
@@ -863,6 +884,7 @@ long
Selection::set (framepos_t start, framepos_t end)
{
clear_objects(); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
clear_time();
if ((start == 0 && end == 0) || end < start) {
@@ -922,6 +944,7 @@ void
Selection::set (boost::shared_ptr<Evoral::ControlList> ac)
{
clear_time(); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
clear_objects();
add (ac);
@@ -980,6 +1003,7 @@ void
Selection::toggle (ControlPoint* cp)
{
clear_time(); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
cp->set_selected (!cp->get_selected ());
PointSelection::iterator i = find (points.begin(), points.end(), cp);
@@ -996,6 +1020,7 @@ void
Selection::toggle (vector<ControlPoint*> const & cps)
{
clear_time(); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
for (vector<ControlPoint*>::const_iterator i = cps.begin(); i != cps.end(); ++i) {
toggle (*i);
@@ -1006,6 +1031,7 @@ void
Selection::toggle (list<Selectable*> const & selectables)
{
clear_time(); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
RegionView* rv;
ControlPoint* cp;
@@ -1038,6 +1064,7 @@ void
Selection::set (list<Selectable*> const & selectables)
{
clear_time (); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
clear_objects ();
if (Config->get_link_region_and_track_selection ()) {
@@ -1051,6 +1078,7 @@ void
Selection::add (PointSelection const & s)
{
clear_time (); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
for (PointSelection::const_iterator i = s.begin(); i != s.end(); ++i) {
points.push_back (*i);
@@ -1061,6 +1089,7 @@ void
Selection::add (list<Selectable*> const & selectables)
{
clear_time (); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
RegionView* rv;
ControlPoint* cp;
@@ -1102,6 +1131,7 @@ void
Selection::add (ControlPoint* cp)
{
clear_time (); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
cp->set_selected (true);
points.push_back (cp);
@@ -1112,6 +1142,7 @@ void
Selection::add (vector<ControlPoint*> const & cps)
{
clear_time (); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
for (vector<ControlPoint*>::const_iterator i = cps.begin(); i != cps.end(); ++i) {
(*i)->set_selected (true);
@@ -1124,6 +1155,7 @@ void
Selection::set (ControlPoint* cp)
{
clear_time (); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
if (cp->get_selected()) {
return;
@@ -1141,6 +1173,7 @@ void
Selection::set (Marker* m)
{
clear_time (); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
markers.clear ();
add (m);
@@ -1173,6 +1206,7 @@ void
Selection::add (Marker* m)
{
clear_time (); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
if (find (markers.begin(), markers.end(), m) == markers.end()) {
markers.push_back (m);
@@ -1184,6 +1218,7 @@ void
Selection::add (const list<Marker*>& m)
{
clear_time (); //enforce region/object exclusivity
+ clear_tracks(); //enforce object/track exclusivity
markers.insert (markers.end(), m.begin(), m.end());
markers.sort ();