Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_sequencer/sequencer_modifier.c
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2012 Blender Foundation. All rights reserved. */ | * Copyright 2012 Blender Foundation. All rights reserved. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup spseq | * \ingroup spseq | ||||
| */ | */ | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_video_edit_types.h" | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| #include "RNA_enum_types.h" | #include "RNA_enum_types.h" | ||||
| #include "SEQ_iterator.h" | #include "SEQ_iterator.h" | ||||
| #include "SEQ_modifier.h" | #include "SEQ_modifier.h" | ||||
| #include "SEQ_relations.h" | #include "SEQ_relations.h" | ||||
| #include "SEQ_select.h" | #include "SEQ_select.h" | ||||
| #include "SEQ_sequencer.h" | #include "SEQ_sequencer.h" | ||||
| /* Own include. */ | /* Own include. */ | ||||
| #include "sequencer_intern.h" | #include "sequencer_intern.h" | ||||
| /*********************** Add modifier operator *************************/ | /*********************** Add modifier operator *************************/ | ||||
| static bool strip_modifier_active_poll(bContext *C) | static bool strip_modifier_active_poll(bContext *C) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Editing *ed = SEQ_editing_get(scene); | if (video_edit == NULL) { | ||||
| return false; | |||||
| if (ed) { | } | ||||
| Sequence *seq = SEQ_select_active_get(scene); | |||||
| Sequence *seq = SEQ_select_active_get(video_edit); | |||||
| if (seq) { | if (seq) { | ||||
| return SEQ_sequence_supports_modifiers(seq); | return SEQ_sequence_supports_modifiers(seq); | ||||
| } | } | ||||
| } | |||||
| return false; | return false; | ||||
| } | } | ||||
| static int strip_modifier_add_exec(bContext *C, wmOperator *op) | static int strip_modifier_add_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Sequence *seq = SEQ_select_active_get(scene); | Sequence *seq = SEQ_select_active_get(video_edit); | ||||
| int type = RNA_enum_get(op->ptr, "type"); | int type = RNA_enum_get(op->ptr, "type"); | ||||
| SEQ_modifier_new(seq, NULL, type); | SEQ_modifier_new(seq, NULL, type); | ||||
| SEQ_relations_invalidate_cache_preprocessed(scene, seq); | SEQ_relations_invalidate_cache_preprocessed(video_edit, seq); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void SEQUENCER_OT_strip_modifier_add(wmOperatorType *ot) | void SEQUENCER_OT_strip_modifier_add(wmOperatorType *ot) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| Show All 18 Lines | prop = RNA_def_enum(ot->srna, | ||||
| ""); | ""); | ||||
| ot->prop = prop; | ot->prop = prop; | ||||
| } | } | ||||
| /*********************** Remove modifier operator *************************/ | /*********************** Remove modifier operator *************************/ | ||||
| static int strip_modifier_remove_exec(bContext *C, wmOperator *op) | static int strip_modifier_remove_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Sequence *seq = SEQ_select_active_get(scene); | Sequence *seq = SEQ_select_active_get(video_edit); | ||||
| char name[MAX_NAME]; | char name[MAX_NAME]; | ||||
| SequenceModifierData *smd; | SequenceModifierData *smd; | ||||
| RNA_string_get(op->ptr, "name", name); | RNA_string_get(op->ptr, "name", name); | ||||
| smd = SEQ_modifier_find_by_name(seq, name); | smd = SEQ_modifier_find_by_name(seq, name); | ||||
| if (!smd) { | if (!smd) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| BLI_remlink(&seq->modifiers, smd); | BLI_remlink(&seq->modifiers, smd); | ||||
| SEQ_modifier_free(smd); | SEQ_modifier_free(smd); | ||||
| SEQ_relations_invalidate_cache_preprocessed(scene, seq); | SEQ_relations_invalidate_cache_preprocessed(video_edit, seq); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void SEQUENCER_OT_strip_modifier_remove(wmOperatorType *ot) | void SEQUENCER_OT_strip_modifier_remove(wmOperatorType *ot) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| Show All 18 Lines | |||||
| enum { | enum { | ||||
| SEQ_MODIFIER_MOVE_UP = 0, | SEQ_MODIFIER_MOVE_UP = 0, | ||||
| SEQ_MODIFIER_MOVE_DOWN, | SEQ_MODIFIER_MOVE_DOWN, | ||||
| }; | }; | ||||
| static int strip_modifier_move_exec(bContext *C, wmOperator *op) | static int strip_modifier_move_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Sequence *seq = SEQ_select_active_get(scene); | Sequence *seq = SEQ_select_active_get(video_edit); | ||||
| char name[MAX_NAME]; | char name[MAX_NAME]; | ||||
| int direction; | int direction; | ||||
| SequenceModifierData *smd; | SequenceModifierData *smd; | ||||
| RNA_string_get(op->ptr, "name", name); | RNA_string_get(op->ptr, "name", name); | ||||
| direction = RNA_enum_get(op->ptr, "direction"); | direction = RNA_enum_get(op->ptr, "direction"); | ||||
| smd = SEQ_modifier_find_by_name(seq, name); | smd = SEQ_modifier_find_by_name(seq, name); | ||||
| Show All 9 Lines | static int strip_modifier_move_exec(bContext *C, wmOperator *op) | ||||
| } | } | ||||
| else if (direction == SEQ_MODIFIER_MOVE_DOWN) { | else if (direction == SEQ_MODIFIER_MOVE_DOWN) { | ||||
| if (smd->next) { | if (smd->next) { | ||||
| BLI_remlink(&seq->modifiers, smd); | BLI_remlink(&seq->modifiers, smd); | ||||
| BLI_insertlinkafter(&seq->modifiers, smd->next, smd); | BLI_insertlinkafter(&seq->modifiers, smd->next, smd); | ||||
| } | } | ||||
| } | } | ||||
| SEQ_relations_invalidate_cache_preprocessed(scene, seq); | SEQ_relations_invalidate_cache_preprocessed(video_edit, seq); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void SEQUENCER_OT_strip_modifier_move(wmOperatorType *ot) | void SEQUENCER_OT_strip_modifier_move(wmOperatorType *ot) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| Show All 26 Lines | |||||
| enum { | enum { | ||||
| SEQ_MODIFIER_COPY_REPLACE = 0, | SEQ_MODIFIER_COPY_REPLACE = 0, | ||||
| SEQ_MODIFIER_COPY_APPEND = 1, | SEQ_MODIFIER_COPY_APPEND = 1, | ||||
| }; | }; | ||||
| static int strip_modifier_copy_exec(bContext *C, wmOperator *op) | static int strip_modifier_copy_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Editing *ed = scene->ed; | Sequence *seq = SEQ_select_active_get(video_edit); | ||||
| Sequence *seq = SEQ_select_active_get(scene); | |||||
| const int type = RNA_enum_get(op->ptr, "type"); | const int type = RNA_enum_get(op->ptr, "type"); | ||||
| if (!seq || !seq->modifiers.first) { | if (!seq || !seq->modifiers.first) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| LISTBASE_FOREACH (Sequence *, seq_iter, SEQ_active_seqbase_get(ed)) { | LISTBASE_FOREACH (Sequence *, seq_iter, SEQ_active_seqbase_get(video_edit)) { | ||||
| if (seq_iter->flag & SELECT) { | if (seq_iter->flag & SELECT) { | ||||
| if (seq_iter == seq) { | if (seq_iter == seq) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (type == SEQ_MODIFIER_COPY_REPLACE) { | if (type == SEQ_MODIFIER_COPY_REPLACE) { | ||||
| if (seq_iter->modifiers.first) { | if (seq_iter->modifiers.first) { | ||||
| SequenceModifierData *smd_tmp, *smd = seq_iter->modifiers.first; | SequenceModifierData *smd_tmp, *smd = seq_iter->modifiers.first; | ||||
| while (smd) { | while (smd) { | ||||
| smd_tmp = smd->next; | smd_tmp = smd->next; | ||||
| BLI_remlink(&seq_iter->modifiers, smd); | BLI_remlink(&seq_iter->modifiers, smd); | ||||
| SEQ_modifier_free(smd); | SEQ_modifier_free(smd); | ||||
| smd = smd_tmp; | smd = smd_tmp; | ||||
| } | } | ||||
| BLI_listbase_clear(&seq_iter->modifiers); | BLI_listbase_clear(&seq_iter->modifiers); | ||||
| } | } | ||||
| } | } | ||||
| SEQ_modifier_list_copy(seq_iter, seq); | SEQ_modifier_list_copy(seq_iter, seq); | ||||
| } | } | ||||
| } | } | ||||
| SEQ_relations_invalidate_cache_preprocessed(scene, seq); | SEQ_relations_invalidate_cache_preprocessed(video_edit, seq); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void SEQUENCER_OT_strip_modifier_copy(wmOperatorType *ot) | void SEQUENCER_OT_strip_modifier_copy(wmOperatorType *ot) | ||||
| { | { | ||||
| static const EnumPropertyItem type_items[] = { | static const EnumPropertyItem type_items[] = { | ||||
| {SEQ_MODIFIER_COPY_REPLACE, "REPLACE", 0, "Replace", "Replace modifiers in destination"}, | {SEQ_MODIFIER_COPY_REPLACE, "REPLACE", 0, "Replace", "Replace modifiers in destination"}, | ||||
| Show All 24 Lines | |||||