Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna/intern/rna_sequencer.c')
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index 0013131e622..a27e699ef3d 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -15,7 +15,9 @@
#include "DNA_vfont_types.h"
#include "BLI_iterator.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
+#include "BLI_string_utils.h"
#include "BLT_translation.h"
@@ -34,6 +36,7 @@
#include "rna_internal.h"
#include "SEQ_add.h"
+#include "SEQ_channels.h"
#include "SEQ_effects.h"
#include "SEQ_iterator.h"
#include "SEQ_modifier.h"
@@ -1374,6 +1377,71 @@ static void rna_Sequence_separate(ID *id, Sequence *seqm, Main *bmain)
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
}
+/* Find channel owner. If NULL, owner is `Editing`, otherwise it's `Sequence`. */
+static Sequence *rna_SeqTimelineChannel_owner_get(Editing *ed, SeqTimelineChannel *channel)
+{
+ SeqCollection *strips = SEQ_query_all_strips_recursive(&ed->seqbase);
+
+ Sequence *channel_owner = NULL;
+ Sequence *seq;
+ SEQ_ITERATOR_FOREACH (seq, strips) {
+ if (seq->type != SEQ_TYPE_META) {
+ continue;
+ }
+ if (BLI_findindex(&seq->channels, channel) >= 0) {
+ channel_owner = seq;
+ }
+ }
+
+ SEQ_collection_free(strips);
+ return channel_owner;
+}
+
+static void rna_SequenceTimelineChannel_name_set(PointerRNA *ptr, const char *value)
+{
+ SeqTimelineChannel *channel = (SeqTimelineChannel *)ptr->data;
+ Scene *scene = (Scene *)ptr->owner_id;
+ Editing *ed = SEQ_editing_get(scene);
+
+ Sequence *channel_owner = rna_SeqTimelineChannel_owner_get(ed, channel);
+ ListBase *channels_base = &ed->channels;
+
+ if (channel_owner != NULL) {
+ channels_base = &channel_owner->channels;
+ }
+
+ BLI_strncpy_utf8(channel->name, value, sizeof(channel->name));
+ BLI_uniquename(channels_base,
+ channel,
+ "Channel",
+ '.',
+ offsetof(SeqTimelineChannel, name),
+ sizeof(channel->name));
+}
+
+static char *rna_SeqTimelineChannel_path(PointerRNA *ptr)
+{
+ Scene *scene = (Scene *)ptr->owner_id;
+ Editing *ed = SEQ_editing_get(scene);
+ SeqTimelineChannel *channel = (SeqTimelineChannel *)ptr->data;
+
+ Sequence *channel_owner = rna_SeqTimelineChannel_owner_get(ed, channel);
+
+ char channel_name_esc[(sizeof(channel->name)) * 2];
+ BLI_str_escape(channel_name_esc, channel->name, sizeof(channel_name_esc));
+
+ if (channel_owner == NULL) {
+ return BLI_sprintfN("sequence_editor.channels[\"%s\"]", channel_name_esc);
+ }
+ else {
+ char owner_name_esc[(sizeof(channel_owner->name) - 2) * 2];
+ BLI_str_escape(owner_name_esc, channel_owner->name + 2, sizeof(owner_name_esc));
+ return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].channels[\"%s\"]",
+ owner_name_esc,
+ channel_name_esc);
+ }
+}
+
#else
static void rna_def_strip_element(BlenderRNA *brna)
@@ -2081,6 +2149,33 @@ static void rna_def_sequence(BlenderRNA *brna)
RNA_api_sequence_strip(srna);
}
+static void rna_def_channel(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "SequenceTimelineChannel", NULL);
+ RNA_def_struct_sdna(srna, "SeqTimelineChannel");
+ RNA_def_struct_path_func(srna, "rna_SeqTimelineChannel_path");
+ RNA_def_struct_ui_text(srna, "Channel", "");
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_maxlength(prop, sizeof(((SeqTimelineChannel *)NULL)->name));
+ RNA_def_property_ui_text(prop, "Name", "");
+ RNA_def_struct_name_property(srna, prop);
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SequenceTimelineChannel_name_set");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+
+ prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_CHANNEL_LOCK);
+ RNA_def_property_ui_text(prop, "Lock channel", "");
+
+ prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_CHANNEL_MUTE);
+ RNA_def_property_ui_text(prop, "Mute channel", "");
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+}
+
static void rna_def_editor(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2129,6 +2224,11 @@ static void rna_def_editor(BlenderRNA *brna)
RNA_def_property_collection_funcs(
prop, NULL, NULL, NULL, "rna_SequenceEditor_meta_stack_get", NULL, NULL, NULL, NULL);
+ prop = RNA_def_property(srna, "channels", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "channels", NULL);
+ RNA_def_property_struct_type(prop, "SequenceTimelineChannel");
+ RNA_def_property_ui_text(prop, "Channels", "");
+
prop = RNA_def_property(srna, "active_strip", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "act_seq");
RNA_def_property_flag(prop, PROP_EDITABLE);
@@ -2475,6 +2575,11 @@ static void rna_def_meta(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Sequences", "Sequences nested in meta strip");
RNA_api_sequences(brna, prop, true);
+ prop = RNA_def_property(srna, "channels", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "channels", NULL);
+ RNA_def_property_struct_type(prop, "SequenceTimelineChannel");
+ RNA_def_property_ui_text(prop, "Channels", "");
+
func = RNA_def_function(srna, "separate", "rna_Sequence_separate");
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Separate meta");
@@ -3472,6 +3577,7 @@ void RNA_def_sequencer(BlenderRNA *brna)
rna_def_sequence(brna);
rna_def_editor(brna);
+ rna_def_channel(brna);
rna_def_image(brna);
rna_def_meta(brna);