region groups: more fixes for drag-copy and range-paste operations

This commit is contained in:
Ben Loftis 2023-09-27 10:56:53 -05:00
parent 40a9ba746e
commit 72761734e8
5 changed files with 10 additions and 7 deletions

View File

@ -1059,7 +1059,7 @@ Editor::finish_bringing_in_material (std::shared_ptr<Region> region,
std::shared_ptr<Playlist> playlist = existing_track->playlist();
std::shared_ptr<Region> copy (RegionFactory::create (region, region->derive_properties ()));
copy->set_region_group(false);
copy->set_region_group(Region::get_retained_group_id());
playlist->clear_changes ();
playlist->clear_owned_changes ();
playlist->add_region (copy, pos);

View File

@ -1549,6 +1549,8 @@ RegionMoveDrag::motion (GdkEvent* event, bool first_move)
/* duplicate the regionview(s) and region(s) */
Region::RegionGroupRetainer rtr;
list<DraggingView> new_regionviews;
for (list<DraggingView>::const_iterator i = _views.begin (); i != _views.end (); ++i) {
@ -1560,6 +1562,7 @@ RegionMoveDrag::motion (GdkEvent* event, bool first_move)
std::shared_ptr<Region> region_copy;
region_copy = RegionFactory::create (original, true);
region_copy->set_region_group( Region::get_region_operation_group_id (original->region_group(), Paste));
/* need to set this so that the drop zone code can work. This doesn't
actually put the region into the playlist, but just sets a weak pointer

View File

@ -3126,7 +3126,7 @@ Editor::group_selected_regions ()
begin_reversible_command (_("group regions"));
for (RegionSelection::iterator i = rs.begin (); i != rs.end (); ++i) {
(*i)->region ()->clear_changes ();
(*i)->region ()->set_region_group (true);
(*i)->region ()->set_region_group (Region::get_retained_group_id(), true);
_session->add_command (new StatefulDiffCommand ((*i)->region ()));
}
commit_reversible_command ();
@ -3144,7 +3144,7 @@ Editor::ungroup_selected_regions ()
begin_reversible_command (_("ungroup regions"));
for (RegionSelection::iterator i = rs.begin (); i != rs.end (); ++i) {
(*i)->region ()->clear_changes ();
(*i)->region ()->unset_region_group ();
(*i)->region ()->unset_region_group (true);
_session->add_command (new StatefulDiffCommand ((*i)->region ()));
}
selection->clear_regions ();

View File

@ -209,8 +209,8 @@ public:
static uint64_t get_region_operation_group_id (uint64_t old_region_group, RegionOperationFlag flags);
uint64_t region_group () const { return _reg_group; }
void set_region_group (bool explicitly) { _reg_group = get_retained_group_id () | (explicitly ? Explicit : NoGroup); }
void unset_region_group () { _reg_group = Explicit; }
void set_region_group (uint64_t rg, bool explicitly = false) { _reg_group = rg | (explicitly ? Explicit : NoGroup); }
void unset_region_group (bool explicitly = false) { _reg_group = (explicitly ? Explicit : NoGroup); }
bool is_explicitly_grouped() { return (_reg_group & Explicit) == Explicit; }
bool is_implicitly_ungrouped() { return (_reg_group == NoGroup); }

View File

@ -1318,8 +1318,8 @@ Playlist::paste (std::shared_ptr<Playlist> other, timepos_t const & position, fl
for (auto const & r : other->regions) {
std::shared_ptr<Region> copy_of_region = RegionFactory::create (r, true, false, &rl1.thawlist);
/* we want newly-pasted regions to share one (implicit) group-id */
copy_of_region->set_region_group(false);
/* we want newly-pasted regions to retain prior group-sharing relationship, but with a new group-id */
copy_of_region->set_region_group (Region::get_region_operation_group_id(r->region_group(), Paste));
/* put these new regions on top of all existing ones, but preserve
the ordering they had in the original playlist.