Add custom properties to sequence strips
This commit is contained in:
parent
ac2530be8c
commit
2fc69d11c8
|
@ -19,6 +19,7 @@
|
|||
# <pep8 compliant>
|
||||
import bpy
|
||||
from bpy.types import Header, Menu, Panel
|
||||
from rna_prop_ui import PropertyPanel
|
||||
from bl_ui.properties_grease_pencil_common import GreasePencilDataPanel, GreasePencilToolsPanel
|
||||
from bpy.app.translations import pgettext_iface as iface_
|
||||
|
||||
|
@ -1107,5 +1108,11 @@ class SEQUENCER_PT_grease_pencil_tools(GreasePencilToolsPanel, SequencerButtonsP
|
|||
# toolbar, which doesn't exist here...
|
||||
|
||||
|
||||
class SEQUENCER_PT_custom_props(SequencerButtonsPanel, PropertyPanel, Panel):
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
|
||||
_context_path = "scene.sequence_editor.active_strip"
|
||||
_property_type = (bpy.types.Sequence,)
|
||||
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
bpy.utils.register_module(__name__)
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
#include "BKE_scene.h"
|
||||
#include "BKE_mask.h"
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_idprop.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
|
@ -210,6 +211,11 @@ static void BKE_sequence_free_ex(Scene *scene, Sequence *seq, const bool do_cach
|
|||
seq_free_animdata(scene, seq);
|
||||
}
|
||||
|
||||
if (seq->prop) {
|
||||
IDP_FreeProperty(seq->prop);
|
||||
MEM_freeN(seq->prop);
|
||||
}
|
||||
|
||||
/* free modifiers */
|
||||
BKE_sequence_modifier_clear(seq);
|
||||
|
||||
|
@ -4630,6 +4636,10 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup
|
|||
seqn->strip->proxy->anim = NULL;
|
||||
}
|
||||
|
||||
if (seq->prop) {
|
||||
seqn->prop = IDP_CopyProperty(seq->prop);
|
||||
}
|
||||
|
||||
if (seqn->modifiers.first) {
|
||||
BLI_listbase_clear(&seqn->modifiers);
|
||||
|
||||
|
|
|
@ -5618,7 +5618,10 @@ static void direct_link_scene(FileData *fd, Scene *sce)
|
|||
SpeedControlVars *s = seq->effectdata;
|
||||
s->frameMap = NULL;
|
||||
}
|
||||
|
||||
|
||||
seq->prop = newdataadr(fd, seq->prop);
|
||||
IDP_DirectLinkGroup_OrFree(&seq->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
|
||||
|
||||
seq->strip = newdataadr(fd, seq->strip);
|
||||
if (seq->strip && seq->strip->done==0) {
|
||||
seq->strip->done = true;
|
||||
|
|
|
@ -2441,6 +2441,10 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
|
|||
strip->done = true;
|
||||
}
|
||||
|
||||
if (seq->prop) {
|
||||
IDP_WriteProperty(seq->prop, wd);
|
||||
}
|
||||
|
||||
write_sequence_modifiers(wd, &seq->modifiers);
|
||||
}
|
||||
SEQ_END
|
||||
|
|
|
@ -189,6 +189,8 @@ typedef struct Sequence {
|
|||
char alpha_mode;
|
||||
char pad[3];
|
||||
|
||||
struct IDProperty *prop;
|
||||
|
||||
/* modifiers */
|
||||
ListBase modifiers;
|
||||
} Sequence;
|
||||
|
|
|
@ -72,6 +72,7 @@ EnumPropertyItem sequence_modifier_type_items[] = {
|
|||
#ifdef RNA_RUNTIME
|
||||
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_idprop.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
@ -564,6 +565,18 @@ static char *rna_Sequence_path(PointerRNA *ptr)
|
|||
}
|
||||
}
|
||||
|
||||
static IDProperty *rna_Sequence_idprops(PointerRNA *ptr, bool create)
|
||||
{
|
||||
Sequence *seq = ptr->data;
|
||||
|
||||
if (create && !seq->prop) {
|
||||
IDPropertyTemplate val = {0};
|
||||
seq->prop = IDP_New(IDP_GROUP, &val, "Sequence ID properties");
|
||||
}
|
||||
|
||||
return seq->prop;
|
||||
}
|
||||
|
||||
static PointerRNA rna_SequenceEditor_meta_stack_get(CollectionPropertyIterator *iter)
|
||||
{
|
||||
ListBaseIterator *internal = &iter->internal.listbase;
|
||||
|
@ -1397,6 +1410,7 @@ static void rna_def_sequence(BlenderRNA *brna)
|
|||
RNA_def_struct_ui_text(srna, "Sequence", "Sequence strip in the sequence editor");
|
||||
RNA_def_struct_refine_func(srna, "rna_Sequence_refine");
|
||||
RNA_def_struct_path_func(srna, "rna_Sequence_path");
|
||||
RNA_def_struct_idprops_func(srna, "rna_Sequence_idprops");
|
||||
|
||||
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_funcs(prop, "rna_Sequence_name_get", "rna_Sequence_name_length", "rna_Sequence_name_set");
|
||||
|
|
Loading…
Reference in New Issue