From d374469f4c045355b2e5b17d7ba5dae9c979c8c7 Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Tue, 13 Jul 2021 12:53:56 +0200 Subject: VSE: Make pasted strip active When adding texts or various simple effects I often copy-paste strips to reuse properties from a template such as font or position. I assume this is common workflow. Issue with this workflow is, that active strip is not changed after pasting, so when adjusting property, it is original strip that is being modified. This is not issue when duplicating strips - selection state is transfered to duplicate strips, such that duplicate of active strip is set to be active and duplicate of selected strip is set to selected. Implement same selection transfering behavior in paste operator, that exists in duplicate operator. Since strip can be deleted after copying, it is not possible to rely on sequencer state. This is true even when pasting strips to different scene. Therefore active strip name must be stored in clipboard. Reviewed By: sergey, Severin Differential Revision: https://developer.blender.org/D11781 --- source/blender/sequencer/SEQ_clipboard.h | 4 ++++ source/blender/sequencer/intern/clipboard.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'source/blender/sequencer') diff --git a/source/blender/sequencer/SEQ_clipboard.h b/source/blender/sequencer/SEQ_clipboard.h index 4b2bf69a8ac..ea7f01e6ae3 100644 --- a/source/blender/sequencer/SEQ_clipboard.h +++ b/source/blender/sequencer/SEQ_clipboard.h @@ -29,12 +29,16 @@ extern "C" { struct ListBase; struct Main; +struct Scene; +struct Sequence; extern struct ListBase seqbase_clipboard; extern int seqbase_clipboard_frame; void SEQ_clipboard_pointers_store(struct Main *bmain, struct ListBase *seqbase); void SEQ_clipboard_pointers_restore(struct ListBase *seqbase, struct Main *bmain); void SEQ_clipboard_free(void); +void SEQ_clipboard_active_seq_name_store(struct Scene *scene); +bool SEQ_clipboard_pasted_seq_was_active(struct Sequence *pasted_seq); #ifdef __cplusplus } diff --git a/source/blender/sequencer/intern/clipboard.c b/source/blender/sequencer/intern/clipboard.c index e3f82dd4bb0..6c7cdbac7b5 100644 --- a/source/blender/sequencer/intern/clipboard.c +++ b/source/blender/sequencer/intern/clipboard.c @@ -24,6 +24,8 @@ * \ingroup bke */ +#include + #include "MEM_guardedalloc.h" #include "DNA_scene_types.h" @@ -31,6 +33,7 @@ #include "DNA_sound_types.h" #include "BLI_listbase.h" +#include "BLI_string.h" #include "BKE_main.h" #include "BKE_movieclip.h" @@ -38,6 +41,7 @@ #include "BKE_sound.h" #include "SEQ_clipboard.h" +#include "SEQ_select.h" #include "sequencer.h" @@ -55,6 +59,7 @@ ListBase seqbase_clipboard; int seqbase_clipboard_frame; +char seq_clipboard_active_seq_name[SEQ_NAME_MAXSTR]; void seq_clipboard_pointers_free(struct ListBase *seqbase); @@ -177,3 +182,27 @@ void SEQ_clipboard_pointers_restore(ListBase *seqbase, Main *bmain) SEQ_clipboard_pointers_restore(&seq->seqbase, bmain); } } + +void SEQ_clipboard_active_seq_name_store(Scene *scene) +{ + Sequence *active_seq = SEQ_select_active_get(scene); + if (active_seq != NULL) { + BLI_strncpy( + seq_clipboard_active_seq_name, active_seq->name, sizeof(seq_clipboard_active_seq_name)); + } + else { + memset(seq_clipboard_active_seq_name, 0, sizeof(seq_clipboard_active_seq_name)); + } +} + +/** + * Check if strip was active when it was copied. User should restrict this check to pasted strips + * before ensuring original name, because strip name comparison is used to check. + * + * \param pasted_seq: Strip that is pasted(duplicated) from clipboard + * \return true if strip was active, false otherwise + */ +bool SEQ_clipboard_pasted_seq_was_active(Sequence *pasted_seq) +{ + return STREQ(pasted_seq->name, seq_clipboard_active_seq_name); +} -- cgit v1.2.3