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
This commit is contained in:
parent
af42b35e53
commit
d374469f4c
|
@ -2414,6 +2414,7 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op)
|
|||
(LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_FREE_NO_MAIN));
|
||||
|
||||
seqbase_clipboard_frame = scene->r.cfra;
|
||||
SEQ_clipboard_active_seq_name_store(scene);
|
||||
|
||||
/* Remove anything that references the current scene. */
|
||||
LISTBASE_FOREACH (Sequence *, seq, &seqbase_clipboard) {
|
||||
|
@ -2504,6 +2505,10 @@ static int sequencer_paste_exec(bContext *C, wmOperator *op)
|
|||
BLI_movelisttolist(ed->seqbasep, &nseqbase);
|
||||
|
||||
for (iseq = iseq_first; iseq; iseq = iseq->next) {
|
||||
if (SEQ_clipboard_pasted_seq_was_active(iseq)) {
|
||||
SEQ_select_active_set(scene, iseq);
|
||||
}
|
||||
|
||||
/* Make sure, that pasted strips have unique names. */
|
||||
SEQ_ensure_unique_name(iseq, scene);
|
||||
/* Translate after name has been changed, otherwise this will affect animdata of original
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
* \ingroup bke
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue