summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_ops.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-04-17 13:55:41 +0000
committerCarl Hetherington <carl@carlh.net>2011-04-17 13:55:41 +0000
commit80abf7693e63da5fba3426c8a32d7d65d6734a8b (patch)
tree7f7eec6daa54adbef0069a2304a44cadb94a8705 /gtk2_ardour/editor_ops.cc
parent47018e771da7a4e9cb8c15e172259928d15f22a4 (diff)
Remove extend-range-to-{start,end}-of-region and replace with move-range-{start,end}-to-{previous,next}-region boundary after discussions with Chris. Seems to make more sense, and works without the need for a region selection, which is fiddly to adjust when one is in range mode.
git-svn-id: svn://localhost/ardour2/branches/3.0@9360 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_ops.cc')
-rw-r--r--gtk2_ardour/editor_ops.cc100
1 files changed, 29 insertions, 71 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index a1bb3c0c99..288802a5a7 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -204,92 +204,50 @@ Editor::split_regions_at (framepos_t where, RegionSelection& regions)
}
}
-boost::shared_ptr<Region>
-Editor::select_region_for_operation (int /*dir*/, TimeAxisView **tv)
+/** Move one extreme of the current range selection. If more than one range is selected,
+ * the start of the earliest range or the end of the latest range is moved.
+ *
+ * @param move_end true to move the end of the current range selection, false to move
+ * the start.
+ * @param next true to move the extreme to the next region boundary, false to move to
+ * the previous.
+ */
+void
+Editor::move_range_selection_start_or_end_to_region_boundary (bool move_end, bool next)
{
- RegionView* rv;
- boost::shared_ptr<Region> region;
- framepos_t start = 0;
-
- if (selection->time.start () == selection->time.end_frame ()) {
-
- /* no current selection-> is there a selected regionview? */
-
- if (selection->regions.empty()) {
- return region;
- }
-
+ if (selection->time.start() == selection->time.end_frame()) {
+ return;
}
- if (!selection->regions.empty()) {
-
- rv = *(selection->regions.begin());
- (*tv) = &rv->get_time_axis_view();
- region = rv->region();
+ framepos_t start = selection->time.start ();
+ framepos_t end = selection->time.end_frame ();
- } else if (!selection->tracks.empty()) {
-
- (*tv) = selection->tracks.front();
-
- RouteTimeAxisView* rtv;
-
- if ((rtv = dynamic_cast<RouteTimeAxisView*> (*tv)) != 0) {
- boost::shared_ptr<Playlist> pl;
+ /* the position of the thing we may move */
+ framepos_t pos = move_end ? end : start;
+ int dir = next ? 1 : -1;
- if ((pl = rtv->playlist()) == 0) {
- return region;
- }
-
- region = pl->top_region_at (start);
- }
+ /* so we don't find the current region again */
+ if (dir > 0 || pos > 0) {
+ pos += dir;
}
- return region;
-}
-
-void
-Editor::extend_selection_to_end_of_region (bool next)
-{
- TimeAxisView *tv;
- boost::shared_ptr<Region> region;
- framepos_t start;
-
- if ((region = select_region_for_operation (next ? 1 : 0, &tv)) == 0) {
+ framepos_t const target = get_region_boundary (pos, dir, false, false);
+ if (target < 0) {
return;
}
- if (region && selection->time.start () == selection->time.end_frame ()) {
- start = region->position();
+ if (move_end) {
+ end = target;
} else {
- start = selection->time.start ();
+ start = target;
}
- begin_reversible_command (_("extend selection"));
- selection->set (start, region->position() + region->length());
- commit_reversible_command ();
-}
-
-void
-Editor::extend_selection_to_start_of_region (bool previous)
-{
- TimeAxisView *tv;
- boost::shared_ptr<Region> region;
- framepos_t end;
-
- if ((region = select_region_for_operation (previous ? -1 : 0, &tv)) == 0) {
+ if (end < start) {
return;
}
-
- if (region && selection->time.start () == selection->time.end_frame ()) {
- end = region->position() + region->length();
- } else {
- end = selection->time.end_frame ();
- }
-
- /* Try to leave the selection with the same route if possible */
-
- begin_reversible_command (_("extend selection"));
- selection->set (region->position(), end);
+
+ begin_reversible_command (_("alter selection"));
+ selection->set_preserving_all_ranges (start, end);
commit_reversible_command ();
}