summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_selection.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-11-12 22:23:01 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-11-12 22:23:01 +0000
commitb01bdb7e70f021da764e81a4b55722e746e4885d (patch)
tree3f22af0fc8399bedd6843f7a9a4383295ac7b3cb /gtk2_ardour/editor_selection.cc
parent99d002dbdf2563bcad880628e7876aebe191ba0c (diff)
merged with trunk revs 2605-2627
git-svn-id: svn://localhost/ardour2/trunk@2628 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_selection.cc')
-rw-r--r--gtk2_ardour/editor_selection.cc124
1 files changed, 111 insertions, 13 deletions
diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc
index 12ca558ea4..554f5c341d 100644
--- a/gtk2_ardour/editor_selection.cc
+++ b/gtk2_ardour/editor_selection.cc
@@ -969,25 +969,45 @@ Editor::select_all_selectables_using_cursor (Cursor *cursor, bool after)
}
void
-Editor::select_all_selectables_between_cursors (Cursor *cursor, Cursor *other_cursor)
+Editor::select_all_selectables_using_edit (bool after)
{
nframes_t start;
nframes_t end;
list<Selectable *> touched;
- bool other_cursor_is_first = cursor->current_frame > other_cursor->current_frame;
- if (cursor->current_frame == other_cursor->current_frame) {
- return;
+ if (after) {
+ begin_reversible_command (_("select all after edit"));
+ start = get_preferred_edit_position();
+ end = session->current_end_frame();
+ } else {
+ if ((end = get_preferred_edit_position()) > 1) {
+ begin_reversible_command (_("select all before edit"));
+ start = 0;
+ end -= 1;
+ } else {
+ return;
+ }
}
- begin_reversible_command (_("select all between cursors"));
- if (other_cursor_is_first) {
- start = other_cursor->current_frame;
- end = cursor->current_frame - 1;
-
- } else {
- start = cursor->current_frame;
- end = other_cursor->current_frame - 1;
+ for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
+ if ((*iter)->hidden()) {
+ continue;
+ }
+ (*iter)->get_selectables (start, end, 0, DBL_MAX, touched);
+ }
+ selection->set (touched);
+ commit_reversible_command ();
+}
+
+void
+Editor::select_all_selectables_between (bool within)
+{
+ nframes64_t start;
+ nframes64_t end;
+ list<Selectable *> touched;
+
+ if (!get_edit_op_range (start, end)) {
+ return;
}
for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
@@ -996,7 +1016,85 @@ Editor::select_all_selectables_between_cursors (Cursor *cursor, Cursor *other_cu
}
(*iter)->get_selectables (start, end, 0, DBL_MAX, touched);
}
+
selection->set (touched);
- commit_reversible_command ();
}
+void
+Editor::select_range_between ()
+{
+ nframes64_t start;
+ nframes64_t end;
+
+ if (!get_edit_op_range (start, end)) {
+ return;
+ }
+
+ set_mouse_mode (MouseRange);
+ selection->set (0, start, end);
+}
+
+bool
+Editor::get_edit_op_range (nframes64_t& start, nframes64_t& end) const
+{
+ nframes64_t m;
+ bool ignored;
+
+ /* in range mode, use any existing selection */
+
+ if (mouse_mode == MouseRange && !selection->time.empty()) {
+ /* we know that these are ordered */
+ start = selection->time.start();
+ end = selection->time.end_frame();
+ return true;
+ }
+
+ if (!mouse_frame (m, ignored)) {
+ /* mouse is not in a canvas, try playhead+selected marker.
+ this is probably most true when using menus.
+ */
+
+ if (selection->markers.empty()) {
+ return false;
+ }
+
+ start = selection->markers.front()->position();
+ end = session->audible_frame();
+
+ } else {
+
+ switch (_edit_point) {
+ case EditAtPlayhead:
+ if (selection->markers.empty()) {
+ /* use mouse + playhead */
+ start = m;
+ end = session->audible_frame();
+ } else {
+ /* use playhead + selected marker */
+ start = session->audible_frame();
+ end = selection->markers.front()->position();
+ }
+ break;
+
+ case EditAtMouse:
+ case EditAtSelectedMarker:
+ /* use mouse + selected marker */
+ if (selection->markers.empty()) {
+ return false;
+ }
+ start = selection->markers.front()->position();
+ end = m;
+ break;
+ }
+ }
+
+ if (start == end) {
+ return false;
+ }
+
+ if (start > end) {
+ swap (start, end);
+ }
+
+ return true;
+}