diff options
author | Richard Antalik <richardantalik@gmail.com> | 2022-04-04 13:52:48 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2022-04-04 13:56:43 +0300 |
commit | 277fa2f441f4ab2c00e7f329ba34a3466956647c (patch) | |
tree | bde615d956239337f88575dc7ce79d26f0f6cf4f /source/blender/makesrna/intern | |
parent | 5a0b4e97e67446ef3a180acb0ad03b4cbf91b356 (diff) |
VSE: Add channel headers
This patch adds channel region to VSE timeline area for drawing channel
headers. It is synchronizedwith timeline region. 3 basic features are
implemented - channel visibility, locking and name.
Channel data is stored in `SeqTimelineChannel` which can be top-level
owned by `Editing`, or it is owned by meta strip to support nesting.
Strip properties are completely independent and channel properties are
applied on top of particular strip property, thus overriding it.
Implementation is separate from channel regions in other editors. This
is mainly because style and topology is quite different in VSE. But
also code seems to be much more readable this way.
Currently channels use functions similar to VSE timeline to draw
background to provide illusion of transparency, but only for background
and sfra/efra regions.
Great portion of this patch is change from using strip visibility and
lock status to include channel state - this is facilitated by functions
`SEQ_transform_is_locked` and `SEQ_render_is_muted`
Originally this included changes in D14263, but patch was split for
easier review.
Reviewed By: fsiddi, Severin
Differential Revision: https://developer.blender.org/D13836
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_sequencer.c | 106 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 1 |
3 files changed, 109 insertions, 1 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); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index e21c10166ab..ff272c34c65 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -5613,7 +5613,8 @@ static void rna_def_space_sequencer(BlenderRNA *brna) rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_TOOL_HEADER) | (1 << RGN_TYPE_UI) | - (1 << RGN_TYPE_TOOLS) | (1 << RGN_TYPE_HUD)); + (1 << RGN_TYPE_TOOLS) | (1 << RGN_TYPE_HUD) | + (1 << RGN_TYPE_CHANNELS)); /* view type, fairly important */ prop = RNA_def_property(srna, "view_type", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index fd2bb9cb7cc..bbbe98e3191 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3149,6 +3149,7 @@ static void rna_def_userdef_theme_space_seq(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Theme Sequence Editor", "Theme settings for the Sequence Editor"); rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_list_main(srna); prop = RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 3); |