13
0

Update 'Cut time' to match 'Insert time', and fix cut-time moving range markers

Add options to move glued & locked markers to Editor::cut_time(), in line
with the insert_time() implementation.

Fix up the order in which operations apply to range marker start & end
points, to avoid problems when a range which lies after the cut point is
shorter than the length of the cut.
This commit is contained in:
Colin Fletcher 2015-06-15 16:07:30 +01:00
parent e234e98f13
commit 721608aef3
2 changed files with 43 additions and 22 deletions

View File

@ -1263,7 +1263,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void insert_time (framepos_t, framecnt_t, Editing::InsertTimeOption, bool, bool, bool, bool, bool, bool); void insert_time (framepos_t, framecnt_t, Editing::InsertTimeOption, bool, bool, bool, bool, bool, bool);
void do_cut_time (); void do_cut_time ();
void cut_time (framepos_t pos, framecnt_t distance, Editing::InsertTimeOption opt, bool ignore_music_glue, bool markers_too, bool tempo_too); void cut_time (framepos_t pos, framecnt_t distance, Editing::InsertTimeOption opt, bool ignore_music_glue, bool markers_too,
bool glued_markers_too, bool locked_markers_too, bool tempo_too);
void tab_to_transient (bool forward); void tab_to_transient (bool forward);

View File

@ -7093,13 +7093,15 @@ Editor::do_cut_time ()
SplitIntersected, SplitIntersected,
d.move_glued(), d.move_glued(),
d.move_markers(), d.move_markers(),
d.move_glued_markers(),
d.move_locked_markers(),
d.move_tempos() d.move_tempos()
); );
} }
void void
Editor::cut_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt, Editor::cut_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt,
bool ignore_music_glue, bool markers_too, bool tempo_too) bool ignore_music_glue, bool markers_too, bool glued_markers_too, bool locked_markers_too, bool tempo_too)
{ {
bool commit = false; bool commit = false;
@ -7147,29 +7149,42 @@ Editor::cut_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt,
Locations::LocationList copy (_session->locations()->list()); Locations::LocationList copy (_session->locations()->list());
for (Locations::LocationList::iterator i = copy.begin(); i != copy.end(); ++i) { for (Locations::LocationList::iterator i = copy.begin(); i != copy.end(); ++i) {
if ((*i)->position_lock_style() == AudioTime || glued_markers_too) {
if (!(*i)->is_mark()) { //range; have to handle both start and end bool const was_locked = (*i)->locked ();
if (locked_markers_too) {
(*i)->unlock ();
}
if (!(*i)->is_mark()) { // it's a range; have to handle both start and end
if ((*i)->end() >= pos if ((*i)->end() >= pos
&& (*i)->end() < pos+frames && (*i)->end() < pos+frames
&& (*i)->start() >= pos && (*i)->start() >= pos
&& (*i)->end() < pos+frames) { // range is completely enclosed; kill it && (*i)->end() < pos+frames) { // range is completely enclosed; kill it
moved = true; moved = true;
loc_kill_list.push_back(*i); loc_kill_list.push_back(*i);
} else { //ony start or end is included, try to do the right thing } else { // only start or end is included, try to do the right thing
// move start before moving end, to avoid trying to move the end to before the start
// if we're removing more time than the length of the range
if ((*i)->start() >= pos && (*i)->start() < pos+frames) {
// start is within cut
(*i)->set_start (pos); // bring the start marker to the beginning of the cut
moved = true;
} else if ((*i)->start() >= pos+frames) {
// start (and thus entire range) lies beyond end of cut
(*i)->set_start ((*i)->start() - frames); // slip the start marker back
moved = true;
}
if ((*i)->end() >= pos && (*i)->end() < pos+frames) { if ((*i)->end() >= pos && (*i)->end() < pos+frames) {
// end is inside cut
(*i)->set_end (pos); // bring the end to the cut (*i)->set_end (pos); // bring the end to the cut
moved = true; moved = true;
} else if ((*i)->end() >= pos) { } else if ((*i)->end() >= pos+frames) {
// end is beyond end of cut
(*i)->set_end ((*i)->end() - frames); // slip the end marker back (*i)->set_end ((*i)->end() - frames); // slip the end marker back
moved = true; moved = true;
} }
if ((*i)->start() >= pos && (*i)->start() < pos+frames) {
(*i)->set_start (pos); //bring the start marker to the beginning of the cut
moved = true;
} else if ((*i)->start() >= pos) {
(*i)->set_start ((*i)->start() -frames); //slip the end marker back
moved = true;
}
} }
} else if ((*i)->start() >= pos && (*i)->start() < pos+frames ) { } else if ((*i)->start() >= pos && (*i)->start() < pos+frames ) {
loc_kill_list.push_back(*i); loc_kill_list.push_back(*i);
@ -7178,6 +7193,11 @@ Editor::cut_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt,
(*i)->set_start ((*i)->start() -frames); (*i)->set_start ((*i)->start() -frames);
moved = true; moved = true;
} }
if (was_locked) {
(*i)->lock ();
}
}
} }
for (list<Location*>::iterator i = loc_kill_list.begin(); i != loc_kill_list.end(); ++i) { for (list<Location*>::iterator i = loc_kill_list.begin(); i != loc_kill_list.end(); ++i) {