Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_sequencer/sequencer_add.c
| Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) | ||||
| if (flag & SEQPROP_STARTFRAME) { | if (flag & SEQPROP_STARTFRAME) { | ||||
| RNA_def_int(ot->srna, | RNA_def_int(ot->srna, | ||||
| "frame_start", | "frame_start", | ||||
| 0, | 0, | ||||
| INT_MIN, | INT_MIN, | ||||
| INT_MAX, | INT_MAX, | ||||
| "Start Frame", | "Start Frame", | ||||
| "Start frame of the sequence strip", | "Start frame of the sequence strip", | ||||
| INT_MIN, | -MAXFRAME, | ||||
| INT_MAX); | MAXFRAME); | ||||
campbellbarton: Negative start frames are supported. Why not set this to `-MAXFRAME` ? | |||||
Not Done Inline ActionsI was thinking about this as well. They are supported, but can not be played back. It is true though, that this is unnecessary limitation. ISS: I was thinking about this as well. They are supported, but can not be played back.
It is true… | |||||
| } | } | ||||
| if (flag & SEQPROP_ENDFRAME) { | if (flag & SEQPROP_ENDFRAME) { | ||||
| /* not usual since most strips have a fixed length */ | /* not usual since most strips have a fixed length */ | ||||
| RNA_def_int(ot->srna, | RNA_def_int(ot->srna, | ||||
| "frame_end", | "frame_end", | ||||
| 0, | 0, | ||||
| INT_MIN, | INT_MIN, | ||||
| INT_MAX, | INT_MAX, | ||||
| "End Frame", | "End Frame", | ||||
| "End frame for the color strip", | "End frame for the color strip", | ||||
| INT_MIN, | -MAXFRAME, | ||||
| INT_MAX); | MAXFRAME); | ||||
| } | } | ||||
| RNA_def_int( | RNA_def_int( | ||||
| ot->srna, "channel", 1, 1, MAXSEQ, "Channel", "Channel to place this strip into", 1, MAXSEQ); | ot->srna, "channel", 1, 1, MAXSEQ, "Channel", "Channel to place this strip into", 1, MAXSEQ); | ||||
| RNA_def_boolean( | RNA_def_boolean( | ||||
| ot->srna, "replace_sel", 1, "Replace Selection", "Replace the current selection"); | ot->srna, "replace_sel", 1, "Replace Selection", "Replace the current selection"); | ||||
| ▲ Show 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | static void sequencer_add_apply_replace_sel(bContext *C, wmOperator *op, Sequence *seq) | ||||
| if (RNA_boolean_get(op->ptr, "replace_sel")) { | if (RNA_boolean_get(op->ptr, "replace_sel")) { | ||||
| ED_sequencer_deselect_all(scene); | ED_sequencer_deselect_all(scene); | ||||
| BKE_sequencer_active_set(scene, seq); | BKE_sequencer_active_set(scene, seq); | ||||
| seq->flag |= SELECT; | seq->flag |= SELECT; | ||||
| } | } | ||||
| } | } | ||||
| static bool seq_effect_add_properties_poll(const bContext *UNUSED(C), | |||||
| wmOperator *op, | |||||
| const PropertyRNA *prop) | |||||
| { | |||||
| const char *prop_id = RNA_property_identifier(prop); | |||||
| int type = RNA_enum_get(op->ptr, "type"); | |||||
| /* Hide start/end frames for effect strips that are locked to their parents' location. */ | |||||
| if (BKE_sequence_effect_get_num_inputs(type) != 0) { | |||||
Not Done Inline ActionsThis should be replaced by BKE_sequence_effect_get_num_inputs(type) == 0 campbellbarton: This should be replaced by `BKE_sequence_effect_get_num_inputs(type) == 0` | |||||
Done Inline ActionsThanks! Definitely more time-proof. a.monti: Thanks! Definitely more time-proof. | |||||
| if ((STREQ(prop_id, "frame_start")) || (STREQ(prop_id, "frame_end"))) { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| if ((type != SEQ_TYPE_COLOR) && (STREQ(prop_id, "color"))) { | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| /* add scene operator */ | /* add scene operator */ | ||||
| static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) | static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Editing *ed = BKE_sequencer_editing_get(scene, true); | Editing *ed = BKE_sequencer_editing_get(scene, true); | ||||
| Scene *sce_seq; | Scene *sce_seq; | ||||
| ▲ Show 20 Lines • Show All 737 Lines • ▼ Show 20 Lines | static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) | ||||
| if (!seq_effect_find_selected(scene, NULL, type, &seq1, &seq2, &seq3, &error_msg)) { | if (!seq_effect_find_selected(scene, NULL, type, &seq1, &seq2, &seq3, &error_msg)) { | ||||
| BKE_report(op->reports, RPT_ERROR, error_msg); | BKE_report(op->reports, RPT_ERROR, error_msg); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* If seq1 is NULL and no error was raised it means the seq is standalone | /* If seq1 is NULL and no error was raised it means the seq is standalone | ||||
| * (like color strips) and we need to check its start and end frames are valid */ | * (like color strips) and we need to check its start and end frames are valid */ | ||||
| if (seq1 == NULL && end_frame <= start_frame) { | if (seq1 == NULL && end_frame <= start_frame) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Start and end frame are not set"); | end_frame = start_frame + 1; | ||||
| return OPERATOR_CANCELLED; | RNA_int_set(op->ptr, "frame_end", end_frame); | ||||
Done Inline ActionsI would suggest overriding actual RNA property value here: ISS: I would suggest overriding actual RNA property value here:
`RNA_int_set(op->ptr, "frame_end"… | |||||
| } | } | ||||
| seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, type); | seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, type); | ||||
| BLI_strncpy(seq->name + 2, BKE_sequence_give_name(seq), sizeof(seq->name) - 2); | BLI_strncpy(seq->name + 2, BKE_sequence_give_name(seq), sizeof(seq->name) - 2); | ||||
| BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); | BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); | ||||
| sh = BKE_sequence_get_effect(seq); | sh = BKE_sequence_get_effect(seq); | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | static int sequencer_add_effect_strip_invoke(bContext *C, | ||||
| sequencer_generic_invoke_xy__internal(C, op, prop_flag, type); | sequencer_generic_invoke_xy__internal(C, op, prop_flag, type); | ||||
| return sequencer_add_effect_strip_exec(C, op); | return sequencer_add_effect_strip_exec(C, op); | ||||
| } | } | ||||
| void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot) | void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot) | ||||
| { | { | ||||
| PropertyRNA *prop; | |||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Add Effect Strip"; | ot->name = "Add Effect Strip"; | ||||
| ot->idname = "SEQUENCER_OT_effect_strip_add"; | ot->idname = "SEQUENCER_OT_effect_strip_add"; | ||||
| ot->description = "Add an effect to the sequencer, most are applied on top of existing strips"; | ot->description = "Add an effect to the sequencer, most are applied on top of existing strips"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->invoke = sequencer_add_effect_strip_invoke; | ot->invoke = sequencer_add_effect_strip_invoke; | ||||
| ot->exec = sequencer_add_effect_strip_exec; | ot->exec = sequencer_add_effect_strip_exec; | ||||
| ot->poll = ED_operator_sequencer_active_editable; | ot->poll = ED_operator_sequencer_active_editable; | ||||
| ot->poll_property = seq_effect_add_properties_poll; | |||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME | SEQPROP_ENDFRAME); | |||||
| RNA_def_enum(ot->srna, | RNA_def_enum(ot->srna, | ||||
| "type", | "type", | ||||
| sequencer_prop_effect_types, | sequencer_prop_effect_types, | ||||
| SEQ_TYPE_CROSS, | SEQ_TYPE_CROSS, | ||||
| "Type", | "Type", | ||||
| "Sequencer effect type"); | "Sequencer effect type"); | ||||
| RNA_def_float_vector(ot->srna, | sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME | SEQPROP_ENDFRAME); | ||||
| prop = RNA_def_float_color(ot->srna, | |||||
| "color", | "color", | ||||
| 3, | 3, | ||||
| NULL, | NULL, | ||||
| 0.0f, | 0.0f, | ||||
| 1.0f, | 1.0f, | ||||
| "Color", | "Color", | ||||
| "Initialize the strip with this color (only used when type='COLOR')", | "Initialize the strip with this color (only used when type='COLOR')", | ||||
| 0.0f, | 0.0f, | ||||
| 1.0f); | 1.0f); | ||||
| RNA_def_property_subtype(prop, PROP_COLOR_GAMMA); | |||||
| } | } | ||||
Negative start frames are supported. Why not set this to -MAXFRAME ?