From bdc1920166c34d1fd5a8f37c96870a476016db4c Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Sun, 7 Aug 2022 11:13:45 +0200 Subject: [PATCH] Clone with copy attributes Two modes of cloning: from the source panel with 'Clone & filter' clones with copy of attributes (geometry, alpha, etc.), from the Insert source panel with 'Internal' source creates a fresh new copy. --- Mixer.cpp | 16 ++++++++++++---- Mixer.h | 2 +- UserInterfaceManager.cpp | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Mixer.cpp b/Mixer.cpp index d3e585e..d3de9d0 100644 --- a/Mixer.cpp +++ b/Mixer.cpp @@ -396,7 +396,7 @@ Source * Mixer::createSourceGroup() return s; } -Source * Mixer::createSourceClone(const std::string &namesource) +Source * Mixer::createSourceClone(const std::string &namesource, bool copy_attributes) { // ready to create a source Source *s = nullptr; @@ -412,9 +412,17 @@ Source * Mixer::createSourceClone(const std::string &namesource) if (origin != session_->end()) { // create a source s = (*origin)->clone(); - // place clone next to origin - s->group(View::MIXING)->translation_ = (*origin)->group(View::MIXING)->translation_; - s->group(View::LAYER)->translation_ = (*origin)->group(View::LAYER)->translation_ + LAYER_STEP; + + // if clone operation asks to copy attributes + if (copy_attributes) { + // place clone next to origin + s->group(View::MIXING)->translation_ = (*origin)->group(View::MIXING)->translation_; + s->group(View::LAYER)->translation_ = (*origin)->group(View::LAYER)->translation_ + LAYER_STEP; + // copy geometry (overlap) + s->group(View::GEOMETRY)->translation_ = (*origin)->group(View::GEOMETRY)->translation_; + s->group(View::GEOMETRY)->scale_ = (*origin)->group(View::GEOMETRY)->scale_; + s->group(View::GEOMETRY)->rotation_ = (*origin)->group(View::GEOMETRY)->rotation_; + } } return s; diff --git a/Mixer.h b/Mixer.h index 39a05e3..92cf39a 100644 --- a/Mixer.h +++ b/Mixer.h @@ -49,7 +49,7 @@ public: // creation of sources Source * createSourceFile (const std::string &path); Source * createSourceMultifile(const std::list &list_files, uint fps); - Source * createSourceClone (const std::string &namesource = ""); + Source * createSourceClone (const std::string &namesource = "", bool copy_attributes = true); Source * createSourceRender (); Source * createSourceStream (const std::string &gstreamerpipeline); Source * createSourcePattern(uint pattern, glm::ivec2 res); diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 76b5f18..b6a7ee6 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -6652,7 +6652,7 @@ void Navigator::RenderNewPannel() label = std::string("Source ") + (*iter)->initials() + " - " + (*iter)->name(); if (ImGui::Selectable( label.c_str() )) { label = std::string("Clone of ") + label; - new_source_preview_.setSource( Mixer::manager().createSourceClone((*iter)->name()),label); + new_source_preview_.setSource( Mixer::manager().createSourceClone((*iter)->name(), false),label); } } ImGui::EndCombo();