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
This commit is contained in:
Carl Hetherington 2011-04-17 13:55:41 +00:00
parent 47018e771d
commit 80abf7693e
8 changed files with 126 additions and 88 deletions

View File

@ -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'/>

View File

@ -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)));

View File

@ -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;

View File

@ -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)));

View File

@ -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)
{
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->regions.empty()) {
rv = *(selection->regions.begin());
(*tv) = &rv->get_time_axis_view();
region = rv->region();
} else if (!selection->tracks.empty()) {
(*tv) = selection->tracks.front();
RouteTimeAxisView* rtv;
if ((rtv = dynamic_cast<RouteTimeAxisView*> (*tv)) != 0) {
boost::shared_ptr<Playlist> pl;
if ((pl = rtv->playlist()) == 0) {
return region;
}
region = pl->top_region_at (start);
}
}
return region;
}
/** 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::extend_selection_to_end_of_region (bool next)
Editor::move_range_selection_start_or_end_to_region_boundary (bool move_end, bool next)
{
TimeAxisView *tv;
boost::shared_ptr<Region> region;
framepos_t start;
if ((region = select_region_for_operation (next ? 1 : 0, &tv)) == 0) {
if (selection->time.start() == selection->time.end_frame()) {
return;
}
if (region && selection->time.start () == selection->time.end_frame ()) {
start = region->position();
} else {
start = selection->time.start ();
framepos_t start = selection->time.start ();
framepos_t end = selection->time.end_frame ();
/* the position of the thing we may move */
framepos_t pos = move_end ? end : start;
int dir = next ? 1 : -1;
/* so we don't find the current region again */
if (dir > 0 || pos > 0) {
pos += dir;
}
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) {
framepos_t const target = get_region_boundary (pos, dir, false, false);
if (target < 0) {
return;
}
if (region && selection->time.start () == selection->time.end_frame ()) {
end = region->position() + region->length();
if (move_end) {
end = target;
} else {
end = selection->time.end_frame ();
start = target;
}
/* Try to leave the selection with the same route if possible */
begin_reversible_command (_("extend selection"));
selection->set (region->position(), end);
if (end < start) {
return;
}
begin_reversible_command (_("alter selection"));
selection->set_preserving_all_ranges (start, end);
commit_reversible_command ();
}

View File

@ -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

View File

@ -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)
{

View File

@ -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> >&);