Prototype region comp by muting layers

This commit is contained in:
Robin Gareus 2025-08-13 02:56:48 +02:00
parent 4b4cd5710f
commit 53aa6576e8
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
4 changed files with 69 additions and 0 deletions

View file

@ -1626,6 +1626,7 @@ private:
void set_playhead_cursor ();
void toggle_region_mute ();
void region_mute_comp ();
void initialize_canvas ();

View file

@ -8647,6 +8647,71 @@ Editor::toggle_region_mute ()
commit_reversible_command ();
}
void
Editor::region_mute_comp ()
{
if (_ignore_region_action) {
return;
}
RegionSelection rs = selection->regions;
if (rs.empty ()) {
return;
}
if (rs.size() > 1) {
begin_reversible_command (_("mute/comp regions"));
} else {
begin_reversible_command (_("mute/comp region"));
}
bool changed = false;
/* unmute selected region(s),
* mute other regions in the playlist at the same position
*/
for (auto const& region_view : rs) {
std::shared_ptr<Region> r = region_view->region ();
std::shared_ptr<Playlist> p = r->playlist ();
if (r->muted ()) {
r->clear_changes ();
r->set_muted (false);
_session->add_command (new StatefulDiffCommand (r));
changed = true;
}
/* p->get_equivalent_regions (r, equivalent_regions); with Config->get_region_equivalence () == Exact */
vector<std::shared_ptr<Region>> equivalent_regions;
std::shared_ptr<RegionList> rl = p->region_list ();
for (auto const& ri : *rl) {
if (ri->exact_equivalent (r)) {
equivalent_regions.push_back (ri);
}
}
for (auto const& ri: equivalent_regions) {
if (r == ri) {
continue;
}
if (!ri->muted ()) {
ri->clear_changes ();
ri->set_muted (true);
_session->add_command (new StatefulDiffCommand (ri));
changed = true;
}
}
}
if (changed) {
commit_reversible_command ();
} else {
abort_reversible_command ();
}
}
void
Editor::combine_regions ()
{

View file

@ -1031,6 +1031,8 @@ LuaInstance::register_classes (lua_State* L, bool sandbox)
//.addFunction ("get_preferred_edit_position", &PublicEditor::get_preferred_edit_position)
//.addFunction ("split_regions_at", &PublicEditor::split_regions_at)
.addFunction ("region_mute_comp", &PublicEditor::region_mute_comp)
.addFunction ("get_paste_offset", &PublicEditor::get_paste_offset)
.addFunction ("toggle_ruler_video", &PublicEditor::toggle_ruler_video)

View file

@ -300,6 +300,7 @@ public:
virtual void maximise_editing_space () = 0;
virtual void restore_editing_space () = 0;
virtual void toggle_meter_updating() = 0;
virtual void region_mute_comp () = 0;
virtual void split_regions_at (Temporal::timepos_t const &, RegionSelection&) = 0;
virtual void split_region_at_points (std::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret, bool select_new = false) = 0;
virtual void foreach_time_axis_view (sigc::slot<void,TimeAxisView&>) = 0;