summaryrefslogtreecommitdiff
path: root/gtk2_ardour
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
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')
-rw-r--r--gtk2_ardour/ardour.menus.in6
-rw-r--r--gtk2_ardour/editor.cc34
-rw-r--r--gtk2_ardour/editor.h4
-rw-r--r--gtk2_ardour/editor_actions.cc31
-rw-r--r--gtk2_ardour/editor_ops.cc100
-rw-r--r--gtk2_ardour/mnemonic-us.bindings.in6
-rw-r--r--gtk2_ardour/selection.cc28
-rw-r--r--gtk2_ardour/selection.h1
8 files changed, 124 insertions, 86 deletions
diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in
index 7e6c16a50e..29aaf16757 100644
--- a/gtk2_ardour/ardour.menus.in
+++ b/gtk2_ardour/ardour.menus.in
@@ -165,8 +165,10 @@
<menuitem action='select-all-in-loop-range'/>
<separator/>
<menuitem action='select-range-between-cursors'/>
- <menuitem action='extend-range-to-start-of-region'/>
- <menuitem action='extend-range-to-end-of-region'/>
+ <menuitem action='move-range-start-to-previous-region-boundary'/>
+ <menuitem action='move-range-start-to-next-region-boundary'/>
+ <menuitem action='move-range-end-to-previous-region-boundary'/>
+ <menuitem action='move-range-end-to-next-region-boundary'/>
<menuitem action='start-range'/>
<menuitem action='finish-range'/>
<menuitem action='finish-add-range'/>
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 91a391cc1c..f0719676a2 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -1803,12 +1803,36 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
edit_items.push_back (SeparatorElem());
edit_items.push_back (MenuElem (_("Spectral Analysis"), sigc::mem_fun(*this, &Editor::analyze_range_selection)));
- if (!selection->regions.empty()) {
- edit_items.push_back (SeparatorElem());
- edit_items.push_back (MenuElem (_("Extend Range to End of Region"), sigc::bind (sigc::mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
- edit_items.push_back (MenuElem (_("Extend Range to Start of Region"), sigc::bind (sigc::mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
- }
+ edit_items.push_back (SeparatorElem());
+ edit_items.push_back (
+ MenuElem (
+ _("Move Range Start to Previous Region Boundary"),
+ sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), false, false)
+ )
+ );
+
+ edit_items.push_back (
+ MenuElem (
+ _("Move Range Start to Next Region Boundary"),
+ sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), false, true)
+ )
+ );
+
+ edit_items.push_back (
+ MenuElem (
+ _("Move Range End to Previous Region Boundary"),
+ sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), true, false)
+ )
+ );
+
+ edit_items.push_back (
+ MenuElem (
+ _("Move Range End to Next Region Boundary"),
+ sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), true, true)
+ )
+ );
+
edit_items.push_back (SeparatorElem());
edit_items.push_back (MenuElem (_("Convert to Region In-Place"), mem_fun(*this, &Editor::separate_region_from_selection)));
edit_items.push_back (MenuElem (_("Convert to Region in Region List"), sigc::mem_fun(*this, &Editor::new_region_from_selection)));
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 6ac0319453..80f3f6182a 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -1286,9 +1286,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
bool have_pending_keyboard_selection;
framepos_t pending_keyboard_selection_start;
- boost::shared_ptr<ARDOUR::Region> select_region_for_operation (int dir, TimeAxisView **tv);
- void extend_selection_to_end_of_region (bool next);
- void extend_selection_to_start_of_region (bool previous);
+ void move_range_selection_start_or_end_to_region_boundary (bool, bool);
Editing::SnapType _snap_type;
Editing::SnapMode _snap_mode;
diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc
index 7f3d6db148..e557fe7999 100644
--- a/gtk2_ardour/editor_actions.cc
+++ b/gtk2_ardour/editor_actions.cc
@@ -315,9 +315,34 @@ Editor::register_actions ()
reg_sens (editor_actions, "finish-range", _("Finish Range"), sigc::bind (sigc::mem_fun(*this, &Editor::keyboard_selection_finish), false));
reg_sens (editor_actions, "finish-add-range", _("Finish Add Range"), sigc::bind (sigc::mem_fun(*this, &Editor::keyboard_selection_finish), true));
- reg_sens (editor_actions, "extend-range-to-end-of-region", _("Extend Range to End of Region"), sigc::bind (sigc::mem_fun(*this, &Editor::extend_selection_to_end_of_region), false));
- reg_sens (editor_actions, "extend-range-to-start-of-region", _("Extend Range to Start of Region"), sigc::bind (sigc::mem_fun(*this, &Editor::extend_selection_to_start_of_region), false));
-
+ reg_sens (
+ editor_actions,
+ "move-range-start-to-previous-region-boundary",
+ _("Move Range Start to Previous Region Boundary"),
+ sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), false, false)
+ );
+
+ reg_sens (
+ editor_actions,
+ "move-range-start-to-next-region-boundary",
+ _("Move Range Start to Next Region Boundary"),
+ sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), false, true)
+ );
+
+ reg_sens (
+ editor_actions,
+ "move-range-end-to-previous-region-boundary",
+ _("Move Range End to Previous Region Boundary"),
+ sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), true, false)
+ );
+
+ reg_sens (
+ editor_actions,
+ "move-range-end-to-next-region-boundary",
+ _("Move Range End to Next Region Boundary"),
+ sigc::bind (sigc::mem_fun (*this, &Editor::move_range_selection_start_or_end_to_region_boundary), true, true)
+ );
+
toggle_reg_sens (editor_actions, "toggle-follow-playhead", _("Follow Playhead"), (sigc::mem_fun(*this, &Editor::toggle_follow_playhead)));
act = reg_sens (editor_actions, "remove-last-capture", _("Remove Last Capture"), (sigc::mem_fun(*this, &Editor::remove_last_capture)));
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 ();
}
diff --git a/gtk2_ardour/mnemonic-us.bindings.in b/gtk2_ardour/mnemonic-us.bindings.in
index f5d38e68a8..99bc729120 100644
--- a/gtk2_ardour/mnemonic-us.bindings.in
+++ b/gtk2_ardour/mnemonic-us.bindings.in
@@ -97,8 +97,10 @@ This mode provides many different operations on both regions and control points,
@eep|Editor/cycle-edit-point|grave|next EP w/o marker
@eep|Editor/cycle-edit-point-with-marker|<@PRIMARY@>asciicircum|next EP w/marker
-@aep|Editor/extend-range-to-end-of-region|rightanglebracket|align sync point relative
-@-group|Editor/extend-range-to-start-of-region|leftanglebracket|some text
+@aep|Editor/move-range-start-to-previous-region-boundary|less|move range start to previous region boundary
+@aep|Editor/move-range-start-to-next-region-boundary|<@PRIMARY@>less|move range start to next region boundary
+@aep|Editor/move-range-end-to-previous-region-boundary|greater|move range end to next region boundary
+@aep|Editor/move-range-end-to-next-region-boundary|<@PRIMARY@>greater|move range end to previous region boundary
@trans|Transport/ToggleRoll|space|toggle roll
@epp|Editor/play-edit-range|<@SECONDARY@>space|play edit range
diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc
index d0b2cab5c7..f734d07375 100644
--- a/gtk2_ardour/selection.cc
+++ b/gtk2_ardour/selection.cc
@@ -769,6 +769,34 @@ Selection::set (framepos_t start, framepos_t end)
return time.front().id;
}
+/** Set the start and end of the range selection. If more than one range
+ * is currently selected, the start of the earliest range and the end of the
+ * latest range are set. If no range is currently selected, this method
+ * selects a single range from start to end.
+ *
+ * @param start New start time.
+ * @param end New end time.
+ */
+void
+Selection::set_preserving_all_ranges (framepos_t start, framepos_t end)
+{
+ if ((start == 0 && end == 0) || (end < start)) {
+ return;
+ }
+
+ if (time.empty ()) {
+ time.push_back (AudioRange (start, end, next_time_id++));
+ } else {
+ time.sort (AudioRangeComparator ());
+ time.front().start = start;
+ time.back().end = end;
+ }
+
+ time.consolidate ();
+
+ TimeChanged ();
+}
+
void
Selection::set (boost::shared_ptr<Evoral::ControlList> ac)
{
diff --git a/gtk2_ardour/selection.h b/gtk2_ardour/selection.h
index c9d3e9b759..ac3c9330f0 100644
--- a/gtk2_ardour/selection.h
+++ b/gtk2_ardour/selection.h
@@ -122,6 +122,7 @@ class Selection : public sigc::trackable, public PBD::ScopedConnectionList
void set (MidiRegionView*);
void set (std::vector<RegionView*>&);
long set (framepos_t, framepos_t);
+ void set_preserving_all_ranges (framepos_t, framepos_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> >&);