From bdf9e023466756b6a75722cfa05ce75150e5ad75 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 7 Jun 2012 18:24:36 +0000 Subject: new sequence strip type for masks. --- source/blender/makesrna/intern/rna_mask.c | 40 ++++++++++++++++++++++ source/blender/makesrna/intern/rna_sequencer.c | 23 +++++++++++++ source/blender/makesrna/intern/rna_sequencer_api.c | 38 ++++++++++++++++++++ 3 files changed, 101 insertions(+) (limited to 'source/blender/makesrna/intern') diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index 51d370d5a88..f25aba6193b 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -312,6 +312,29 @@ static void rna_MaskLayer_spline_add(ID *id, MaskLayer *masklay, int number) WM_main_add_notifier(NC_MASK|NA_EDITED, mask); } +static void rna_Mask_start_frame_set(PointerRNA *ptr, int value) +{ + Mask *data = (Mask *)ptr->data; + /* MINFRAME not MINAFRAME, since some output formats can't taken negative frames */ + CLAMP(value, MINFRAME, MAXFRAME); + data->sfra = value; + + if (data->sfra >= data->efra) { + data->efra = MIN2(data->sfra, MAXFRAME); + } +} + +static void rna_Mask_end_frame_set(PointerRNA *ptr, int value) +{ + Mask *data = (Mask *)ptr->data; + CLAMP(value, MINFRAME, MAXFRAME); + data->efra = value; + + if (data->sfra >= data->efra) { + data->sfra = MAX2(data->efra, MINFRAME); + } +} + #else static void rna_def_maskParent(BlenderRNA *brna) @@ -644,6 +667,23 @@ static void rna_def_mask(BlenderRNA *brna) RNA_def_property_int_funcs(prop, "rna_Mask_layer_active_index_get", "rna_Mask_layer_active_index_set", "rna_Mask_layer_active_index_range"); RNA_def_property_ui_text(prop, "Active Shape Index", "Index of active layer in list of all mask's layers"); + /* frame range */ + prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "sfra"); + RNA_def_property_int_funcs(prop, NULL, "rna_Mask_start_frame_set", NULL); + RNA_def_property_range(prop, MINFRAME, MAXFRAME); + RNA_def_property_ui_text(prop, "Start Frame", "First frame of the mask (used for sequencer)"); + RNA_def_property_update(prop, NC_SCENE | ND_FRAME_RANGE, NULL); + + prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "efra"); + RNA_def_property_int_funcs(prop, NULL, "rna_Mask_end_frame_set", NULL); + RNA_def_property_range(prop, MINFRAME, MAXFRAME); + RNA_def_property_ui_text(prop, "End Frame", "Final frame of the mask (used for sequencer)"); + RNA_def_property_update(prop, NC_SCENE | ND_FRAME_RANGE, NULL); + /* pointers */ rna_def_animdata_common(srna); } diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 1edf144452d..fb8ba2f863e 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -406,6 +406,8 @@ static StructRNA *rna_Sequence_refine(struct PointerRNA *ptr) return &RNA_MovieSequence; case SEQ_TYPE_MOVIECLIP: return &RNA_MovieClipSequence; + case SEQ_TYPE_MASK: + return &RNA_MaskSequence; case SEQ_TYPE_SOUND_RAM: return &RNA_SoundSequence; case SEQ_TYPE_CROSS: @@ -989,6 +991,7 @@ static void rna_def_sequence(BlenderRNA *brna) {SEQ_TYPE_SCENE, "SCENE", 0, "Scene", ""}, {SEQ_TYPE_MOVIE, "MOVIE", 0, "Movie", ""}, {SEQ_TYPE_MOVIECLIP, "MOVIECLIP", 0, "Clip", ""}, + {SEQ_TYPE_MASK, "MASK", 0, "Mask", ""}, {SEQ_TYPE_SOUND_RAM, "SOUND", 0, "Sound", ""}, {SEQ_TYPE_CROSS, "CROSS", 0, "Cross", ""}, {SEQ_TYPE_ADD, "ADD", 0, "Add", ""}, @@ -1505,6 +1508,8 @@ static void rna_def_movieclip(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "MovieClip Sequence", "Sequence strip to load a video from the clip editor"); RNA_def_struct_sdna(srna, "Sequence"); + /* TODO - add clip property? */ + prop = RNA_def_property(srna, "undistort", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "clip_flag", SEQ_MOVIECLIP_RENDER_UNDISTORTED); RNA_def_property_ui_text(prop, "Undistort Clip", "Use the undistorted version of the clip"); @@ -1519,6 +1524,23 @@ static void rna_def_movieclip(BlenderRNA *brna) rna_def_input(srna); } +static void rna_def_mask(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "MaskSequence", "Sequence"); + RNA_def_struct_ui_text(srna, "Mask Sequence", "Sequence strip to load a video from a mask"); + RNA_def_struct_sdna(srna, "Sequence"); + + prop = RNA_def_property(srna, "mask", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Mask", "Mask that this sequence uses"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); + + rna_def_filter_video(srna); + rna_def_input(srna); +} static void rna_def_sound(BlenderRNA *brna) { @@ -1883,6 +1905,7 @@ void RNA_def_sequencer(BlenderRNA *brna) rna_def_scene(brna); rna_def_movie(brna); rna_def_movieclip(brna); + rna_def_mask(brna); rna_def_sound(brna); rna_def_effect(brna); rna_def_effects(brna); diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index bbc772770ea..e20435a07cd 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -45,6 +45,7 @@ extern EnumPropertyItem blend_mode_items[]; #include "DNA_image_types.h" #include "DNA_scene_types.h" #include "DNA_sequence_types.h" +#include "DNA_mask_types.h" #include "DNA_sound_types.h" #include "BLI_path_util.h" /* BLI_split_dirfile */ @@ -52,6 +53,7 @@ extern EnumPropertyItem blend_mode_items[]; #include "BKE_image.h" #include "BKE_library.h" /* id_us_plus */ #include "BKE_movieclip.h" +#include "BKE_mask.h" #include "BKE_report.h" #include "BKE_sequencer.h" @@ -116,6 +118,25 @@ static Sequence *rna_Sequences_new_clip(ID *id, Editing *ed, ReportList *reports return seq; } +static Sequence *rna_Sequences_new_mask(ID *id, Editing *ed, ReportList *reports, + const char *name, Mask *mask, int channel, + int start_frame) +{ + Scene *scene = (Scene *)id; + Sequence *seq; + + seq = alloc_generic_sequence(ed, name, start_frame, channel, SEQ_TYPE_MASK, mask->id.name); + seq->mask = mask; + seq->len = BKE_mask_get_duration(mask); + id_us_plus((ID *)mask); + + calc_sequence_disp(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); + + return seq; +} + static Sequence *rna_Sequences_new_scene(ID *id, Editing *ed, ReportList *reports, const char *name, Scene *sce_seq, int channel, int start_frame) @@ -451,6 +472,23 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence"); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "new_mask", "rna_Sequences_new_mask"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Add a new movie clip sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_pointer(func, "mask", "Mask", "", "Mask to add"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_int(func, "channel", 0, 0, MAXSEQ - 1, "Channel", + "The channel for the new sequence", 0, MAXSEQ - 1); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int(func, "start_frame", 0, -MAXFRAME, MAXFRAME, "", + "The start frame for the new sequence", -MAXFRAME, MAXFRAME); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence"); + RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "new_scene", "rna_Sequences_new_scene"); RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a new scene sequence"); -- cgit v1.2.3