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/editors/space_sequencer')
-rw-r--r--source/blender/editors/space_sequencer/CMakeLists.txt64
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c1693
-rw-r--r--source/blender/editors/space_sequencer/sequencer_buttons.c127
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c3201
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c6053
-rw-r--r--source/blender/editors/space_sequencer/sequencer_intern.h62
-rw-r--r--source/blender/editors/space_sequencer/sequencer_modifier.c360
-rw-r--r--source/blender/editors/space_sequencer/sequencer_ops.c183
-rw-r--r--source/blender/editors/space_sequencer/sequencer_preview.c203
-rw-r--r--source/blender/editors/space_sequencer/sequencer_scopes.c1168
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c2075
-rw-r--r--source/blender/editors/space_sequencer/sequencer_view.c298
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c1301
13 files changed, 8540 insertions, 8248 deletions
diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt
index 5724e811e77..8b97f7537f8 100644
--- a/source/blender/editors/space_sequencer/CMakeLists.txt
+++ b/source/blender/editors/space_sequencer/CMakeLists.txt
@@ -16,55 +16,55 @@
# ***** END GPL LICENSE BLOCK *****
set(INC
- ../include
- ../../blenkernel
- ../../blenlib
- ../../blentranslation
- ../../imbuf
- ../../gpu
- ../../makesdna
- ../../makesrna
- ../../windowmanager
- ../../../../intern/atomic
- ../../../../intern/guardedalloc
- ../../../../intern/glew-mx
+ ../include
+ ../../blenkernel
+ ../../blenlib
+ ../../blentranslation
+ ../../imbuf
+ ../../gpu
+ ../../makesdna
+ ../../makesrna
+ ../../windowmanager
+ ../../../../intern/atomic
+ ../../../../intern/guardedalloc
+ ../../../../intern/glew-mx
)
set(INC_SYS
- ${GLEW_INCLUDE_PATH}
+ ${GLEW_INCLUDE_PATH}
)
set(SRC
- sequencer_add.c
- sequencer_buttons.c
- sequencer_draw.c
- sequencer_edit.c
- sequencer_modifier.c
- sequencer_ops.c
- sequencer_preview.c
- sequencer_scopes.c
- sequencer_select.c
- sequencer_view.c
- space_sequencer.c
+ sequencer_add.c
+ sequencer_buttons.c
+ sequencer_draw.c
+ sequencer_edit.c
+ sequencer_modifier.c
+ sequencer_ops.c
+ sequencer_preview.c
+ sequencer_scopes.c
+ sequencer_select.c
+ sequencer_view.c
+ space_sequencer.c
- sequencer_intern.h
+ sequencer_intern.h
)
set(LIB
- bf_editor_interface
- bf_editor_util
+ bf_editor_interface
+ bf_editor_util
)
if(WITH_AUDASPACE)
- add_definitions(-DWITH_AUDASPACE)
+ add_definitions(-DWITH_AUDASPACE)
- list(APPEND INC_SYS
- ${AUDASPACE_C_INCLUDE_DIRS}
- )
+ list(APPEND INC_SYS
+ ${AUDASPACE_C_INCLUDE_DIRS}
+ )
endif()
if(WITH_INTERNATIONAL)
- add_definitions(-DWITH_INTERNATIONAL)
+ add_definitions(-DWITH_INTERNATIONAL)
endif()
add_definitions(${GL_DEFINITIONS})
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 5e36ad9e8bc..218804b0ab4 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -37,7 +37,6 @@
#include "DNA_scene_types.h"
#include "DNA_mask_types.h"
-
#include "BKE_context.h"
#include "BKE_library.h"
#include "BKE_main.h"
@@ -69,201 +68,219 @@
#include "sequencer_intern.h"
typedef struct SequencerAddData {
- ImageFormatData im_format;
+ ImageFormatData im_format;
} SequencerAddData;
/* Generic functions, reused by add strip operators */
/* avoid passing multiple args and be more verbose */
-#define SEQPROP_STARTFRAME (1 << 0)
-#define SEQPROP_ENDFRAME (1 << 1)
-#define SEQPROP_NOPATHS (1 << 2)
-#define SEQPROP_NOCHAN (1 << 3)
+#define SEQPROP_STARTFRAME (1 << 0)
+#define SEQPROP_ENDFRAME (1 << 1)
+#define SEQPROP_NOPATHS (1 << 2)
+#define SEQPROP_NOCHAN (1 << 3)
#define SELECT 1
static void sequencer_generic_props__internal(wmOperatorType *ot, int flag)
{
- PropertyRNA *prop;
-
- if (flag & SEQPROP_STARTFRAME) {
- RNA_def_int(ot->srna, "frame_start", 0, INT_MIN, INT_MAX,
- "Start Frame", "Start frame of the sequence strip", INT_MIN, INT_MAX);
- }
-
- if (flag & SEQPROP_ENDFRAME) {
- /* not usual since most strips have a fixed length */
- RNA_def_int(ot->srna, "frame_end", 0, INT_MIN, INT_MAX,
- "End Frame", "End frame for the color strip", INT_MIN, INT_MAX);
- }
-
- RNA_def_int(ot->srna, "channel", 1, 1, MAXSEQ,
- "Channel", "Channel to place this strip into", 1, MAXSEQ);
-
- RNA_def_boolean(ot->srna, "replace_sel", 1,
- "Replace Selection", "Replace the current selection");
-
- /* only for python scripts which import strips and place them after */
- prop = RNA_def_boolean(ot->srna, "overlap", 0,
- "Allow Overlap", "Don't correct overlap on new sequence strips");
- RNA_def_property_flag(prop, PROP_HIDDEN);
+ PropertyRNA *prop;
+
+ if (flag & SEQPROP_STARTFRAME) {
+ RNA_def_int(ot->srna,
+ "frame_start",
+ 0,
+ INT_MIN,
+ INT_MAX,
+ "Start Frame",
+ "Start frame of the sequence strip",
+ INT_MIN,
+ INT_MAX);
+ }
+
+ if (flag & SEQPROP_ENDFRAME) {
+ /* not usual since most strips have a fixed length */
+ RNA_def_int(ot->srna,
+ "frame_end",
+ 0,
+ INT_MIN,
+ INT_MAX,
+ "End Frame",
+ "End frame for the color strip",
+ INT_MIN,
+ INT_MAX);
+ }
+
+ RNA_def_int(
+ ot->srna, "channel", 1, 1, MAXSEQ, "Channel", "Channel to place this strip into", 1, MAXSEQ);
+
+ RNA_def_boolean(
+ ot->srna, "replace_sel", 1, "Replace Selection", "Replace the current selection");
+
+ /* only for python scripts which import strips and place them after */
+ prop = RNA_def_boolean(
+ ot->srna, "overlap", 0, "Allow Overlap", "Don't correct overlap on new sequence strips");
+ RNA_def_property_flag(prop, PROP_HIDDEN);
}
-static void sequencer_generic_invoke_path__internal(bContext *C, wmOperator *op, const char *identifier)
+static void sequencer_generic_invoke_path__internal(bContext *C,
+ wmOperator *op,
+ const char *identifier)
{
- if (RNA_struct_find_property(op->ptr, identifier)) {
- Scene *scene = CTX_data_scene(C);
- Sequence *last_seq = BKE_sequencer_active_get(scene);
- if (last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) {
- Main *bmain = CTX_data_main(C);
- char path[FILE_MAX];
- BLI_strncpy(path, last_seq->strip->dir, sizeof(path));
- BLI_path_abs(path, BKE_main_blendfile_path(bmain));
- RNA_string_set(op->ptr, identifier, path);
- }
- }
+ if (RNA_struct_find_property(op->ptr, identifier)) {
+ Scene *scene = CTX_data_scene(C);
+ Sequence *last_seq = BKE_sequencer_active_get(scene);
+ if (last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) {
+ Main *bmain = CTX_data_main(C);
+ char path[FILE_MAX];
+ BLI_strncpy(path, last_seq->strip->dir, sizeof(path));
+ BLI_path_abs(path, BKE_main_blendfile_path(bmain));
+ RNA_string_set(op->ptr, identifier, path);
+ }
+ }
}
static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type)
{
- Sequence *tgt = NULL;
- Sequence *seq;
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, true);
- int cfra = (int) CFRA;
- int proximity = INT_MAX;
-
- if (!ed || !ed->seqbasep) {
- return 1;
- }
-
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if ((type == -1 || seq->type == type) &&
- (seq->enddisp < cfra) &&
- (cfra - seq->enddisp < proximity))
- {
- tgt = seq;
- proximity = cfra - seq->enddisp;
- }
- }
-
- if (tgt) {
- return tgt->machine;
- }
- return 1;
+ Sequence *tgt = NULL;
+ Sequence *seq;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, true);
+ int cfra = (int)CFRA;
+ int proximity = INT_MAX;
+
+ if (!ed || !ed->seqbasep) {
+ return 1;
+ }
+
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if ((type == -1 || seq->type == type) && (seq->enddisp < cfra) &&
+ (cfra - seq->enddisp < proximity)) {
+ tgt = seq;
+ proximity = cfra - seq->enddisp;
+ }
+ }
+
+ if (tgt) {
+ return tgt->machine;
+ }
+ return 1;
}
static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, int flag, int type)
{
- Scene *scene = CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
- int cfra = (int) CFRA;
+ int cfra = (int)CFRA;
- /* effect strips don't need a channel initialized from the mouse */
- if (!(flag & SEQPROP_NOCHAN)) {
- RNA_int_set(op->ptr, "channel", sequencer_generic_invoke_xy_guess_channel(C, type));
- }
+ /* effect strips don't need a channel initialized from the mouse */
+ if (!(flag & SEQPROP_NOCHAN)) {
+ RNA_int_set(op->ptr, "channel", sequencer_generic_invoke_xy_guess_channel(C, type));
+ }
- RNA_int_set(op->ptr, "frame_start", cfra);
+ RNA_int_set(op->ptr, "frame_start", cfra);
- if ((flag & SEQPROP_ENDFRAME) && RNA_struct_property_is_set(op->ptr, "frame_end") == 0) {
- RNA_int_set(op->ptr, "frame_end", cfra + 25); // XXX arbitrary but ok for now.
- }
+ if ((flag & SEQPROP_ENDFRAME) && RNA_struct_property_is_set(op->ptr, "frame_end") == 0) {
+ RNA_int_set(op->ptr, "frame_end", cfra + 25); // XXX arbitrary but ok for now.
+ }
- if (!(flag & SEQPROP_NOPATHS)) {
- sequencer_generic_invoke_path__internal(C, op, "filepath");
- sequencer_generic_invoke_path__internal(C, op, "directory");
- }
+ if (!(flag & SEQPROP_NOPATHS)) {
+ sequencer_generic_invoke_path__internal(C, op, "filepath");
+ sequencer_generic_invoke_path__internal(C, op, "directory");
+ }
}
static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperator *op)
{
- Main *bmain = CTX_data_main(C);
-
- PropertyRNA *prop;
- const bool relative = (prop = RNA_struct_find_property(op->ptr, "relative_path")) && RNA_property_boolean_get(op->ptr, prop);
- int is_file = -1;
- memset(seq_load, 0, sizeof(SeqLoadInfo));
-
- seq_load->start_frame = RNA_int_get(op->ptr, "frame_start");
- seq_load->end_frame = seq_load->start_frame; /* un-set */
-
- seq_load->channel = RNA_int_get(op->ptr, "channel");
- seq_load->len = 1; // images only, if endframe isn't set!
-
- if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) {
- /* full path, file is set by the caller */
- RNA_property_string_get(op->ptr, prop, seq_load->path);
- is_file = 1;
- }
- else if ((prop = RNA_struct_find_property(op->ptr, "directory"))) {
- /* full path, file is set by the caller */
- RNA_property_string_get(op->ptr, prop, seq_load->path);
- is_file = 0;
- }
-
- if ((is_file != -1) && relative) {
- BLI_path_rel(seq_load->path, BKE_main_blendfile_path(bmain));
- }
-
-
- if ((prop = RNA_struct_find_property(op->ptr, "frame_end"))) {
- seq_load->end_frame = RNA_property_int_get(op->ptr, prop);
- }
-
- if ((prop = RNA_struct_find_property(op->ptr, "replace_sel")) && RNA_property_boolean_get(op->ptr, prop)) {
- seq_load->flag |= SEQ_LOAD_REPLACE_SEL;
- }
-
- if ((prop = RNA_struct_find_property(op->ptr, "cache")) && RNA_property_boolean_get(op->ptr, prop)) {
- seq_load->flag |= SEQ_LOAD_SOUND_CACHE;
- }
-
- if ((prop = RNA_struct_find_property(op->ptr, "mono")) && RNA_property_boolean_get(op->ptr, prop)) {
- seq_load->flag |= SEQ_LOAD_SOUND_MONO;
- }
-
- if ((prop = RNA_struct_find_property(op->ptr, "sound")) && RNA_property_boolean_get(op->ptr, prop)) {
- seq_load->flag |= SEQ_LOAD_MOVIE_SOUND;
- }
-
- if ((prop = RNA_struct_find_property(op->ptr, "use_framerate")) && RNA_property_boolean_get(op->ptr, prop)) {
- seq_load->flag |= SEQ_LOAD_SYNC_FPS;
- }
-
- /* always use this for ops */
- seq_load->flag |= SEQ_LOAD_FRAME_ADVANCE;
-
-
- if (is_file == 1) {
- BLI_strncpy(seq_load->name, BLI_path_basename(seq_load->path), sizeof(seq_load->name));
- }
- else if ((prop = RNA_struct_find_property(op->ptr, "files"))) {
- /* used for image strip */
- /* best guess, first images name */
- RNA_PROP_BEGIN (op->ptr, itemptr, prop)
- {
- char *name = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
- BLI_strncpy(seq_load->name, name, sizeof(seq_load->name));
- MEM_freeN(name);
- break;
- }
- RNA_PROP_END;
- }
-
- if ((prop = RNA_struct_find_property(op->ptr, "use_multiview")) && RNA_property_boolean_get(op->ptr, prop)) {
- if (op->customdata) {
- SequencerAddData *sad = op->customdata;
- ImageFormatData *imf = &sad->im_format;
-
- seq_load->views_format = imf->views_format;
- seq_load->flag |= SEQ_USE_VIEWS;
-
- /* operator custom data is always released after the SeqLoadInfo,
- * no need to handle the memory here */
- seq_load->stereo3d_format = &imf->stereo3d_format;
- }
- }
+ Main *bmain = CTX_data_main(C);
+
+ PropertyRNA *prop;
+ const bool relative = (prop = RNA_struct_find_property(op->ptr, "relative_path")) &&
+ RNA_property_boolean_get(op->ptr, prop);
+ int is_file = -1;
+ memset(seq_load, 0, sizeof(SeqLoadInfo));
+
+ seq_load->start_frame = RNA_int_get(op->ptr, "frame_start");
+ seq_load->end_frame = seq_load->start_frame; /* un-set */
+
+ seq_load->channel = RNA_int_get(op->ptr, "channel");
+ seq_load->len = 1; // images only, if endframe isn't set!
+
+ if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) {
+ /* full path, file is set by the caller */
+ RNA_property_string_get(op->ptr, prop, seq_load->path);
+ is_file = 1;
+ }
+ else if ((prop = RNA_struct_find_property(op->ptr, "directory"))) {
+ /* full path, file is set by the caller */
+ RNA_property_string_get(op->ptr, prop, seq_load->path);
+ is_file = 0;
+ }
+
+ if ((is_file != -1) && relative) {
+ BLI_path_rel(seq_load->path, BKE_main_blendfile_path(bmain));
+ }
+
+ if ((prop = RNA_struct_find_property(op->ptr, "frame_end"))) {
+ seq_load->end_frame = RNA_property_int_get(op->ptr, prop);
+ }
+
+ if ((prop = RNA_struct_find_property(op->ptr, "replace_sel")) &&
+ RNA_property_boolean_get(op->ptr, prop)) {
+ seq_load->flag |= SEQ_LOAD_REPLACE_SEL;
+ }
+
+ if ((prop = RNA_struct_find_property(op->ptr, "cache")) &&
+ RNA_property_boolean_get(op->ptr, prop)) {
+ seq_load->flag |= SEQ_LOAD_SOUND_CACHE;
+ }
+
+ if ((prop = RNA_struct_find_property(op->ptr, "mono")) &&
+ RNA_property_boolean_get(op->ptr, prop)) {
+ seq_load->flag |= SEQ_LOAD_SOUND_MONO;
+ }
+
+ if ((prop = RNA_struct_find_property(op->ptr, "sound")) &&
+ RNA_property_boolean_get(op->ptr, prop)) {
+ seq_load->flag |= SEQ_LOAD_MOVIE_SOUND;
+ }
+
+ if ((prop = RNA_struct_find_property(op->ptr, "use_framerate")) &&
+ RNA_property_boolean_get(op->ptr, prop)) {
+ seq_load->flag |= SEQ_LOAD_SYNC_FPS;
+ }
+
+ /* always use this for ops */
+ seq_load->flag |= SEQ_LOAD_FRAME_ADVANCE;
+
+ if (is_file == 1) {
+ BLI_strncpy(seq_load->name, BLI_path_basename(seq_load->path), sizeof(seq_load->name));
+ }
+ else if ((prop = RNA_struct_find_property(op->ptr, "files"))) {
+ /* used for image strip */
+ /* best guess, first images name */
+ RNA_PROP_BEGIN (op->ptr, itemptr, prop) {
+ char *name = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
+ BLI_strncpy(seq_load->name, name, sizeof(seq_load->name));
+ MEM_freeN(name);
+ break;
+ }
+ RNA_PROP_END;
+ }
+
+ if ((prop = RNA_struct_find_property(op->ptr, "use_multiview")) &&
+ RNA_property_boolean_get(op->ptr, prop)) {
+ if (op->customdata) {
+ SequencerAddData *sad = op->customdata;
+ ImageFormatData *imf = &sad->im_format;
+
+ seq_load->views_format = imf->views_format;
+ seq_load->flag |= SEQ_USE_VIEWS;
+
+ /* operator custom data is always released after the SeqLoadInfo,
+ * no need to handle the memory here */
+ seq_load->stereo3d_format = &imf->stereo3d_format;
+ }
+ }
}
/**
@@ -271,875 +288,909 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato
*/
static void sequencer_add_apply_overlap(bContext *C, wmOperator *op, Sequence *seq)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
-
- if (RNA_boolean_get(op->ptr, "overlap") == false) {
- if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
- BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
- }
- }
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+
+ if (RNA_boolean_get(op->ptr, "overlap") == false) {
+ if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
+ BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
+ }
+ }
}
static void sequencer_add_apply_replace_sel(bContext *C, wmOperator *op, Sequence *seq)
{
- Scene *scene = CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
- if (RNA_boolean_get(op->ptr, "replace_sel")) {
- ED_sequencer_deselect_all(scene);
- BKE_sequencer_active_set(scene, seq);
- seq->flag |= SELECT;
- }
+ if (RNA_boolean_get(op->ptr, "replace_sel")) {
+ ED_sequencer_deselect_all(scene);
+ BKE_sequencer_active_set(scene, seq);
+ seq->flag |= SELECT;
+ }
}
/* add scene operator */
static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, true);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, true);
- Scene *sce_seq;
+ Scene *sce_seq;
- Sequence *seq; /* generic strip vars */
- Strip *strip;
+ Sequence *seq; /* generic strip vars */
+ Strip *strip;
- int start_frame, channel; /* operator props */
+ int start_frame, channel; /* operator props */
- start_frame = RNA_int_get(op->ptr, "frame_start");
- channel = RNA_int_get(op->ptr, "channel");
+ start_frame = RNA_int_get(op->ptr, "frame_start");
+ channel = RNA_int_get(op->ptr, "channel");
- sce_seq = BLI_findlink(&CTX_data_main(C)->scenes, RNA_enum_get(op->ptr, "scene"));
+ sce_seq = BLI_findlink(&CTX_data_main(C)->scenes, RNA_enum_get(op->ptr, "scene"));
- if (sce_seq == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Scene not found");
- return OPERATOR_CANCELLED;
- }
+ if (sce_seq == NULL) {
+ BKE_report(op->reports, RPT_ERROR, "Scene not found");
+ return OPERATOR_CANCELLED;
+ }
- seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
- seq->type = SEQ_TYPE_SCENE;
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
+ seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
+ seq->type = SEQ_TYPE_SCENE;
+ seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
- seq->scene = sce_seq;
+ seq->scene = sce_seq;
- /* basic defaults */
- seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
- seq->len = sce_seq->r.efra - sce_seq->r.sfra + 1;
- strip->us = 1;
+ /* basic defaults */
+ seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
+ seq->len = sce_seq->r.efra - sce_seq->r.sfra + 1;
+ strip->us = 1;
- BLI_strncpy(seq->name + 2, sce_seq->id.name + 2, sizeof(seq->name) - 2);
- BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
+ BLI_strncpy(seq->name + 2, sce_seq->id.name + 2, sizeof(seq->name) - 2);
+ BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
- seq->scene_sound = BKE_sound_scene_add_scene_sound(scene, seq, start_frame, start_frame + seq->len, 0);
+ seq->scene_sound = BKE_sound_scene_add_scene_sound(
+ scene, seq, start_frame, start_frame + seq->len, 0);
- BKE_sequence_calc_disp(scene, seq);
- BKE_sequencer_sort(scene);
+ BKE_sequence_calc_disp(scene, seq);
+ BKE_sequencer_sort(scene);
- sequencer_add_apply_replace_sel(C, op, seq);
- sequencer_add_apply_overlap(C, op, seq);
+ sequencer_add_apply_replace_sel(C, op, seq);
+ sequencer_add_apply_overlap(C, op, seq);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
-
static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (!RNA_struct_property_is_set(op->ptr, "scene")) {
- return WM_enum_search_invoke(C, op, event);
- }
-
- sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_SCENE);
- return sequencer_add_scene_strip_exec(C, op);
- // needs a menu
- // return WM_menu_invoke(C, op, event);
+ if (!RNA_struct_property_is_set(op->ptr, "scene")) {
+ return WM_enum_search_invoke(C, op, event);
+ }
+
+ sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_SCENE);
+ return sequencer_add_scene_strip_exec(C, op);
+ // needs a menu
+ // return WM_menu_invoke(C, op, event);
}
-
void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot)
{
- PropertyRNA *prop;
+ PropertyRNA *prop;
- /* identifiers */
- ot->name = "Add Scene Strip";
- ot->idname = "SEQUENCER_OT_scene_strip_add";
- ot->description = "Add a strip to the sequencer using a blender scene as a source";
+ /* identifiers */
+ ot->name = "Add Scene Strip";
+ ot->idname = "SEQUENCER_OT_scene_strip_add";
+ ot->description = "Add a strip to the sequencer using a blender scene as a source";
- /* api callbacks */
- ot->invoke = sequencer_add_scene_strip_invoke;
- ot->exec = sequencer_add_scene_strip_exec;
+ /* api callbacks */
+ ot->invoke = sequencer_add_scene_strip_invoke;
+ ot->exec = sequencer_add_scene_strip_exec;
- ot->poll = ED_operator_sequencer_active_editable;
+ ot->poll = ED_operator_sequencer_active_editable;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
- prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
- RNA_def_enum_funcs(prop, RNA_scene_without_active_itemf);
- RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
- ot->prop = prop;
+ sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
+ prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
+ RNA_def_enum_funcs(prop, RNA_scene_without_active_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
+ ot->prop = prop;
}
/* add movieclip operator */
static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, true);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, true);
- MovieClip *clip;
+ MovieClip *clip;
- Sequence *seq; /* generic strip vars */
- Strip *strip;
+ Sequence *seq; /* generic strip vars */
+ Strip *strip;
- int start_frame, channel; /* operator props */
+ int start_frame, channel; /* operator props */
- start_frame = RNA_int_get(op->ptr, "frame_start");
- channel = RNA_int_get(op->ptr, "channel");
+ start_frame = RNA_int_get(op->ptr, "frame_start");
+ channel = RNA_int_get(op->ptr, "channel");
- clip = BLI_findlink(&CTX_data_main(C)->movieclips, RNA_enum_get(op->ptr, "clip"));
+ clip = BLI_findlink(&CTX_data_main(C)->movieclips, RNA_enum_get(op->ptr, "clip"));
- if (clip == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Movie clip not found");
- return OPERATOR_CANCELLED;
- }
+ if (clip == NULL) {
+ BKE_report(op->reports, RPT_ERROR, "Movie clip not found");
+ return OPERATOR_CANCELLED;
+ }
- seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
- seq->type = SEQ_TYPE_MOVIECLIP;
- seq->blend_mode = SEQ_TYPE_CROSS;
- seq->clip = clip;
+ seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
+ seq->type = SEQ_TYPE_MOVIECLIP;
+ seq->blend_mode = SEQ_TYPE_CROSS;
+ seq->clip = clip;
- id_us_ensure_real(&seq->clip->id);
+ id_us_ensure_real(&seq->clip->id);
- /* basic defaults */
- seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
- seq->len = BKE_movieclip_get_duration(clip);
- strip->us = 1;
+ /* basic defaults */
+ seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
+ seq->len = BKE_movieclip_get_duration(clip);
+ strip->us = 1;
- BLI_strncpy(seq->name + 2, clip->id.name + 2, sizeof(seq->name) - 2);
- BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
+ BLI_strncpy(seq->name + 2, clip->id.name + 2, sizeof(seq->name) - 2);
+ BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
- BKE_sequence_calc_disp(scene, seq);
- BKE_sequencer_sort(scene);
+ BKE_sequence_calc_disp(scene, seq);
+ BKE_sequencer_sort(scene);
- sequencer_add_apply_replace_sel(C, op, seq);
- sequencer_add_apply_overlap(C, op, seq);
+ sequencer_add_apply_replace_sel(C, op, seq);
+ sequencer_add_apply_overlap(C, op, seq);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
static int sequencer_add_movieclip_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (!RNA_struct_property_is_set(op->ptr, "clip")) {
- return WM_enum_search_invoke(C, op, event);
- }
-
- sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIECLIP);
- return sequencer_add_movieclip_strip_exec(C, op);
- // needs a menu
- // return WM_menu_invoke(C, op, event);
+ if (!RNA_struct_property_is_set(op->ptr, "clip")) {
+ return WM_enum_search_invoke(C, op, event);
+ }
+
+ sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIECLIP);
+ return sequencer_add_movieclip_strip_exec(C, op);
+ // needs a menu
+ // return WM_menu_invoke(C, op, event);
}
void SEQUENCER_OT_movieclip_strip_add(struct wmOperatorType *ot)
{
- PropertyRNA *prop;
+ PropertyRNA *prop;
- /* identifiers */
- ot->name = "Add MovieClip Strip";
- ot->idname = "SEQUENCER_OT_movieclip_strip_add";
- ot->description = "Add a movieclip strip to the sequencer";
+ /* identifiers */
+ ot->name = "Add MovieClip Strip";
+ ot->idname = "SEQUENCER_OT_movieclip_strip_add";
+ ot->description = "Add a movieclip strip to the sequencer";
- /* api callbacks */
- ot->invoke = sequencer_add_movieclip_strip_invoke;
- ot->exec = sequencer_add_movieclip_strip_exec;
+ /* api callbacks */
+ ot->invoke = sequencer_add_movieclip_strip_invoke;
+ ot->exec = sequencer_add_movieclip_strip_exec;
- ot->poll = ED_operator_sequencer_active_editable;
+ ot->poll = ED_operator_sequencer_active_editable;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
- prop = RNA_def_enum(ot->srna, "clip", DummyRNA_NULL_items, 0, "Clip", "");
- RNA_def_enum_funcs(prop, RNA_movieclip_itemf);
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MOVIECLIP);
- RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
- ot->prop = prop;
+ sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
+ prop = RNA_def_enum(ot->srna, "clip", DummyRNA_NULL_items, 0, "Clip", "");
+ RNA_def_enum_funcs(prop, RNA_movieclip_itemf);
+ RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MOVIECLIP);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
+ ot->prop = prop;
}
static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, true);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, true);
- Mask *mask;
+ Mask *mask;
- Sequence *seq; /* generic strip vars */
- Strip *strip;
+ Sequence *seq; /* generic strip vars */
+ Strip *strip;
- int start_frame, channel; /* operator props */
+ int start_frame, channel; /* operator props */
- start_frame = RNA_int_get(op->ptr, "frame_start");
- channel = RNA_int_get(op->ptr, "channel");
+ start_frame = RNA_int_get(op->ptr, "frame_start");
+ channel = RNA_int_get(op->ptr, "channel");
- mask = BLI_findlink(&CTX_data_main(C)->masks, RNA_enum_get(op->ptr, "mask"));
+ mask = BLI_findlink(&CTX_data_main(C)->masks, RNA_enum_get(op->ptr, "mask"));
- if (mask == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Mask not found");
- return OPERATOR_CANCELLED;
- }
+ if (mask == NULL) {
+ BKE_report(op->reports, RPT_ERROR, "Mask not found");
+ return OPERATOR_CANCELLED;
+ }
- seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
- seq->type = SEQ_TYPE_MASK;
- seq->blend_mode = SEQ_TYPE_CROSS;
- seq->mask = mask;
+ seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
+ seq->type = SEQ_TYPE_MASK;
+ seq->blend_mode = SEQ_TYPE_CROSS;
+ seq->mask = mask;
- id_us_ensure_real(&seq->mask->id);
+ id_us_ensure_real(&seq->mask->id);
- /* basic defaults */
- seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
- seq->len = BKE_mask_get_duration(mask);
- strip->us = 1;
+ /* basic defaults */
+ seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
+ seq->len = BKE_mask_get_duration(mask);
+ strip->us = 1;
- BLI_strncpy(seq->name + 2, mask->id.name + 2, sizeof(seq->name) - 2);
- BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
+ BLI_strncpy(seq->name + 2, mask->id.name + 2, sizeof(seq->name) - 2);
+ BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
- BKE_sequence_calc_disp(scene, seq);
- BKE_sequencer_sort(scene);
+ BKE_sequence_calc_disp(scene, seq);
+ BKE_sequencer_sort(scene);
- sequencer_add_apply_replace_sel(C, op, seq);
- sequencer_add_apply_overlap(C, op, seq);
+ sequencer_add_apply_replace_sel(C, op, seq);
+ sequencer_add_apply_overlap(C, op, seq);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
static int sequencer_add_mask_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (!RNA_struct_property_is_set(op->ptr, "mask")) {
- return WM_enum_search_invoke(C, op, event);
- }
-
- sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MASK);
- return sequencer_add_mask_strip_exec(C, op);
- // needs a menu
- // return WM_menu_invoke(C, op, event);
+ if (!RNA_struct_property_is_set(op->ptr, "mask")) {
+ return WM_enum_search_invoke(C, op, event);
+ }
+
+ sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MASK);
+ return sequencer_add_mask_strip_exec(C, op);
+ // needs a menu
+ // return WM_menu_invoke(C, op, event);
}
-
void SEQUENCER_OT_mask_strip_add(struct wmOperatorType *ot)
{
- PropertyRNA *prop;
+ PropertyRNA *prop;
- /* identifiers */
- ot->name = "Add Mask Strip";
- ot->idname = "SEQUENCER_OT_mask_strip_add";
- ot->description = "Add a mask strip to the sequencer";
+ /* identifiers */
+ ot->name = "Add Mask Strip";
+ ot->idname = "SEQUENCER_OT_mask_strip_add";
+ ot->description = "Add a mask strip to the sequencer";
- /* api callbacks */
- ot->invoke = sequencer_add_mask_strip_invoke;
- ot->exec = sequencer_add_mask_strip_exec;
+ /* api callbacks */
+ ot->invoke = sequencer_add_mask_strip_invoke;
+ ot->exec = sequencer_add_mask_strip_exec;
- ot->poll = ED_operator_sequencer_active_editable;
+ ot->poll = ED_operator_sequencer_active_editable;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
- prop = RNA_def_enum(ot->srna, "mask", DummyRNA_NULL_items, 0, "Mask", "");
- RNA_def_enum_funcs(prop, RNA_mask_itemf);
- RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
- ot->prop = prop;
+ sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
+ prop = RNA_def_enum(ot->srna, "mask", DummyRNA_NULL_items, 0, "Mask", "");
+ RNA_def_enum_funcs(prop, RNA_mask_itemf);
+ RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
+ ot->prop = prop;
}
-
static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoadFunc seq_load_func)
{
- Scene *scene = CTX_data_scene(C); /* only for sound */
- Editing *ed = BKE_sequencer_editing_get(scene, true);
- SeqLoadInfo seq_load;
- int tot_files;
-
- seq_load_operator_info(&seq_load, C, op);
-
- if (seq_load.flag & SEQ_LOAD_REPLACE_SEL) {
- ED_sequencer_deselect_all(scene);
- }
-
- if (RNA_struct_property_is_set(op->ptr, "files")) {
- tot_files = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
- }
- else {
- tot_files = 0;
- }
-
- if (tot_files) {
- /* multiple files */
- char dir_only[FILE_MAX];
- char file_only[FILE_MAX];
-
- BLI_split_dir_part(seq_load.path, dir_only, sizeof(dir_only));
-
- RNA_BEGIN (op->ptr, itemptr, "files")
- {
- Sequence *seq;
-
- RNA_string_get(&itemptr, "name", file_only);
- BLI_join_dirfile(seq_load.path, sizeof(seq_load.path), dir_only, file_only);
-
- /* Set seq_load.name, else all video/audio files get the same name! ugly! */
- BLI_strncpy(seq_load.name, file_only, sizeof(seq_load.name));
-
- seq = seq_load_func(C, ed->seqbasep, &seq_load);
- if (seq) {
- sequencer_add_apply_overlap(C, op, seq);
- if (seq_load.seq_sound) {
- sequencer_add_apply_overlap(C, op, seq_load.seq_sound);
- }
- }
- }
- RNA_END;
- }
- else {
- Sequence *seq;
-
- /* single file */
- seq = seq_load_func(C, ed->seqbasep, &seq_load);
- if (seq) {
- sequencer_add_apply_overlap(C, op, seq);
- if (seq_load.seq_sound) {
- sequencer_add_apply_overlap(C, op, seq_load.seq_sound);
- }
- }
- }
-
- if (seq_load.tot_success == 0) {
- BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", seq_load.path);
- return OPERATOR_CANCELLED;
- }
-
- if (op->customdata) {
- MEM_freeN(op->customdata);
- }
-
- BKE_sequencer_sort(scene);
- BKE_sequencer_update_muting(ed);
-
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- return OPERATOR_FINISHED;
+ Scene *scene = CTX_data_scene(C); /* only for sound */
+ Editing *ed = BKE_sequencer_editing_get(scene, true);
+ SeqLoadInfo seq_load;
+ int tot_files;
+
+ seq_load_operator_info(&seq_load, C, op);
+
+ if (seq_load.flag & SEQ_LOAD_REPLACE_SEL) {
+ ED_sequencer_deselect_all(scene);
+ }
+
+ if (RNA_struct_property_is_set(op->ptr, "files")) {
+ tot_files = RNA_property_collection_length(op->ptr,
+ RNA_struct_find_property(op->ptr, "files"));
+ }
+ else {
+ tot_files = 0;
+ }
+
+ if (tot_files) {
+ /* multiple files */
+ char dir_only[FILE_MAX];
+ char file_only[FILE_MAX];
+
+ BLI_split_dir_part(seq_load.path, dir_only, sizeof(dir_only));
+
+ RNA_BEGIN (op->ptr, itemptr, "files") {
+ Sequence *seq;
+
+ RNA_string_get(&itemptr, "name", file_only);
+ BLI_join_dirfile(seq_load.path, sizeof(seq_load.path), dir_only, file_only);
+
+ /* Set seq_load.name, else all video/audio files get the same name! ugly! */
+ BLI_strncpy(seq_load.name, file_only, sizeof(seq_load.name));
+
+ seq = seq_load_func(C, ed->seqbasep, &seq_load);
+ if (seq) {
+ sequencer_add_apply_overlap(C, op, seq);
+ if (seq_load.seq_sound) {
+ sequencer_add_apply_overlap(C, op, seq_load.seq_sound);
+ }
+ }
+ }
+ RNA_END;
+ }
+ else {
+ Sequence *seq;
+
+ /* single file */
+ seq = seq_load_func(C, ed->seqbasep, &seq_load);
+ if (seq) {
+ sequencer_add_apply_overlap(C, op, seq);
+ if (seq_load.seq_sound) {
+ sequencer_add_apply_overlap(C, op, seq_load.seq_sound);
+ }
+ }
+ }
+
+ if (seq_load.tot_success == 0) {
+ BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", seq_load.path);
+ return OPERATOR_CANCELLED;
+ }
+
+ if (op->customdata) {
+ MEM_freeN(op->customdata);
+ }
+
+ BKE_sequencer_sort(scene);
+ BKE_sequencer_update_muting(ed);
+
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+
+ return OPERATOR_FINISHED;
}
/* add sequencer operators */
static void sequencer_add_init(bContext *UNUSED(C), wmOperator *op)
{
- op->customdata = MEM_callocN(sizeof(SequencerAddData), __func__);
+ op->customdata = MEM_callocN(sizeof(SequencerAddData), __func__);
}
static void sequencer_add_cancel(bContext *UNUSED(C), wmOperator *op)
{
- if (op->customdata) {
- MEM_freeN(op->customdata);
- }
- op->customdata = NULL;
+ if (op->customdata) {
+ MEM_freeN(op->customdata);
+ }
+ op->customdata = NULL;
}
-static bool sequencer_add_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop, void *UNUSED(user_data))
+static bool sequencer_add_draw_check_prop(PointerRNA *UNUSED(ptr),
+ PropertyRNA *prop,
+ void *UNUSED(user_data))
{
- const char *prop_id = RNA_property_identifier(prop);
+ const char *prop_id = RNA_property_identifier(prop);
- return !(STREQ(prop_id, "filepath") ||
- STREQ(prop_id, "directory") ||
- STREQ(prop_id, "filename")
- );
+ return !(STREQ(prop_id, "filepath") || STREQ(prop_id, "directory") ||
+ STREQ(prop_id, "filename"));
}
/* add movie operator */
static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op)
{
- return sequencer_add_generic_strip_exec(C, op, BKE_sequencer_add_movie_strip);
+ return sequencer_add_generic_strip_exec(C, op, BKE_sequencer_add_movie_strip);
}
-static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+static int sequencer_add_movie_strip_invoke(bContext *C,
+ wmOperator *op,
+ const wmEvent *UNUSED(event))
{
- PropertyRNA *prop;
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
-
- /* only enable "use_framerate" if there aren't any existing strips
- * - When there are no strips yet, there is no harm in enabling this,
- * and it makes the single-strip case really nice for casual users
- * - When there are strips, it's best we don't touch the framerate,
- * as all hell may break loose (e.g. audio strips start overlapping
- * and can't be restored)
- * - These initial guesses can still be manually overridden by users
- * from the modal options panel
- */
- if (ed && ed->seqbasep && ed->seqbasep->first) {
- RNA_boolean_set(op->ptr, "use_framerate", false);
- }
-
- /* This is for drag and drop */
- if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) ||
- RNA_struct_property_is_set(op->ptr, "filepath"))
- {
- sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_MOVIE);
- return sequencer_add_movie_strip_exec(C, op);
- }
-
- sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIE);
-
- sequencer_add_init(C, op);
-
- /* show multiview save options only if scene has multiviews */
- prop = RNA_struct_find_property(op->ptr, "show_multiview");
- RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0);
-
- WM_event_add_fileselect(C, op);
- return OPERATOR_RUNNING_MODAL;
-
- //return sequencer_add_movie_strip_exec(C, op);
+ PropertyRNA *prop;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+
+ /* only enable "use_framerate" if there aren't any existing strips
+ * - When there are no strips yet, there is no harm in enabling this,
+ * and it makes the single-strip case really nice for casual users
+ * - When there are strips, it's best we don't touch the framerate,
+ * as all hell may break loose (e.g. audio strips start overlapping
+ * and can't be restored)
+ * - These initial guesses can still be manually overridden by users
+ * from the modal options panel
+ */
+ if (ed && ed->seqbasep && ed->seqbasep->first) {
+ RNA_boolean_set(op->ptr, "use_framerate", false);
+ }
+
+ /* This is for drag and drop */
+ if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) ||
+ RNA_struct_property_is_set(op->ptr, "filepath")) {
+ sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_MOVIE);
+ return sequencer_add_movie_strip_exec(C, op);
+ }
+
+ sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIE);
+
+ sequencer_add_init(C, op);
+
+ /* show multiview save options only if scene has multiviews */
+ prop = RNA_struct_find_property(op->ptr, "show_multiview");
+ RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0);
+
+ WM_event_add_fileselect(C, op);
+ return OPERATOR_RUNNING_MODAL;
+
+ //return sequencer_add_movie_strip_exec(C, op);
}
static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op)
{
- uiLayout *layout = op->layout;
- SequencerAddData *sad = op->customdata;
- ImageFormatData *imf = &sad->im_format;
- PointerRNA imf_ptr, ptr;
-
- /* main draw call */
- RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, sequencer_add_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
-
- /* image template */
- RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
-
- /* multiview template */
- if (RNA_boolean_get(op->ptr, "show_multiview")) {
- uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr);
- }
+ uiLayout *layout = op->layout;
+ SequencerAddData *sad = op->customdata;
+ ImageFormatData *imf = &sad->im_format;
+ PointerRNA imf_ptr, ptr;
+
+ /* main draw call */
+ RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
+ uiDefAutoButsRNA(
+ layout, &ptr, sequencer_add_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false);
+
+ /* image template */
+ RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
+
+ /* multiview template */
+ if (RNA_boolean_get(op->ptr, "show_multiview")) {
+ uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr);
+ }
}
void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Add Movie Strip";
- ot->idname = "SEQUENCER_OT_movie_strip_add";
- ot->description = "Add a movie strip to the sequencer";
-
- /* api callbacks */
- ot->invoke = sequencer_add_movie_strip_invoke;
- ot->exec = sequencer_add_movie_strip_exec;
- ot->cancel = sequencer_add_cancel;
- ot->ui = sequencer_add_draw;
-
- ot->poll = ED_operator_sequencer_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- WM_operator_properties_filesel(
- ot, FILE_TYPE_FOLDER | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_OPENFILE,
- WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
- sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
- RNA_def_boolean(ot->srna, "sound", true, "Sound", "Load sound with the movie");
- RNA_def_boolean(ot->srna, "use_framerate", true, "Use Movie Framerate", "Use framerate from the movie to keep sound and video in sync");
+ /* identifiers */
+ ot->name = "Add Movie Strip";
+ ot->idname = "SEQUENCER_OT_movie_strip_add";
+ ot->description = "Add a movie strip to the sequencer";
+
+ /* api callbacks */
+ ot->invoke = sequencer_add_movie_strip_invoke;
+ ot->exec = sequencer_add_movie_strip_exec;
+ ot->cancel = sequencer_add_cancel;
+ ot->ui = sequencer_add_draw;
+
+ ot->poll = ED_operator_sequencer_active_editable;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ WM_operator_properties_filesel(ot,
+ FILE_TYPE_FOLDER | FILE_TYPE_MOVIE,
+ FILE_SPECIAL,
+ FILE_OPENFILE,
+ WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES,
+ FILE_DEFAULTDISPLAY,
+ FILE_SORT_ALPHA);
+ sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
+ RNA_def_boolean(ot->srna, "sound", true, "Sound", "Load sound with the movie");
+ RNA_def_boolean(ot->srna,
+ "use_framerate",
+ true,
+ "Use Movie Framerate",
+ "Use framerate from the movie to keep sound and video in sync");
}
/* add sound operator */
static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op)
{
- return sequencer_add_generic_strip_exec(C, op, BKE_sequencer_add_sound_strip);
+ return sequencer_add_generic_strip_exec(C, op, BKE_sequencer_add_sound_strip);
}
-static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+static int sequencer_add_sound_strip_invoke(bContext *C,
+ wmOperator *op,
+ const wmEvent *UNUSED(event))
{
- /* This is for drag and drop */
- if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) ||
- RNA_struct_property_is_set(op->ptr, "filepath"))
- {
- sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_SOUND_RAM);
- return sequencer_add_sound_strip_exec(C, op);
- }
+ /* This is for drag and drop */
+ if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) ||
+ RNA_struct_property_is_set(op->ptr, "filepath")) {
+ sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_SOUND_RAM);
+ return sequencer_add_sound_strip_exec(C, op);
+ }
- sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_SOUND_RAM);
+ sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_SOUND_RAM);
- WM_event_add_fileselect(C, op);
- return OPERATOR_RUNNING_MODAL;
+ WM_event_add_fileselect(C, op);
+ return OPERATOR_RUNNING_MODAL;
- //return sequencer_add_sound_strip_exec(C, op);
+ //return sequencer_add_sound_strip_exec(C, op);
}
-
void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Add Sound Strip";
- ot->idname = "SEQUENCER_OT_sound_strip_add";
- ot->description = "Add a sound strip to the sequencer";
-
- /* api callbacks */
- ot->invoke = sequencer_add_sound_strip_invoke;
- ot->exec = sequencer_add_sound_strip_exec;
-
- ot->poll = ED_operator_sequencer_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- WM_operator_properties_filesel(
- ot, FILE_TYPE_FOLDER | FILE_TYPE_SOUND, FILE_SPECIAL, FILE_OPENFILE,
- WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
- sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
- RNA_def_boolean(ot->srna, "cache", false, "Cache", "Cache the sound in memory");
- RNA_def_boolean(ot->srna, "mono", false, "Mono", "Merge all the sound's channels into one");
+ /* identifiers */
+ ot->name = "Add Sound Strip";
+ ot->idname = "SEQUENCER_OT_sound_strip_add";
+ ot->description = "Add a sound strip to the sequencer";
+
+ /* api callbacks */
+ ot->invoke = sequencer_add_sound_strip_invoke;
+ ot->exec = sequencer_add_sound_strip_exec;
+
+ ot->poll = ED_operator_sequencer_active_editable;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ WM_operator_properties_filesel(ot,
+ FILE_TYPE_FOLDER | FILE_TYPE_SOUND,
+ FILE_SPECIAL,
+ FILE_OPENFILE,
+ WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES,
+ FILE_DEFAULTDISPLAY,
+ FILE_SORT_ALPHA);
+ sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
+ RNA_def_boolean(ot->srna, "cache", false, "Cache", "Cache the sound in memory");
+ RNA_def_boolean(ot->srna, "mono", false, "Mono", "Merge all the sound's channels into one");
}
-int sequencer_image_seq_get_minmax_frame(wmOperator *op, int sfra, int *r_minframe, int *r_numdigits)
+int sequencer_image_seq_get_minmax_frame(wmOperator *op,
+ int sfra,
+ int *r_minframe,
+ int *r_numdigits)
{
- int minframe = INT32_MAX, maxframe = INT32_MIN;
- int numdigits = 0;
-
- RNA_BEGIN (op->ptr, itemptr, "files")
- {
- char *filename;
- int frame;
- /* just get the first filename */
- filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
-
- if (filename) {
- if (BLI_path_frame_get(filename, &frame, &numdigits)) {
- minframe = min_ii(minframe, frame);
- maxframe = max_ii(maxframe, frame);
- }
-
- MEM_freeN(filename);
- }
- }
- RNA_END;
-
- if (minframe == INT32_MAX) {
- minframe = sfra;
- maxframe = minframe + 1;
- }
-
- *r_minframe = minframe;
- *r_numdigits = numdigits;
-
- return maxframe - minframe + 1;
+ int minframe = INT32_MAX, maxframe = INT32_MIN;
+ int numdigits = 0;
+
+ RNA_BEGIN (op->ptr, itemptr, "files") {
+ char *filename;
+ int frame;
+ /* just get the first filename */
+ filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
+
+ if (filename) {
+ if (BLI_path_frame_get(filename, &frame, &numdigits)) {
+ minframe = min_ii(minframe, frame);
+ maxframe = max_ii(maxframe, frame);
+ }
+
+ MEM_freeN(filename);
+ }
+ }
+ RNA_END;
+
+ if (minframe == INT32_MAX) {
+ minframe = sfra;
+ maxframe = minframe + 1;
+ }
+
+ *r_minframe = minframe;
+ *r_numdigits = numdigits;
+
+ return maxframe - minframe + 1;
}
-void sequencer_image_seq_reserve_frames(wmOperator *op, StripElem *se, int len, int minframe, int numdigits)
+void sequencer_image_seq_reserve_frames(
+ wmOperator *op, StripElem *se, int len, int minframe, int numdigits)
{
- int i;
- char *filename = NULL;
- RNA_BEGIN (op->ptr, itemptr, "files")
- {
- /* just get the first filename */
- filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
- break;
- }
- RNA_END;
-
- if (filename) {
- char ext[PATH_MAX];
- char filename_stripped[PATH_MAX];
- /* strip the frame from filename and substitute with # */
- BLI_path_frame_strip(filename, ext);
-
- for (i = 0; i < len; i++, se++) {
- BLI_strncpy(filename_stripped, filename, sizeof(filename_stripped));
- BLI_path_frame(filename_stripped, minframe + i, numdigits);
- BLI_snprintf(se->name, sizeof(se->name), "%s%s", filename_stripped, ext);
- }
-
- MEM_freeN(filename);
- }
+ int i;
+ char *filename = NULL;
+ RNA_BEGIN (op->ptr, itemptr, "files") {
+ /* just get the first filename */
+ filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
+ break;
+ }
+ RNA_END;
+
+ if (filename) {
+ char ext[PATH_MAX];
+ char filename_stripped[PATH_MAX];
+ /* strip the frame from filename and substitute with # */
+ BLI_path_frame_strip(filename, ext);
+
+ for (i = 0; i < len; i++, se++) {
+ BLI_strncpy(filename_stripped, filename, sizeof(filename_stripped));
+ BLI_path_frame(filename_stripped, minframe + i, numdigits);
+ BLI_snprintf(se->name, sizeof(se->name), "%s%s", filename_stripped, ext);
+ }
+
+ MEM_freeN(filename);
+ }
}
-
/* add image operator */
static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
{
- int minframe, numdigits;
- /* cant use the generic function for this */
- Scene *scene = CTX_data_scene(C); /* only for sound */
- Editing *ed = BKE_sequencer_editing_get(scene, true);
- SeqLoadInfo seq_load;
- Sequence *seq;
-
- Strip *strip;
- StripElem *se;
- const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
-
- seq_load_operator_info(&seq_load, C, op);
-
- /* images are unique in how they handle this - 1 per strip elem */
- if (use_placeholders) {
- seq_load.len = sequencer_image_seq_get_minmax_frame(op, seq_load.start_frame, &minframe, &numdigits);
- }
- else {
- seq_load.len = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
- }
-
- if (seq_load.len == 0) {
- return OPERATOR_CANCELLED;
- }
-
- if (seq_load.flag & SEQ_LOAD_REPLACE_SEL) {
- ED_sequencer_deselect_all(scene);
- }
-
- /* main adding function */
- seq = BKE_sequencer_add_image_strip(C, ed->seqbasep, &seq_load);
- strip = seq->strip;
- se = strip->stripdata;
-
- seq->blend_mode = SEQ_TYPE_ALPHAOVER;
-
- if (use_placeholders) {
- sequencer_image_seq_reserve_frames(op, se, seq_load.len, minframe, numdigits);
- }
- else {
- RNA_BEGIN (op->ptr, itemptr, "files")
- {
- char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
- BLI_strncpy(se->name, filename, sizeof(se->name));
- MEM_freeN(filename);
- se++;
- }
- RNA_END;
- }
-
- if (seq_load.len == 1) {
- if (seq_load.start_frame < seq_load.end_frame) {
- seq->endstill = seq_load.end_frame - seq_load.start_frame;
- }
- }
-
- BKE_sequence_init_colorspace(seq);
-
- BKE_sequence_calc_disp(scene, seq);
-
- BKE_sequencer_sort(scene);
-
- /* last active name */
- BLI_strncpy(ed->act_imagedir, strip->dir, sizeof(ed->act_imagedir));
-
- sequencer_add_apply_overlap(C, op, seq);
-
- if (op->customdata) {
- MEM_freeN(op->customdata);
- }
-
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- return OPERATOR_FINISHED;
+ int minframe, numdigits;
+ /* cant use the generic function for this */
+ Scene *scene = CTX_data_scene(C); /* only for sound */
+ Editing *ed = BKE_sequencer_editing_get(scene, true);
+ SeqLoadInfo seq_load;
+ Sequence *seq;
+
+ Strip *strip;
+ StripElem *se;
+ const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
+
+ seq_load_operator_info(&seq_load, C, op);
+
+ /* images are unique in how they handle this - 1 per strip elem */
+ if (use_placeholders) {
+ seq_load.len = sequencer_image_seq_get_minmax_frame(
+ op, seq_load.start_frame, &minframe, &numdigits);
+ }
+ else {
+ seq_load.len = RNA_property_collection_length(op->ptr,
+ RNA_struct_find_property(op->ptr, "files"));
+ }
+
+ if (seq_load.len == 0) {
+ return OPERATOR_CANCELLED;
+ }
+
+ if (seq_load.flag & SEQ_LOAD_REPLACE_SEL) {
+ ED_sequencer_deselect_all(scene);
+ }
+
+ /* main adding function */
+ seq = BKE_sequencer_add_image_strip(C, ed->seqbasep, &seq_load);
+ strip = seq->strip;
+ se = strip->stripdata;
+
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
+
+ if (use_placeholders) {
+ sequencer_image_seq_reserve_frames(op, se, seq_load.len, minframe, numdigits);
+ }
+ else {
+ RNA_BEGIN (op->ptr, itemptr, "files") {
+ char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
+ BLI_strncpy(se->name, filename, sizeof(se->name));
+ MEM_freeN(filename);
+ se++;
+ }
+ RNA_END;
+ }
+
+ if (seq_load.len == 1) {
+ if (seq_load.start_frame < seq_load.end_frame) {
+ seq->endstill = seq_load.end_frame - seq_load.start_frame;
+ }
+ }
+
+ BKE_sequence_init_colorspace(seq);
+
+ BKE_sequence_calc_disp(scene, seq);
+
+ BKE_sequencer_sort(scene);
+
+ /* last active name */
+ BLI_strncpy(ed->act_imagedir, strip->dir, sizeof(ed->act_imagedir));
+
+ sequencer_add_apply_overlap(C, op, seq);
+
+ if (op->customdata) {
+ MEM_freeN(op->customdata);
+ }
+
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+
+ return OPERATOR_FINISHED;
}
-static int sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+static int sequencer_add_image_strip_invoke(bContext *C,
+ wmOperator *op,
+ const wmEvent *UNUSED(event))
{
- PropertyRNA *prop;
- Scene *scene = CTX_data_scene(C);
+ PropertyRNA *prop;
+ Scene *scene = CTX_data_scene(C);
- /* drag drop has set the names */
- if (RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) {
- sequencer_generic_invoke_xy__internal(C, op, SEQPROP_ENDFRAME | SEQPROP_NOPATHS, SEQ_TYPE_IMAGE);
- return sequencer_add_image_strip_exec(C, op);
- }
+ /* drag drop has set the names */
+ if (RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) {
+ sequencer_generic_invoke_xy__internal(
+ C, op, SEQPROP_ENDFRAME | SEQPROP_NOPATHS, SEQ_TYPE_IMAGE);
+ return sequencer_add_image_strip_exec(C, op);
+ }
- sequencer_generic_invoke_xy__internal(C, op, SEQPROP_ENDFRAME, SEQ_TYPE_IMAGE);
+ sequencer_generic_invoke_xy__internal(C, op, SEQPROP_ENDFRAME, SEQ_TYPE_IMAGE);
- sequencer_add_init(C, op);
+ sequencer_add_init(C, op);
- /* show multiview save options only if scene has multiviews */
- prop = RNA_struct_find_property(op->ptr, "show_multiview");
- RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0);
+ /* show multiview save options only if scene has multiviews */
+ prop = RNA_struct_find_property(op->ptr, "show_multiview");
+ RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0);
- WM_event_add_fileselect(C, op);
- return OPERATOR_RUNNING_MODAL;
+ WM_event_add_fileselect(C, op);
+ return OPERATOR_RUNNING_MODAL;
}
-
void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Add Image Strip";
- ot->idname = "SEQUENCER_OT_image_strip_add";
- ot->description = "Add an image or image sequence to the sequencer";
-
- /* api callbacks */
- ot->invoke = sequencer_add_image_strip_invoke;
- ot->exec = sequencer_add_image_strip_exec;
- ot->cancel = sequencer_add_cancel;
- ot->ui = sequencer_add_draw;
-
- ot->poll = ED_operator_sequencer_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- WM_operator_properties_filesel(
- ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE, FILE_SPECIAL, FILE_OPENFILE,
- WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
- sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME | SEQPROP_ENDFRAME);
-
- RNA_def_boolean(ot->srna, "use_placeholders", false, "Use Placeholders", "Use placeholders for missing frames of the strip");
+ /* identifiers */
+ ot->name = "Add Image Strip";
+ ot->idname = "SEQUENCER_OT_image_strip_add";
+ ot->description = "Add an image or image sequence to the sequencer";
+
+ /* api callbacks */
+ ot->invoke = sequencer_add_image_strip_invoke;
+ ot->exec = sequencer_add_image_strip_exec;
+ ot->cancel = sequencer_add_cancel;
+ ot->ui = sequencer_add_draw;
+
+ ot->poll = ED_operator_sequencer_active_editable;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ WM_operator_properties_filesel(ot,
+ FILE_TYPE_FOLDER | FILE_TYPE_IMAGE,
+ FILE_SPECIAL,
+ FILE_OPENFILE,
+ WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILES,
+ FILE_DEFAULTDISPLAY,
+ FILE_SORT_ALPHA);
+ sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME | SEQPROP_ENDFRAME);
+
+ RNA_def_boolean(ot->srna,
+ "use_placeholders",
+ false,
+ "Use Placeholders",
+ "Use placeholders for missing frames of the strip");
}
-
/* add_effect_strip operator */
static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, true);
-
- Sequence *seq; /* generic strip vars */
- Strip *strip;
- struct SeqEffectHandle sh;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, true);
- int start_frame, end_frame, channel, type; /* operator props */
+ Sequence *seq; /* generic strip vars */
+ Strip *strip;
+ struct SeqEffectHandle sh;
- Sequence *seq1, *seq2, *seq3;
- const char *error_msg;
+ int start_frame, end_frame, channel, type; /* operator props */
- start_frame = RNA_int_get(op->ptr, "frame_start");
- end_frame = RNA_int_get(op->ptr, "frame_end");
- channel = RNA_int_get(op->ptr, "channel");
+ Sequence *seq1, *seq2, *seq3;
+ const char *error_msg;
- type = RNA_enum_get(op->ptr, "type");
+ start_frame = RNA_int_get(op->ptr, "frame_start");
+ end_frame = RNA_int_get(op->ptr, "frame_end");
+ channel = RNA_int_get(op->ptr, "channel");
- // XXX move to invoke
- if (!seq_effect_find_selected(scene, NULL, type, &seq1, &seq2, &seq3, &error_msg)) {
- BKE_report(op->reports, RPT_ERROR, error_msg);
- return OPERATOR_CANCELLED;
- }
+ type = RNA_enum_get(op->ptr, "type");
- /* 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 */
- if (seq1 == NULL && end_frame <= start_frame) {
- BKE_report(op->reports, RPT_ERROR, "Start and end frame are not set");
- return OPERATOR_CANCELLED;
- }
+ // XXX move to invoke
+ if (!seq_effect_find_selected(scene, NULL, type, &seq1, &seq2, &seq3, &error_msg)) {
+ BKE_report(op->reports, RPT_ERROR, error_msg);
+ return OPERATOR_CANCELLED;
+ }
- seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
- seq->type = type;
+ /* 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 */
+ if (seq1 == NULL && end_frame <= start_frame) {
+ BKE_report(op->reports, RPT_ERROR, "Start and end frame are not set");
+ return OPERATOR_CANCELLED;
+ }
- BLI_strncpy(seq->name + 2, BKE_sequence_give_name(seq), sizeof(seq->name) - 2);
- BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
+ seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel);
+ seq->type = type;
- sh = BKE_sequence_get_effect(seq);
+ BLI_strncpy(seq->name + 2, BKE_sequence_give_name(seq), sizeof(seq->name) - 2);
+ BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
- seq->seq1 = seq1;
- seq->seq2 = seq2;
- seq->seq3 = seq3;
+ sh = BKE_sequence_get_effect(seq);
- sh.init(seq);
+ seq->seq1 = seq1;
+ seq->seq2 = seq2;
+ seq->seq3 = seq3;
- if (!seq1) { /* effect has no deps */
- seq->len = 1;
- BKE_sequence_tx_set_final_right(seq, end_frame);
- }
+ sh.init(seq);
- seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE;
+ if (!seq1) { /* effect has no deps */
+ seq->len = 1;
+ BKE_sequence_tx_set_final_right(seq, end_frame);
+ }
- BKE_sequence_calc(scene, seq);
+ seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE;
- /* basic defaults */
- seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
- strip->us = 1;
+ BKE_sequence_calc(scene, seq);
- if (seq->type == SEQ_TYPE_COLOR) {
- SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
- RNA_float_get_array(op->ptr, "color", colvars->col);
- seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
+ /* basic defaults */
+ seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
+ strip->us = 1;
- }
- else if (seq->type == SEQ_TYPE_ADJUSTMENT) {
- seq->blend_mode = SEQ_TYPE_CROSS;
- }
- else if (seq->type == SEQ_TYPE_TEXT) {
- seq->blend_mode = SEQ_TYPE_ALPHAOVER;
- }
+ if (seq->type == SEQ_TYPE_COLOR) {
+ SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
+ RNA_float_get_array(op->ptr, "color", colvars->col);
+ seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */
+ }
+ else if (seq->type == SEQ_TYPE_ADJUSTMENT) {
+ seq->blend_mode = SEQ_TYPE_CROSS;
+ }
+ else if (seq->type == SEQ_TYPE_TEXT) {
+ seq->blend_mode = SEQ_TYPE_ALPHAOVER;
+ }
- /* an unset channel is a special case where we automatically go above
- * the other strips. */
- if (!RNA_struct_property_is_set(op->ptr, "channel")) {
- if (seq->seq1) {
- int chan = max_iii(seq->seq1 ? seq->seq1->machine : 0,
- seq->seq2 ? seq->seq2->machine : 0,
- seq->seq3 ? seq->seq3->machine : 0);
- if (chan < MAXSEQ) {
- seq->machine = chan;
- }
- }
- }
+ /* an unset channel is a special case where we automatically go above
+ * the other strips. */
+ if (!RNA_struct_property_is_set(op->ptr, "channel")) {
+ if (seq->seq1) {
+ int chan = max_iii(seq->seq1 ? seq->seq1->machine : 0,
+ seq->seq2 ? seq->seq2->machine : 0,
+ seq->seq3 ? seq->seq3->machine : 0);
+ if (chan < MAXSEQ) {
+ seq->machine = chan;
+ }
+ }
+ }
- sequencer_add_apply_replace_sel(C, op, seq);
- sequencer_add_apply_overlap(C, op, seq);
+ sequencer_add_apply_replace_sel(C, op, seq);
+ sequencer_add_apply_overlap(C, op, seq);
- BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1); /* runs BKE_sequence_calc */
+ BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1); /* runs BKE_sequence_calc */
+ /* not sure if this is needed with update_changed_seq_and_deps.
+ * it was NOT called in blender 2.4x, but wont hurt */
+ BKE_sequencer_sort(scene);
- /* not sure if this is needed with update_changed_seq_and_deps.
- * it was NOT called in blender 2.4x, but wont hurt */
- BKE_sequencer_sort(scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
-
/* add color */
-static int sequencer_add_effect_strip_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+static int sequencer_add_effect_strip_invoke(bContext *C,
+ wmOperator *op,
+ const wmEvent *UNUSED(event))
{
- bool is_type_set = RNA_struct_property_is_set(op->ptr, "type");
- int type = -1;
- int prop_flag = SEQPROP_ENDFRAME | SEQPROP_NOPATHS;
+ bool is_type_set = RNA_struct_property_is_set(op->ptr, "type");
+ int type = -1;
+ int prop_flag = SEQPROP_ENDFRAME | SEQPROP_NOPATHS;
- if (is_type_set) {
- type = RNA_enum_get(op->ptr, "type");
+ if (is_type_set) {
+ type = RNA_enum_get(op->ptr, "type");
- /* when invoking an effect strip which uses inputs,
- * skip initializing the channel from the mouse.
- * Instead leave the property unset so exec() initializes it to be
- * above the strips its applied to. */
- if (BKE_sequence_effect_get_num_inputs(type) != 0) {
- prop_flag |= SEQPROP_NOCHAN;
- }
- }
+ /* when invoking an effect strip which uses inputs,
+ * skip initializing the channel from the mouse.
+ * Instead leave the property unset so exec() initializes it to be
+ * above the strips its applied to. */
+ if (BKE_sequence_effect_get_num_inputs(type) != 0) {
+ prop_flag |= SEQPROP_NOCHAN;
+ }
+ }
- 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)
{
- /* identifiers */
- ot->name = "Add Effect Strip";
- ot->idname = "SEQUENCER_OT_effect_strip_add";
- ot->description = "Add an effect to the sequencer, most are applied on top of existing strips";
-
- /* api callbacks */
- ot->invoke = sequencer_add_effect_strip_invoke;
- ot->exec = sequencer_add_effect_strip_exec;
-
- ot->poll = ED_operator_sequencer_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME | SEQPROP_ENDFRAME);
- RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_TYPE_CROSS, "Type", "Sequencer effect type");
- RNA_def_float_vector(ot->srna, "color", 3, NULL, 0.0f, 1.0f, "Color",
- "Initialize the strip with this color (only used when type='COLOR')", 0.0f, 1.0f);
+ /* identifiers */
+ ot->name = "Add Effect Strip";
+ ot->idname = "SEQUENCER_OT_effect_strip_add";
+ ot->description = "Add an effect to the sequencer, most are applied on top of existing strips";
+
+ /* api callbacks */
+ ot->invoke = sequencer_add_effect_strip_invoke;
+ ot->exec = sequencer_add_effect_strip_exec;
+
+ ot->poll = ED_operator_sequencer_active_editable;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME | SEQPROP_ENDFRAME);
+ RNA_def_enum(ot->srna,
+ "type",
+ sequencer_prop_effect_types,
+ SEQ_TYPE_CROSS,
+ "Type",
+ "Sequencer effect type");
+ RNA_def_float_vector(ot->srna,
+ "color",
+ 3,
+ NULL,
+ 0.0f,
+ 1.0f,
+ "Color",
+ "Initialize the strip with this color (only used when type='COLOR')",
+ 0.0f,
+ 1.0f);
}
diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c
index 7b7f6599404..8d9fea2cb98 100644
--- a/source/blender/editors/space_sequencer/sequencer_buttons.c
+++ b/source/blender/editors/space_sequencer/sequencer_buttons.c
@@ -24,7 +24,6 @@
#include <string.h>
#include <stdio.h>
-
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
@@ -53,101 +52,97 @@
#if 0
static bool sequencer_grease_pencil_panel_poll(const bContext *C, PanelType *UNUSED(pt))
{
- SpaceSeq *sseq = CTX_wm_space_seq(C);
+ SpaceSeq *sseq = CTX_wm_space_seq(C);
- /* don't show the gpencil if we are not showing the image */
- return ED_space_sequencer_check_show_imbuf(sseq);
+ /* don't show the gpencil if we are not showing the image */
+ return ED_space_sequencer_check_show_imbuf(sseq);
}
#endif
static bool metadata_panel_context_poll(const bContext *C, PanelType *UNUSED(pt))
{
- SpaceSeq *space_sequencer = CTX_wm_space_seq(C);
- if (space_sequencer == NULL) {
- return false;
- }
- return ED_space_sequencer_check_show_imbuf(space_sequencer);
+ SpaceSeq *space_sequencer = CTX_wm_space_seq(C);
+ if (space_sequencer == NULL) {
+ return false;
+ }
+ return ED_space_sequencer_check_show_imbuf(space_sequencer);
}
static void metadata_panel_context_draw(const bContext *C, Panel *panel)
{
- /* Image buffer can not be acquired during render, similar to
- * draw_image_seq(). */
- if (G.is_rendering) {
- return;
- }
- struct Main *bmain = CTX_data_main(C);
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
- struct Scene *scene = CTX_data_scene(C);
- SpaceSeq *space_sequencer = CTX_wm_space_seq(C);
- /* NOTE: We can only reliably show metadata for the original (current)
- * frame when split view is used. */
- const bool show_split = (
- scene->ed &&
- (scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) &&
- (space_sequencer->mainb == SEQ_DRAW_IMG_IMBUF));
- if (show_split &&
- space_sequencer->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE)
- {
- return;
- }
- /* NOTE: We disable multiview for drawing, since we don't know what is the
- * from the panel (is kind of all the views?). */
- ImBuf *ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, space_sequencer, scene->r.cfra, 0, "");
- if (ibuf != NULL) {
- ED_region_image_metadata_panel_draw(ibuf, panel->layout);
- IMB_freeImBuf(ibuf);
- }
+ /* Image buffer can not be acquired during render, similar to
+ * draw_image_seq(). */
+ if (G.is_rendering) {
+ return;
+ }
+ struct Main *bmain = CTX_data_main(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ struct Scene *scene = CTX_data_scene(C);
+ SpaceSeq *space_sequencer = CTX_wm_space_seq(C);
+ /* NOTE: We can only reliably show metadata for the original (current)
+ * frame when split view is used. */
+ const bool show_split = (scene->ed && (scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) &&
+ (space_sequencer->mainb == SEQ_DRAW_IMG_IMBUF));
+ if (show_split && space_sequencer->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) {
+ return;
+ }
+ /* NOTE: We disable multiview for drawing, since we don't know what is the
+ * from the panel (is kind of all the views?). */
+ ImBuf *ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, space_sequencer, scene->r.cfra, 0, "");
+ if (ibuf != NULL) {
+ ED_region_image_metadata_panel_draw(ibuf, panel->layout);
+ IMB_freeImBuf(ibuf);
+ }
}
void sequencer_buttons_register(ARegionType *art)
{
- PanelType *pt;
+ PanelType *pt;
#if 0
- pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel gpencil");
- strcpy(pt->idname, "SEQUENCER_PT_gpencil");
- strcpy(pt->label, N_("Grease Pencil"));
- strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
- pt->draw_header = ED_gpencil_panel_standard_header;
- pt->draw = ED_gpencil_panel_standard;
- pt->poll = sequencer_grease_pencil_panel_poll;
- BLI_addtail(&art->paneltypes, pt);
+ pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel gpencil");
+ strcpy(pt->idname, "SEQUENCER_PT_gpencil");
+ strcpy(pt->label, N_("Grease Pencil"));
+ strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+ pt->draw_header = ED_gpencil_panel_standard_header;
+ pt->draw = ED_gpencil_panel_standard;
+ pt->poll = sequencer_grease_pencil_panel_poll;
+ BLI_addtail(&art->paneltypes, pt);
#endif
- pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel metadata");
- strcpy(pt->idname, "SEQUENCER_PT_metadata");
- strcpy(pt->label, N_("Metadata"));
- strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
- pt->poll = metadata_panel_context_poll;
- pt->draw = metadata_panel_context_draw;
- pt->flag |= PNL_DEFAULT_CLOSED;
- BLI_addtail(&art->paneltypes, pt);
+ pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel metadata");
+ strcpy(pt->idname, "SEQUENCER_PT_metadata");
+ strcpy(pt->label, N_("Metadata"));
+ strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+ pt->poll = metadata_panel_context_poll;
+ pt->draw = metadata_panel_context_draw;
+ pt->flag |= PNL_DEFAULT_CLOSED;
+ BLI_addtail(&art->paneltypes, pt);
}
/* **************** operator to open/close properties view ************* */
static int sequencer_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = sequencer_has_buttons_region(sa);
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = sequencer_has_buttons_region(sa);
- if (ar) {
- ED_region_toggle_hidden(C, ar);
- }
+ if (ar) {
+ ED_region_toggle_hidden(C, ar);
+ }
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_properties(wmOperatorType *ot)
{
- ot->name = "Properties";
- ot->idname = "SEQUENCER_OT_properties";
- ot->description = "Toggle the properties region visibility";
+ ot->name = "Properties";
+ ot->idname = "SEQUENCER_OT_properties";
+ ot->description = "Toggle the properties region visibility";
- ot->exec = sequencer_properties_toggle_exec;
- ot->poll = ED_operator_sequencer_active;
+ ot->exec = sequencer_properties_toggle_exec;
+ ot->poll = ED_operator_sequencer_active;
- /* flags */
- ot->flag = 0;
+ /* flags */
+ ot->flag = 0;
}
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 7bd19287e29..e2140fba1f6 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -21,7 +21,6 @@
* \ingroup spseq
*/
-
#include <string.h>
#include <math.h>
@@ -49,7 +48,6 @@
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
-
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
@@ -75,16 +73,14 @@
/* own include */
#include "sequencer_intern.h"
+#define SEQ_LEFTHANDLE 1
+#define SEQ_RIGHTHANDLE 2
-#define SEQ_LEFTHANDLE 1
-#define SEQ_RIGHTHANDLE 2
-
-#define SEQ_HANDLE_SIZE_MIN 7.0f
+#define SEQ_HANDLE_SIZE_MIN 7.0f
#define SEQ_HANDLE_SIZE_MAX 40.0f
#define SEQ_SCROLLER_TEXT_OFFSET 8
-
/* Note, Don't use SEQ_BEGIN/SEQ_END while drawing!
* it messes up transform, - Campbell */
#undef SEQ_BEGIN
@@ -95,1710 +91,1827 @@ static Sequence *special_seq_update = NULL;
void color3ubv_from_seq(Scene *curscene, Sequence *seq, unsigned char col[3])
{
- unsigned char blendcol[3];
- SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
-
- switch (seq->type) {
- case SEQ_TYPE_IMAGE:
- UI_GetThemeColor3ubv(TH_SEQ_IMAGE, col);
- break;
-
- case SEQ_TYPE_META:
- UI_GetThemeColor3ubv(TH_SEQ_META, col);
- break;
-
- case SEQ_TYPE_MOVIE:
- UI_GetThemeColor3ubv(TH_SEQ_MOVIE, col);
- break;
-
- case SEQ_TYPE_MOVIECLIP:
- UI_GetThemeColor3ubv(TH_SEQ_MOVIECLIP, col);
- break;
-
- case SEQ_TYPE_MASK:
- UI_GetThemeColor3ubv(TH_SEQ_MASK, col); /* TODO */
- break;
-
- case SEQ_TYPE_SCENE:
- UI_GetThemeColor3ubv(TH_SEQ_SCENE, col);
-
- if (seq->scene == curscene) {
- UI_GetColorPtrShade3ubv(col, col, 20);
- }
- break;
-
- /* transitions */
- case SEQ_TYPE_CROSS:
- case SEQ_TYPE_GAMCROSS:
- case SEQ_TYPE_WIPE:
- UI_GetThemeColor3ubv(TH_SEQ_TRANSITION, col);
-
- /* slightly offset hue to distinguish different effects */
- if (seq->type == SEQ_TYPE_CROSS) { rgb_byte_set_hue_float_offset(col, 0.04); }
- if (seq->type == SEQ_TYPE_GAMCROSS) { rgb_byte_set_hue_float_offset(col, 0.08); }
- if (seq->type == SEQ_TYPE_WIPE) { rgb_byte_set_hue_float_offset(col, 0.12); }
- break;
-
- /* effects */
- case SEQ_TYPE_TRANSFORM:
- case SEQ_TYPE_SPEED:
- case SEQ_TYPE_ADD:
- case SEQ_TYPE_SUB:
- case SEQ_TYPE_MUL:
- case SEQ_TYPE_ALPHAOVER:
- case SEQ_TYPE_ALPHAUNDER:
- case SEQ_TYPE_OVERDROP:
- case SEQ_TYPE_GLOW:
- case SEQ_TYPE_MULTICAM:
- case SEQ_TYPE_ADJUSTMENT:
- case SEQ_TYPE_GAUSSIAN_BLUR:
- case SEQ_TYPE_COLORMIX:
- UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col);
-
- /* slightly offset hue to distinguish different effects */
- if (seq->type == SEQ_TYPE_ADD) { rgb_byte_set_hue_float_offset(col, 0.04); }
- else if (seq->type == SEQ_TYPE_SUB) { rgb_byte_set_hue_float_offset(col, 0.08); }
- else if (seq->type == SEQ_TYPE_MUL) { rgb_byte_set_hue_float_offset(col, 0.12); }
- else if (seq->type == SEQ_TYPE_ALPHAOVER) { rgb_byte_set_hue_float_offset(col, 0.16); }
- else if (seq->type == SEQ_TYPE_ALPHAUNDER) { rgb_byte_set_hue_float_offset(col, 0.20); }
- else if (seq->type == SEQ_TYPE_OVERDROP) { rgb_byte_set_hue_float_offset(col, 0.24); }
- else if (seq->type == SEQ_TYPE_GLOW) { rgb_byte_set_hue_float_offset(col, 0.28); }
- else if (seq->type == SEQ_TYPE_TRANSFORM) { rgb_byte_set_hue_float_offset(col, 0.36); }
- else if (seq->type == SEQ_TYPE_MULTICAM) { rgb_byte_set_hue_float_offset(col, 0.32); }
- else if (seq->type == SEQ_TYPE_ADJUSTMENT) { rgb_byte_set_hue_float_offset(col, 0.40); }
- else if (seq->type == SEQ_TYPE_GAUSSIAN_BLUR) { rgb_byte_set_hue_float_offset(col, 0.42); }
- else if (seq->type == SEQ_TYPE_COLORMIX) { rgb_byte_set_hue_float_offset(col, 0.46); }
- break;
-
- case SEQ_TYPE_COLOR:
- rgb_float_to_uchar(col, colvars->col);
- break;
-
- case SEQ_TYPE_SOUND_RAM:
- UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col);
- blendcol[0] = blendcol[1] = blendcol[2] = 128;
- if (seq->flag & SEQ_MUTE) {
- UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20);
- }
- break;
-
- case SEQ_TYPE_TEXT:
- UI_GetThemeColor3ubv(TH_SEQ_TEXT, col);
- break;
-
- default:
- col[0] = 10; col[1] = 255; col[2] = 40;
- break;
- }
+ unsigned char blendcol[3];
+ SolidColorVars *colvars = (SolidColorVars *)seq->effectdata;
+
+ switch (seq->type) {
+ case SEQ_TYPE_IMAGE:
+ UI_GetThemeColor3ubv(TH_SEQ_IMAGE, col);
+ break;
+
+ case SEQ_TYPE_META:
+ UI_GetThemeColor3ubv(TH_SEQ_META, col);
+ break;
+
+ case SEQ_TYPE_MOVIE:
+ UI_GetThemeColor3ubv(TH_SEQ_MOVIE, col);
+ break;
+
+ case SEQ_TYPE_MOVIECLIP:
+ UI_GetThemeColor3ubv(TH_SEQ_MOVIECLIP, col);
+ break;
+
+ case SEQ_TYPE_MASK:
+ UI_GetThemeColor3ubv(TH_SEQ_MASK, col); /* TODO */
+ break;
+
+ case SEQ_TYPE_SCENE:
+ UI_GetThemeColor3ubv(TH_SEQ_SCENE, col);
+
+ if (seq->scene == curscene) {
+ UI_GetColorPtrShade3ubv(col, col, 20);
+ }
+ break;
+
+ /* transitions */
+ case SEQ_TYPE_CROSS:
+ case SEQ_TYPE_GAMCROSS:
+ case SEQ_TYPE_WIPE:
+ UI_GetThemeColor3ubv(TH_SEQ_TRANSITION, col);
+
+ /* slightly offset hue to distinguish different effects */
+ if (seq->type == SEQ_TYPE_CROSS) {
+ rgb_byte_set_hue_float_offset(col, 0.04);
+ }
+ if (seq->type == SEQ_TYPE_GAMCROSS) {
+ rgb_byte_set_hue_float_offset(col, 0.08);
+ }
+ if (seq->type == SEQ_TYPE_WIPE) {
+ rgb_byte_set_hue_float_offset(col, 0.12);
+ }
+ break;
+
+ /* effects */
+ case SEQ_TYPE_TRANSFORM:
+ case SEQ_TYPE_SPEED:
+ case SEQ_TYPE_ADD:
+ case SEQ_TYPE_SUB:
+ case SEQ_TYPE_MUL:
+ case SEQ_TYPE_ALPHAOVER:
+ case SEQ_TYPE_ALPHAUNDER:
+ case SEQ_TYPE_OVERDROP:
+ case SEQ_TYPE_GLOW:
+ case SEQ_TYPE_MULTICAM:
+ case SEQ_TYPE_ADJUSTMENT:
+ case SEQ_TYPE_GAUSSIAN_BLUR:
+ case SEQ_TYPE_COLORMIX:
+ UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col);
+
+ /* slightly offset hue to distinguish different effects */
+ if (seq->type == SEQ_TYPE_ADD) {
+ rgb_byte_set_hue_float_offset(col, 0.04);
+ }
+ else if (seq->type == SEQ_TYPE_SUB) {
+ rgb_byte_set_hue_float_offset(col, 0.08);
+ }
+ else if (seq->type == SEQ_TYPE_MUL) {
+ rgb_byte_set_hue_float_offset(col, 0.12);
+ }
+ else if (seq->type == SEQ_TYPE_ALPHAOVER) {
+ rgb_byte_set_hue_float_offset(col, 0.16);
+ }
+ else if (seq->type == SEQ_TYPE_ALPHAUNDER) {
+ rgb_byte_set_hue_float_offset(col, 0.20);
+ }
+ else if (seq->type == SEQ_TYPE_OVERDROP) {
+ rgb_byte_set_hue_float_offset(col, 0.24);
+ }
+ else if (seq->type == SEQ_TYPE_GLOW) {
+ rgb_byte_set_hue_float_offset(col, 0.28);
+ }
+ else if (seq->type == SEQ_TYPE_TRANSFORM) {
+ rgb_byte_set_hue_float_offset(col, 0.36);
+ }
+ else if (seq->type == SEQ_TYPE_MULTICAM) {
+ rgb_byte_set_hue_float_offset(col, 0.32);
+ }
+ else if (seq->type == SEQ_TYPE_ADJUSTMENT) {
+ rgb_byte_set_hue_float_offset(col, 0.40);
+ }
+ else if (seq->type == SEQ_TYPE_GAUSSIAN_BLUR) {
+ rgb_byte_set_hue_float_offset(col, 0.42);
+ }
+ else if (seq->type == SEQ_TYPE_COLORMIX) {
+ rgb_byte_set_hue_float_offset(col, 0.46);
+ }
+ break;
+
+ case SEQ_TYPE_COLOR:
+ rgb_float_to_uchar(col, colvars->col);
+ break;
+
+ case SEQ_TYPE_SOUND_RAM:
+ UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col);
+ blendcol[0] = blendcol[1] = blendcol[2] = 128;
+ if (seq->flag & SEQ_MUTE) {
+ UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20);
+ }
+ break;
+
+ case SEQ_TYPE_TEXT:
+ UI_GetThemeColor3ubv(TH_SEQ_TEXT, col);
+ break;
+
+ default:
+ col[0] = 10;
+ col[1] = 255;
+ col[2] = 40;
+ break;
+ }
}
-static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *scene, Sequence *seq,
- float x1, float y1, float x2, float y2, float stepsize)
+static void drawseqwave(View2D *v2d,
+ const bContext *C,
+ SpaceSeq *sseq,
+ Scene *scene,
+ Sequence *seq,
+ float x1,
+ float y1,
+ float x2,
+ float y2,
+ float stepsize)
{
- /*
- * x1 is the starting x value to draw the wave,
- * x2 the end x value, same for y1 and y2
- * stepsize is width of a pixel.
- */
-
- /* offset x1 and x2 values, to match view min/max, if strip is out of bounds */
- int x1_offset = max_ff(v2d->cur.xmin, x1);
- int x2_offset = min_ff(v2d->cur.xmax + 1.0f, x2);
-
- if (seq->sound && ((sseq->flag & SEQ_ALL_WAVEFORMS) || (seq->flag & SEQ_AUDIO_DRAW_WAVEFORM))) {
- int i, j, p;
- int length = floor((x2_offset - x1_offset) / stepsize) + 1;
- float ymid = (y1 + y2) / 2.0f;
- float yscale = (y2 - y1) / 2.0f;
- float samplestep;
- float startsample, endsample;
- float value1, value2;
- bSound *sound = seq->sound;
-
- SoundWaveform *waveform;
-
- if (length < 2) {
- return;
- }
-
- if (!sound->spinlock) {
- sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
- BLI_spin_init(sound->spinlock);
- }
-
- BLI_spin_lock(sound->spinlock);
- if (!sound->waveform) {
- if (!(sound->tags & SOUND_TAGS_WAVEFORM_LOADING)) {
- /* prevent sounds from reloading */
- sound->tags |= SOUND_TAGS_WAVEFORM_LOADING;
- BLI_spin_unlock(sound->spinlock);
- sequencer_preview_add_sound(C, seq);
- }
- else {
- BLI_spin_unlock(sound->spinlock);
- }
- return; /* nothing to draw */
- }
- BLI_spin_unlock(sound->spinlock);
-
- waveform = sound->waveform;
-
- if (waveform->length == 0) {
- /* BKE_sound_read_waveform() set an empty SoundWaveform data in case it cannot generate a valid one...
- * See T45726. */
- return;
- }
-
- startsample = floor((seq->startofs + seq->anim_startofs) / FPS * SOUND_WAVE_SAMPLES_PER_SECOND);
- endsample = ceil((seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp) / FPS * SOUND_WAVE_SAMPLES_PER_SECOND);
- samplestep = (endsample - startsample) * stepsize / (x2 - x1);
-
- length = min_ii(floor((waveform->length - startsample) / samplestep - (x1_offset - x1) / stepsize), length);
-
- if (length < 2) {
- return;
- }
-
- GPU_blend(true);
- GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(GPU_PRIM_TRI_STRIP, length * 2);
-
- for (i = 0; i < length; i++) {
- float sampleoffset = startsample + ((x1_offset - x1) / stepsize + i) * samplestep;
- p = sampleoffset;
-
- value1 = waveform->data[p * 3];
- value2 = waveform->data[p * 3 + 1];
-
- if (samplestep > 1.0f) {
- for (j = p + 1; (j < waveform->length) && (j < p + samplestep); j++) {
- if (value1 > waveform->data[j * 3]) {
- value1 = waveform->data[j * 3];
- }
-
- if (value2 < waveform->data[j * 3 + 1]) {
- value2 = waveform->data[j * 3 + 1];
- }
- }
- }
- else if (p + 1 < waveform->length) {
- /* use simple linear interpolation */
- float f = sampleoffset - p;
- value1 = (1.0f - f) * value1 + f * waveform->data[p * 3 + 3];
- value2 = (1.0f - f) * value2 + f * waveform->data[p * 3 + 4];
- }
-
- value1 *= seq->volume;
- value2 *= seq->volume;
-
- if (value2 > 1 || value1 < -1) {
- immAttr4f(col, 1.0f, 0.0f, 0.0f, 0.5f);
-
- CLAMP_MAX(value2, 1.0f);
- CLAMP_MIN(value1, -1.0f);
- }
- else {
- immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.5f);
- }
-
- immVertex2f(pos, x1_offset + i * stepsize, ymid + value1 * yscale);
- immVertex2f(pos, x1_offset + i * stepsize, ymid + value2 * yscale);
- }
-
- immEnd();
- immUnbindProgram();
- GPU_blend(false);
- }
+ /*
+ * x1 is the starting x value to draw the wave,
+ * x2 the end x value, same for y1 and y2
+ * stepsize is width of a pixel.
+ */
+
+ /* offset x1 and x2 values, to match view min/max, if strip is out of bounds */
+ int x1_offset = max_ff(v2d->cur.xmin, x1);
+ int x2_offset = min_ff(v2d->cur.xmax + 1.0f, x2);
+
+ if (seq->sound && ((sseq->flag & SEQ_ALL_WAVEFORMS) || (seq->flag & SEQ_AUDIO_DRAW_WAVEFORM))) {
+ int i, j, p;
+ int length = floor((x2_offset - x1_offset) / stepsize) + 1;
+ float ymid = (y1 + y2) / 2.0f;
+ float yscale = (y2 - y1) / 2.0f;
+ float samplestep;
+ float startsample, endsample;
+ float value1, value2;
+ bSound *sound = seq->sound;
+
+ SoundWaveform *waveform;
+
+ if (length < 2) {
+ return;
+ }
+
+ if (!sound->spinlock) {
+ sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
+ BLI_spin_init(sound->spinlock);
+ }
+
+ BLI_spin_lock(sound->spinlock);
+ if (!sound->waveform) {
+ if (!(sound->tags & SOUND_TAGS_WAVEFORM_LOADING)) {
+ /* prevent sounds from reloading */
+ sound->tags |= SOUND_TAGS_WAVEFORM_LOADING;
+ BLI_spin_unlock(sound->spinlock);
+ sequencer_preview_add_sound(C, seq);
+ }
+ else {
+ BLI_spin_unlock(sound->spinlock);
+ }
+ return; /* nothing to draw */
+ }
+ BLI_spin_unlock(sound->spinlock);
+
+ waveform = sound->waveform;
+
+ if (waveform->length == 0) {
+ /* BKE_sound_read_waveform() set an empty SoundWaveform data in case it cannot generate a valid one...
+ * See T45726. */
+ return;
+ }
+
+ startsample = floor((seq->startofs + seq->anim_startofs) / FPS *
+ SOUND_WAVE_SAMPLES_PER_SECOND);
+ endsample = ceil((seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp) / FPS *
+ SOUND_WAVE_SAMPLES_PER_SECOND);
+ samplestep = (endsample - startsample) * stepsize / (x2 - x1);
+
+ length = min_ii(
+ floor((waveform->length - startsample) / samplestep - (x1_offset - x1) / stepsize),
+ length);
+
+ if (length < 2) {
+ return;
+ }
+
+ GPU_blend(true);
+ GPUVertFormat *format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+ immBegin(GPU_PRIM_TRI_STRIP, length * 2);
+
+ for (i = 0; i < length; i++) {
+ float sampleoffset = startsample + ((x1_offset - x1) / stepsize + i) * samplestep;
+ p = sampleoffset;
+
+ value1 = waveform->data[p * 3];
+ value2 = waveform->data[p * 3 + 1];
+
+ if (samplestep > 1.0f) {
+ for (j = p + 1; (j < waveform->length) && (j < p + samplestep); j++) {
+ if (value1 > waveform->data[j * 3]) {
+ value1 = waveform->data[j * 3];
+ }
+
+ if (value2 < waveform->data[j * 3 + 1]) {
+ value2 = waveform->data[j * 3 + 1];
+ }
+ }
+ }
+ else if (p + 1 < waveform->length) {
+ /* use simple linear interpolation */
+ float f = sampleoffset - p;
+ value1 = (1.0f - f) * value1 + f * waveform->data[p * 3 + 3];
+ value2 = (1.0f - f) * value2 + f * waveform->data[p * 3 + 4];
+ }
+
+ value1 *= seq->volume;
+ value2 *= seq->volume;
+
+ if (value2 > 1 || value1 < -1) {
+ immAttr4f(col, 1.0f, 0.0f, 0.0f, 0.5f);
+
+ CLAMP_MAX(value2, 1.0f);
+ CLAMP_MIN(value1, -1.0f);
+ }
+ else {
+ immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.5f);
+ }
+
+ immVertex2f(pos, x1_offset + i * stepsize, ymid + value1 * yscale);
+ immVertex2f(pos, x1_offset + i * stepsize, ymid + value2 * yscale);
+ }
+
+ immEnd();
+ immUnbindProgram();
+ GPU_blend(false);
+ }
}
static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, float x2, float y2)
{
- /* note: this used to use SEQ_BEGIN/SEQ_END, but it messes up the
- * seq->depth value, (needed by transform when doing overlap checks)
- * so for now, just use the meta's immediate children, could be fixed but
- * its only drawing - campbell */
- Sequence *seq;
- unsigned char col[4];
-
- int chan_min = MAXSEQ;
- int chan_max = 0;
- int chan_range = 0;
- float draw_range = y2 - y1;
- float draw_height;
- ListBase *seqbase;
- int offset;
-
- seqbase = BKE_sequence_seqbase_get(seqm, &offset);
- if (!seqbase || BLI_listbase_is_empty(seqbase)) {
- return;
- }
-
- if (seqm->type == SEQ_TYPE_SCENE) {
- offset = seqm->start - offset;
- }
- else {
- offset = 0;
- }
-
- GPU_blend(true);
- GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
-
- for (seq = seqbase->first; seq; seq = seq->next) {
- chan_min = min_ii(chan_min, seq->machine);
- chan_max = max_ii(chan_max, seq->machine);
- }
-
- chan_range = (chan_max - chan_min) + 1;
- draw_height = draw_range / chan_range;
-
- col[3] = 196; /* alpha, used for all meta children */
-
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- for (seq = seqbase->first; seq; seq = seq->next) {
- const int startdisp = seq->startdisp + offset;
- const int enddisp = seq->enddisp + offset;
-
- if ((startdisp > x2 || enddisp < x1) == 0) {
- float y_chan = (seq->machine - chan_min) / (float)(chan_range) * draw_range;
- float x1_chan = startdisp;
- float x2_chan = enddisp;
- float y1_chan, y2_chan;
-
- color3ubv_from_seq(scene, seq, col);
-
- if ((seqm->flag & SEQ_MUTE) || (seq->flag & SEQ_MUTE)) {
- col[3] = 64;
- }
- else {
- col[3] = 196;
- }
-
- immUniformColor4ubv(col);
-
- /* clamp within parent sequence strip bounds */
- if (x1_chan < x1) {
- x1_chan = x1;
- }
- if (x2_chan > x2) {
- x2_chan = x2;
- }
-
- y1_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSBOTTOM);
- y2_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSTOP);
-
- immRectf(pos, x1_chan, y1_chan, x2_chan, y2_chan);
- }
- }
-
- immUnbindProgram();
-
- GPU_blend(false);
+ /* note: this used to use SEQ_BEGIN/SEQ_END, but it messes up the
+ * seq->depth value, (needed by transform when doing overlap checks)
+ * so for now, just use the meta's immediate children, could be fixed but
+ * its only drawing - campbell */
+ Sequence *seq;
+ unsigned char col[4];
+
+ int chan_min = MAXSEQ;
+ int chan_max = 0;
+ int chan_range = 0;
+ float draw_range = y2 - y1;
+ float draw_height;
+ ListBase *seqbase;
+ int offset;
+
+ seqbase = BKE_sequence_seqbase_get(seqm, &offset);
+ if (!seqbase || BLI_listbase_is_empty(seqbase)) {
+ return;
+ }
+
+ if (seqm->type == SEQ_TYPE_SCENE) {
+ offset = seqm->start - offset;
+ }
+ else {
+ offset = 0;
+ }
+
+ GPU_blend(true);
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ chan_min = min_ii(chan_min, seq->machine);
+ chan_max = max_ii(chan_max, seq->machine);
+ }
+
+ chan_range = (chan_max - chan_min) + 1;
+ draw_height = draw_range / chan_range;
+
+ col[3] = 196; /* alpha, used for all meta children */
+
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ const int startdisp = seq->startdisp + offset;
+ const int enddisp = seq->enddisp + offset;
+
+ if ((startdisp > x2 || enddisp < x1) == 0) {
+ float y_chan = (seq->machine - chan_min) / (float)(chan_range)*draw_range;
+ float x1_chan = startdisp;
+ float x2_chan = enddisp;
+ float y1_chan, y2_chan;
+
+ color3ubv_from_seq(scene, seq, col);
+
+ if ((seqm->flag & SEQ_MUTE) || (seq->flag & SEQ_MUTE)) {
+ col[3] = 64;
+ }
+ else {
+ col[3] = 196;
+ }
+
+ immUniformColor4ubv(col);
+
+ /* clamp within parent sequence strip bounds */
+ if (x1_chan < x1) {
+ x1_chan = x1;
+ }
+ if (x2_chan > x2) {
+ x2_chan = x2;
+ }
+
+ y1_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSBOTTOM);
+ y2_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSTOP);
+
+ immRectf(pos, x1_chan, y1_chan, x2_chan, y2_chan);
+ }
+ }
+
+ immUnbindProgram();
+
+ GPU_blend(false);
}
/* clamp handles to defined size in pixel space */
static float draw_seq_handle_size_get_clamped(Sequence *seq, const float pixelx)
{
- const float minhandle = pixelx * SEQ_HANDLE_SIZE_MIN;
- const float maxhandle = pixelx * SEQ_HANDLE_SIZE_MAX;
- float size = CLAMPIS(seq->handsize, minhandle, maxhandle);
+ const float minhandle = pixelx * SEQ_HANDLE_SIZE_MIN;
+ const float maxhandle = pixelx * SEQ_HANDLE_SIZE_MAX;
+ float size = CLAMPIS(seq->handsize, minhandle, maxhandle);
- /* ensure we're not greater than half width */
- return min_ff(size, ((float)(seq->enddisp - seq->startdisp) / 2.0f) / pixelx);
+ /* ensure we're not greater than half width */
+ return min_ff(size, ((float)(seq->enddisp - seq->startdisp) / 2.0f) / pixelx);
}
/* draw a handle, for each end of a sequence strip */
-static void draw_seq_handle(
- View2D *v2d, Sequence *seq, const float handsize_clamped,
- const short direction, unsigned int pos)
+static void draw_seq_handle(View2D *v2d,
+ Sequence *seq,
+ const float handsize_clamped,
+ const short direction,
+ unsigned int pos)
{
- float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; //for triangles and rect
- float x1, x2, y1, y2;
- unsigned int whichsel = 0;
-
- x1 = seq->startdisp;
- x2 = seq->enddisp;
-
- y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
- y2 = seq->machine + SEQ_STRIP_OFSTOP;
-
- /* set up co-ordinates/dimensions for either left or right handle */
- if (direction == SEQ_LEFTHANDLE) {
- rx1 = x1;
- rx2 = x1 + handsize_clamped * 0.75f;
-
- v1[0] = x1 + handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2);
- v2[0] = x1 + handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2);
- v3[0] = v2[0] + handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f;
-
- whichsel = SEQ_LEFTSEL;
- }
- else if (direction == SEQ_RIGHTHANDLE) {
- rx1 = x2 - handsize_clamped * 0.75f;
- rx2 = x2;
-
- v1[0] = x2 - handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2);
- v2[0] = x2 - handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2);
- v3[0] = v2[0] - handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f;
-
- whichsel = SEQ_RIGHTSEL;
- }
-
- /* draw! */
- if (!(seq->type & SEQ_TYPE_EFFECT) ||
- BKE_sequence_effect_get_num_inputs(seq->type) == 0)
- {
- GPU_blend(true);
-
- GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
-
- if (seq->flag & whichsel) {
- immUniformColor4ub(0, 0, 0, 80);
- }
- else if (seq->flag & SELECT) {
- immUniformColor4ub(255, 255, 255, 30);
- }
- else {
- immUniformColor4ub(0, 0, 0, 22);
- }
-
- immRectf(pos, rx1, y1, rx2, y2);
-
- if (seq->flag & whichsel) {
- immUniformColor4ub(255, 255, 255, 200);
- }
- else {
- immUniformColor4ub(0, 0, 0, 50);
- }
-
- immBegin(GPU_PRIM_TRIS, 3);
- immVertex2fv(pos, v1);
- immVertex2fv(pos, v2);
- immVertex2fv(pos, v3);
- immEnd();
-
- GPU_blend(false);
- }
-
- if ((G.moving & G_TRANSFORM_SEQ) || (seq->flag & whichsel)) {
- const char col[4] = {255, 255, 255, 255};
- char numstr[32];
- size_t numstr_len;
-
- if (direction == SEQ_LEFTHANDLE) {
- numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", seq->startdisp);
- x1 = rx1;
- y1 -= 0.45f;
- }
- else {
- numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", seq->enddisp - 1);
- x1 = x2 - handsize_clamped * 0.75f;
- y1 = y2 + 0.05f;
- }
- UI_view2d_text_cache_add(v2d, x1, y1, numstr, numstr_len, col);
- }
+ float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; //for triangles and rect
+ float x1, x2, y1, y2;
+ unsigned int whichsel = 0;
+
+ x1 = seq->startdisp;
+ x2 = seq->enddisp;
+
+ y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
+ y2 = seq->machine + SEQ_STRIP_OFSTOP;
+
+ /* set up co-ordinates/dimensions for either left or right handle */
+ if (direction == SEQ_LEFTHANDLE) {
+ rx1 = x1;
+ rx2 = x1 + handsize_clamped * 0.75f;
+
+ v1[0] = x1 + handsize_clamped / 4;
+ v1[1] = y1 + (((y1 + y2) / 2.0f - y1) / 2);
+ v2[0] = x1 + handsize_clamped / 4;
+ v2[1] = y2 - (((y1 + y2) / 2.0f - y1) / 2);
+ v3[0] = v2[0] + handsize_clamped / 4;
+ v3[1] = (y1 + y2) / 2.0f;
+
+ whichsel = SEQ_LEFTSEL;
+ }
+ else if (direction == SEQ_RIGHTHANDLE) {
+ rx1 = x2 - handsize_clamped * 0.75f;
+ rx2 = x2;
+
+ v1[0] = x2 - handsize_clamped / 4;
+ v1[1] = y1 + (((y1 + y2) / 2.0f - y1) / 2);
+ v2[0] = x2 - handsize_clamped / 4;
+ v2[1] = y2 - (((y1 + y2) / 2.0f - y1) / 2);
+ v3[0] = v2[0] - handsize_clamped / 4;
+ v3[1] = (y1 + y2) / 2.0f;
+
+ whichsel = SEQ_RIGHTSEL;
+ }
+
+ /* draw! */
+ if (!(seq->type & SEQ_TYPE_EFFECT) || BKE_sequence_effect_get_num_inputs(seq->type) == 0) {
+ GPU_blend(true);
+
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+
+ if (seq->flag & whichsel) {
+ immUniformColor4ub(0, 0, 0, 80);
+ }
+ else if (seq->flag & SELECT) {
+ immUniformColor4ub(255, 255, 255, 30);
+ }
+ else {
+ immUniformColor4ub(0, 0, 0, 22);
+ }
+
+ immRectf(pos, rx1, y1, rx2, y2);
+
+ if (seq->flag & whichsel) {
+ immUniformColor4ub(255, 255, 255, 200);
+ }
+ else {
+ immUniformColor4ub(0, 0, 0, 50);
+ }
+
+ immBegin(GPU_PRIM_TRIS, 3);
+ immVertex2fv(pos, v1);
+ immVertex2fv(pos, v2);
+ immVertex2fv(pos, v3);
+ immEnd();
+
+ GPU_blend(false);
+ }
+
+ if ((G.moving & G_TRANSFORM_SEQ) || (seq->flag & whichsel)) {
+ const char col[4] = {255, 255, 255, 255};
+ char numstr[32];
+ size_t numstr_len;
+
+ if (direction == SEQ_LEFTHANDLE) {
+ numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", seq->startdisp);
+ x1 = rx1;
+ y1 -= 0.45f;
+ }
+ else {
+ numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", seq->enddisp - 1);
+ x1 = x2 - handsize_clamped * 0.75f;
+ y1 = y2 + 0.05f;
+ }
+ UI_view2d_text_cache_add(v2d, x1, y1, numstr, numstr_len, col);
+ }
}
/* draw info text on a sequence strip */
-static void draw_seq_text(
- View2D *v2d, SpaceSeq *sseq, Sequence *seq,
- float x1, float x2, float y1, float y2,
- const unsigned char background_col[3])
+static void draw_seq_text(View2D *v2d,
+ SpaceSeq *sseq,
+ Sequence *seq,
+ float x1,
+ float x2,
+ float y1,
+ float y2,
+ const unsigned char background_col[3])
{
- rctf rect;
- char str[32 + FILE_MAX];
- size_t str_len;
- const char *name = seq->name + 2;
- char col[4];
-
- /* note, all strings should include 'name' */
- if (name[0] == '\0') {
- name = BKE_sequence_give_name(seq);
- }
-
- if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) {
- str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
- }
- else if (seq->type == SEQ_TYPE_SCENE) {
- if (seq->scene) {
- if (seq->scene_camera) {
- str_len = BLI_snprintf(str, sizeof(str), "%s: %s (%s) | %d",
- name, seq->scene->id.name + 2, ((ID *)seq->scene_camera)->name + 2, seq->len);
- }
- else {
- str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d",
- name, seq->scene->id.name + 2, seq->len);
- }
- }
- else {
- str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
- name, seq->len);
- }
- }
- else if (seq->type == SEQ_TYPE_MOVIECLIP) {
- if (seq->clip && !STREQ(name, seq->clip->id.name + 2)) {
- str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d",
- name, seq->clip->id.name + 2, seq->len);
- }
- else {
- str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
- name, seq->len);
- }
- }
- else if (seq->type == SEQ_TYPE_MASK) {
- if (seq->mask && !STREQ(name, seq->mask->id.name + 2)) {
- str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d",
- name, seq->mask->id.name + 2, seq->len);
- }
- else {
- str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
- name, seq->len);
- }
- }
- else if (seq->type == SEQ_TYPE_MULTICAM) {
- str_len = BLI_snprintf(str, sizeof(str), "Cam %s: %d",
- name, seq->multicam_source);
- }
- else if (seq->type == SEQ_TYPE_IMAGE) {
- str_len = BLI_snprintf(str, sizeof(str), "%s: %s%s | %d",
- name, seq->strip->dir, seq->strip->stripdata->name, seq->len);
- }
- else if (seq->type == SEQ_TYPE_TEXT) {
- TextVars *textdata = seq->effectdata;
- str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
- textdata->text, seq->startdisp);
- }
- else if (seq->type & SEQ_TYPE_EFFECT) {
- str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
- name, seq->len);
- }
- else if (seq->type == SEQ_TYPE_SOUND_RAM) {
- /* If a waveform is drawn, we don't want to overlay it with text,
- * as it would make both hard to read. */
- if ((sseq->flag & SEQ_ALL_WAVEFORMS) || (seq->flag & SEQ_AUDIO_DRAW_WAVEFORM)) {
- str[0] = 0;
- str_len = 0;
- }
- else if (seq->sound) {
- str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d",
- name, seq->sound->name, seq->len);
- }
- else {
- str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
- name, seq->len);
- }
- }
- else if (seq->type == SEQ_TYPE_MOVIE) {
- str_len = BLI_snprintf(str, sizeof(str), "%s: %s%s | %d",
- name, seq->strip->dir, seq->strip->stripdata->name, seq->len);
- }
- else {
- /* should never get here!, but might with files from future */
- BLI_assert(0);
-
- str_len = BLI_snprintf(str, sizeof(str), "%s | %d",
- name, seq->len);
- }
-
- if (seq->flag & SELECT) {
- col[0] = col[1] = col[2] = 255;
- }
- else if ((((int)background_col[0] + (int)background_col[1] + (int)background_col[2]) / 3) < 50) {
- col[0] = col[1] = col[2] = 80; /* use lighter text color for dark background */
- }
- else {
- col[0] = col[1] = col[2] = 0;
- }
- col[3] = 255;
-
- rect.xmin = x1;
- rect.ymin = y1;
- rect.xmax = x2;
- rect.ymax = y2;
-
- UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, col);
+ rctf rect;
+ char str[32 + FILE_MAX];
+ size_t str_len;
+ const char *name = seq->name + 2;
+ char col[4];
+
+ /* note, all strings should include 'name' */
+ if (name[0] == '\0') {
+ name = BKE_sequence_give_name(seq);
+ }
+
+ if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) {
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
+ }
+ else if (seq->type == SEQ_TYPE_SCENE) {
+ if (seq->scene) {
+ if (seq->scene_camera) {
+ str_len = BLI_snprintf(str,
+ sizeof(str),
+ "%s: %s (%s) | %d",
+ name,
+ seq->scene->id.name + 2,
+ ((ID *)seq->scene_camera)->name + 2,
+ seq->len);
+ }
+ else {
+ str_len = BLI_snprintf(
+ str, sizeof(str), "%s: %s | %d", name, seq->scene->id.name + 2, seq->len);
+ }
+ }
+ else {
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
+ }
+ }
+ else if (seq->type == SEQ_TYPE_MOVIECLIP) {
+ if (seq->clip && !STREQ(name, seq->clip->id.name + 2)) {
+ str_len = BLI_snprintf(
+ str, sizeof(str), "%s: %s | %d", name, seq->clip->id.name + 2, seq->len);
+ }
+ else {
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
+ }
+ }
+ else if (seq->type == SEQ_TYPE_MASK) {
+ if (seq->mask && !STREQ(name, seq->mask->id.name + 2)) {
+ str_len = BLI_snprintf(
+ str, sizeof(str), "%s: %s | %d", name, seq->mask->id.name + 2, seq->len);
+ }
+ else {
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
+ }
+ }
+ else if (seq->type == SEQ_TYPE_MULTICAM) {
+ str_len = BLI_snprintf(str, sizeof(str), "Cam %s: %d", name, seq->multicam_source);
+ }
+ else if (seq->type == SEQ_TYPE_IMAGE) {
+ str_len = BLI_snprintf(str,
+ sizeof(str),
+ "%s: %s%s | %d",
+ name,
+ seq->strip->dir,
+ seq->strip->stripdata->name,
+ seq->len);
+ }
+ else if (seq->type == SEQ_TYPE_TEXT) {
+ TextVars *textdata = seq->effectdata;
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d", textdata->text, seq->startdisp);
+ }
+ else if (seq->type & SEQ_TYPE_EFFECT) {
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
+ }
+ else if (seq->type == SEQ_TYPE_SOUND_RAM) {
+ /* If a waveform is drawn, we don't want to overlay it with text,
+ * as it would make both hard to read. */
+ if ((sseq->flag & SEQ_ALL_WAVEFORMS) || (seq->flag & SEQ_AUDIO_DRAW_WAVEFORM)) {
+ str[0] = 0;
+ str_len = 0;
+ }
+ else if (seq->sound) {
+ str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d", name, seq->sound->name, seq->len);
+ }
+ else {
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
+ }
+ }
+ else if (seq->type == SEQ_TYPE_MOVIE) {
+ str_len = BLI_snprintf(str,
+ sizeof(str),
+ "%s: %s%s | %d",
+ name,
+ seq->strip->dir,
+ seq->strip->stripdata->name,
+ seq->len);
+ }
+ else {
+ /* should never get here!, but might with files from future */
+ BLI_assert(0);
+
+ str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len);
+ }
+
+ if (seq->flag & SELECT) {
+ col[0] = col[1] = col[2] = 255;
+ }
+ else if ((((int)background_col[0] + (int)background_col[1] + (int)background_col[2]) / 3) < 50) {
+ col[0] = col[1] = col[2] = 80; /* use lighter text color for dark background */
+ }
+ else {
+ col[0] = col[1] = col[2] = 0;
+ }
+ col[3] = 255;
+
+ rect.xmin = x1;
+ rect.ymin = y1;
+ rect.xmax = x2;
+ rect.ymax = y2;
+
+ UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, col);
}
static void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq, unsigned int pos)
{
- float x1, x2, y1, y2, pixely;
- unsigned char col[4], blendcol[3];
- View2D *v2d = &ar->v2d;
-
- x1 = seq->startdisp;
- x2 = seq->enddisp;
-
- y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
- y2 = seq->machine + SEQ_STRIP_OFSTOP;
-
- pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
-
- if (pixely <= 0) {
- return; /* can happen when the view is split/resized */
- }
-
- blendcol[0] = blendcol[1] = blendcol[2] = 120;
-
- if (seq->startofs || seq->endofs) {
- GPU_blend(true);
- GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
-
- color3ubv_from_seq(scene, seq, col);
-
- if (seq->flag & SELECT) {
- UI_GetColorPtrShade3ubv(col, col, -50);
- }
-
- if (seq->flag & SEQ_MUTE) {
- col[3] = 64;
- }
- else {
- if (seq->flag & SELECT) {
- col[3] = 170;
- }
- else {
- col[3] = 80;
- }
- }
- }
-
- if (seq->startofs) {
- immUniformColor4ubv(col);
- immRectf(pos, (float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1);
-
- immUniformColor3ubvAlpha(col, col[3] + 50);
-
- /* outline */
- imm_draw_box_wire_2d(pos, (float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1);
- }
- if (seq->endofs) {
- immUniformColor4ubv(col);
- immRectf(pos, x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM);
-
- immUniformColor3ubvAlpha(col, col[3] + 50);
-
- /* outline */
- imm_draw_box_wire_2d(pos, x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM);
- }
-
- if (seq->startofs || seq->endofs) {
- GPU_blend(false);
- }
-
- if (seq->startstill || seq->endstill) {
- GPU_blend(true);
- GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
-
- color3ubv_from_seq(scene, seq, col);
- UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5f, 60);
-
- if (seq->flag & SEQ_MUTE) {
- col[3] = 96;
- }
- else {
- if (seq->flag & SELECT) {
- col[3] = 255;
- }
- else {
- col[3] = 170;
- }
- }
-
- immUniformColor4ubv(col);
- }
-
- if (seq->startstill) {
- immRectf(pos, x1, y1, (float)(seq->start), y2);
- }
- if (seq->endstill) {
- immRectf(pos, (float)(seq->start + seq->len), y1, x2, y2);
- }
-
- if (seq->startstill || seq->endstill) {
- GPU_blend(false);
- }
+ float x1, x2, y1, y2, pixely;
+ unsigned char col[4], blendcol[3];
+ View2D *v2d = &ar->v2d;
+
+ x1 = seq->startdisp;
+ x2 = seq->enddisp;
+
+ y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
+ y2 = seq->machine + SEQ_STRIP_OFSTOP;
+
+ pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
+
+ if (pixely <= 0) {
+ return; /* can happen when the view is split/resized */
+ }
+
+ blendcol[0] = blendcol[1] = blendcol[2] = 120;
+
+ if (seq->startofs || seq->endofs) {
+ GPU_blend(true);
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+
+ color3ubv_from_seq(scene, seq, col);
+
+ if (seq->flag & SELECT) {
+ UI_GetColorPtrShade3ubv(col, col, -50);
+ }
+
+ if (seq->flag & SEQ_MUTE) {
+ col[3] = 64;
+ }
+ else {
+ if (seq->flag & SELECT) {
+ col[3] = 170;
+ }
+ else {
+ col[3] = 80;
+ }
+ }
+ }
+
+ if (seq->startofs) {
+ immUniformColor4ubv(col);
+ immRectf(pos, (float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1);
+
+ immUniformColor3ubvAlpha(col, col[3] + 50);
+
+ /* outline */
+ imm_draw_box_wire_2d(pos, (float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1);
+ }
+ if (seq->endofs) {
+ immUniformColor4ubv(col);
+ immRectf(pos, x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM);
+
+ immUniformColor3ubvAlpha(col, col[3] + 50);
+
+ /* outline */
+ imm_draw_box_wire_2d(pos, x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM);
+ }
+
+ if (seq->startofs || seq->endofs) {
+ GPU_blend(false);
+ }
+
+ if (seq->startstill || seq->endstill) {
+ GPU_blend(true);
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+
+ color3ubv_from_seq(scene, seq, col);
+ UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5f, 60);
+
+ if (seq->flag & SEQ_MUTE) {
+ col[3] = 96;
+ }
+ else {
+ if (seq->flag & SELECT) {
+ col[3] = 255;
+ }
+ else {
+ col[3] = 170;
+ }
+ }
+
+ immUniformColor4ubv(col);
+ }
+
+ if (seq->startstill) {
+ immRectf(pos, x1, y1, (float)(seq->start), y2);
+ }
+ if (seq->endstill) {
+ immRectf(pos, (float)(seq->start + seq->len), y1, x2, y2);
+ }
+
+ if (seq->startstill || seq->endstill) {
+ GPU_blend(false);
+ }
}
-
/*
* Draw a sequence strip, bounds check already made
* ARegion is currently only used to get the windows width in pixels
* so wave file sample drawing precision is zoom adjusted
*/
-static void draw_seq_strip(
- const bContext *C, SpaceSeq *sseq, Scene *scene, ARegion *ar, Sequence *seq,
- int outline_tint, float pixelx)
+static void draw_seq_strip(const bContext *C,
+ SpaceSeq *sseq,
+ Scene *scene,
+ ARegion *ar,
+ Sequence *seq,
+ int outline_tint,
+ float pixelx)
{
- View2D *v2d = &ar->v2d;
- float x1, x2, y1, y2;
- unsigned char col[4], background_col[4], is_single_image;
- const float handsize_clamped = draw_seq_handle_size_get_clamped(seq, pixelx);
-
- /* we need to know if this is a single image/color or not for drawing */
- is_single_image = (char)BKE_sequence_single_check(seq);
-
- /* body */
- x1 = (seq->startstill) ? seq->start : seq->startdisp;
- y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
- x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp;
- y2 = seq->machine + SEQ_STRIP_OFSTOP;
-
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- /* get the correct color per strip type*/
- //color3ubv_from_seq(scene, seq, col);
- color3ubv_from_seq(scene, seq, background_col);
-
- if (seq->flag & SEQ_MUTE) {
- background_col[3] = 128;
-
- GPU_blend(true);
- GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- }
- else {
- background_col[3] = 255;
- }
-
- if (seq->flag & SELECT) {
- UI_GetColorPtrShade3ubv(background_col, background_col, -50);
- }
-
- immUniformColor4ubv(background_col);
-
- /* draw the main strip body */
- if (is_single_image) { /* single image */
- immRectf(pos, BKE_sequence_tx_get_final_left(seq, false), y1,
- BKE_sequence_tx_get_final_right(seq, false), y2);
- }
- else { /* normal operation */
- immRectf(pos, x1, y1, x2, y2);
- }
-
- if (seq->flag & SEQ_MUTE) {
- GPU_blend(false);
- }
-
- if (!is_single_image) {
- if ((sseq->draw_flag & SEQ_DRAW_OFFSET_EXT) || (seq == special_seq_update)) {
- draw_sequence_extensions(scene, ar, seq, pos);
- }
- }
-
- draw_seq_handle(v2d, seq, handsize_clamped, SEQ_LEFTHANDLE, pos);
- draw_seq_handle(v2d, seq, handsize_clamped, SEQ_RIGHTHANDLE, pos);
+ View2D *v2d = &ar->v2d;
+ float x1, x2, y1, y2;
+ unsigned char col[4], background_col[4], is_single_image;
+ const float handsize_clamped = draw_seq_handle_size_get_clamped(seq, pixelx);
+
+ /* we need to know if this is a single image/color or not for drawing */
+ is_single_image = (char)BKE_sequence_single_check(seq);
+
+ /* body */
+ x1 = (seq->startstill) ? seq->start : seq->startdisp;
+ y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
+ x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp;
+ y2 = seq->machine + SEQ_STRIP_OFSTOP;
- x1 = seq->startdisp;
- x2 = seq->enddisp;
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immUnbindProgram();
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- /* draw sound wave */
- if (seq->type == SEQ_TYPE_SOUND_RAM) {
- if (!(sseq->flag & SEQ_NO_WAVEFORMS)) {
- drawseqwave(v2d, C, sseq, scene, seq, x1, y1, x2, y2, BLI_rctf_size_x(&ar->v2d.cur) / ar->winx);
- }
- }
-
- /* draw lock */
- if (seq->flag & SEQ_LOCK) {
- GPU_blend(true);
-
- pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES);
-
- immUniform4f("color1", 1.0f, 1.0f, 1.0f, 0.125f);
- immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.125f);
- immUniform1i("size1", 8);
- immUniform1i("size2", 8);
-
- immRectf(pos, x1, y1, x2, y2);
-
- immUnbindProgram();
-
- GPU_blend(false);
- }
-
- if (!BKE_sequence_is_valid_check(seq)) {
- GPU_blend(true);
-
- pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES);
-
- immUniform4f("color1", 1.0f, 0.0f, 0.0f, 1.0f);
- immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
- immUniform1i("size1", 8);
- immUniform1i("size2", 8);
-
- immRectf(pos, x1, y1, x2, y2);
-
- immUnbindProgram();
-
- GPU_blend(false);
- }
-
- color3ubv_from_seq(scene, seq, col);
-
- /* draw the strip outline */
- color3ubv_from_seq(scene, seq, col);
- if ((G.moving & G_TRANSFORM_SEQ) && (seq->flag & SELECT)) {
- if (seq->flag & SEQ_OVERLAP) {
- col[0] = 255; col[1] = col[2] = 40;
- }
- else {
- UI_GetColorPtrShade3ubv(col, col, 120 + outline_tint);
- }
- }
- else {
- UI_GetColorPtrShade3ubv(col, col, outline_tint);
- }
-
- if ((seq->type == SEQ_TYPE_META) ||
- ((seq->type == SEQ_TYPE_SCENE) && (seq->flag & SEQ_SCENE_STRIPS)))
- {
- drawmeta_contents(scene, seq, x1, y1, x2, y2);
- }
-
- pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-
- /* TODO: add back stippled line for muted strips? */
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- if (seq->flag & SEQ_MUTE) {
- col[3] = 96;
-
- GPU_blend(true);
- GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
-
- immUniformColor4ubv(col);
- }
- else {
- immUniformColor3ubv(col);
- }
-
- imm_draw_box_wire_2d(pos, x1, y1, x2, y2); /* outline */
+ /* get the correct color per strip type*/
+ //color3ubv_from_seq(scene, seq, col);
+ color3ubv_from_seq(scene, seq, background_col);
- immUnbindProgram();
-
- /* calculate if seq is long enough to print a name */
- x1 = seq->startdisp + handsize_clamped;
- x2 = seq->enddisp - handsize_clamped;
+ if (seq->flag & SEQ_MUTE) {
+ background_col[3] = 128;
+
+ GPU_blend(true);
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+ }
+ else {
+ background_col[3] = 255;
+ }
+
+ if (seq->flag & SELECT) {
+ UI_GetColorPtrShade3ubv(background_col, background_col, -50);
+ }
+
+ immUniformColor4ubv(background_col);
+
+ /* draw the main strip body */
+ if (is_single_image) { /* single image */
+ immRectf(pos,
+ BKE_sequence_tx_get_final_left(seq, false),
+ y1,
+ BKE_sequence_tx_get_final_right(seq, false),
+ y2);
+ }
+ else { /* normal operation */
+ immRectf(pos, x1, y1, x2, y2);
+ }
+
+ if (seq->flag & SEQ_MUTE) {
+ GPU_blend(false);
+ }
+
+ if (!is_single_image) {
+ if ((sseq->draw_flag & SEQ_DRAW_OFFSET_EXT) || (seq == special_seq_update)) {
+ draw_sequence_extensions(scene, ar, seq, pos);
+ }
+ }
+
+ draw_seq_handle(v2d, seq, handsize_clamped, SEQ_LEFTHANDLE, pos);
+ draw_seq_handle(v2d, seq, handsize_clamped, SEQ_RIGHTHANDLE, pos);
- float scroller_vert_xoffs = (V2D_SCROLL_WIDTH_TEXT + SEQ_SCROLLER_TEXT_OFFSET) * pixelx;
+ x1 = seq->startdisp;
+ x2 = seq->enddisp;
- /* info text on the strip */
- if (x1 < v2d->cur.xmin + scroller_vert_xoffs) {
- x1 = v2d->cur.xmin + scroller_vert_xoffs;
- }
- else if (x1 > v2d->cur.xmax) {
- x1 = v2d->cur.xmax;
- }
- if (x2 < v2d->cur.xmin) {
- x2 = v2d->cur.xmin;
- }
- else if (x2 > v2d->cur.xmax) {
- x2 = v2d->cur.xmax;
- }
+ immUnbindProgram();
+
+ /* draw sound wave */
+ if (seq->type == SEQ_TYPE_SOUND_RAM) {
+ if (!(sseq->flag & SEQ_NO_WAVEFORMS)) {
+ drawseqwave(
+ v2d, C, sseq, scene, seq, x1, y1, x2, y2, BLI_rctf_size_x(&ar->v2d.cur) / ar->winx);
+ }
+ }
+
+ /* draw lock */
+ if (seq->flag & SEQ_LOCK) {
+ GPU_blend(true);
+
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES);
+
+ immUniform4f("color1", 1.0f, 1.0f, 1.0f, 0.125f);
+ immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.125f);
+ immUniform1i("size1", 8);
+ immUniform1i("size2", 8);
+
+ immRectf(pos, x1, y1, x2, y2);
+
+ immUnbindProgram();
+
+ GPU_blend(false);
+ }
+
+ if (!BKE_sequence_is_valid_check(seq)) {
+ GPU_blend(true);
+
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES);
+
+ immUniform4f("color1", 1.0f, 0.0f, 0.0f, 1.0f);
+ immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
+ immUniform1i("size1", 8);
+ immUniform1i("size2", 8);
+
+ immRectf(pos, x1, y1, x2, y2);
+
+ immUnbindProgram();
+
+ GPU_blend(false);
+ }
+
+ color3ubv_from_seq(scene, seq, col);
+
+ /* draw the strip outline */
+ color3ubv_from_seq(scene, seq, col);
+ if ((G.moving & G_TRANSFORM_SEQ) && (seq->flag & SELECT)) {
+ if (seq->flag & SEQ_OVERLAP) {
+ col[0] = 255;
+ col[1] = col[2] = 40;
+ }
+ else {
+ UI_GetColorPtrShade3ubv(col, col, 120 + outline_tint);
+ }
+ }
+ else {
+ UI_GetColorPtrShade3ubv(col, col, outline_tint);
+ }
+
+ if ((seq->type == SEQ_TYPE_META) ||
+ ((seq->type == SEQ_TYPE_SCENE) && (seq->flag & SEQ_SCENE_STRIPS))) {
+ drawmeta_contents(scene, seq, x1, y1, x2, y2);
+ }
+
+ pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+
+ /* TODO: add back stippled line for muted strips? */
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+ if (seq->flag & SEQ_MUTE) {
+ col[3] = 96;
+
+ GPU_blend(true);
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+
+ immUniformColor4ubv(col);
+ }
+ else {
+ immUniformColor3ubv(col);
+ }
+
+ imm_draw_box_wire_2d(pos, x1, y1, x2, y2); /* outline */
+
+ immUnbindProgram();
+
+ /* calculate if seq is long enough to print a name */
+ x1 = seq->startdisp + handsize_clamped;
+ x2 = seq->enddisp - handsize_clamped;
+
+ float scroller_vert_xoffs = (V2D_SCROLL_WIDTH_TEXT + SEQ_SCROLLER_TEXT_OFFSET) * pixelx;
- /* nice text here would require changing the view matrix for texture text */
- if ((x2 - x1) / pixelx > 32) {
- draw_seq_text(v2d, sseq, seq, x1, x2, y1, y2, background_col);
- }
+ /* info text on the strip */
+ if (x1 < v2d->cur.xmin + scroller_vert_xoffs) {
+ x1 = v2d->cur.xmin + scroller_vert_xoffs;
+ }
+ else if (x1 > v2d->cur.xmax) {
+ x1 = v2d->cur.xmax;
+ }
+ if (x2 < v2d->cur.xmin) {
+ x2 = v2d->cur.xmin;
+ }
+ else if (x2 > v2d->cur.xmax) {
+ x2 = v2d->cur.xmax;
+ }
+
+ /* nice text here would require changing the view matrix for texture text */
+ if ((x2 - x1) / pixelx > 32) {
+ draw_seq_text(v2d, sseq, seq, x1, x2, y1, y2, background_col);
+ }
}
void sequencer_special_update_set(Sequence *seq)
{
- special_seq_update = seq;
+ special_seq_update = seq;
}
Sequence *ED_sequencer_special_preview_get(void)
{
- return special_seq_update;
+ return special_seq_update;
}
void ED_sequencer_special_preview_set(bContext *C, const int mval[2])
{
- Scene *scene = CTX_data_scene(C);
- ARegion *ar = CTX_wm_region(C);
- int hand;
- Sequence *seq;
- seq = find_nearest_seq(scene, &ar->v2d, &hand, mval);
- sequencer_special_update_set(seq);
+ Scene *scene = CTX_data_scene(C);
+ ARegion *ar = CTX_wm_region(C);
+ int hand;
+ Sequence *seq;
+ seq = find_nearest_seq(scene, &ar->v2d, &hand, mval);
+ sequencer_special_update_set(seq);
}
void ED_sequencer_special_preview_clear(void)
{
- sequencer_special_update_set(NULL);
+ sequencer_special_update_set(NULL);
}
-ImBuf *sequencer_ibuf_get(
- struct Main *bmain, struct Depsgraph *depsgraph, Scene *scene,
- SpaceSeq *sseq, int cfra, int frame_ofs, const char *viewname)
+ImBuf *sequencer_ibuf_get(struct Main *bmain,
+ struct Depsgraph *depsgraph,
+ Scene *scene,
+ SpaceSeq *sseq,
+ int cfra,
+ int frame_ofs,
+ const char *viewname)
{
- SeqRenderData context = {0};
- ImBuf *ibuf;
- int rectx, recty;
- float render_size;
- float proxy_size = 100.0;
- short is_break = G.is_break;
-
- render_size = sseq->render_size;
- if (render_size == 0) {
- render_size = scene->r.size;
- }
- else {
- proxy_size = render_size;
- }
-
- if (render_size < 0) {
- return NULL;
- }
-
- rectx = (render_size * (float)scene->r.xsch) / 100.0f + 0.5f;
- recty = (render_size * (float)scene->r.ysch) / 100.0f + 0.5f;
-
- BKE_sequencer_new_render_data(
- bmain, depsgraph, scene,
- rectx, recty, proxy_size, false,
- &context);
- context.view_id = BKE_scene_multiview_view_id_get(&scene->r, viewname);
-
- /* sequencer could start rendering, in this case we need to be sure it wouldn't be canceled
- * by Esc pressed somewhere in the past
- */
- G.is_break = false;
-
- /* Rendering can change OGL context. Save & Restore framebuffer. */
- GPUFrameBuffer *fb = GPU_framebuffer_active_get();
- GPU_framebuffer_restore();
-
- if (special_seq_update) {
- ibuf = BKE_sequencer_give_ibuf_direct(&context, cfra + frame_ofs, special_seq_update);
- }
- else if (!U.prefetchframes) { // XXX || (G.f & G_PLAYANIM) == 0) {
- ibuf = BKE_sequencer_give_ibuf(&context, cfra + frame_ofs, sseq->chanshown);
- }
- else {
- ibuf = BKE_sequencer_give_ibuf_threaded(&context, cfra + frame_ofs, sseq->chanshown);
- }
-
- if (fb) {
- GPU_framebuffer_bind(fb);
- }
-
- /* restore state so real rendering would be canceled (if needed) */
- G.is_break = is_break;
-
- return ibuf;
+ SeqRenderData context = {0};
+ ImBuf *ibuf;
+ int rectx, recty;
+ float render_size;
+ float proxy_size = 100.0;
+ short is_break = G.is_break;
+
+ render_size = sseq->render_size;
+ if (render_size == 0) {
+ render_size = scene->r.size;
+ }
+ else {
+ proxy_size = render_size;
+ }
+
+ if (render_size < 0) {
+ return NULL;
+ }
+
+ rectx = (render_size * (float)scene->r.xsch) / 100.0f + 0.5f;
+ recty = (render_size * (float)scene->r.ysch) / 100.0f + 0.5f;
+
+ BKE_sequencer_new_render_data(
+ bmain, depsgraph, scene, rectx, recty, proxy_size, false, &context);
+ context.view_id = BKE_scene_multiview_view_id_get(&scene->r, viewname);
+
+ /* sequencer could start rendering, in this case we need to be sure it wouldn't be canceled
+ * by Esc pressed somewhere in the past
+ */
+ G.is_break = false;
+
+ /* Rendering can change OGL context. Save & Restore framebuffer. */
+ GPUFrameBuffer *fb = GPU_framebuffer_active_get();
+ GPU_framebuffer_restore();
+
+ if (special_seq_update) {
+ ibuf = BKE_sequencer_give_ibuf_direct(&context, cfra + frame_ofs, special_seq_update);
+ }
+ else if (!U.prefetchframes) { // XXX || (G.f & G_PLAYANIM) == 0) {
+ ibuf = BKE_sequencer_give_ibuf(&context, cfra + frame_ofs, sseq->chanshown);
+ }
+ else {
+ ibuf = BKE_sequencer_give_ibuf_threaded(&context, cfra + frame_ofs, sseq->chanshown);
+ }
+
+ if (fb) {
+ GPU_framebuffer_bind(fb);
+ }
+
+ /* restore state so real rendering would be canceled (if needed) */
+ G.is_break = is_break;
+
+ return ibuf;
}
static void sequencer_check_scopes(SequencerScopes *scopes, ImBuf *ibuf)
{
- if (scopes->reference_ibuf != ibuf) {
- if (scopes->zebra_ibuf) {
- IMB_freeImBuf(scopes->zebra_ibuf);
- scopes->zebra_ibuf = NULL;
- }
-
- if (scopes->waveform_ibuf) {
- IMB_freeImBuf(scopes->waveform_ibuf);
- scopes->waveform_ibuf = NULL;
- }
-
- if (scopes->sep_waveform_ibuf) {
- IMB_freeImBuf(scopes->sep_waveform_ibuf);
- scopes->sep_waveform_ibuf = NULL;
- }
-
- if (scopes->vector_ibuf) {
- IMB_freeImBuf(scopes->vector_ibuf);
- scopes->vector_ibuf = NULL;
- }
-
- if (scopes->histogram_ibuf) {
- IMB_freeImBuf(scopes->histogram_ibuf);
- scopes->histogram_ibuf = NULL;
- }
- }
+ if (scopes->reference_ibuf != ibuf) {
+ if (scopes->zebra_ibuf) {
+ IMB_freeImBuf(scopes->zebra_ibuf);
+ scopes->zebra_ibuf = NULL;
+ }
+
+ if (scopes->waveform_ibuf) {
+ IMB_freeImBuf(scopes->waveform_ibuf);
+ scopes->waveform_ibuf = NULL;
+ }
+
+ if (scopes->sep_waveform_ibuf) {
+ IMB_freeImBuf(scopes->sep_waveform_ibuf);
+ scopes->sep_waveform_ibuf = NULL;
+ }
+
+ if (scopes->vector_ibuf) {
+ IMB_freeImBuf(scopes->vector_ibuf);
+ scopes->vector_ibuf = NULL;
+ }
+
+ if (scopes->histogram_ibuf) {
+ IMB_freeImBuf(scopes->histogram_ibuf);
+ scopes->histogram_ibuf = NULL;
+ }
+ }
}
-static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scope_cb) (ImBuf *ibuf))
+static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scope_cb)(ImBuf *ibuf))
{
- ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
- ImBuf *scope;
+ ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
+ ImBuf *scope;
- IMB_colormanagement_imbuf_make_display_space(
- display_ibuf, &scene->view_settings,
- &scene->display_settings);
+ IMB_colormanagement_imbuf_make_display_space(
+ display_ibuf, &scene->view_settings, &scene->display_settings);
- scope = make_scope_cb(display_ibuf);
+ scope = make_scope_cb(display_ibuf);
- IMB_freeImBuf(display_ibuf);
+ IMB_freeImBuf(display_ibuf);
- return scope;
+ return scope;
}
static void sequencer_display_size(Scene *scene, float r_viewrect[2])
{
- r_viewrect[0] = (float)scene->r.xsch;
- r_viewrect[1] = (float)scene->r.ysch;
+ r_viewrect[0] = (float)scene->r.xsch;
+ r_viewrect[1] = (float)scene->r.ysch;
- /* Aspect ratio seems to have no effect on output image*/
- /* r_viewrect[0] *= scene->r.xasp / scene->r.yasp; */
+ /* Aspect ratio seems to have no effect on output image*/
+ /* r_viewrect[0] *= scene->r.xasp / scene->r.yasp; */
}
static void sequencer_draw_gpencil(const bContext *C)
{
- /* draw grease-pencil (image aligned) */
- ED_annotation_draw_2dimage(C);
+ /* draw grease-pencil (image aligned) */
+ ED_annotation_draw_2dimage(C);
- /* ortho at pixel level */
- UI_view2d_view_restore(C);
+ /* ortho at pixel level */
+ UI_view2d_view_restore(C);
- /* draw grease-pencil (screen aligned) */
- ED_annotation_draw_view2d(C, 0);
+ /* draw grease-pencil (screen aligned) */
+ ED_annotation_draw_view2d(C, 0);
}
/* draws content borders plus safety borders if needed */
static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, const Scene *scene)
{
- float x1 = v2d->tot.xmin;
- float y1 = v2d->tot.ymin;
- float x2 = v2d->tot.xmax;
- float y2 = v2d->tot.ymax;
+ float x1 = v2d->tot.xmin;
+ float y1 = v2d->tot.ymin;
+ float x2 = v2d->tot.xmax;
+ float y2 = v2d->tot.ymax;
- GPU_line_width(1.0f);
+ GPU_line_width(1.0f);
- /* border */
- const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ /* border */
+ const uint shdr_pos = GPU_vertformat_attr_add(
+ immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
- float viewport_size[4];
- GPU_viewport_size_get_f(viewport_size);
- immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
+ float viewport_size[4];
+ GPU_viewport_size_get_f(viewport_size);
+ immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
- immUniformThemeColor(TH_BACK);
- immUniform1i("colors_len", 0); /* Simple dashes. */
- immUniform1f("dash_width", 6.0f);
- immUniform1f("dash_factor", 0.5f);
+ immUniformThemeColor(TH_BACK);
+ immUniform1i("colors_len", 0); /* Simple dashes. */
+ immUniform1f("dash_width", 6.0f);
+ immUniform1f("dash_factor", 0.5f);
- imm_draw_box_wire_2d(shdr_pos, x1 - 0.5f, y1 - 0.5f, x2 + 0.5f, y2 + 0.5f);
+ imm_draw_box_wire_2d(shdr_pos, x1 - 0.5f, y1 - 0.5f, x2 + 0.5f, y2 + 0.5f);
- /* safety border */
- if (sseq->flag & SEQ_SHOW_SAFE_MARGINS) {
- immUniformThemeColorBlend(TH_VIEW_OVERLAY, TH_BACK, 0.25f);
+ /* safety border */
+ if (sseq->flag & SEQ_SHOW_SAFE_MARGINS) {
+ immUniformThemeColorBlend(TH_VIEW_OVERLAY, TH_BACK, 0.25f);
- UI_draw_safe_areas(
- shdr_pos, x1, x2, y1, y2,
- scene->safe_areas.title,
- scene->safe_areas.action);
+ UI_draw_safe_areas(
+ shdr_pos, x1, x2, y1, y2, scene->safe_areas.title, scene->safe_areas.action);
- if (sseq->flag & SEQ_SHOW_SAFE_CENTER) {
- UI_draw_safe_areas(
- shdr_pos, x1, x2, y1, y2,
- scene->safe_areas.title_center,
- scene->safe_areas.action_center);
- }
- }
+ if (sseq->flag & SEQ_SHOW_SAFE_CENTER) {
+ UI_draw_safe_areas(shdr_pos,
+ x1,
+ x2,
+ y1,
+ y2,
+ scene->safe_areas.title_center,
+ scene->safe_areas.action_center);
+ }
+ }
- immUnbindProgram();
+ immUnbindProgram();
}
#if 0
void sequencer_draw_maskedit(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq)
{
- /* NOTE: sequencer mask editing isnt finished, the draw code is working but editing not,
- * for now just disable drawing since the strip frame will likely be offset */
-
- // if (sc->mode == SC_MODE_MASKEDIT)
- if (0 && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
- Mask *mask = BKE_sequencer_mask_get(scene);
-
- if (mask) {
- int width, height;
- float aspx = 1.0f, aspy = 1.0f;
- // ED_mask_get_size(C, &width, &height);
-
- //Scene *scene = CTX_data_scene(C);
- width = (scene->r.size * scene->r.xsch) / 100;
- height = (scene->r.size * scene->r.ysch) / 100;
-
- ED_mask_draw_region(
- mask, ar,
- 0, 0, 0, /* TODO */
- width, height,
- aspx, aspy,
- false, true,
- NULL, C);
- }
- }
+ /* NOTE: sequencer mask editing isnt finished, the draw code is working but editing not,
+ * for now just disable drawing since the strip frame will likely be offset */
+
+ // if (sc->mode == SC_MODE_MASKEDIT)
+ if (0 && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
+ Mask *mask = BKE_sequencer_mask_get(scene);
+
+ if (mask) {
+ int width, height;
+ float aspx = 1.0f, aspy = 1.0f;
+ // ED_mask_get_size(C, &width, &height);
+
+ //Scene *scene = CTX_data_scene(C);
+ width = (scene->r.size * scene->r.xsch) / 100;
+ height = (scene->r.size * scene->r.ysch) / 100;
+
+ ED_mask_draw_region(
+ mask, ar,
+ 0, 0, 0, /* TODO */
+ width, height,
+ aspx, aspy,
+ false, true,
+ NULL, C);
+ }
+ }
}
#endif
-static void *sequencer_OCIO_transform_ibuf(const bContext *C, ImBuf *ibuf, bool *glsl_used, int *format, int *type)
+static void *sequencer_OCIO_transform_ibuf(
+ const bContext *C, ImBuf *ibuf, bool *glsl_used, int *format, int *type)
{
- void *display_buffer;
- void *cache_handle = NULL;
- bool force_fallback = false;
- *glsl_used = false;
- force_fallback |= (U.image_draw_method != IMAGE_DRAW_METHOD_GLSL);
- force_fallback |= (ibuf->dither != 0.0f);
-
- if (force_fallback) {
- /* Fallback to CPU based color space conversion */
- *glsl_used = false;
- *format = GL_RGBA;
- *type = GL_UNSIGNED_BYTE;
- display_buffer = NULL;
- }
- else if (ibuf->rect_float) {
- display_buffer = ibuf->rect_float;
-
- if (ibuf->channels == 4) {
- *format = GL_RGBA;
- }
- else if (ibuf->channels == 3) {
- *format = GL_RGB;
- }
- else {
- BLI_assert(!"Incompatible number of channels for float buffer in sequencer");
- *format = GL_RGBA;
- display_buffer = NULL;
- }
-
- *type = GL_FLOAT;
-
- if (ibuf->float_colorspace) {
- *glsl_used = IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, ibuf->float_colorspace, ibuf->dither, true);
- }
- else {
- *glsl_used = IMB_colormanagement_setup_glsl_draw_ctx(C, ibuf->dither, true);
- }
- }
- else if (ibuf->rect) {
- display_buffer = ibuf->rect;
- *format = GL_RGBA;
- *type = GL_UNSIGNED_BYTE;
-
- *glsl_used = IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, ibuf->rect_colorspace, ibuf->dither, false);
- }
- else {
- *format = GL_RGBA;
- *type = GL_UNSIGNED_BYTE;
- display_buffer = NULL;
- }
-
- /* there's a data to be displayed, but GLSL is not initialized
- * properly, in this case we fallback to CPU-based display transform
- */
- if ((ibuf->rect || ibuf->rect_float) && !*glsl_used) {
- display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
- *format = GL_RGBA;
- *type = GL_UNSIGNED_BYTE;
- }
- if (cache_handle) {
- IMB_display_buffer_release(cache_handle);
- }
-
- return display_buffer;
+ void *display_buffer;
+ void *cache_handle = NULL;
+ bool force_fallback = false;
+ *glsl_used = false;
+ force_fallback |= (U.image_draw_method != IMAGE_DRAW_METHOD_GLSL);
+ force_fallback |= (ibuf->dither != 0.0f);
+
+ if (force_fallback) {
+ /* Fallback to CPU based color space conversion */
+ *glsl_used = false;
+ *format = GL_RGBA;
+ *type = GL_UNSIGNED_BYTE;
+ display_buffer = NULL;
+ }
+ else if (ibuf->rect_float) {
+ display_buffer = ibuf->rect_float;
+
+ if (ibuf->channels == 4) {
+ *format = GL_RGBA;
+ }
+ else if (ibuf->channels == 3) {
+ *format = GL_RGB;
+ }
+ else {
+ BLI_assert(!"Incompatible number of channels for float buffer in sequencer");
+ *format = GL_RGBA;
+ display_buffer = NULL;
+ }
+
+ *type = GL_FLOAT;
+
+ if (ibuf->float_colorspace) {
+ *glsl_used = IMB_colormanagement_setup_glsl_draw_from_space_ctx(
+ C, ibuf->float_colorspace, ibuf->dither, true);
+ }
+ else {
+ *glsl_used = IMB_colormanagement_setup_glsl_draw_ctx(C, ibuf->dither, true);
+ }
+ }
+ else if (ibuf->rect) {
+ display_buffer = ibuf->rect;
+ *format = GL_RGBA;
+ *type = GL_UNSIGNED_BYTE;
+
+ *glsl_used = IMB_colormanagement_setup_glsl_draw_from_space_ctx(
+ C, ibuf->rect_colorspace, ibuf->dither, false);
+ }
+ else {
+ *format = GL_RGBA;
+ *type = GL_UNSIGNED_BYTE;
+ display_buffer = NULL;
+ }
+
+ /* there's a data to be displayed, but GLSL is not initialized
+ * properly, in this case we fallback to CPU-based display transform
+ */
+ if ((ibuf->rect || ibuf->rect_float) && !*glsl_used) {
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
+ *format = GL_RGBA;
+ *type = GL_UNSIGNED_BYTE;
+ }
+ if (cache_handle) {
+ IMB_display_buffer_release(cache_handle);
+ }
+
+ return display_buffer;
}
static void sequencer_stop_running_jobs(const bContext *C, Scene *scene)
{
- if (G.is_rendering == false && (scene->r.seq_prev_type) == OB_RENDER) {
- /* stop all running jobs, except screen one. currently previews frustrate Render
- * needed to make so sequencer's rendering doesn't conflict with compositor
- */
- WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_COMPOSITE);
-
- /* in case of final rendering used for preview, kill all previews,
- * otherwise threading conflict will happen in rendering module
- */
- WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_RENDER_PREVIEW);
- }
+ if (G.is_rendering == false && (scene->r.seq_prev_type) == OB_RENDER) {
+ /* stop all running jobs, except screen one. currently previews frustrate Render
+ * needed to make so sequencer's rendering doesn't conflict with compositor
+ */
+ WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_COMPOSITE);
+
+ /* in case of final rendering used for preview, kill all previews,
+ * otherwise threading conflict will happen in rendering module
+ */
+ WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_RENDER_PREVIEW);
+ }
}
static void sequencer_preview_clear(void)
{
- float col[3];
+ float col[3];
- UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col);
- GPU_clear_color(col[0], col[1], col[2], 0.0);
- GPU_clear(GPU_COLOR_BIT);
+ UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col);
+ GPU_clear_color(col[0], col[1], col[2], 0.0);
+ GPU_clear(GPU_COLOR_BIT);
}
-static void sequencer_preview_get_rect(
- rctf *preview, Scene *scene, ARegion *ar, SpaceSeq *sseq,
- bool draw_overlay, bool draw_backdrop)
+static void sequencer_preview_get_rect(rctf *preview,
+ Scene *scene,
+ ARegion *ar,
+ SpaceSeq *sseq,
+ bool draw_overlay,
+ bool draw_backdrop)
{
- struct View2D *v2d = &ar->v2d;
- float viewrect[2];
-
- sequencer_display_size(scene, viewrect);
- BLI_rctf_init(preview, -1.0f, 1.0f, -1.0f, 1.0f);
-
- if (draw_overlay && sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
- preview->xmax = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmax);
- preview->xmin = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmin);
- preview->ymax = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymax);
- preview->ymin = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymin);
- }
- else if (draw_backdrop) {
- float aspect = BLI_rcti_size_x(&ar->winrct) / (float)BLI_rcti_size_y(&ar->winrct);
- float image_aspect = viewrect[0] / viewrect[1];
-
- if (aspect >= image_aspect) {
- preview->xmax = image_aspect / aspect;
- preview->xmin = -preview->xmax;
- }
- else {
- preview->ymax = aspect / image_aspect;
- preview->ymin = -preview->ymax;
- }
- }
- else {
- *preview = v2d->tot;
- }
+ struct View2D *v2d = &ar->v2d;
+ float viewrect[2];
+
+ sequencer_display_size(scene, viewrect);
+ BLI_rctf_init(preview, -1.0f, 1.0f, -1.0f, 1.0f);
+
+ if (draw_overlay && sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
+ preview->xmax = v2d->tot.xmin +
+ (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmax);
+ preview->xmin = v2d->tot.xmin +
+ (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmin);
+ preview->ymax = v2d->tot.ymin +
+ (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymax);
+ preview->ymin = v2d->tot.ymin +
+ (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymin);
+ }
+ else if (draw_backdrop) {
+ float aspect = BLI_rcti_size_x(&ar->winrct) / (float)BLI_rcti_size_y(&ar->winrct);
+ float image_aspect = viewrect[0] / viewrect[1];
+
+ if (aspect >= image_aspect) {
+ preview->xmax = image_aspect / aspect;
+ preview->xmin = -preview->xmax;
+ }
+ else {
+ preview->ymax = aspect / image_aspect;
+ preview->ymin = -preview->ymax;
+ }
+ }
+ else {
+ *preview = v2d->tot;
+ }
}
-static void sequencer_draw_display_buffer(
- const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, ImBuf *ibuf, ImBuf *scope,
- bool draw_overlay, bool draw_backdrop)
+static void sequencer_draw_display_buffer(const bContext *C,
+ Scene *scene,
+ ARegion *ar,
+ SpaceSeq *sseq,
+ ImBuf *ibuf,
+ ImBuf *scope,
+ bool draw_overlay,
+ bool draw_backdrop)
{
- void *display_buffer;
-
- if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA) {
- GPU_blend(true);
- GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- }
-
- /* Format needs to be created prior to any immBindProgram call.
- * Do it here because OCIO binds it's own shader.
- */
- int format, type;
- bool glsl_used = false;
- GLuint texid;
- GPUVertFormat *imm_format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(imm_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint texCoord = GPU_vertformat_attr_add(imm_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-
- if (scope) {
- ibuf = scope;
-
- if (ibuf->rect_float && ibuf->rect == NULL) {
- IMB_rect_from_float(ibuf);
- }
-
- display_buffer = (unsigned char *)ibuf->rect;
- format = GL_RGBA;
- type = GL_UNSIGNED_BYTE;
- }
- else {
- display_buffer = sequencer_OCIO_transform_ibuf(C, ibuf, &glsl_used, &format, &type);
- }
-
- if (draw_backdrop) {
- GPU_matrix_push();
- GPU_matrix_identity_set();
- GPU_matrix_push_projection();
- GPU_matrix_identity_projection_set();
- }
-
- glGenTextures(1, (GLuint *)&texid);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, texid);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-
- if (type == GL_FLOAT) {
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, ibuf->x, ibuf->y, 0, format, type, display_buffer);
- }
- else {
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, format, type, display_buffer);
- }
-
- if (!glsl_used) {
- immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
- immUniformColor3f(1.0f, 1.0f, 1.0f);
- immUniform1i("image", 0);
- }
-
- immBegin(GPU_PRIM_TRI_FAN, 4);
-
- rctf preview;
- rctf canvas;
- sequencer_preview_get_rect(&preview, scene, ar, sseq, draw_overlay, draw_backdrop);
-
- if (draw_overlay && sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
- canvas = scene->ed->over_border;
- }
- else {
- BLI_rctf_init(&canvas, 0.0f, 1.0f, 0.0f, 1.0f);
- }
-
- immAttr2f(texCoord, canvas.xmin, canvas.ymin);
- immVertex2f(pos, preview.xmin, preview.ymin);
-
- immAttr2f(texCoord, canvas.xmin, canvas.ymax);
- immVertex2f(pos, preview.xmin, preview.ymax);
-
- immAttr2f(texCoord, canvas.xmax, canvas.ymax);
- immVertex2f(pos, preview.xmax, preview.ymax);
-
- immAttr2f(texCoord, canvas.xmax, canvas.ymin);
- immVertex2f(pos, preview.xmax, preview.ymin);
-
- immEnd();
- glBindTexture(GL_TEXTURE_2D, 0);
- glDeleteTextures(1, &texid);
-
- if (!glsl_used) {
- immUnbindProgram();
- }
- else {
- IMB_colormanagement_finish_glsl_draw();
- }
-
- if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA) {
- GPU_blend(false);
- }
-
- if (draw_backdrop) {
- GPU_matrix_pop();
- GPU_matrix_pop_projection();
- }
+ void *display_buffer;
+
+ if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA) {
+ GPU_blend(true);
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+ }
+
+ /* Format needs to be created prior to any immBindProgram call.
+ * Do it here because OCIO binds it's own shader.
+ */
+ int format, type;
+ bool glsl_used = false;
+ GLuint texid;
+ GPUVertFormat *imm_format = immVertexFormat();
+ uint pos = GPU_vertformat_attr_add(imm_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uint texCoord = GPU_vertformat_attr_add(
+ imm_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+
+ if (scope) {
+ ibuf = scope;
+
+ if (ibuf->rect_float && ibuf->rect == NULL) {
+ IMB_rect_from_float(ibuf);
+ }
+
+ display_buffer = (unsigned char *)ibuf->rect;
+ format = GL_RGBA;
+ type = GL_UNSIGNED_BYTE;
+ }
+ else {
+ display_buffer = sequencer_OCIO_transform_ibuf(C, ibuf, &glsl_used, &format, &type);
+ }
+
+ if (draw_backdrop) {
+ GPU_matrix_push();
+ GPU_matrix_identity_set();
+ GPU_matrix_push_projection();
+ GPU_matrix_identity_projection_set();
+ }
+
+ glGenTextures(1, (GLuint *)&texid);
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, texid);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ if (type == GL_FLOAT) {
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, ibuf->x, ibuf->y, 0, format, type, display_buffer);
+ }
+ else {
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, format, type, display_buffer);
+ }
+
+ if (!glsl_used) {
+ immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
+ immUniformColor3f(1.0f, 1.0f, 1.0f);
+ immUniform1i("image", 0);
+ }
+
+ immBegin(GPU_PRIM_TRI_FAN, 4);
+
+ rctf preview;
+ rctf canvas;
+ sequencer_preview_get_rect(&preview, scene, ar, sseq, draw_overlay, draw_backdrop);
+
+ if (draw_overlay && sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
+ canvas = scene->ed->over_border;
+ }
+ else {
+ BLI_rctf_init(&canvas, 0.0f, 1.0f, 0.0f, 1.0f);
+ }
+
+ immAttr2f(texCoord, canvas.xmin, canvas.ymin);
+ immVertex2f(pos, preview.xmin, preview.ymin);
+
+ immAttr2f(texCoord, canvas.xmin, canvas.ymax);
+ immVertex2f(pos, preview.xmin, preview.ymax);
+
+ immAttr2f(texCoord, canvas.xmax, canvas.ymax);
+ immVertex2f(pos, preview.xmax, preview.ymax);
+
+ immAttr2f(texCoord, canvas.xmax, canvas.ymin);
+ immVertex2f(pos, preview.xmax, preview.ymin);
+
+ immEnd();
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glDeleteTextures(1, &texid);
+
+ if (!glsl_used) {
+ immUnbindProgram();
+ }
+ else {
+ IMB_colormanagement_finish_glsl_draw();
+ }
+
+ if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA) {
+ GPU_blend(false);
+ }
+
+ if (draw_backdrop) {
+ GPU_matrix_pop();
+ GPU_matrix_pop_projection();
+ }
}
static ImBuf *sequencer_get_scope(Scene *scene, SpaceSeq *sseq, ImBuf *ibuf, bool draw_backdrop)
{
- struct ImBuf *scope = NULL;
- SequencerScopes *scopes = &sseq->scopes;
-
- if (!draw_backdrop && (sseq->mainb != SEQ_DRAW_IMG_IMBUF || sseq->zebra != 0)) {
- sequencer_check_scopes(scopes, ibuf);
-
-
- switch (sseq->mainb) {
- case SEQ_DRAW_IMG_IMBUF:
- if (!scopes->zebra_ibuf) {
- ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
-
- if (display_ibuf->rect_float) {
- IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings,
- &scene->display_settings);
- }
- scopes->zebra_ibuf = make_zebra_view_from_ibuf(display_ibuf, sseq->zebra);
- IMB_freeImBuf(display_ibuf);
- }
- scope = scopes->zebra_ibuf;
- break;
- case SEQ_DRAW_IMG_WAVEFORM:
- if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) {
- if (!scopes->sep_waveform_ibuf) {
- scopes->sep_waveform_ibuf = sequencer_make_scope(scene, ibuf, make_sep_waveform_view_from_ibuf);
- }
- scope = scopes->sep_waveform_ibuf;
- }
- else {
- if (!scopes->waveform_ibuf) {
- scopes->waveform_ibuf = sequencer_make_scope(scene, ibuf, make_waveform_view_from_ibuf);
- }
- scope = scopes->waveform_ibuf;
- }
- break;
- case SEQ_DRAW_IMG_VECTORSCOPE:
- if (!scopes->vector_ibuf) {
- scopes->vector_ibuf = sequencer_make_scope(scene, ibuf, make_vectorscope_view_from_ibuf);
- }
- scope = scopes->vector_ibuf;
- break;
- case SEQ_DRAW_IMG_HISTOGRAM:
- if (!scopes->histogram_ibuf) {
- scopes->histogram_ibuf = sequencer_make_scope(scene, ibuf, make_histogram_view_from_ibuf);
- }
- scope = scopes->histogram_ibuf;
- break;
- }
-
- /* future files may have new scopes we don't catch above */
- if (scope) {
- scopes->reference_ibuf = ibuf;
- }
- }
- return scope;
+ struct ImBuf *scope = NULL;
+ SequencerScopes *scopes = &sseq->scopes;
+
+ if (!draw_backdrop && (sseq->mainb != SEQ_DRAW_IMG_IMBUF || sseq->zebra != 0)) {
+ sequencer_check_scopes(scopes, ibuf);
+
+ switch (sseq->mainb) {
+ case SEQ_DRAW_IMG_IMBUF:
+ if (!scopes->zebra_ibuf) {
+ ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
+
+ if (display_ibuf->rect_float) {
+ IMB_colormanagement_imbuf_make_display_space(
+ display_ibuf, &scene->view_settings, &scene->display_settings);
+ }
+ scopes->zebra_ibuf = make_zebra_view_from_ibuf(display_ibuf, sseq->zebra);
+ IMB_freeImBuf(display_ibuf);
+ }
+ scope = scopes->zebra_ibuf;
+ break;
+ case SEQ_DRAW_IMG_WAVEFORM:
+ if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) {
+ if (!scopes->sep_waveform_ibuf) {
+ scopes->sep_waveform_ibuf = sequencer_make_scope(
+ scene, ibuf, make_sep_waveform_view_from_ibuf);
+ }
+ scope = scopes->sep_waveform_ibuf;
+ }
+ else {
+ if (!scopes->waveform_ibuf) {
+ scopes->waveform_ibuf = sequencer_make_scope(
+ scene, ibuf, make_waveform_view_from_ibuf);
+ }
+ scope = scopes->waveform_ibuf;
+ }
+ break;
+ case SEQ_DRAW_IMG_VECTORSCOPE:
+ if (!scopes->vector_ibuf) {
+ scopes->vector_ibuf = sequencer_make_scope(scene, ibuf, make_vectorscope_view_from_ibuf);
+ }
+ scope = scopes->vector_ibuf;
+ break;
+ case SEQ_DRAW_IMG_HISTOGRAM:
+ if (!scopes->histogram_ibuf) {
+ scopes->histogram_ibuf = sequencer_make_scope(
+ scene, ibuf, make_histogram_view_from_ibuf);
+ }
+ scope = scopes->histogram_ibuf;
+ break;
+ }
+
+ /* future files may have new scopes we don't catch above */
+ if (scope) {
+ scopes->reference_ibuf = ibuf;
+ }
+ }
+ return scope;
}
-void sequencer_draw_preview(
- const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq,
- int cfra, int frame_ofs,
- bool draw_overlay, bool draw_backdrop)
+void sequencer_draw_preview(const bContext *C,
+ Scene *scene,
+ ARegion *ar,
+ SpaceSeq *sseq,
+ int cfra,
+ int frame_ofs,
+ bool draw_overlay,
+ bool draw_backdrop)
{
- struct Main *bmain = CTX_data_main(C);
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
- struct View2D *v2d = &ar->v2d;
- struct ImBuf *ibuf = NULL;
- struct ImBuf *scope = NULL;
- float viewrect[2];
- const bool show_imbuf = ED_space_sequencer_check_show_imbuf(sseq);
- const bool draw_gpencil = ((sseq->flag & SEQ_SHOW_GPENCIL) && sseq->gpd);
- const char *names[2] = { STEREO_LEFT_NAME, STEREO_RIGHT_NAME };
-
- sequencer_stop_running_jobs(C, scene);
- if (G.is_rendering) {
- return;
- }
-
- if (sseq->render_size == SEQ_PROXY_RENDER_SIZE_NONE) {
- sequencer_preview_clear();
- return;
- }
-
- /* Setup view */
- sequencer_display_size(scene, viewrect);
- UI_view2d_totRect_set(v2d, viewrect[0] + 0.5f, viewrect[1] + 0.5f);
- UI_view2d_curRect_validate(v2d);
- UI_view2d_view_ortho(v2d);
-
- /* Draw background */
- if (!draw_backdrop && (!draw_overlay || sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE)) {
- sequencer_preview_clear();
-
- if (sseq->flag & SEQ_USE_ALPHA) {
- imm_draw_box_checker_2d(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax);
- }
- }
- /* Get image */
- ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, sseq, cfra, frame_ofs, names[sseq->multiview_eye]);
-
- if (ibuf) {
- scope = sequencer_get_scope(scene, sseq, ibuf, draw_backdrop);
-
- /* Draw image */
- sequencer_draw_display_buffer(C, scene, ar, sseq, ibuf, scope, draw_overlay, draw_backdrop);
-
- /* Draw over image */
- if (sseq->flag & SEQ_SHOW_METADATA) {
- ED_region_image_metadata_draw(0.0, 0.0, ibuf, &v2d->tot, 1.0, 1.0);
- }
- }
-
- if (show_imbuf) {
- sequencer_draw_borders(sseq, v2d, scene);
- }
-
- if (draw_gpencil && show_imbuf) {
- sequencer_draw_gpencil(C);
- }
-
- /* TODO */
- /* sequencer_draw_maskedit(C, scene, ar, sseq); */
-
- /* Scope is freed in sequencer_check_scopes when ibuf changes and scope image is to be replaced. */
- if (ibuf) {
- IMB_freeImBuf(ibuf);
- }
-
- UI_view2d_view_restore(C);
+ struct Main *bmain = CTX_data_main(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ struct View2D *v2d = &ar->v2d;
+ struct ImBuf *ibuf = NULL;
+ struct ImBuf *scope = NULL;
+ float viewrect[2];
+ const bool show_imbuf = ED_space_sequencer_check_show_imbuf(sseq);
+ const bool draw_gpencil = ((sseq->flag & SEQ_SHOW_GPENCIL) && sseq->gpd);
+ const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
+
+ sequencer_stop_running_jobs(C, scene);
+ if (G.is_rendering) {
+ return;
+ }
+
+ if (sseq->render_size == SEQ_PROXY_RENDER_SIZE_NONE) {
+ sequencer_preview_clear();
+ return;
+ }
+
+ /* Setup view */
+ sequencer_display_size(scene, viewrect);
+ UI_view2d_totRect_set(v2d, viewrect[0] + 0.5f, viewrect[1] + 0.5f);
+ UI_view2d_curRect_validate(v2d);
+ UI_view2d_view_ortho(v2d);
+
+ /* Draw background */
+ if (!draw_backdrop && (!draw_overlay || sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE)) {
+ sequencer_preview_clear();
+
+ if (sseq->flag & SEQ_USE_ALPHA) {
+ imm_draw_box_checker_2d(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax);
+ }
+ }
+ /* Get image */
+ ibuf = sequencer_ibuf_get(
+ bmain, depsgraph, scene, sseq, cfra, frame_ofs, names[sseq->multiview_eye]);
+
+ if (ibuf) {
+ scope = sequencer_get_scope(scene, sseq, ibuf, draw_backdrop);
+
+ /* Draw image */
+ sequencer_draw_display_buffer(C, scene, ar, sseq, ibuf, scope, draw_overlay, draw_backdrop);
+
+ /* Draw over image */
+ if (sseq->flag & SEQ_SHOW_METADATA) {
+ ED_region_image_metadata_draw(0.0, 0.0, ibuf, &v2d->tot, 1.0, 1.0);
+ }
+ }
+
+ if (show_imbuf) {
+ sequencer_draw_borders(sseq, v2d, scene);
+ }
+
+ if (draw_gpencil && show_imbuf) {
+ sequencer_draw_gpencil(C);
+ }
+
+ /* TODO */
+ /* sequencer_draw_maskedit(C, scene, ar, sseq); */
+
+ /* Scope is freed in sequencer_check_scopes when ibuf changes and scope image is to be replaced. */
+ if (ibuf) {
+ IMB_freeImBuf(ibuf);
+ }
+
+ UI_view2d_view_restore(C);
}
#if 0
void drawprefetchseqspace(Scene *scene, ARegion *UNUSED(ar), SpaceSeq *sseq)
{
- int rectx, recty;
- int render_size = sseq->render_size;
- int proxy_size = 100.0;
- if (render_size == 0) {
- render_size = scene->r.size;
- }
- else {
- proxy_size = render_size;
- }
- if (render_size < 0) {
- return;
- }
-
- rectx = (render_size * scene->r.xsch) / 100;
- recty = (render_size * scene->r.ysch) / 100;
-
- if (sseq->mainb != SEQ_DRAW_SEQUENCE) {
- give_ibuf_prefetch_request(
- rectx, recty, (scene->r.cfra), sseq->chanshown,
- proxy_size);
- }
+ int rectx, recty;
+ int render_size = sseq->render_size;
+ int proxy_size = 100.0;
+ if (render_size == 0) {
+ render_size = scene->r.size;
+ }
+ else {
+ proxy_size = render_size;
+ }
+ if (render_size < 0) {
+ return;
+ }
+
+ rectx = (render_size * scene->r.xsch) / 100;
+ recty = (render_size * scene->r.ysch) / 100;
+
+ if (sseq->mainb != SEQ_DRAW_SEQUENCE) {
+ give_ibuf_prefetch_request(
+ rectx, recty, (scene->r.cfra), sseq->chanshown,
+ proxy_size);
+ }
}
#endif
/* draw backdrop of the sequencer strips view */
static void draw_seq_backdrop(View2D *v2d)
{
- int i;
-
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- /* darker gray overlay over the view backdrop */
- immUniformThemeColorShade(TH_BACK, -20);
- immRectf(pos, v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0);
-
- /* Alternating horizontal stripes */
- i = max_ii(1, ((int)v2d->cur.ymin) - 1);
-
- while (i < v2d->cur.ymax) {
- if (i & 1) {
- immUniformThemeColorShade(TH_BACK, -15);
- }
- else {
- immUniformThemeColorShade(TH_BACK, -25);
- }
-
- immRectf(pos, v2d->cur.xmin, i, v2d->cur.xmax, i + 1);
-
- i++;
- }
-
- /* Darker lines separating the horizontal bands */
- i = max_ii(1, ((int)v2d->cur.ymin) - 1);
- int line_len = (int)v2d->cur.ymax - i + 1;
- immUniformThemeColor(TH_GRID);
- immBegin(GPU_PRIM_LINES, line_len * 2);
- while (line_len--) {
- immVertex2f(pos, v2d->cur.xmax, i);
- immVertex2f(pos, v2d->cur.xmin, i);
- }
- immEnd();
-
- immUnbindProgram();
+ int i;
+
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+ /* darker gray overlay over the view backdrop */
+ immUniformThemeColorShade(TH_BACK, -20);
+ immRectf(pos, v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0);
+
+ /* Alternating horizontal stripes */
+ i = max_ii(1, ((int)v2d->cur.ymin) - 1);
+
+ while (i < v2d->cur.ymax) {
+ if (i & 1) {
+ immUniformThemeColorShade(TH_BACK, -15);
+ }
+ else {
+ immUniformThemeColorShade(TH_BACK, -25);
+ }
+
+ immRectf(pos, v2d->cur.xmin, i, v2d->cur.xmax, i + 1);
+
+ i++;
+ }
+
+ /* Darker lines separating the horizontal bands */
+ i = max_ii(1, ((int)v2d->cur.ymin) - 1);
+ int line_len = (int)v2d->cur.ymax - i + 1;
+ immUniformThemeColor(TH_GRID);
+ immBegin(GPU_PRIM_LINES, line_len * 2);
+ while (line_len--) {
+ immVertex2f(pos, v2d->cur.xmax, i);
+ immVertex2f(pos, v2d->cur.xmin, i);
+ }
+ immEnd();
+
+ immUnbindProgram();
}
/* draw the contents of the sequencer strips view */
static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
{
- Scene *scene = CTX_data_scene(C);
- View2D *v2d = &ar->v2d;
- SpaceSeq *sseq = CTX_wm_space_seq(C);
- Sequence *last_seq = BKE_sequencer_active_get(scene);
- int sel = 0, j;
- float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
-
- /* loop through twice, first unselected, then selected */
- for (j = 0; j < 2; j++) {
- Sequence *seq;
- /* highlighting around strip edges indicating selection */
- int outline_tint = (j) ? -60 : -150;
-
- /* loop through strips, checking for those that are visible */
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- /* boundbox and selection tests for NOT drawing the strip... */
- if ((seq->flag & SELECT) != sel) { continue; }
- else if (seq == last_seq) { continue; }
- else if (min_ii(seq->startdisp, seq->start) > v2d->cur.xmax) { continue; }
- else if (max_ii(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) { continue; }
- else if (seq->machine + 1.0f < v2d->cur.ymin) { continue; }
- else if (seq->machine > v2d->cur.ymax) { continue; }
-
- /* strip passed all tests unscathed... so draw it now */
- draw_seq_strip(C, sseq, scene, ar, seq, outline_tint, pixelx);
- }
-
- /* draw selected next time round */
- sel = SELECT;
- }
-
- /* draw the last selected last (i.e. 'active' in other parts of Blender),
- * removes some overlapping error */
- if (last_seq) {
- draw_seq_strip(C, sseq, scene, ar, last_seq, 120, pixelx);
- }
-
- /* draw highlight when previewing a single strip */
- if (special_seq_update) {
- const Sequence *seq = special_seq_update;
- GPU_blend(true);
-
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- immUniformColor4ub(255, 255, 255, 48);
- immRectf(pos, seq->startdisp, seq->machine + SEQ_STRIP_OFSBOTTOM, seq->enddisp, seq->machine + SEQ_STRIP_OFSTOP);
-
- immUnbindProgram();
-
- GPU_blend(false);
- }
+ Scene *scene = CTX_data_scene(C);
+ View2D *v2d = &ar->v2d;
+ SpaceSeq *sseq = CTX_wm_space_seq(C);
+ Sequence *last_seq = BKE_sequencer_active_get(scene);
+ int sel = 0, j;
+ float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
+
+ /* loop through twice, first unselected, then selected */
+ for (j = 0; j < 2; j++) {
+ Sequence *seq;
+ /* highlighting around strip edges indicating selection */
+ int outline_tint = (j) ? -60 : -150;
+
+ /* loop through strips, checking for those that are visible */
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ /* boundbox and selection tests for NOT drawing the strip... */
+ if ((seq->flag & SELECT) != sel) {
+ continue;
+ }
+ else if (seq == last_seq) {
+ continue;
+ }
+ else if (min_ii(seq->startdisp, seq->start) > v2d->cur.xmax) {
+ continue;
+ }
+ else if (max_ii(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) {
+ continue;
+ }
+ else if (seq->machine + 1.0f < v2d->cur.ymin) {
+ continue;
+ }
+ else if (seq->machine > v2d->cur.ymax) {
+ continue;
+ }
+
+ /* strip passed all tests unscathed... so draw it now */
+ draw_seq_strip(C, sseq, scene, ar, seq, outline_tint, pixelx);
+ }
+
+ /* draw selected next time round */
+ sel = SELECT;
+ }
+
+ /* draw the last selected last (i.e. 'active' in other parts of Blender),
+ * removes some overlapping error */
+ if (last_seq) {
+ draw_seq_strip(C, sseq, scene, ar, last_seq, 120, pixelx);
+ }
+
+ /* draw highlight when previewing a single strip */
+ if (special_seq_update) {
+ const Sequence *seq = special_seq_update;
+ GPU_blend(true);
+
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+ immUniformColor4ub(255, 255, 255, 48);
+ immRectf(pos,
+ seq->startdisp,
+ seq->machine + SEQ_STRIP_OFSBOTTOM,
+ seq->enddisp,
+ seq->machine + SEQ_STRIP_OFSTOP);
+
+ immUnbindProgram();
+
+ GPU_blend(false);
+ }
}
static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
{
- const Editing *ed = BKE_sequencer_editing_get(scene, false);
- const int frame_sta = PSFRA;
- const int frame_end = PEFRA + 1;
+ const Editing *ed = BKE_sequencer_editing_get(scene, false);
+ const int frame_sta = PSFRA;
+ const int frame_end = PEFRA + 1;
- GPU_blend(true);
+ GPU_blend(true);
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- /* draw darkened area outside of active timeline
- * frame range used is preview range or scene range */
- immUniformThemeColorShadeAlpha(TH_BACK, -25, -100);
+ /* draw darkened area outside of active timeline
+ * frame range used is preview range or scene range */
+ immUniformThemeColorShadeAlpha(TH_BACK, -25, -100);
- if (frame_sta < frame_end) {
- immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, (float)frame_sta, v2d->cur.ymax);
- immRectf(pos, (float)frame_end, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
- }
- else {
- immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
- }
+ if (frame_sta < frame_end) {
+ immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, (float)frame_sta, v2d->cur.ymax);
+ immRectf(pos, (float)frame_end, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+ }
+ else {
+ immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+ }
- immUniformThemeColorShade(TH_BACK, -60);
+ immUniformThemeColorShade(TH_BACK, -60);
- /* thin lines where the actual frames are */
- immBegin(GPU_PRIM_LINES, 4);
+ /* thin lines where the actual frames are */
+ immBegin(GPU_PRIM_LINES, 4);
- immVertex2f(pos, frame_sta, v2d->cur.ymin);
- immVertex2f(pos, frame_sta, v2d->cur.ymax);
+ immVertex2f(pos, frame_sta, v2d->cur.ymin);
+ immVertex2f(pos, frame_sta, v2d->cur.ymax);
- immVertex2f(pos, frame_end, v2d->cur.ymin);
- immVertex2f(pos, frame_end, v2d->cur.ymax);
+ immVertex2f(pos, frame_end, v2d->cur.ymin);
+ immVertex2f(pos, frame_end, v2d->cur.ymax);
- immEnd();
+ immEnd();
- if (ed && !BLI_listbase_is_empty(&ed->metastack)) {
- MetaStack *ms = ed->metastack.last;
+ if (ed && !BLI_listbase_is_empty(&ed->metastack)) {
+ MetaStack *ms = ed->metastack.last;
- immUniformColor4ub(255, 255, 255, 8);
- immRectf(pos, ms->disp_range[0], v2d->cur.ymin, ms->disp_range[1], v2d->cur.ymax);
+ immUniformColor4ub(255, 255, 255, 8);
+ immRectf(pos, ms->disp_range[0], v2d->cur.ymin, ms->disp_range[1], v2d->cur.ymax);
- immUniformThemeColorShade(TH_BACK, -40);
+ immUniformThemeColorShade(TH_BACK, -40);
- immBegin(GPU_PRIM_LINES, 4);
+ immBegin(GPU_PRIM_LINES, 4);
- immVertex2f(pos, ms->disp_range[0], v2d->cur.ymin);
- immVertex2f(pos, ms->disp_range[0], v2d->cur.ymax);
+ immVertex2f(pos, ms->disp_range[0], v2d->cur.ymin);
+ immVertex2f(pos, ms->disp_range[0], v2d->cur.ymax);
- immVertex2f(pos, ms->disp_range[1], v2d->cur.ymin);
- immVertex2f(pos, ms->disp_range[1], v2d->cur.ymax);
+ immVertex2f(pos, ms->disp_range[1], v2d->cur.ymin);
+ immVertex2f(pos, ms->disp_range[1], v2d->cur.ymax);
- immEnd();
- }
+ immEnd();
+ }
- immUnbindProgram();
+ immUnbindProgram();
- GPU_blend(false);
+ GPU_blend(false);
}
/* Draw Timeline/Strip Editor Mode for Sequencer */
void draw_timeline_seq(const bContext *C, ARegion *ar)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- SpaceSeq *sseq = CTX_wm_space_seq(C);
- View2D *v2d = &ar->v2d;
- View2DScrollers *scrollers;
- short unit = 0, cfra_flag = 0;
- float col[3];
-
- /* clear and setup matrix */
- UI_GetThemeColor3fv(TH_BACK, col);
- if (ed && ed->metastack.first) {
- GPU_clear_color(col[0], col[1], col[2] - 0.1f, 0.0f);
- }
- else {
- GPU_clear_color(col[0], col[1], col[2], 0.0f);
- }
- GPU_clear(GPU_COLOR_BIT);
-
- UI_view2d_view_ortho(v2d);
-
-
- /* calculate extents of sequencer strips/data
- * NOTE: needed for the scrollers later
- */
- boundbox_seq(scene, &v2d->tot);
-
-
- /* draw backdrop */
- draw_seq_backdrop(v2d);
-
- /* regular grid-pattern over the rest of the view (i.e. 1-second grid lines) */
- UI_view2d_constant_grid_draw(v2d, FPS);
-
- /* Only draw backdrop in pure sequence view. */
- if (sseq->view == SEQ_VIEW_SEQUENCE && sseq->draw_flag & SEQ_DRAW_BACKDROP) {
- sequencer_draw_preview(C, scene, ar, sseq, scene->r.cfra, 0, false, true);
- UI_view2d_view_ortho(v2d);
- }
-
- ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
-
- seq_draw_sfra_efra(scene, v2d);
-
- /* sequence strips (if there is data available to be drawn) */
- if (ed) {
- /* draw the data */
- draw_seq_strips(C, ed, ar);
-
- /* text draw cached (for sequence names), in pixelspace now */
- UI_view2d_text_cache_draw(ar);
- }
-
- /* current frame */
- UI_view2d_view_ortho(v2d);
- if ((sseq->flag & SEQ_DRAWFRAMES) == 0) {
- cfra_flag |= DRAWCFRA_UNIT_SECONDS;
- }
- ANIM_draw_cfra(C, v2d, cfra_flag);
-
- /* markers */
- UI_view2d_view_orthoSpecial(ar, v2d, 1);
- int marker_draw_flag = DRAW_MARKERS_MARGIN;
- if (sseq->flag & SEQ_SHOW_MARKER_LINES) {
- marker_draw_flag |= DRAW_MARKERS_LINES;
- }
- ED_markers_draw(C, marker_draw_flag);
-
- /* preview range */
- UI_view2d_view_ortho(v2d);
- ANIM_draw_previewrange(C, v2d, 1);
-
- /* overlap playhead */
- if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) {
- int cfra_over = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ? scene->ed->over_cfra : scene->r.cfra + scene->ed->over_ofs;
-
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- immUniformColor3f(0.2f, 0.2f, 0.2f);
-
- immBegin(GPU_PRIM_LINES, 2);
- immVertex2f(pos, cfra_over, v2d->cur.ymin);
- immVertex2f(pos, cfra_over, v2d->cur.ymax);
- immEnd();
-
- immUnbindProgram();
- }
-
- /* callback */
- ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
-
- /* reset view matrix */
- UI_view2d_view_restore(C);
-
- /* scrollers */
- unit = (sseq->flag & SEQ_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS;
- scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP);
- UI_view2d_scrollers_draw(C, v2d, scrollers);
- UI_view2d_scrollers_free(scrollers);
-
- /* draw current frame number-indicator on top of scrollers */
- if ((sseq->flag & SEQ_NO_DRAW_CFRANUM) == 0) {
- UI_view2d_view_orthoSpecial(ar, v2d, 1);
- ANIM_draw_cfra_number(C, v2d, cfra_flag);
- }
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ SpaceSeq *sseq = CTX_wm_space_seq(C);
+ View2D *v2d = &ar->v2d;
+ View2DScrollers *scrollers;
+ short unit = 0, cfra_flag = 0;
+ float col[3];
+
+ /* clear and setup matrix */
+ UI_GetThemeColor3fv(TH_BACK, col);
+ if (ed && ed->metastack.first) {
+ GPU_clear_color(col[0], col[1], col[2] - 0.1f, 0.0f);
+ }
+ else {
+ GPU_clear_color(col[0], col[1], col[2], 0.0f);
+ }
+ GPU_clear(GPU_COLOR_BIT);
+
+ UI_view2d_view_ortho(v2d);
+
+ /* calculate extents of sequencer strips/data
+ * NOTE: needed for the scrollers later
+ */
+ boundbox_seq(scene, &v2d->tot);
+
+ /* draw backdrop */
+ draw_seq_backdrop(v2d);
+
+ /* regular grid-pattern over the rest of the view (i.e. 1-second grid lines) */
+ UI_view2d_constant_grid_draw(v2d, FPS);
+
+ /* Only draw backdrop in pure sequence view. */
+ if (sseq->view == SEQ_VIEW_SEQUENCE && sseq->draw_flag & SEQ_DRAW_BACKDROP) {
+ sequencer_draw_preview(C, scene, ar, sseq, scene->r.cfra, 0, false, true);
+ UI_view2d_view_ortho(v2d);
+ }
+
+ ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
+
+ seq_draw_sfra_efra(scene, v2d);
+
+ /* sequence strips (if there is data available to be drawn) */
+ if (ed) {
+ /* draw the data */
+ draw_seq_strips(C, ed, ar);
+
+ /* text draw cached (for sequence names), in pixelspace now */
+ UI_view2d_text_cache_draw(ar);
+ }
+
+ /* current frame */
+ UI_view2d_view_ortho(v2d);
+ if ((sseq->flag & SEQ_DRAWFRAMES) == 0) {
+ cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
+ ANIM_draw_cfra(C, v2d, cfra_flag);
+
+ /* markers */
+ UI_view2d_view_orthoSpecial(ar, v2d, 1);
+ int marker_draw_flag = DRAW_MARKERS_MARGIN;
+ if (sseq->flag & SEQ_SHOW_MARKER_LINES) {
+ marker_draw_flag |= DRAW_MARKERS_LINES;
+ }
+ ED_markers_draw(C, marker_draw_flag);
+
+ /* preview range */
+ UI_view2d_view_ortho(v2d);
+ ANIM_draw_previewrange(C, v2d, 1);
+
+ /* overlap playhead */
+ if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) {
+ int cfra_over = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ?
+ scene->ed->over_cfra :
+ scene->r.cfra + scene->ed->over_ofs;
+
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+ immUniformColor3f(0.2f, 0.2f, 0.2f);
+
+ immBegin(GPU_PRIM_LINES, 2);
+ immVertex2f(pos, cfra_over, v2d->cur.ymin);
+ immVertex2f(pos, cfra_over, v2d->cur.ymax);
+ immEnd();
+
+ immUnbindProgram();
+ }
+
+ /* callback */
+ ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
+
+ /* reset view matrix */
+ UI_view2d_view_restore(C);
+
+ /* scrollers */
+ unit = (sseq->flag & SEQ_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS;
+ scrollers = UI_view2d_scrollers_calc(
+ C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP);
+ UI_view2d_scrollers_draw(C, v2d, scrollers);
+ UI_view2d_scrollers_free(scrollers);
+
+ /* draw current frame number-indicator on top of scrollers */
+ if ((sseq->flag & SEQ_NO_DRAW_CFRANUM) == 0) {
+ UI_view2d_view_orthoSpecial(ar, v2d, 1);
+ ANIM_draw_cfra_number(C, v2d, cfra_flag);
+ }
}
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 9e5a2624226..cf07e252404 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -21,7 +21,6 @@
* \ingroup spseq
*/
-
#include <stdlib.h>
#include <math.h>
#include <string.h>
@@ -71,25 +70,25 @@
/* XXX */
/* RNA Enums, used in multiple files */
EnumPropertyItem sequencer_prop_effect_types[] = {
- {SEQ_TYPE_CROSS, "CROSS", 0, "Crossfade", "Crossfade effect strip type"},
- {SEQ_TYPE_ADD, "ADD", 0, "Add", "Add effect strip type"},
- {SEQ_TYPE_SUB, "SUBTRACT", 0, "Subtract", "Subtract effect strip type"},
- {SEQ_TYPE_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", "Alpha Over effect strip type"},
- {SEQ_TYPE_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", "Alpha Under effect strip type"},
- {SEQ_TYPE_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", "Gamma Cross effect strip type"},
- {SEQ_TYPE_MUL, "MULTIPLY", 0, "Multiply", "Multiply effect strip type"},
- {SEQ_TYPE_OVERDROP, "OVER_DROP", 0, "Alpha Over Drop", "Alpha Over Drop effect strip type"},
- {SEQ_TYPE_WIPE, "WIPE", 0, "Wipe", "Wipe effect strip type"},
- {SEQ_TYPE_GLOW, "GLOW", 0, "Glow", "Glow effect strip type"},
- {SEQ_TYPE_TRANSFORM, "TRANSFORM", 0, "Transform", "Transform effect strip type"},
- {SEQ_TYPE_COLOR, "COLOR", 0, "Color", "Color effect strip type"},
- {SEQ_TYPE_SPEED, "SPEED", 0, "Speed", "Color effect strip type"},
- {SEQ_TYPE_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""},
- {SEQ_TYPE_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""},
- {SEQ_TYPE_GAUSSIAN_BLUR, "GAUSSIAN_BLUR", 0, "Gaussian Blur", ""},
- {SEQ_TYPE_TEXT, "TEXT", 0, "Text", ""},
- {SEQ_TYPE_COLORMIX, "COLORMIX", 0, "Color Mix", ""},
- {0, NULL, 0, NULL, NULL},
+ {SEQ_TYPE_CROSS, "CROSS", 0, "Crossfade", "Crossfade effect strip type"},
+ {SEQ_TYPE_ADD, "ADD", 0, "Add", "Add effect strip type"},
+ {SEQ_TYPE_SUB, "SUBTRACT", 0, "Subtract", "Subtract effect strip type"},
+ {SEQ_TYPE_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", "Alpha Over effect strip type"},
+ {SEQ_TYPE_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", "Alpha Under effect strip type"},
+ {SEQ_TYPE_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", "Gamma Cross effect strip type"},
+ {SEQ_TYPE_MUL, "MULTIPLY", 0, "Multiply", "Multiply effect strip type"},
+ {SEQ_TYPE_OVERDROP, "OVER_DROP", 0, "Alpha Over Drop", "Alpha Over Drop effect strip type"},
+ {SEQ_TYPE_WIPE, "WIPE", 0, "Wipe", "Wipe effect strip type"},
+ {SEQ_TYPE_GLOW, "GLOW", 0, "Glow", "Glow effect strip type"},
+ {SEQ_TYPE_TRANSFORM, "TRANSFORM", 0, "Transform", "Transform effect strip type"},
+ {SEQ_TYPE_COLOR, "COLOR", 0, "Color", "Color effect strip type"},
+ {SEQ_TYPE_SPEED, "SPEED", 0, "Speed", "Color effect strip type"},
+ {SEQ_TYPE_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""},
+ {SEQ_TYPE_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""},
+ {SEQ_TYPE_GAUSSIAN_BLUR, "GAUSSIAN_BLUR", 0, "Gaussian Blur", ""},
+ {SEQ_TYPE_TEXT, "TEXT", 0, "Text", ""},
+ {SEQ_TYPE_COLORMIX, "COLORMIX", 0, "Color Mix", ""},
+ {0, NULL, 0, NULL, NULL},
};
/* mute operator */
@@ -97,27 +96,27 @@ EnumPropertyItem sequencer_prop_effect_types[] = {
#define SEQ_SIDE_MOUSE -1
EnumPropertyItem prop_side_types[] = {
- {SEQ_SIDE_MOUSE, "MOUSE", 0, "Mouse position", "" },
- {SEQ_SIDE_LEFT, "LEFT", 0, "Left", "" },
- {SEQ_SIDE_RIGHT, "RIGHT", 0, "Right", ""},
- {SEQ_SIDE_BOTH, "BOTH", 0, "Both", ""},
- {0, NULL, 0, NULL, NULL},
+ {SEQ_SIDE_MOUSE, "MOUSE", 0, "Mouse position", ""},
+ {SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""},
+ {SEQ_SIDE_RIGHT, "RIGHT", 0, "Right", ""},
+ {SEQ_SIDE_BOTH, "BOTH", 0, "Both", ""},
+ {0, NULL, 0, NULL, NULL},
};
static const EnumPropertyItem prop_side_lr_types[] = {
- {SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""},
- {SEQ_SIDE_RIGHT, "RIGHT", 0, "Right", ""},
- {0, NULL, 0, NULL, NULL},
+ {SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""},
+ {SEQ_SIDE_RIGHT, "RIGHT", 0, "Right", ""},
+ {0, NULL, 0, NULL, NULL},
};
typedef struct TransSeq {
- int start, machine;
- int startstill, endstill;
- int startdisp, enddisp;
- int startofs, endofs;
- int anim_startofs, anim_endofs;
- /* int final_left, final_right; */ /* UNUSED */
- int len;
+ int start, machine;
+ int startstill, endstill;
+ int startdisp, enddisp;
+ int startofs, endofs;
+ int anim_startofs, anim_endofs;
+ /* int final_left, final_right; */ /* UNUSED */
+ int len;
} TransSeq;
/* ********************************************************************** */
@@ -125,828 +124,831 @@ typedef struct TransSeq {
/* ***************** proxy job manager ********************** */
typedef struct ProxyBuildJob {
- struct Main *main;
- struct Depsgraph *depsgraph;
- Scene *scene;
- ListBase queue;
- int stop;
+ struct Main *main;
+ struct Depsgraph *depsgraph;
+ Scene *scene;
+ ListBase queue;
+ int stop;
} ProxyJob;
static void proxy_freejob(void *pjv)
{
- ProxyJob *pj = pjv;
+ ProxyJob *pj = pjv;
- BLI_freelistN(&pj->queue);
+ BLI_freelistN(&pj->queue);
- MEM_freeN(pj);
+ MEM_freeN(pj);
}
/* only this runs inside thread */
static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress)
{
- ProxyJob *pj = pjv;
- LinkData *link;
+ ProxyJob *pj = pjv;
+ LinkData *link;
- for (link = pj->queue.first; link; link = link->next) {
- struct SeqIndexBuildContext *context = link->data;
+ for (link = pj->queue.first; link; link = link->next) {
+ struct SeqIndexBuildContext *context = link->data;
- BKE_sequencer_proxy_rebuild(context, stop, do_update, progress);
+ BKE_sequencer_proxy_rebuild(context, stop, do_update, progress);
- if (*stop) {
- pj->stop = 1;
- fprintf(stderr, "Canceling proxy rebuild on users request...\n");
- break;
- }
- }
+ if (*stop) {
+ pj->stop = 1;
+ fprintf(stderr, "Canceling proxy rebuild on users request...\n");
+ break;
+ }
+ }
}
static void proxy_endjob(void *pjv)
{
- ProxyJob *pj = pjv;
- Editing *ed = BKE_sequencer_editing_get(pj->scene, false);
- LinkData *link;
+ ProxyJob *pj = pjv;
+ Editing *ed = BKE_sequencer_editing_get(pj->scene, false);
+ LinkData *link;
- for (link = pj->queue.first; link; link = link->next) {
- BKE_sequencer_proxy_rebuild_finish(link->data, pj->stop);
- }
+ for (link = pj->queue.first; link; link = link->next) {
+ BKE_sequencer_proxy_rebuild_finish(link->data, pj->stop);
+ }
- BKE_sequencer_free_imbuf(pj->scene, &ed->seqbase, false);
+ BKE_sequencer_free_imbuf(pj->scene, &ed->seqbase, false);
- WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, pj->scene);
+ WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, pj->scene);
}
static void seq_proxy_build_job(const bContext *C)
{
- wmJob *wm_job;
- ProxyJob *pj;
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- ScrArea *sa = CTX_wm_area(C);
- Sequence *seq;
- GSet *file_list;
+ wmJob *wm_job;
+ ProxyJob *pj;
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ ScrArea *sa = CTX_wm_area(C);
+ Sequence *seq;
+ GSet *file_list;
- if (ed == NULL) {
- return;
- }
+ if (ed == NULL) {
+ return;
+ }
- wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies",
- WM_JOB_PROGRESS, WM_JOB_TYPE_SEQ_BUILD_PROXY);
+ wm_job = WM_jobs_get(CTX_wm_manager(C),
+ CTX_wm_window(C),
+ sa,
+ "Building Proxies",
+ WM_JOB_PROGRESS,
+ WM_JOB_TYPE_SEQ_BUILD_PROXY);
- pj = WM_jobs_customdata_get(wm_job);
+ pj = WM_jobs_customdata_get(wm_job);
- if (!pj) {
- pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job");
+ if (!pj) {
+ pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job");
- pj->depsgraph = depsgraph;
- pj->scene = scene;
- pj->main = CTX_data_main(C);
+ pj->depsgraph = depsgraph;
+ pj->scene = scene;
+ pj->main = CTX_data_main(C);
- WM_jobs_customdata_set(wm_job, pj, proxy_freejob);
- WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER);
- WM_jobs_callbacks(wm_job, proxy_startjob, NULL, NULL, proxy_endjob);
- }
+ WM_jobs_customdata_set(wm_job, pj, proxy_freejob);
+ WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER);
+ WM_jobs_callbacks(wm_job, proxy_startjob, NULL, NULL, proxy_endjob);
+ }
- file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
- SEQP_BEGIN (ed, seq)
- {
- if ((seq->flag & SELECT)) {
- BKE_sequencer_proxy_rebuild_context(pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue);
- }
- } SEQ_END;
+ file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
+ SEQP_BEGIN (ed, seq) {
+ if ((seq->flag & SELECT)) {
+ BKE_sequencer_proxy_rebuild_context(
+ pj->main, pj->depsgraph, pj->scene, seq, file_list, &pj->queue);
+ }
+ }
+ SEQ_END;
- BLI_gset_free(file_list, MEM_freeN);
+ BLI_gset_free(file_list, MEM_freeN);
- if (!WM_jobs_is_running(wm_job)) {
- G.is_break = false;
- WM_jobs_start(CTX_wm_manager(C), wm_job);
- }
+ if (!WM_jobs_is_running(wm_job)) {
+ G.is_break = false;
+ WM_jobs_start(CTX_wm_manager(C), wm_job);
+ }
- ED_area_tag_redraw(sa);
+ ED_area_tag_redraw(sa);
}
/* ********************************************************************** */
void seq_rectf(Sequence *seq, rctf *rectf)
{
- if (seq->startstill) {
- rectf->xmin = seq->start;
- }
- else {
- rectf->xmin = seq->startdisp;
- }
+ if (seq->startstill) {
+ rectf->xmin = seq->start;
+ }
+ else {
+ rectf->xmin = seq->startdisp;
+ }
- rectf->ymin = seq->machine + SEQ_STRIP_OFSBOTTOM;
- if (seq->endstill) {
- rectf->xmax = seq->start + seq->len;
- }
- else {
- rectf->xmax = seq->enddisp;
- }
- rectf->ymax = seq->machine + SEQ_STRIP_OFSTOP;
+ rectf->ymin = seq->machine + SEQ_STRIP_OFSBOTTOM;
+ if (seq->endstill) {
+ rectf->xmax = seq->start + seq->len;
+ }
+ else {
+ rectf->xmax = seq->enddisp;
+ }
+ rectf->ymax = seq->machine + SEQ_STRIP_OFSTOP;
}
void boundbox_seq(Scene *scene, rctf *rect)
{
- Sequence *seq;
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- float min[2], max[2];
-
-
- if (ed == NULL) {
- return;
- }
+ Sequence *seq;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ float min[2], max[2];
- min[0] = 0.0;
- max[0] = EFRA + 1;
- min[1] = 0.0;
- max[1] = 8.0;
+ if (ed == NULL) {
+ return;
+ }
- seq = ed->seqbasep->first;
- while (seq) {
+ min[0] = 0.0;
+ max[0] = EFRA + 1;
+ min[1] = 0.0;
+ max[1] = 8.0;
- if (min[0] > seq->startdisp - 1) {
- min[0] = seq->startdisp - 1;
- }
- if (max[0] < seq->enddisp + 1) {
- max[0] = seq->enddisp + 1;
- }
- if (max[1] < seq->machine + 2) {
- max[1] = seq->machine + 2;
- }
+ seq = ed->seqbasep->first;
+ while (seq) {
- seq = seq->next;
- }
+ if (min[0] > seq->startdisp - 1) {
+ min[0] = seq->startdisp - 1;
+ }
+ if (max[0] < seq->enddisp + 1) {
+ max[0] = seq->enddisp + 1;
+ }
+ if (max[1] < seq->machine + 2) {
+ max[1] = seq->machine + 2;
+ }
- rect->xmin = min[0];
- rect->xmax = max[0];
- rect->ymin = min[1];
- rect->ymax = max[1];
+ seq = seq->next;
+ }
+ rect->xmin = min[0];
+ rect->xmax = max[0];
+ rect->ymin = min[1];
+ rect->ymax = max[1];
}
static int mouse_frame_side(View2D *v2d, short mouse_x, int frame)
{
- int mval[2];
- float mouseloc[2];
+ int mval[2];
+ float mouseloc[2];
- mval[0] = mouse_x;
- mval[1] = 0;
+ mval[0] = mouse_x;
+ mval[1] = 0;
- /* choose the side based on which side of the playhead the mouse is on */
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &mouseloc[0], &mouseloc[1]);
+ /* choose the side based on which side of the playhead the mouse is on */
+ UI_view2d_region_to_view(v2d, mval[0], mval[1], &mouseloc[0], &mouseloc[1]);
- return mouseloc[0] > frame ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT;
+ return mouseloc[0] > frame ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT;
}
-
Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int sel)
{
- /* sel - 0==unselected, 1==selected, -1==done care*/
- Sequence *seq;
- Editing *ed = BKE_sequencer_editing_get(scene, false);
-
- if (ed == NULL) {
- return NULL;
- }
-
- if (sel > 0) {
- sel = SELECT;
- }
-
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if ((seq != test) &&
- (test->machine == seq->machine) &&
- ((sel == -1) || (sel && (seq->flag & SELECT)) || (sel == 0 && (seq->flag & SELECT) == 0)))
- {
- switch (lr) {
- case SEQ_SIDE_LEFT:
- if (test->startdisp == (seq->enddisp)) {
- return seq;
- }
- break;
- case SEQ_SIDE_RIGHT:
- if (test->enddisp == (seq->startdisp)) {
- return seq;
- }
- break;
- }
- }
- }
- return NULL;
+ /* sel - 0==unselected, 1==selected, -1==done care*/
+ Sequence *seq;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+
+ if (ed == NULL) {
+ return NULL;
+ }
+
+ if (sel > 0) {
+ sel = SELECT;
+ }
+
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if ((seq != test) && (test->machine == seq->machine) &&
+ ((sel == -1) || (sel && (seq->flag & SELECT)) ||
+ (sel == 0 && (seq->flag & SELECT) == 0))) {
+ switch (lr) {
+ case SEQ_SIDE_LEFT:
+ if (test->startdisp == (seq->enddisp)) {
+ return seq;
+ }
+ break;
+ case SEQ_SIDE_RIGHT:
+ if (test->enddisp == (seq->startdisp)) {
+ return seq;
+ }
+ break;
+ }
+ }
+ }
+ return NULL;
}
static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, int sel)
{
- /* sel - 0==unselected, 1==selected, -1==done care*/
- Sequence *seq, *best_seq = NULL;
- Editing *ed = BKE_sequencer_editing_get(scene, false);
-
- int dist, best_dist;
- best_dist = MAXFRAME * 2;
-
-
- if (ed == NULL) {
- return NULL;
- }
-
- seq = ed->seqbasep->first;
- while (seq) {
- if ((seq != test) &&
- (test->machine == seq->machine) &&
- (test->depth == seq->depth) &&
- ((sel == -1) || (sel == (seq->flag & SELECT))))
- {
- dist = MAXFRAME * 2;
-
- switch (lr) {
- case SEQ_SIDE_LEFT:
- if (seq->enddisp <= test->startdisp) {
- dist = test->enddisp - seq->startdisp;
- }
- break;
- case SEQ_SIDE_RIGHT:
- if (seq->startdisp >= test->enddisp) {
- dist = seq->startdisp - test->enddisp;
- }
- break;
- }
-
- if (dist == 0) {
- best_seq = seq;
- break;
- }
- else if (dist < best_dist) {
- best_dist = dist;
- best_seq = seq;
- }
- }
- seq = seq->next;
- }
- return best_seq; /* can be null */
+ /* sel - 0==unselected, 1==selected, -1==done care*/
+ Sequence *seq, *best_seq = NULL;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+
+ int dist, best_dist;
+ best_dist = MAXFRAME * 2;
+
+ if (ed == NULL) {
+ return NULL;
+ }
+
+ seq = ed->seqbasep->first;
+ while (seq) {
+ if ((seq != test) && (test->machine == seq->machine) && (test->depth == seq->depth) &&
+ ((sel == -1) || (sel == (seq->flag & SELECT)))) {
+ dist = MAXFRAME * 2;
+
+ switch (lr) {
+ case SEQ_SIDE_LEFT:
+ if (seq->enddisp <= test->startdisp) {
+ dist = test->enddisp - seq->startdisp;
+ }
+ break;
+ case SEQ_SIDE_RIGHT:
+ if (seq->startdisp >= test->enddisp) {
+ dist = seq->startdisp - test->enddisp;
+ }
+ break;
+ }
+
+ if (dist == 0) {
+ best_seq = seq;
+ break;
+ }
+ else if (dist < best_dist) {
+ best_dist = dist;
+ best_seq = seq;
+ }
+ }
+ seq = seq->next;
+ }
+ return best_seq; /* can be null */
}
-
Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[2])
{
- Sequence *seq;
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- float x, y;
- float pixelx;
- float handsize;
- float displen;
- *hand = SEQ_SIDE_NONE;
-
-
- if (ed == NULL) {
- return NULL;
- }
-
- pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
-
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
-
- seq = ed->seqbasep->first;
-
- while (seq) {
- if (seq->machine == (int)y) {
- /* check for both normal strips, and strips that have been flipped horizontally */
- if (((seq->startdisp < seq->enddisp) && (seq->startdisp <= x && seq->enddisp >= x)) ||
- ((seq->startdisp > seq->enddisp) && (seq->startdisp >= x && seq->enddisp <= x)) )
- {
- if (BKE_sequence_tx_test(seq)) {
-
- /* clamp handles to defined size in pixel space */
-
- handsize = seq->handsize;
- displen = (float)abs(seq->startdisp - seq->enddisp);
-
- /* don't even try to grab the handles of small strips */
- if (displen / pixelx > 16) {
- /* Set the max value to handle to 1/3 of the total len when its
- * less than 28. This is important because otherwise selecting
- * handles happens even when you click in the middle. */
-
- if ((displen / 3) < 30 * pixelx) {
- handsize = displen / 3;
- }
- else {
- CLAMP(handsize, 7 * pixelx, 30 * pixelx);
- }
-
- if (handsize + seq->startdisp >= x) {
- *hand = SEQ_SIDE_LEFT;
- }
- else if (-handsize + seq->enddisp <= x) {
- *hand = SEQ_SIDE_RIGHT;
- }
- }
- }
- return seq;
- }
- }
- seq = seq->next;
- }
- return NULL;
+ Sequence *seq;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ float x, y;
+ float pixelx;
+ float handsize;
+ float displen;
+ *hand = SEQ_SIDE_NONE;
+
+ if (ed == NULL) {
+ return NULL;
+ }
+
+ pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
+
+ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
+
+ seq = ed->seqbasep->first;
+
+ while (seq) {
+ if (seq->machine == (int)y) {
+ /* check for both normal strips, and strips that have been flipped horizontally */
+ if (((seq->startdisp < seq->enddisp) && (seq->startdisp <= x && seq->enddisp >= x)) ||
+ ((seq->startdisp > seq->enddisp) && (seq->startdisp >= x && seq->enddisp <= x))) {
+ if (BKE_sequence_tx_test(seq)) {
+
+ /* clamp handles to defined size in pixel space */
+
+ handsize = seq->handsize;
+ displen = (float)abs(seq->startdisp - seq->enddisp);
+
+ /* don't even try to grab the handles of small strips */
+ if (displen / pixelx > 16) {
+ /* Set the max value to handle to 1/3 of the total len when its
+ * less than 28. This is important because otherwise selecting
+ * handles happens even when you click in the middle. */
+
+ if ((displen / 3) < 30 * pixelx) {
+ handsize = displen / 3;
+ }
+ else {
+ CLAMP(handsize, 7 * pixelx, 30 * pixelx);
+ }
+
+ if (handsize + seq->startdisp >= x) {
+ *hand = SEQ_SIDE_LEFT;
+ }
+ else if (-handsize + seq->enddisp <= x) {
+ *hand = SEQ_SIDE_RIGHT;
+ }
+ }
+ }
+ return seq;
+ }
+ }
+ seq = seq->next;
+ }
+ return NULL;
}
-
static bool seq_is_parent(Sequence *par, Sequence *seq)
{
- return ((par->seq1 == seq) || (par->seq2 == seq) || (par->seq3 == seq));
+ return ((par->seq1 == seq) || (par->seq2 == seq) || (par->seq3 == seq));
}
static bool seq_is_predecessor(Sequence *pred, Sequence *seq)
{
- if (!pred) { return 0; }
- if (pred == seq) { return 0; }
- else if (seq_is_parent(pred, seq)) { return 1; }
- else if (pred->seq1 && seq_is_predecessor(pred->seq1, seq)) { return 1; }
- else if (pred->seq2 && seq_is_predecessor(pred->seq2, seq)) { return 1; }
- else if (pred->seq3 && seq_is_predecessor(pred->seq3, seq)) { return 1; }
-
- return 0;
+ if (!pred) {
+ return 0;
+ }
+ if (pred == seq) {
+ return 0;
+ }
+ else if (seq_is_parent(pred, seq)) {
+ return 1;
+ }
+ else if (pred->seq1 && seq_is_predecessor(pred->seq1, seq)) {
+ return 1;
+ }
+ else if (pred->seq2 && seq_is_predecessor(pred->seq2, seq)) {
+ return 1;
+ }
+ else if (pred->seq3 && seq_is_predecessor(pred->seq3, seq)) {
+ return 1;
+ }
+
+ return 0;
}
void ED_sequencer_deselect_all(Scene *scene)
{
- Sequence *seq;
- Editing *ed = BKE_sequencer_editing_get(scene, false);
-
-
- if (ed == NULL) {
- return;
- }
+ Sequence *seq;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
- SEQP_BEGIN (ed, seq)
- {
- seq->flag &= ~SEQ_ALLSEL;
- } SEQ_END;
+ if (ed == NULL) {
+ return;
+ }
+ SEQP_BEGIN (ed, seq) {
+ seq->flag &= ~SEQ_ALLSEL;
+ }
+ SEQ_END;
}
void recurs_sel_seq(Sequence *seqm)
{
- Sequence *seq;
+ Sequence *seq;
- seq = seqm->seqbase.first;
- while (seq) {
+ seq = seqm->seqbase.first;
+ while (seq) {
- if (seqm->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) {
- seq->flag &= ~SEQ_ALLSEL;
- }
- else if (seqm->flag & SELECT) {
- seq->flag |= SELECT;
- }
- else {
- seq->flag &= ~SEQ_ALLSEL;
- }
+ if (seqm->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) {
+ seq->flag &= ~SEQ_ALLSEL;
+ }
+ else if (seqm->flag & SELECT) {
+ seq->flag |= SELECT;
+ }
+ else {
+ seq->flag &= ~SEQ_ALLSEL;
+ }
- if (seq->seqbase.first) {
- recurs_sel_seq(seq);
- }
+ if (seq->seqbase.first) {
+ recurs_sel_seq(seq);
+ }
- seq = seq->next;
- }
+ seq = seq->next;
+ }
}
bool ED_space_sequencer_maskedit_mask_poll(bContext *C)
{
- /* in this case both funcs are the same, for clip editor not */
- return ED_space_sequencer_maskedit_poll(C);
+ /* in this case both funcs are the same, for clip editor not */
+ return ED_space_sequencer_maskedit_poll(C);
}
bool ED_space_sequencer_check_show_maskedit(SpaceSeq *sseq, Scene *scene)
{
- if (sseq && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
- return (BKE_sequencer_mask_get(scene) != NULL);
- }
+ if (sseq && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
+ return (BKE_sequencer_mask_get(scene) != NULL);
+ }
- return false;
+ return false;
}
bool ED_space_sequencer_maskedit_poll(bContext *C)
{
- SpaceSeq *sseq = CTX_wm_space_seq(C);
+ SpaceSeq *sseq = CTX_wm_space_seq(C);
- if (sseq) {
- Scene *scene = CTX_data_scene(C);
- return ED_space_sequencer_check_show_maskedit(sseq, scene);
- }
+ if (sseq) {
+ Scene *scene = CTX_data_scene(C);
+ return ED_space_sequencer_check_show_maskedit(sseq, scene);
+ }
- return false;
+ return false;
}
/* are we displaying the seq output (not channels or histogram)*/
bool ED_space_sequencer_check_show_imbuf(SpaceSeq *sseq)
{
- return (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW) &&
- ELEM(sseq->mainb, SEQ_DRAW_SEQUENCE, SEQ_DRAW_IMG_IMBUF));
+ return (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW) &&
+ ELEM(sseq->mainb, SEQ_DRAW_SEQUENCE, SEQ_DRAW_IMG_IMBUF));
}
bool ED_space_sequencer_check_show_strip(SpaceSeq *sseq)
{
- return (ELEM(sseq->view, SEQ_VIEW_SEQUENCE, SEQ_VIEW_SEQUENCE_PREVIEW) &&
- ELEM(sseq->mainb, SEQ_DRAW_SEQUENCE, SEQ_DRAW_IMG_IMBUF));
-}
-
-
-int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequence **selseq1, Sequence **selseq2, Sequence **selseq3, const char **error_str)
-{
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq1 = NULL, *seq2 = NULL, *seq3 = NULL, *seq;
-
- *error_str = NULL;
-
- if (!activeseq) {
- seq2 = BKE_sequencer_active_get(scene);
- }
-
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SELECT) {
- if (seq->type == SEQ_TYPE_SOUND_RAM && BKE_sequence_effect_get_num_inputs(type) != 0) {
- *error_str = N_("Cannot apply effects to audio sequence strips");
- return 0;
- }
- if ((seq != activeseq) && (seq != seq2)) {
- if (seq2 == NULL) {
- seq2 = seq;
- }
- else if (seq1 == NULL) {
- seq1 = seq;
- }
- else if (seq3 == NULL) {
- seq3 = seq;
- }
- else {
- *error_str = N_("Cannot apply effect to more than 3 sequence strips");
- return 0;
- }
- }
- }
- }
-
- /* make sequence selection a little bit more intuitive
- * for 3 strips: the last-strip should be sequence3 */
- if (seq3 != NULL && seq2 != NULL) {
- Sequence *tmp = seq2;
- seq2 = seq3;
- seq3 = tmp;
- }
-
-
- switch (BKE_sequence_effect_get_num_inputs(type)) {
- case 0:
- *selseq1 = *selseq2 = *selseq3 = NULL;
- return 1; /* success */
- case 1:
- if (seq2 == NULL) {
- *error_str = N_("At least one selected sequence strip is needed");
- return 0;
- }
- if (seq1 == NULL) {
- seq1 = seq2;
- }
- if (seq3 == NULL) {
- seq3 = seq2;
- }
- ATTR_FALLTHROUGH;
- case 2:
- if (seq1 == NULL || seq2 == NULL) {
- *error_str = N_("2 selected sequence strips are needed");
- return 0;
- }
- if (seq3 == NULL) {
- seq3 = seq2;
- }
- break;
- }
-
- if (seq1 == NULL && seq2 == NULL && seq3 == NULL) {
- *error_str = N_("TODO: in what cases does this happen?");
- return 0;
- }
-
- *selseq1 = seq1;
- *selseq2 = seq2;
- *selseq3 = seq3;
-
- return 1;
+ return (ELEM(sseq->view, SEQ_VIEW_SEQUENCE, SEQ_VIEW_SEQUENCE_PREVIEW) &&
+ ELEM(sseq->mainb, SEQ_DRAW_SEQUENCE, SEQ_DRAW_IMG_IMBUF));
+}
+
+int seq_effect_find_selected(Scene *scene,
+ Sequence *activeseq,
+ int type,
+ Sequence **selseq1,
+ Sequence **selseq2,
+ Sequence **selseq3,
+ const char **error_str)
+{
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq1 = NULL, *seq2 = NULL, *seq3 = NULL, *seq;
+
+ *error_str = NULL;
+
+ if (!activeseq) {
+ seq2 = BKE_sequencer_active_get(scene);
+ }
+
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT) {
+ if (seq->type == SEQ_TYPE_SOUND_RAM && BKE_sequence_effect_get_num_inputs(type) != 0) {
+ *error_str = N_("Cannot apply effects to audio sequence strips");
+ return 0;
+ }
+ if ((seq != activeseq) && (seq != seq2)) {
+ if (seq2 == NULL) {
+ seq2 = seq;
+ }
+ else if (seq1 == NULL) {
+ seq1 = seq;
+ }
+ else if (seq3 == NULL) {
+ seq3 = seq;
+ }
+ else {
+ *error_str = N_("Cannot apply effect to more than 3 sequence strips");
+ return 0;
+ }
+ }
+ }
+ }
+
+ /* make sequence selection a little bit more intuitive
+ * for 3 strips: the last-strip should be sequence3 */
+ if (seq3 != NULL && seq2 != NULL) {
+ Sequence *tmp = seq2;
+ seq2 = seq3;
+ seq3 = tmp;
+ }
+
+ switch (BKE_sequence_effect_get_num_inputs(type)) {
+ case 0:
+ *selseq1 = *selseq2 = *selseq3 = NULL;
+ return 1; /* success */
+ case 1:
+ if (seq2 == NULL) {
+ *error_str = N_("At least one selected sequence strip is needed");
+ return 0;
+ }
+ if (seq1 == NULL) {
+ seq1 = seq2;
+ }
+ if (seq3 == NULL) {
+ seq3 = seq2;
+ }
+ ATTR_FALLTHROUGH;
+ case 2:
+ if (seq1 == NULL || seq2 == NULL) {
+ *error_str = N_("2 selected sequence strips are needed");
+ return 0;
+ }
+ if (seq3 == NULL) {
+ seq3 = seq2;
+ }
+ break;
+ }
+
+ if (seq1 == NULL && seq2 == NULL && seq3 == NULL) {
+ *error_str = N_("TODO: in what cases does this happen?");
+ return 0;
+ }
+
+ *selseq1 = seq1;
+ *selseq2 = seq2;
+ *selseq3 = seq3;
+
+ return 1;
}
static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq)
{
- Sequence *seq1, *seq2, *seq3;
-
- /* try to find a replacement input sequence, and flag for later deletion if
- * no replacement can be found */
-
- if (!seq) {
- return NULL;
- }
- else if (!(seq->type & SEQ_TYPE_EFFECT)) {
- return ((seq->flag & SELECT) ? NULL : seq);
- }
- else if (!(seq->flag & SELECT)) {
- /* try to find replacement for effect inputs */
- seq1 = del_seq_find_replace_recurs(scene, seq->seq1);
- seq2 = del_seq_find_replace_recurs(scene, seq->seq2);
- seq3 = del_seq_find_replace_recurs(scene, seq->seq3);
-
- if (seq1 == seq->seq1 && seq2 == seq->seq2 && seq3 == seq->seq3) {
- /* pass */
- }
- else if (seq1 || seq2 || seq3) {
- seq->seq1 = (seq1) ? seq1 : (seq2) ? seq2 : seq3;
- seq->seq2 = (seq2) ? seq2 : (seq1) ? seq1 : seq3;
- seq->seq3 = (seq3) ? seq3 : (seq1) ? seq1 : seq2;
-
- BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1);
- }
- else {
- seq->flag |= SELECT; /* mark for delete */
- }
- }
-
- if (seq->flag & SELECT) {
- if ((seq1 = del_seq_find_replace_recurs(scene, seq->seq1))) { return seq1; }
- if ((seq2 = del_seq_find_replace_recurs(scene, seq->seq2))) { return seq2; }
- if ((seq3 = del_seq_find_replace_recurs(scene, seq->seq3))) { return seq3; }
- else {
- return NULL;
- }
- }
- else {
- return seq;
- }
+ Sequence *seq1, *seq2, *seq3;
+
+ /* try to find a replacement input sequence, and flag for later deletion if
+ * no replacement can be found */
+
+ if (!seq) {
+ return NULL;
+ }
+ else if (!(seq->type & SEQ_TYPE_EFFECT)) {
+ return ((seq->flag & SELECT) ? NULL : seq);
+ }
+ else if (!(seq->flag & SELECT)) {
+ /* try to find replacement for effect inputs */
+ seq1 = del_seq_find_replace_recurs(scene, seq->seq1);
+ seq2 = del_seq_find_replace_recurs(scene, seq->seq2);
+ seq3 = del_seq_find_replace_recurs(scene, seq->seq3);
+
+ if (seq1 == seq->seq1 && seq2 == seq->seq2 && seq3 == seq->seq3) {
+ /* pass */
+ }
+ else if (seq1 || seq2 || seq3) {
+ seq->seq1 = (seq1) ? seq1 : (seq2) ? seq2 : seq3;
+ seq->seq2 = (seq2) ? seq2 : (seq1) ? seq1 : seq3;
+ seq->seq3 = (seq3) ? seq3 : (seq1) ? seq1 : seq2;
+
+ BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1);
+ }
+ else {
+ seq->flag |= SELECT; /* mark for delete */
+ }
+ }
+
+ if (seq->flag & SELECT) {
+ if ((seq1 = del_seq_find_replace_recurs(scene, seq->seq1))) {
+ return seq1;
+ }
+ if ((seq2 = del_seq_find_replace_recurs(scene, seq->seq2))) {
+ return seq2;
+ }
+ if ((seq3 = del_seq_find_replace_recurs(scene, seq->seq3))) {
+ return seq3;
+ }
+ else {
+ return NULL;
+ }
+ }
+ else {
+ return seq;
+ }
}
static void del_seq_clear_modifiers_recurs(Scene *scene, Sequence *deleting_sequence)
{
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *current_sequence;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *current_sequence;
- SEQP_BEGIN(ed, current_sequence)
- {
- if (!(current_sequence->flag & SELECT) && current_sequence != deleting_sequence) {
- SequenceModifierData *smd;
+ SEQP_BEGIN (ed, current_sequence) {
+ if (!(current_sequence->flag & SELECT) && current_sequence != deleting_sequence) {
+ SequenceModifierData *smd;
- for (smd = current_sequence->modifiers.first; smd; smd = smd->next) {
- if (smd->mask_sequence == deleting_sequence) {
- smd->mask_sequence = NULL;
- }
- }
- }
- } SEQ_END;
+ for (smd = current_sequence->modifiers.first; smd; smd = smd->next) {
+ if (smd->mask_sequence == deleting_sequence) {
+ smd->mask_sequence = NULL;
+ }
+ }
+ }
+ }
+ SEQ_END;
}
static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short deleteall)
{
- Sequence *seq, *seqn;
- Sequence *last_seq = BKE_sequencer_active_get(scene);
-
- seq = lb->first;
- while (seq) {
- seqn = seq->next;
- if ((seq->flag & flag) || deleteall) {
- BLI_remlink(lb, seq);
- if (seq == last_seq) {
- BKE_sequencer_active_set(scene, NULL);
- }
- if (seq->type == SEQ_TYPE_META) {
- recurs_del_seq_flag(scene, &seq->seqbase, flag, 1);
- }
- BKE_sequence_free(scene, seq);
- }
- seq = seqn;
- }
+ Sequence *seq, *seqn;
+ Sequence *last_seq = BKE_sequencer_active_get(scene);
+
+ seq = lb->first;
+ while (seq) {
+ seqn = seq->next;
+ if ((seq->flag & flag) || deleteall) {
+ BLI_remlink(lb, seq);
+ if (seq == last_seq) {
+ BKE_sequencer_active_set(scene, NULL);
+ }
+ if (seq->type == SEQ_TYPE_META) {
+ recurs_del_seq_flag(scene, &seq->seqbase, flag, 1);
+ }
+ BKE_sequence_free(scene, seq);
+ }
+ seq = seqn;
+ }
}
-
static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, ListBase *new_seq_list, int cutframe)
{
- TransSeq ts;
- Sequence *seqn = NULL;
- bool skip_dup = false;
-
- /* Unlike soft-cut, it's important to use the same value for both strips. */
- const bool is_end_exact = ((seq->start + seq->len) == cutframe);
-
- /* backup values */
- ts.start = seq->start;
- ts.machine = seq->machine;
- ts.startstill = seq->startstill;
- ts.endstill = seq->endstill;
- ts.startdisp = seq->startdisp;
- ts.enddisp = seq->enddisp;
- ts.startofs = seq->startofs;
- ts.endofs = seq->endofs;
- ts.anim_startofs = seq->anim_startofs;
- ts.anim_endofs = seq->anim_endofs;
- ts.len = seq->len;
-
- /* First Strip! */
- /* strips with extended stillfames before */
-
- /* Precaution, needed because the length saved on-disk may not match the length saved in the blend file,
- * or our code may have minor differences reading file length between versions.
- * This causes hard-cut to fail, see: T47862 */
- if (seq->type != SEQ_TYPE_META) {
- BKE_sequence_reload_new_file(scene, seq, true);
- BKE_sequence_calc(scene, seq);
- }
-
- /* Important to offset the start when 'cutframe == seq->start'
- * because we need at least one frame of content after start/end still have clipped it. */
- if ((seq->startstill) && (cutframe <= seq->start)) {
- /* don't do funny things with METAs ... */
- if (seq->type == SEQ_TYPE_META) {
- skip_dup = true;
- seq->startstill = seq->start - cutframe;
- }
- else {
- seq->start = cutframe - 1;
- seq->startstill = cutframe - seq->startdisp - 1;
- seq->anim_endofs += seq->len - 1;
- seq->endstill = 0;
- }
- }
- /* normal strip */
- else if ((is_end_exact == false) &&
- ((cutframe >= seq->start) && (cutframe <= (seq->start + seq->len))))
- {
- seq->endofs = 0;
- seq->endstill = 0;
- seq->anim_endofs += (seq->start + seq->len) - cutframe;
- }
- /* strips with extended stillframes after */
- else if ((is_end_exact == true) ||
- (((seq->start + seq->len) < cutframe) && (seq->endstill)))
- {
- seq->endstill -= seq->enddisp - cutframe;
- /* don't do funny things with METAs ... */
- if (seq->type == SEQ_TYPE_META) {
- skip_dup = true;
- }
- }
-
- BKE_sequence_reload_new_file(scene, seq, false);
- BKE_sequence_calc(scene, seq);
-
- if (!skip_dup) {
- /* Duplicate AFTER the first change */
- seqn = BKE_sequence_dupli_recursive(scene, scene, new_seq_list, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
- }
-
- if (seqn) {
- seqn->flag |= SELECT;
-
- /* Important not to re-assign this (unlike soft-cut) */
+ TransSeq ts;
+ Sequence *seqn = NULL;
+ bool skip_dup = false;
+
+ /* Unlike soft-cut, it's important to use the same value for both strips. */
+ const bool is_end_exact = ((seq->start + seq->len) == cutframe);
+
+ /* backup values */
+ ts.start = seq->start;
+ ts.machine = seq->machine;
+ ts.startstill = seq->startstill;
+ ts.endstill = seq->endstill;
+ ts.startdisp = seq->startdisp;
+ ts.enddisp = seq->enddisp;
+ ts.startofs = seq->startofs;
+ ts.endofs = seq->endofs;
+ ts.anim_startofs = seq->anim_startofs;
+ ts.anim_endofs = seq->anim_endofs;
+ ts.len = seq->len;
+
+ /* First Strip! */
+ /* strips with extended stillfames before */
+
+ /* Precaution, needed because the length saved on-disk may not match the length saved in the blend file,
+ * or our code may have minor differences reading file length between versions.
+ * This causes hard-cut to fail, see: T47862 */
+ if (seq->type != SEQ_TYPE_META) {
+ BKE_sequence_reload_new_file(scene, seq, true);
+ BKE_sequence_calc(scene, seq);
+ }
+
+ /* Important to offset the start when 'cutframe == seq->start'
+ * because we need at least one frame of content after start/end still have clipped it. */
+ if ((seq->startstill) && (cutframe <= seq->start)) {
+ /* don't do funny things with METAs ... */
+ if (seq->type == SEQ_TYPE_META) {
+ skip_dup = true;
+ seq->startstill = seq->start - cutframe;
+ }
+ else {
+ seq->start = cutframe - 1;
+ seq->startstill = cutframe - seq->startdisp - 1;
+ seq->anim_endofs += seq->len - 1;
+ seq->endstill = 0;
+ }
+ }
+ /* normal strip */
+ else if ((is_end_exact == false) &&
+ ((cutframe >= seq->start) && (cutframe <= (seq->start + seq->len)))) {
+ seq->endofs = 0;
+ seq->endstill = 0;
+ seq->anim_endofs += (seq->start + seq->len) - cutframe;
+ }
+ /* strips with extended stillframes after */
+ else if ((is_end_exact == true) || (((seq->start + seq->len) < cutframe) && (seq->endstill))) {
+ seq->endstill -= seq->enddisp - cutframe;
+ /* don't do funny things with METAs ... */
+ if (seq->type == SEQ_TYPE_META) {
+ skip_dup = true;
+ }
+ }
+
+ BKE_sequence_reload_new_file(scene, seq, false);
+ BKE_sequence_calc(scene, seq);
+
+ if (!skip_dup) {
+ /* Duplicate AFTER the first change */
+ seqn = BKE_sequence_dupli_recursive(
+ scene, scene, new_seq_list, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
+ }
+
+ if (seqn) {
+ seqn->flag |= SELECT;
+
+ /* Important not to re-assign this (unlike soft-cut) */
#if 0
- is_end_exact = ((seqn->start + seqn->len) == cutframe);
+ is_end_exact = ((seqn->start + seqn->len) == cutframe);
#endif
- /* Second Strip! */
- /* strips with extended stillframes before */
- if ((seqn->startstill) && (cutframe == seqn->start + 1)) {
- seqn->start = ts.start;
- seqn->startstill = ts.start - cutframe;
- seqn->anim_endofs = ts.anim_endofs;
- seqn->endstill = ts.endstill;
- }
-
- /* normal strip */
- else if ((is_end_exact == false) &&
- ((cutframe >= seqn->start) && (cutframe <= (seqn->start + seqn->len))))
- {
- seqn->start = cutframe;
- seqn->startstill = 0;
- seqn->startofs = 0;
- seqn->endofs = ts.endofs;
- seqn->anim_startofs += cutframe - ts.start;
- seqn->anim_endofs = ts.anim_endofs;
- seqn->endstill = ts.endstill;
- }
-
- /* strips with extended stillframes after */
- else if ((is_end_exact == true) ||
- (((seqn->start + seqn->len) < cutframe) && (seqn->endstill)))
- {
- seqn->start = cutframe;
- seqn->startofs = 0;
- seqn->anim_startofs += ts.len - 1;
- seqn->endstill = ts.enddisp - cutframe - 1;
- seqn->startstill = 0;
- }
-
- BKE_sequence_reload_new_file(scene, seqn, false);
- BKE_sequence_calc(scene, seqn);
- }
- return seqn;
+ /* Second Strip! */
+ /* strips with extended stillframes before */
+ if ((seqn->startstill) && (cutframe == seqn->start + 1)) {
+ seqn->start = ts.start;
+ seqn->startstill = ts.start - cutframe;
+ seqn->anim_endofs = ts.anim_endofs;
+ seqn->endstill = ts.endstill;
+ }
+
+ /* normal strip */
+ else if ((is_end_exact == false) &&
+ ((cutframe >= seqn->start) && (cutframe <= (seqn->start + seqn->len)))) {
+ seqn->start = cutframe;
+ seqn->startstill = 0;
+ seqn->startofs = 0;
+ seqn->endofs = ts.endofs;
+ seqn->anim_startofs += cutframe - ts.start;
+ seqn->anim_endofs = ts.anim_endofs;
+ seqn->endstill = ts.endstill;
+ }
+
+ /* strips with extended stillframes after */
+ else if ((is_end_exact == true) ||
+ (((seqn->start + seqn->len) < cutframe) && (seqn->endstill))) {
+ seqn->start = cutframe;
+ seqn->startofs = 0;
+ seqn->anim_startofs += ts.len - 1;
+ seqn->endstill = ts.enddisp - cutframe - 1;
+ seqn->startstill = 0;
+ }
+
+ BKE_sequence_reload_new_file(scene, seqn, false);
+ BKE_sequence_calc(scene, seqn);
+ }
+ return seqn;
}
static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, ListBase *new_seq_list, int cutframe)
{
- TransSeq ts;
- Sequence *seqn = NULL;
- bool skip_dup = false;
-
- bool is_end_exact = ((seq->start + seq->len) == cutframe);
-
- /* backup values */
- ts.start = seq->start;
- ts.machine = seq->machine;
- ts.startstill = seq->startstill;
- ts.endstill = seq->endstill;
- ts.startdisp = seq->startdisp;
- ts.enddisp = seq->enddisp;
- ts.startofs = seq->startofs;
- ts.endofs = seq->endofs;
- ts.anim_startofs = seq->anim_startofs;
- ts.anim_endofs = seq->anim_endofs;
- ts.len = seq->len;
-
- /* First Strip! */
- /* strips with extended stillfames before */
-
- /* Important to offset the start when 'cutframe == seq->start'
- * because we need at least one frame of content after start/end still have clipped it. */
- if ((seq->startstill) && (cutframe <= seq->start)) {
- /* don't do funny things with METAs ... */
- if (seq->type == SEQ_TYPE_META) {
- skip_dup = true;
- seq->startstill = seq->start - cutframe;
- }
- else {
- seq->start = cutframe - 1;
- seq->startstill = cutframe - seq->startdisp - 1;
- seq->endofs = seq->len - 1;
- seq->endstill = 0;
- }
- }
- /* normal strip */
- else if ((is_end_exact == false) &&
- (cutframe >= seq->start) && (cutframe <= (seq->start + seq->len)))
- {
- seq->endofs = (seq->start + seq->len) - cutframe;
- }
- /* strips with extended stillframes after */
- else if ((is_end_exact == true) ||
- (((seq->start + seq->len) < cutframe) && (seq->endstill)))
- {
- seq->endstill -= seq->enddisp - cutframe;
- /* don't do funny things with METAs ... */
- if (seq->type == SEQ_TYPE_META) {
- skip_dup = true;
- }
- }
-
- BKE_sequence_calc(scene, seq);
-
- if (!skip_dup) {
- /* Duplicate AFTER the first change */
- seqn = BKE_sequence_dupli_recursive(scene, scene, new_seq_list, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
- }
-
- if (seqn) {
- seqn->flag |= SELECT;
-
- is_end_exact = ((seqn->start + seqn->len) == cutframe);
-
- /* Second Strip! */
- /* strips with extended stillframes before */
- if ((seqn->startstill) && (cutframe == seqn->start + 1)) {
- seqn->start = ts.start;
- seqn->startstill = ts.start - cutframe;
- seqn->endofs = ts.endofs;
- seqn->endstill = ts.endstill;
- }
-
- /* normal strip */
- else if ((is_end_exact == false) &&
- (cutframe >= seqn->start) && (cutframe <= (seqn->start + seqn->len)))
- {
- seqn->startstill = 0;
- seqn->startofs = cutframe - ts.start;
- seqn->endofs = ts.endofs;
- seqn->endstill = ts.endstill;
- }
-
- /* strips with extended stillframes after */
- else if ((is_end_exact == true) ||
- (((seqn->start + seqn->len) < cutframe) && (seqn->endstill)))
- {
- seqn->start = cutframe - ts.len + 1;
- seqn->startofs = ts.len - 1;
- seqn->endstill = ts.enddisp - cutframe - 1;
- seqn->startstill = 0;
- }
-
- BKE_sequence_calc(scene, seqn);
- }
- return seqn;
+ TransSeq ts;
+ Sequence *seqn = NULL;
+ bool skip_dup = false;
+
+ bool is_end_exact = ((seq->start + seq->len) == cutframe);
+
+ /* backup values */
+ ts.start = seq->start;
+ ts.machine = seq->machine;
+ ts.startstill = seq->startstill;
+ ts.endstill = seq->endstill;
+ ts.startdisp = seq->startdisp;
+ ts.enddisp = seq->enddisp;
+ ts.startofs = seq->startofs;
+ ts.endofs = seq->endofs;
+ ts.anim_startofs = seq->anim_startofs;
+ ts.anim_endofs = seq->anim_endofs;
+ ts.len = seq->len;
+
+ /* First Strip! */
+ /* strips with extended stillfames before */
+
+ /* Important to offset the start when 'cutframe == seq->start'
+ * because we need at least one frame of content after start/end still have clipped it. */
+ if ((seq->startstill) && (cutframe <= seq->start)) {
+ /* don't do funny things with METAs ... */
+ if (seq->type == SEQ_TYPE_META) {
+ skip_dup = true;
+ seq->startstill = seq->start - cutframe;
+ }
+ else {
+ seq->start = cutframe - 1;
+ seq->startstill = cutframe - seq->startdisp - 1;
+ seq->endofs = seq->len - 1;
+ seq->endstill = 0;
+ }
+ }
+ /* normal strip */
+ else if ((is_end_exact == false) && (cutframe >= seq->start) &&
+ (cutframe <= (seq->start + seq->len))) {
+ seq->endofs = (seq->start + seq->len) - cutframe;
+ }
+ /* strips with extended stillframes after */
+ else if ((is_end_exact == true) || (((seq->start + seq->len) < cutframe) && (seq->endstill))) {
+ seq->endstill -= seq->enddisp - cutframe;
+ /* don't do funny things with METAs ... */
+ if (seq->type == SEQ_TYPE_META) {
+ skip_dup = true;
+ }
+ }
+
+ BKE_sequence_calc(scene, seq);
+
+ if (!skip_dup) {
+ /* Duplicate AFTER the first change */
+ seqn = BKE_sequence_dupli_recursive(
+ scene, scene, new_seq_list, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
+ }
+
+ if (seqn) {
+ seqn->flag |= SELECT;
+
+ is_end_exact = ((seqn->start + seqn->len) == cutframe);
+
+ /* Second Strip! */
+ /* strips with extended stillframes before */
+ if ((seqn->startstill) && (cutframe == seqn->start + 1)) {
+ seqn->start = ts.start;
+ seqn->startstill = ts.start - cutframe;
+ seqn->endofs = ts.endofs;
+ seqn->endstill = ts.endstill;
+ }
+
+ /* normal strip */
+ else if ((is_end_exact == false) && (cutframe >= seqn->start) &&
+ (cutframe <= (seqn->start + seqn->len))) {
+ seqn->startstill = 0;
+ seqn->startofs = cutframe - ts.start;
+ seqn->endofs = ts.endofs;
+ seqn->endstill = ts.endstill;
+ }
+
+ /* strips with extended stillframes after */
+ else if ((is_end_exact == true) ||
+ (((seqn->start + seqn->len) < cutframe) && (seqn->endstill))) {
+ seqn->start = cutframe - ts.len + 1;
+ seqn->startofs = ts.len - 1;
+ seqn->endstill = ts.enddisp - cutframe - 1;
+ seqn->startstill = 0;
+ }
+
+ BKE_sequence_calc(scene, seqn);
+ }
+ return seqn;
}
-
/* like duplicate, but only duplicate and cut overlapping strips,
* strips to the left of the cutframe are ignored and strips to the right
* are moved to the end of slist
@@ -955,1277 +957,1307 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, ListBase *new_seq_lis
* may generate strips with the same name (which will mess up animdata)
*/
-static bool cut_seq_list(Scene *scene, ListBase *slist, int cutframe,
- Sequence * (*cut_seq)(Scene *, Sequence *, ListBase *, int))
-{
- Sequence *seq, *seq_next_iter;
- Sequence *seq_first_new = NULL;
-
- seq = slist->first;
-
- while (seq && seq != seq_first_new) {
- seq_next_iter = seq->next; /* we need this because we may remove seq */
- seq->tmp = NULL;
- if (seq->flag & SELECT) {
- if (cutframe > seq->startdisp &&
- cutframe < seq->enddisp)
- {
- Sequence *seqn = cut_seq(scene, seq, slist, cutframe);
- if (seqn) {
- if (seq_first_new == NULL) {
- seq_first_new = seqn;
- }
- }
- }
- else if (seq->enddisp <= cutframe) {
- /* do nothing */
- }
- else if (seq->startdisp >= cutframe) {
- /* move to tail */
- BLI_remlink(slist, seq);
- BLI_addtail(slist, seq);
-
- if (seq_first_new == NULL) {
- seq_first_new = seq;
- }
- }
- }
- seq = seq_next_iter;
- }
-
- return (seq_first_new != NULL);
+static bool cut_seq_list(Scene *scene,
+ ListBase *slist,
+ int cutframe,
+ Sequence *(*cut_seq)(Scene *, Sequence *, ListBase *, int))
+{
+ Sequence *seq, *seq_next_iter;
+ Sequence *seq_first_new = NULL;
+
+ seq = slist->first;
+
+ while (seq && seq != seq_first_new) {
+ seq_next_iter = seq->next; /* we need this because we may remove seq */
+ seq->tmp = NULL;
+ if (seq->flag & SELECT) {
+ if (cutframe > seq->startdisp && cutframe < seq->enddisp) {
+ Sequence *seqn = cut_seq(scene, seq, slist, cutframe);
+ if (seqn) {
+ if (seq_first_new == NULL) {
+ seq_first_new = seqn;
+ }
+ }
+ }
+ else if (seq->enddisp <= cutframe) {
+ /* do nothing */
+ }
+ else if (seq->startdisp >= cutframe) {
+ /* move to tail */
+ BLI_remlink(slist, seq);
+ BLI_addtail(slist, seq);
+
+ if (seq_first_new == NULL) {
+ seq_first_new = seq;
+ }
+ }
+ }
+ seq = seq_next_iter;
+ }
+
+ return (seq_first_new != NULL);
}
static bool sequence_offset_after_frame(Scene *scene, const int delta, const int cfra)
{
- Sequence *seq;
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- bool done = false;
- TimeMarker *marker;
+ Sequence *seq;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ bool done = false;
+ TimeMarker *marker;
- /* all strips >= cfra are shifted */
+ /* all strips >= cfra are shifted */
- if (ed == NULL) {
- return 0;
- }
+ if (ed == NULL) {
+ return 0;
+ }
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->startdisp >= cfra) {
- BKE_sequence_translate(scene, seq, delta);
- BKE_sequence_calc(scene, seq);
- done = true;
- }
- }
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->startdisp >= cfra) {
+ BKE_sequence_translate(scene, seq, delta);
+ BKE_sequence_calc(scene, seq);
+ done = true;
+ }
+ }
- if (!scene->toolsettings->lock_markers) {
- for (marker = scene->markers.first; marker; marker = marker->next) {
- if (marker->frame >= cfra) {
- marker->frame += delta;
- }
- }
- }
+ if (!scene->toolsettings->lock_markers) {
+ for (marker = scene->markers.first; marker; marker = marker->next) {
+ if (marker->frame >= cfra) {
+ marker->frame += delta;
+ }
+ }
+ }
- return done;
+ return done;
}
#if 0
static void set_filter_seq(Scene *scene)
{
- Sequence *seq;
- Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
- if (ed == NULL) return;
+ if (ed == NULL) return;
- if (okee("Set Deinterlace") == 0) return;
+ if (okee("Set Deinterlace") == 0) return;
- SEQP_BEGIN (ed, seq)
- {
- if (seq->flag & SELECT) {
- if (seq->type == SEQ_TYPE_MOVIE) {
- seq->flag |= SEQ_FILTERY;
- BKE_sequence_reload_new_file(scene, seq, false);
- BKE_sequence_calc(scene, seq);
- }
+ SEQP_BEGIN (ed, seq)
+ {
+ if (seq->flag & SELECT) {
+ if (seq->type == SEQ_TYPE_MOVIE) {
+ seq->flag |= SEQ_FILTERY;
+ BKE_sequence_reload_new_file(scene, seq, false);
+ BKE_sequence_calc(scene, seq);
+ }
- }
- } SEQ_END;
+ }
+ } SEQ_END;
}
#endif
-static void UNUSED_FUNCTION(seq_remap_paths) (Scene *scene)
+static void UNUSED_FUNCTION(seq_remap_paths)(Scene *scene)
{
- Sequence *seq, *last_seq = BKE_sequencer_active_get(scene);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- char from[FILE_MAX], to[FILE_MAX], stripped[FILE_MAX];
-
-
- if (last_seq == NULL) {
- return;
- }
+ Sequence *seq, *last_seq = BKE_sequencer_active_get(scene);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ char from[FILE_MAX], to[FILE_MAX], stripped[FILE_MAX];
- BLI_strncpy(from, last_seq->strip->dir, sizeof(from));
-// XXX if (0 == sbutton(from, 0, sizeof(from) - 1, "From: "))
-// return;
+ if (last_seq == NULL) {
+ return;
+ }
- BLI_strncpy(to, from, sizeof(to));
-// XXX if (0 == sbutton(to, 0, sizeof(to) - 1, "To: "))
-// return;
+ BLI_strncpy(from, last_seq->strip->dir, sizeof(from));
+ // XXX if (0 == sbutton(from, 0, sizeof(from) - 1, "From: "))
+ // return;
- if (STREQ(to, from)) {
- return;
- }
+ BLI_strncpy(to, from, sizeof(to));
+ // XXX if (0 == sbutton(to, 0, sizeof(to) - 1, "To: "))
+ // return;
- SEQP_BEGIN (ed, seq)
- {
- if (seq->flag & SELECT) {
- if (STREQLEN(seq->strip->dir, from, strlen(from))) {
- printf("found %s\n", seq->strip->dir);
+ if (STREQ(to, from)) {
+ return;
+ }
- /* strip off the beginning */
- stripped[0] = 0;
- BLI_strncpy(stripped, seq->strip->dir + strlen(from), FILE_MAX);
+ SEQP_BEGIN (ed, seq) {
+ if (seq->flag & SELECT) {
+ if (STREQLEN(seq->strip->dir, from, strlen(from))) {
+ printf("found %s\n", seq->strip->dir);
- /* new path */
- BLI_snprintf(seq->strip->dir, sizeof(seq->strip->dir), "%s%s", to, stripped);
- printf("new %s\n", seq->strip->dir);
- }
- }
- } SEQ_END;
+ /* strip off the beginning */
+ stripped[0] = 0;
+ BLI_strncpy(stripped, seq->strip->dir + strlen(from), FILE_MAX);
+ /* new path */
+ BLI_snprintf(seq->strip->dir, sizeof(seq->strip->dir), "%s%s", to, stripped);
+ printf("new %s\n", seq->strip->dir);
+ }
+ }
+ }
+ SEQ_END;
}
-
static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- rctf rectf;
- int cfra, efra, sfra;
- bool first = false, done;
- bool do_all = RNA_boolean_get(op->ptr, "all");
-
- /* get first and last frame */
- boundbox_seq(scene, &rectf);
- sfra = (int)rectf.xmin;
- efra = (int)rectf.xmax;
-
- /* first check if the current frame has a gap already */
- for (cfra = CFRA; cfra >= sfra; cfra--) {
- if (BKE_sequencer_evaluate_frame(scene, cfra)) {
- first = true;
- break;
- }
- }
-
- for ( ; cfra < efra; cfra++) {
- /* first == 0 means there's still no strip to remove a gap for */
- if (first == false) {
- if (BKE_sequencer_evaluate_frame(scene, cfra) ) {
- first = true;
- }
- }
- else if (BKE_sequencer_evaluate_frame(scene, cfra) == 0) {
- done = true;
- while (BKE_sequencer_evaluate_frame(scene, cfra) == 0) {
- done = sequence_offset_after_frame(scene, -1, cfra);
- if (done == false) {
- break;
- }
- }
- if (done == false || do_all == false) {
- break;
- }
- }
- }
-
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- return OPERATOR_FINISHED;
-
+ Scene *scene = CTX_data_scene(C);
+ rctf rectf;
+ int cfra, efra, sfra;
+ bool first = false, done;
+ bool do_all = RNA_boolean_get(op->ptr, "all");
+
+ /* get first and last frame */
+ boundbox_seq(scene, &rectf);
+ sfra = (int)rectf.xmin;
+ efra = (int)rectf.xmax;
+
+ /* first check if the current frame has a gap already */
+ for (cfra = CFRA; cfra >= sfra; cfra--) {
+ if (BKE_sequencer_evaluate_frame(scene, cfra)) {
+ first = true;
+ break;
+ }
+ }
+
+ for (; cfra < efra; cfra++) {
+ /* first == 0 means there's still no strip to remove a gap for */
+ if (first == false) {
+ if (BKE_sequencer_evaluate_frame(scene, cfra)) {
+ first = true;
+ }
+ }
+ else if (BKE_sequencer_evaluate_frame(scene, cfra) == 0) {
+ done = true;
+ while (BKE_sequencer_evaluate_frame(scene, cfra) == 0) {
+ done = sequence_offset_after_frame(scene, -1, cfra);
+ if (done == false) {
+ break;
+ }
+ }
+ if (done == false || do_all == false) {
+ break;
+ }
+ }
+ }
+
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+
+ return OPERATOR_FINISHED;
}
-
void SEQUENCER_OT_gap_remove(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Remove Gaps";
- ot->idname = "SEQUENCER_OT_gap_remove";
- ot->description = "Remove gap at current frame to first strip at the right, independent of selection or locked state of strips";
+ /* identifiers */
+ ot->name = "Remove Gaps";
+ ot->idname = "SEQUENCER_OT_gap_remove";
+ ot->description =
+ "Remove gap at current frame to first strip at the right, independent of selection or "
+ "locked state of strips";
- /* api callbacks */
-// ot->invoke = sequencer_snap_invoke;
- ot->exec = sequencer_gap_remove_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ // ot->invoke = sequencer_snap_invoke;
+ ot->exec = sequencer_gap_remove_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_boolean(ot->srna, "all", 0, "All Gaps", "Do all gaps to right of current frame");
+ RNA_def_boolean(ot->srna, "all", 0, "All Gaps", "Do all gaps to right of current frame");
}
static int sequencer_gap_insert_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- int frames = RNA_int_get(op->ptr, "frames");
+ Scene *scene = CTX_data_scene(C);
+ int frames = RNA_int_get(op->ptr, "frames");
- sequence_offset_after_frame(scene, frames, CFRA);
+ sequence_offset_after_frame(scene, frames, CFRA);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- return OPERATOR_FINISHED;
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_gap_insert(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Insert Gaps";
- ot->idname = "SEQUENCER_OT_gap_insert";
- ot->description = "Insert gap at current frame to first strips at the right, independent of selection or locked state of strips";
+ /* identifiers */
+ ot->name = "Insert Gaps";
+ ot->idname = "SEQUENCER_OT_gap_insert";
+ ot->description =
+ "Insert gap at current frame to first strips at the right, independent of selection or "
+ "locked state of strips";
- /* api callbacks */
- // ot->invoke = sequencer_snap_invoke;
- ot->exec = sequencer_gap_insert_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ // ot->invoke = sequencer_snap_invoke;
+ ot->exec = sequencer_gap_insert_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_int(ot->srna, "frames", 10, 0, INT_MAX, "Frames", "Frames to insert after current strip", 0, 1000);
+ RNA_def_int(ot->srna,
+ "frames",
+ 10,
+ 0,
+ INT_MAX,
+ "Frames",
+ "Frames to insert after current strip",
+ 0,
+ 1000);
}
-
#if 0
static int seq_get_snaplimit(View2D *v2d)
{
- /* fake mouse coords to get the snap value
- * a bit lazy but its only done once pre transform */
- float xmouse, ymouse, x;
- int mval[2] = {24, 0}; /* 24 screen px snap */
+ /* fake mouse coords to get the snap value
+ * a bit lazy but its only done once pre transform */
+ float xmouse, ymouse, x;
+ int mval[2] = {24, 0}; /* 24 screen px snap */
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &xmouse, &ymouse);
- x = xmouse;
- mval[0] = 0;
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &xmouse, &ymouse);
- return (int)(x - xmouse);
+ UI_view2d_region_to_view(v2d, mval[0], mval[1], &xmouse, &ymouse);
+ x = xmouse;
+ mval[0] = 0;
+ UI_view2d_region_to_view(v2d, mval[0], mval[1], &xmouse, &ymouse);
+ return (int)(x - xmouse);
}
#endif
/* Operator functions */
bool sequencer_edit_poll(bContext *C)
{
- return (BKE_sequencer_editing_get(CTX_data_scene(C), false) != NULL);
+ return (BKE_sequencer_editing_get(CTX_data_scene(C), false) != NULL);
}
#if 0 /* UNUSED */
bool sequencer_strip_poll(bContext *C)
{
- Editing *ed;
- return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), false)) != NULL) && (ed->act_seq != NULL));
+ Editing *ed;
+ return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), false)) != NULL) && (ed->act_seq != NULL));
}
#endif
bool sequencer_strip_has_path_poll(bContext *C)
{
- Editing *ed;
- Sequence *seq;
- return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), false)) != NULL) && ((seq = ed->act_seq) != NULL) && (SEQ_HAS_PATH(seq)));
+ Editing *ed;
+ Sequence *seq;
+ return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), false)) != NULL) &&
+ ((seq = ed->act_seq) != NULL) && (SEQ_HAS_PATH(seq)));
}
bool sequencer_view_preview_poll(bContext *C)
{
- SpaceSeq *sseq = CTX_wm_space_seq(C);
- Editing *ed = BKE_sequencer_editing_get(CTX_data_scene(C), false);
- if (ed && sseq && (sseq->mainb == SEQ_DRAW_IMG_IMBUF)) {
- return 1;
- }
+ SpaceSeq *sseq = CTX_wm_space_seq(C);
+ Editing *ed = BKE_sequencer_editing_get(CTX_data_scene(C), false);
+ if (ed && sseq && (sseq->mainb == SEQ_DRAW_IMG_IMBUF)) {
+ return 1;
+ }
- return 0;
+ return 0;
}
bool sequencer_view_strips_poll(bContext *C)
{
- SpaceSeq *sseq = CTX_wm_space_seq(C);
- if (sseq && ED_space_sequencer_check_show_strip(sseq)) {
- return 1;
- }
+ SpaceSeq *sseq = CTX_wm_space_seq(C);
+ if (sseq && ED_space_sequencer_check_show_strip(sseq)) {
+ return 1;
+ }
- return 0;
+ return 0;
}
/* snap operator*/
static int sequencer_snap_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
-
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
- int snap_frame;
-
- snap_frame = RNA_int_get(op->ptr, "frame");
-
- /* also check metas */
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK) &&
- BKE_sequence_tx_test(seq))
- {
- if ((seq->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) == 0) {
- /* simple but no anim update */
- /* seq->start = snap_frame-seq->startofs+seq->startstill; */
-
- BKE_sequence_translate(scene, seq, (snap_frame - seq->startofs + seq->startstill) - seq->start);
- }
- else {
- if (seq->flag & SEQ_LEFTSEL) {
- BKE_sequence_tx_set_final_left(seq, snap_frame);
- }
- else { /* SEQ_RIGHTSEL */
- BKE_sequence_tx_set_final_right(seq, snap_frame);
- }
- BKE_sequence_tx_handle_xlimits(seq, seq->flag & SEQ_LEFTSEL, seq->flag & SEQ_RIGHTSEL);
- BKE_sequence_single_fix(seq);
- }
- BKE_sequence_calc(scene, seq);
- }
- }
-
- /* test for effects and overlap
- * don't use SEQP_BEGIN since that would be recursive */
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK)) {
- seq->flag &= ~SEQ_OVERLAP;
- if (BKE_sequence_test_overlap(ed->seqbasep, seq) ) {
- BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
- }
- }
- else if (seq->type & SEQ_TYPE_EFFECT) {
- if (seq->seq1 && (seq->seq1->flag & SELECT)) {
- BKE_sequence_calc(scene, seq);
- }
- else if (seq->seq2 && (seq->seq2->flag & SELECT)) {
- BKE_sequence_calc(scene, seq);
- }
- else if (seq->seq3 && (seq->seq3->flag & SELECT)) {
- BKE_sequence_calc(scene, seq);
- }
- }
- }
-
- /* as last: */
- BKE_sequencer_sort(scene);
-
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- return OPERATOR_FINISHED;
+ Scene *scene = CTX_data_scene(C);
+
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+ int snap_frame;
+
+ snap_frame = RNA_int_get(op->ptr, "frame");
+
+ /* also check metas */
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK) &&
+ BKE_sequence_tx_test(seq)) {
+ if ((seq->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) == 0) {
+ /* simple but no anim update */
+ /* seq->start = snap_frame-seq->startofs+seq->startstill; */
+
+ BKE_sequence_translate(
+ scene, seq, (snap_frame - seq->startofs + seq->startstill) - seq->start);
+ }
+ else {
+ if (seq->flag & SEQ_LEFTSEL) {
+ BKE_sequence_tx_set_final_left(seq, snap_frame);
+ }
+ else { /* SEQ_RIGHTSEL */
+ BKE_sequence_tx_set_final_right(seq, snap_frame);
+ }
+ BKE_sequence_tx_handle_xlimits(seq, seq->flag & SEQ_LEFTSEL, seq->flag & SEQ_RIGHTSEL);
+ BKE_sequence_single_fix(seq);
+ }
+ BKE_sequence_calc(scene, seq);
+ }
+ }
+
+ /* test for effects and overlap
+ * don't use SEQP_BEGIN since that would be recursive */
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK)) {
+ seq->flag &= ~SEQ_OVERLAP;
+ if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
+ BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
+ }
+ }
+ else if (seq->type & SEQ_TYPE_EFFECT) {
+ if (seq->seq1 && (seq->seq1->flag & SELECT)) {
+ BKE_sequence_calc(scene, seq);
+ }
+ else if (seq->seq2 && (seq->seq2->flag & SELECT)) {
+ BKE_sequence_calc(scene, seq);
+ }
+ else if (seq->seq3 && (seq->seq3->flag & SELECT)) {
+ BKE_sequence_calc(scene, seq);
+ }
+ }
+ }
+
+ /* as last: */
+ BKE_sequencer_sort(scene);
+
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+
+ return OPERATOR_FINISHED;
}
static int sequencer_snap_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- Scene *scene = CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
- int snap_frame;
+ int snap_frame;
- snap_frame = CFRA;
+ snap_frame = CFRA;
- RNA_int_set(op->ptr, "frame", snap_frame);
- return sequencer_snap_exec(C, op);
+ RNA_int_set(op->ptr, "frame", snap_frame);
+ return sequencer_snap_exec(C, op);
}
void SEQUENCER_OT_snap(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Snap Strips to Frame";
- ot->idname = "SEQUENCER_OT_snap";
- ot->description = "Frame where selected strips will be snapped";
+ /* identifiers */
+ ot->name = "Snap Strips to Frame";
+ ot->idname = "SEQUENCER_OT_snap";
+ ot->description = "Frame where selected strips will be snapped";
- /* api callbacks */
- ot->invoke = sequencer_snap_invoke;
- ot->exec = sequencer_snap_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->invoke = sequencer_snap_invoke;
+ ot->exec = sequencer_snap_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_int(ot->srna, "frame", 0, INT_MIN, INT_MAX, "Frame", "Frame where selected strips will be snapped", INT_MIN, INT_MAX);
+ RNA_def_int(ot->srna,
+ "frame",
+ 0,
+ INT_MIN,
+ INT_MAX,
+ "Frame",
+ "Frame where selected strips will be snapped",
+ INT_MIN,
+ INT_MAX);
}
typedef struct SlipData {
- int init_mouse[2];
- float init_mouseloc[2];
- TransSeq *ts;
- Sequence **seq_array;
- bool *trim;
- int num_seq;
- bool slow;
- int slow_offset; /* offset at the point where offset was turned on */
- NumInput num_input;
+ int init_mouse[2];
+ float init_mouseloc[2];
+ TransSeq *ts;
+ Sequence **seq_array;
+ bool *trim;
+ int num_seq;
+ bool slow;
+ int slow_offset; /* offset at the point where offset was turned on */
+ NumInput num_input;
} SlipData;
static void transseq_backup(TransSeq *ts, Sequence *seq)
{
- ts->start = seq->start;
- ts->machine = seq->machine;
- ts->startstill = seq->startstill;
- ts->endstill = seq->endstill;
- ts->startdisp = seq->startdisp;
- ts->enddisp = seq->enddisp;
- ts->startofs = seq->startofs;
- ts->endofs = seq->endofs;
- ts->anim_startofs = seq->anim_startofs;
- ts->anim_endofs = seq->anim_endofs;
- ts->len = seq->len;
+ ts->start = seq->start;
+ ts->machine = seq->machine;
+ ts->startstill = seq->startstill;
+ ts->endstill = seq->endstill;
+ ts->startdisp = seq->startdisp;
+ ts->enddisp = seq->enddisp;
+ ts->startofs = seq->startofs;
+ ts->endofs = seq->endofs;
+ ts->anim_startofs = seq->anim_startofs;
+ ts->anim_endofs = seq->anim_endofs;
+ ts->len = seq->len;
}
-
static void transseq_restore(TransSeq *ts, Sequence *seq)
{
- seq->start = ts->start;
- seq->machine = ts->machine;
- seq->startstill = ts->startstill;
- seq->endstill = ts->endstill;
- seq->startdisp = ts->startdisp;
- seq->enddisp = ts->enddisp;
- seq->startofs = ts->startofs;
- seq->endofs = ts->endofs;
- seq->anim_startofs = ts->anim_startofs;
- seq->anim_endofs = ts->anim_endofs;
- seq->len = ts->len;
-}
-
-static int slip_add_sequences_rec(ListBase *seqbasep, Sequence **seq_array, bool *trim, int offset, bool do_trim)
-{
- Sequence *seq;
- int num_items = 0;
-
- for (seq = seqbasep->first; seq; seq = seq->next) {
- if (!do_trim || (!(seq->type & SEQ_TYPE_EFFECT) && (seq->flag & SELECT))) {
- seq_array[offset + num_items] = seq;
- trim[offset + num_items] = do_trim;
- num_items++;
-
- if (seq->type == SEQ_TYPE_META) {
- /* trim the sub-sequences */
- num_items += slip_add_sequences_rec(&seq->seqbase, seq_array, trim, num_items + offset, false);
- }
- else if (seq->type & SEQ_TYPE_EFFECT) {
- trim[offset + num_items] = false;
- }
- }
- }
-
- return num_items;
+ seq->start = ts->start;
+ seq->machine = ts->machine;
+ seq->startstill = ts->startstill;
+ seq->endstill = ts->endstill;
+ seq->startdisp = ts->startdisp;
+ seq->enddisp = ts->enddisp;
+ seq->startofs = ts->startofs;
+ seq->endofs = ts->endofs;
+ seq->anim_startofs = ts->anim_startofs;
+ seq->anim_endofs = ts->anim_endofs;
+ seq->len = ts->len;
+}
+
+static int slip_add_sequences_rec(
+ ListBase *seqbasep, Sequence **seq_array, bool *trim, int offset, bool do_trim)
+{
+ Sequence *seq;
+ int num_items = 0;
+
+ for (seq = seqbasep->first; seq; seq = seq->next) {
+ if (!do_trim || (!(seq->type & SEQ_TYPE_EFFECT) && (seq->flag & SELECT))) {
+ seq_array[offset + num_items] = seq;
+ trim[offset + num_items] = do_trim;
+ num_items++;
+
+ if (seq->type == SEQ_TYPE_META) {
+ /* trim the sub-sequences */
+ num_items += slip_add_sequences_rec(
+ &seq->seqbase, seq_array, trim, num_items + offset, false);
+ }
+ else if (seq->type & SEQ_TYPE_EFFECT) {
+ trim[offset + num_items] = false;
+ }
+ }
+ }
+
+ return num_items;
}
static int slip_count_sequences_rec(ListBase *seqbasep, bool first_level)
{
- Sequence *seq;
- int trimmed_sequences = 0;
+ Sequence *seq;
+ int trimmed_sequences = 0;
- for (seq = seqbasep->first; seq; seq = seq->next) {
- if (!first_level || (!(seq->type & SEQ_TYPE_EFFECT) && (seq->flag & SELECT))) {
- trimmed_sequences++;
+ for (seq = seqbasep->first; seq; seq = seq->next) {
+ if (!first_level || (!(seq->type & SEQ_TYPE_EFFECT) && (seq->flag & SELECT))) {
+ trimmed_sequences++;
- if (seq->type == SEQ_TYPE_META) {
- /* trim the sub-sequences */
- trimmed_sequences += slip_count_sequences_rec(&seq->seqbase, false);
- }
- }
- }
+ if (seq->type == SEQ_TYPE_META) {
+ /* trim the sub-sequences */
+ trimmed_sequences += slip_count_sequences_rec(&seq->seqbase, false);
+ }
+ }
+ }
- return trimmed_sequences;
+ return trimmed_sequences;
}
static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- SlipData *data;
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- float mouseloc[2];
- int num_seq, i;
- View2D *v2d = UI_view2d_fromcontext(C);
+ SlipData *data;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ float mouseloc[2];
+ int num_seq, i;
+ View2D *v2d = UI_view2d_fromcontext(C);
- /* first recursively count the trimmed elements */
- num_seq = slip_count_sequences_rec(ed->seqbasep, true);
+ /* first recursively count the trimmed elements */
+ num_seq = slip_count_sequences_rec(ed->seqbasep, true);
- if (num_seq == 0) {
- return OPERATOR_CANCELLED;
- }
+ if (num_seq == 0) {
+ return OPERATOR_CANCELLED;
+ }
- data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata");
- data->ts = MEM_mallocN(num_seq * sizeof(TransSeq), "trimdata_transform");
- data->seq_array = MEM_mallocN(num_seq * sizeof(Sequence *), "trimdata_sequences");
- data->trim = MEM_mallocN(num_seq * sizeof(bool), "trimdata_trim");
- data->num_seq = num_seq;
+ data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata");
+ data->ts = MEM_mallocN(num_seq * sizeof(TransSeq), "trimdata_transform");
+ data->seq_array = MEM_mallocN(num_seq * sizeof(Sequence *), "trimdata_sequences");
+ data->trim = MEM_mallocN(num_seq * sizeof(bool), "trimdata_trim");
+ data->num_seq = num_seq;
- initNumInput(&data->num_input);
- data->num_input.idx_max = 0;
- data->num_input.val_flag[0] |= NUM_NO_FRACTION;
- data->num_input.unit_sys = USER_UNIT_NONE;
- data->num_input.unit_type[0] = 0;
+ initNumInput(&data->num_input);
+ data->num_input.idx_max = 0;
+ data->num_input.val_flag[0] |= NUM_NO_FRACTION;
+ data->num_input.unit_sys = USER_UNIT_NONE;
+ data->num_input.unit_type[0] = 0;
+ slip_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true);
- slip_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true);
+ for (i = 0; i < num_seq; i++) {
+ transseq_backup(data->ts + i, data->seq_array[i]);
+ }
- for (i = 0; i < num_seq; i++) {
- transseq_backup(data->ts + i, data->seq_array[i]);
- }
+ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &mouseloc[0], &mouseloc[1]);
- UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &mouseloc[0], &mouseloc[1]);
+ copy_v2_v2_int(data->init_mouse, event->mval);
+ copy_v2_v2(data->init_mouseloc, mouseloc);
- copy_v2_v2_int(data->init_mouse, event->mval);
- copy_v2_v2(data->init_mouseloc, mouseloc);
+ data->slow = false;
- data->slow = false;
+ WM_event_add_modal_handler(C, op);
- WM_event_add_modal_handler(C, op);
+ /* notify so we draw extensions immediately */
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- /* notify so we draw extensions immediately */
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- return OPERATOR_RUNNING_MODAL;
+ return OPERATOR_RUNNING_MODAL;
}
static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset)
{
- /* only data types supported for now */
- if (offset != 0) {
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- int i;
-
- /* we iterate in reverse so metastrips are iterated after their children */
- for (i = data->num_seq - 1; i >= 0; i--) {
- Sequence *seq = data->seq_array[i];
- int endframe;
- /* we have the offset, do the terrible math */
-
- /* first, do the offset */
- seq->start = data->ts[i].start + offset;
-
- if (data->trim[i]) {
- /* find the endframe */
- endframe = seq->start + seq->len;
-
- /* now compute the terrible offsets */
- if (endframe > seq->enddisp) {
- seq->endstill = 0;
- seq->endofs = endframe - seq->enddisp;
- }
- else if (endframe <= seq->enddisp) {
- seq->endstill = seq->enddisp - endframe;
- seq->endofs = 0;
- }
-
- if (seq->start > seq->startdisp) {
- seq->startstill = seq->start - seq->startdisp;
- seq->startofs = 0;
- }
- else if (seq->start <= seq->startdisp) {
- seq->startstill = 0;
- seq->startofs = seq->startdisp - seq->start;
- }
- }
- else {
- /* if no real trim, don't change the data, rather transform the strips themselves */
- seq->startdisp = data->ts[i].startdisp + offset;
- seq->enddisp = data->ts[i].enddisp + offset;
- }
-
- /* effects are only added if we they are in a metastrip. In this case, dependent strips will just be transformed and we can skip calculating for effects
- * This way we can avoid an extra loop just for effects*/
- if (!(seq->type & SEQ_TYPE_EFFECT)) {
- BKE_sequence_calc(scene, seq);
- }
- }
- BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
-
- return true;
- }
-
- return false;
+ /* only data types supported for now */
+ if (offset != 0) {
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ int i;
+
+ /* we iterate in reverse so metastrips are iterated after their children */
+ for (i = data->num_seq - 1; i >= 0; i--) {
+ Sequence *seq = data->seq_array[i];
+ int endframe;
+ /* we have the offset, do the terrible math */
+
+ /* first, do the offset */
+ seq->start = data->ts[i].start + offset;
+
+ if (data->trim[i]) {
+ /* find the endframe */
+ endframe = seq->start + seq->len;
+
+ /* now compute the terrible offsets */
+ if (endframe > seq->enddisp) {
+ seq->endstill = 0;
+ seq->endofs = endframe - seq->enddisp;
+ }
+ else if (endframe <= seq->enddisp) {
+ seq->endstill = seq->enddisp - endframe;
+ seq->endofs = 0;
+ }
+
+ if (seq->start > seq->startdisp) {
+ seq->startstill = seq->start - seq->startdisp;
+ seq->startofs = 0;
+ }
+ else if (seq->start <= seq->startdisp) {
+ seq->startstill = 0;
+ seq->startofs = seq->startdisp - seq->start;
+ }
+ }
+ else {
+ /* if no real trim, don't change the data, rather transform the strips themselves */
+ seq->startdisp = data->ts[i].startdisp + offset;
+ seq->enddisp = data->ts[i].enddisp + offset;
+ }
+
+ /* effects are only added if we they are in a metastrip. In this case, dependent strips will just be transformed and we can skip calculating for effects
+ * This way we can avoid an extra loop just for effects*/
+ if (!(seq->type & SEQ_TYPE_EFFECT)) {
+ BKE_sequence_calc(scene, seq);
+ }
+ }
+ BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
+
+ return true;
+ }
+
+ return false;
}
static int sequencer_slip_exec(bContext *C, wmOperator *op)
{
- SlipData *data;
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- int num_seq, i;
- int offset = RNA_int_get(op->ptr, "offset");
- bool success = false;
+ SlipData *data;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ int num_seq, i;
+ int offset = RNA_int_get(op->ptr, "offset");
+ bool success = false;
- /* first recursively count the trimmed elements */
- num_seq = slip_count_sequences_rec(ed->seqbasep, true);
+ /* first recursively count the trimmed elements */
+ num_seq = slip_count_sequences_rec(ed->seqbasep, true);
- if (num_seq == 0) {
- return OPERATOR_CANCELLED;
- }
+ if (num_seq == 0) {
+ return OPERATOR_CANCELLED;
+ }
- data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata");
- data->ts = MEM_mallocN(num_seq * sizeof(TransSeq), "trimdata_transform");
- data->seq_array = MEM_mallocN(num_seq * sizeof(Sequence *), "trimdata_sequences");
- data->trim = MEM_mallocN(num_seq * sizeof(bool), "trimdata_trim");
- data->num_seq = num_seq;
+ data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata");
+ data->ts = MEM_mallocN(num_seq * sizeof(TransSeq), "trimdata_transform");
+ data->seq_array = MEM_mallocN(num_seq * sizeof(Sequence *), "trimdata_sequences");
+ data->trim = MEM_mallocN(num_seq * sizeof(bool), "trimdata_trim");
+ data->num_seq = num_seq;
- slip_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true);
+ slip_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true);
- for (i = 0; i < num_seq; i++) {
- transseq_backup(data->ts + i, data->seq_array[i]);
- }
+ for (i = 0; i < num_seq; i++) {
+ transseq_backup(data->ts + i, data->seq_array[i]);
+ }
- success = sequencer_slip_recursively(scene, data, offset);
+ success = sequencer_slip_recursively(scene, data, offset);
- MEM_freeN(data->seq_array);
- MEM_freeN(data->trim);
- MEM_freeN(data->ts);
- MEM_freeN(data);
+ MEM_freeN(data->seq_array);
+ MEM_freeN(data->trim);
+ MEM_freeN(data->ts);
+ MEM_freeN(data);
- if (success) {
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
+ if (success) {
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
}
-
static void sequencer_slip_update_header(Scene *scene, ScrArea *sa, SlipData *data, int offset)
{
- char msg[UI_MAX_DRAW_STR];
+ char msg[UI_MAX_DRAW_STR];
- if (sa) {
- if (hasNumInput(&data->num_input)) {
- char num_str[NUM_STR_REP_LEN];
- outputNumInput(&data->num_input, num_str, &scene->unit);
- BLI_snprintf(msg, sizeof(msg), IFACE_("Trim offset: %s"), num_str);
- }
- else {
- BLI_snprintf(msg, sizeof(msg), IFACE_("Trim offset: %d"), offset);
- }
- }
+ if (sa) {
+ if (hasNumInput(&data->num_input)) {
+ char num_str[NUM_STR_REP_LEN];
+ outputNumInput(&data->num_input, num_str, &scene->unit);
+ BLI_snprintf(msg, sizeof(msg), IFACE_("Trim offset: %s"), num_str);
+ }
+ else {
+ BLI_snprintf(msg, sizeof(msg), IFACE_("Trim offset: %d"), offset);
+ }
+ }
- ED_area_status_text(sa, msg);
+ ED_area_status_text(sa, msg);
}
static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
- Scene *scene = CTX_data_scene(C);
- SlipData *data = (SlipData *)op->customdata;
- ScrArea *sa = CTX_wm_area(C);
- const bool has_numInput = hasNumInput(&data->num_input);
- bool handled = true;
-
- /* Modal numinput active, try to handle numeric inputs first... */
- if (event->val == KM_PRESS && has_numInput && handleNumInput(C, &data->num_input, event)) {
- float offset;
- applyNumInput(&data->num_input, &offset);
-
- sequencer_slip_update_header(scene, sa, data, (int)offset);
-
- RNA_int_set(op->ptr, "offset", offset);
-
- if (sequencer_slip_recursively(scene, data, offset)) {
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- }
-
- return OPERATOR_RUNNING_MODAL;
- }
-
- switch (event->type) {
- case MOUSEMOVE:
- {
- if (!has_numInput) {
- float mouseloc[2];
- int offset;
- int mouse_x;
- View2D *v2d = UI_view2d_fromcontext(C);
-
- if (data->slow) {
- mouse_x = event->mval[0] - data->slow_offset;
- mouse_x *= 0.1f;
- mouse_x += data->slow_offset;
- }
- else {
- mouse_x = event->mval[0];
- }
-
-
- /* choose the side based on which side of the playhead the mouse is on */
- UI_view2d_region_to_view(v2d, mouse_x, 0, &mouseloc[0], &mouseloc[1]);
- offset = mouseloc[0] - data->init_mouseloc[0];
-
- sequencer_slip_update_header(scene, sa, data, offset);
-
- RNA_int_set(op->ptr, "offset", offset);
-
- if (sequencer_slip_recursively(scene, data, offset)) {
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- }
- }
- break;
- }
-
- case LEFTMOUSE:
- case RETKEY:
- case SPACEKEY:
- {
- MEM_freeN(data->seq_array);
- MEM_freeN(data->trim);
- MEM_freeN(data->ts);
- MEM_freeN(data);
- op->customdata = NULL;
- if (sa) {
- ED_area_status_text(sa, NULL);
- }
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
- }
-
- case ESCKEY:
- case RIGHTMOUSE:
- {
- int i;
- Editing *ed = BKE_sequencer_editing_get(scene, false);
-
- for (i = 0; i < data->num_seq; i++) {
- transseq_restore(data->ts + i, data->seq_array[i]);
- }
-
- for (i = 0; i < data->num_seq; i++) {
- Sequence *seq = data->seq_array[i];
- BKE_sequence_reload_new_file(scene, seq, false);
- BKE_sequence_calc(scene, seq);
- }
-
- MEM_freeN(data->seq_array);
- MEM_freeN(data->ts);
- MEM_freeN(data->trim);
- MEM_freeN(data);
- op->customdata = NULL;
-
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
-
- if (sa) {
- ED_area_status_text(sa, NULL);
- }
-
- return OPERATOR_CANCELLED;
- }
-
- case RIGHTSHIFTKEY:
- case LEFTSHIFTKEY:
- if (!has_numInput) {
- if (event->val == KM_PRESS) {
- data->slow = true;
- data->slow_offset = event->mval[0];
- }
- else if (event->val == KM_RELEASE) {
- data->slow = false;
- }
- }
- break;
-
- default:
- handled = false;
- break;
- }
-
- /* Modal numinput inactive, try to handle numeric inputs last... */
- if (!handled && event->val == KM_PRESS && handleNumInput(C, &data->num_input, event)) {
- float offset;
- applyNumInput(&data->num_input, &offset);
-
- sequencer_slip_update_header(scene, sa, data, (int)offset);
-
- RNA_int_set(op->ptr, "offset", offset);
-
- if (sequencer_slip_recursively(scene, data, offset)) {
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- }
- }
-
- return OPERATOR_RUNNING_MODAL;
+ Scene *scene = CTX_data_scene(C);
+ SlipData *data = (SlipData *)op->customdata;
+ ScrArea *sa = CTX_wm_area(C);
+ const bool has_numInput = hasNumInput(&data->num_input);
+ bool handled = true;
+
+ /* Modal numinput active, try to handle numeric inputs first... */
+ if (event->val == KM_PRESS && has_numInput && handleNumInput(C, &data->num_input, event)) {
+ float offset;
+ applyNumInput(&data->num_input, &offset);
+
+ sequencer_slip_update_header(scene, sa, data, (int)offset);
+
+ RNA_int_set(op->ptr, "offset", offset);
+
+ if (sequencer_slip_recursively(scene, data, offset)) {
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ }
+
+ return OPERATOR_RUNNING_MODAL;
+ }
+
+ switch (event->type) {
+ case MOUSEMOVE: {
+ if (!has_numInput) {
+ float mouseloc[2];
+ int offset;
+ int mouse_x;
+ View2D *v2d = UI_view2d_fromcontext(C);
+
+ if (data->slow) {
+ mouse_x = event->mval[0] - data->slow_offset;
+ mouse_x *= 0.1f;
+ mouse_x += data->slow_offset;
+ }
+ else {
+ mouse_x = event->mval[0];
+ }
+
+ /* choose the side based on which side of the playhead the mouse is on */
+ UI_view2d_region_to_view(v2d, mouse_x, 0, &mouseloc[0], &mouseloc[1]);
+ offset = mouseloc[0] - data->init_mouseloc[0];
+
+ sequencer_slip_update_header(scene, sa, data, offset);
+
+ RNA_int_set(op->ptr, "offset", offset);
+
+ if (sequencer_slip_recursively(scene, data, offset)) {
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ }
+ }
+ break;
+ }
+
+ case LEFTMOUSE:
+ case RETKEY:
+ case SPACEKEY: {
+ MEM_freeN(data->seq_array);
+ MEM_freeN(data->trim);
+ MEM_freeN(data->ts);
+ MEM_freeN(data);
+ op->customdata = NULL;
+ if (sa) {
+ ED_area_status_text(sa, NULL);
+ }
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ return OPERATOR_FINISHED;
+ }
+
+ case ESCKEY:
+ case RIGHTMOUSE: {
+ int i;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+
+ for (i = 0; i < data->num_seq; i++) {
+ transseq_restore(data->ts + i, data->seq_array[i]);
+ }
+
+ for (i = 0; i < data->num_seq; i++) {
+ Sequence *seq = data->seq_array[i];
+ BKE_sequence_reload_new_file(scene, seq, false);
+ BKE_sequence_calc(scene, seq);
+ }
+
+ MEM_freeN(data->seq_array);
+ MEM_freeN(data->ts);
+ MEM_freeN(data->trim);
+ MEM_freeN(data);
+ op->customdata = NULL;
+
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+
+ BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
+
+ if (sa) {
+ ED_area_status_text(sa, NULL);
+ }
+
+ return OPERATOR_CANCELLED;
+ }
+
+ case RIGHTSHIFTKEY:
+ case LEFTSHIFTKEY:
+ if (!has_numInput) {
+ if (event->val == KM_PRESS) {
+ data->slow = true;
+ data->slow_offset = event->mval[0];
+ }
+ else if (event->val == KM_RELEASE) {
+ data->slow = false;
+ }
+ }
+ break;
+
+ default:
+ handled = false;
+ break;
+ }
+
+ /* Modal numinput inactive, try to handle numeric inputs last... */
+ if (!handled && event->val == KM_PRESS && handleNumInput(C, &data->num_input, event)) {
+ float offset;
+ applyNumInput(&data->num_input, &offset);
+
+ sequencer_slip_update_header(scene, sa, data, (int)offset);
+
+ RNA_int_set(op->ptr, "offset", offset);
+
+ if (sequencer_slip_recursively(scene, data, offset)) {
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ }
+ }
+
+ return OPERATOR_RUNNING_MODAL;
}
void SEQUENCER_OT_slip(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Trim Strips";
- ot->idname = "SEQUENCER_OT_slip";
- ot->description = "Trim the contents of the active strip";
+ /* identifiers */
+ ot->name = "Trim Strips";
+ ot->idname = "SEQUENCER_OT_slip";
+ ot->description = "Trim the contents of the active strip";
- /* api callbacks */
- ot->invoke = sequencer_slip_invoke;
- ot->modal = sequencer_slip_modal;
- ot->exec = sequencer_slip_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->invoke = sequencer_slip_invoke;
+ ot->modal = sequencer_slip_modal;
+ ot->exec = sequencer_slip_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_int(ot->srna, "offset", 0, INT32_MIN, INT32_MAX, "Offset", "Offset to the data of the strip",
- INT32_MIN, INT32_MAX);
+ RNA_def_int(ot->srna,
+ "offset",
+ 0,
+ INT32_MIN,
+ INT32_MAX,
+ "Offset",
+ "Offset to the data of the strip",
+ INT32_MIN,
+ INT32_MAX);
}
/* mute operator */
static int sequencer_mute_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
- bool selected;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+ bool selected;
- selected = !RNA_boolean_get(op->ptr, "unselected");
+ selected = !RNA_boolean_get(op->ptr, "unselected");
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if ((seq->flag & SEQ_LOCK) == 0) {
- if (selected) { /* mute unselected */
- if (seq->flag & SELECT) {
- seq->flag |= SEQ_MUTE;
- BKE_sequence_invalidate_dependent(scene, seq);
- }
- }
- else {
- if ((seq->flag & SELECT) == 0) {
- seq->flag |= SEQ_MUTE;
- BKE_sequence_invalidate_dependent(scene, seq);
- }
- }
- }
- }
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if ((seq->flag & SEQ_LOCK) == 0) {
+ if (selected) { /* mute unselected */
+ if (seq->flag & SELECT) {
+ seq->flag |= SEQ_MUTE;
+ BKE_sequence_invalidate_dependent(scene, seq);
+ }
+ }
+ else {
+ if ((seq->flag & SELECT) == 0) {
+ seq->flag |= SEQ_MUTE;
+ BKE_sequence_invalidate_dependent(scene, seq);
+ }
+ }
+ }
+ }
- BKE_sequencer_update_muting(ed);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ BKE_sequencer_update_muting(ed);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_mute(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Mute Strips";
- ot->idname = "SEQUENCER_OT_mute";
- ot->description = "Mute (un)selected strips";
+ /* identifiers */
+ ot->name = "Mute Strips";
+ ot->idname = "SEQUENCER_OT_mute";
+ ot->description = "Mute (un)selected strips";
- /* api callbacks */
- ot->exec = sequencer_mute_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_mute_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Mute unselected rather than selected strips");
+ RNA_def_boolean(
+ ot->srna, "unselected", 0, "Unselected", "Mute unselected rather than selected strips");
}
-
/* unmute operator */
static int sequencer_unmute_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
- bool selected;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+ bool selected;
- selected = !RNA_boolean_get(op->ptr, "unselected");
+ selected = !RNA_boolean_get(op->ptr, "unselected");
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if ((seq->flag & SEQ_LOCK) == 0) {
- if (selected) { /* unmute unselected */
- if (seq->flag & SELECT) {
- seq->flag &= ~SEQ_MUTE;
- BKE_sequence_invalidate_dependent(scene, seq);
- }
- }
- else {
- if ((seq->flag & SELECT) == 0) {
- seq->flag &= ~SEQ_MUTE;
- BKE_sequence_invalidate_dependent(scene, seq);
- }
- }
- }
- }
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if ((seq->flag & SEQ_LOCK) == 0) {
+ if (selected) { /* unmute unselected */
+ if (seq->flag & SELECT) {
+ seq->flag &= ~SEQ_MUTE;
+ BKE_sequence_invalidate_dependent(scene, seq);
+ }
+ }
+ else {
+ if ((seq->flag & SELECT) == 0) {
+ seq->flag &= ~SEQ_MUTE;
+ BKE_sequence_invalidate_dependent(scene, seq);
+ }
+ }
+ }
+ }
- BKE_sequencer_update_muting(ed);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ BKE_sequencer_update_muting(ed);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_unmute(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Unmute Strips";
- ot->idname = "SEQUENCER_OT_unmute";
- ot->description = "Unmute (un)selected strips";
+ /* identifiers */
+ ot->name = "Unmute Strips";
+ ot->idname = "SEQUENCER_OT_unmute";
+ ot->description = "Unmute (un)selected strips";
- /* api callbacks */
- ot->exec = sequencer_unmute_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_unmute_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Unmute unselected rather than selected strips");
+ RNA_def_boolean(
+ ot->srna, "unselected", 0, "Unselected", "Unmute unselected rather than selected strips");
}
-
/* lock operator */
static int sequencer_lock_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SELECT) {
- seq->flag |= SEQ_LOCK;
- }
- }
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT) {
+ seq->flag |= SEQ_LOCK;
+ }
+ }
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_lock(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Lock Strips";
- ot->idname = "SEQUENCER_OT_lock";
- ot->description = "Lock strips so they can't be transformed";
+ /* identifiers */
+ ot->name = "Lock Strips";
+ ot->idname = "SEQUENCER_OT_lock";
+ ot->description = "Lock strips so they can't be transformed";
- /* api callbacks */
- ot->exec = sequencer_lock_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_lock_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* unlock operator */
static int sequencer_unlock_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SELECT) {
- seq->flag &= ~SEQ_LOCK;
- }
- }
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT) {
+ seq->flag &= ~SEQ_LOCK;
+ }
+ }
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_unlock(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Unlock Strips";
- ot->idname = "SEQUENCER_OT_unlock";
- ot->description = "Unlock strips so they can be transformed";
+ /* identifiers */
+ ot->name = "Unlock Strips";
+ ot->idname = "SEQUENCER_OT_unlock";
+ ot->description = "Unlock strips so they can be transformed";
- /* api callbacks */
- ot->exec = sequencer_unlock_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_unlock_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* reload operator */
static int sequencer_reload_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
- const bool adjust_length = RNA_boolean_get(op->ptr, "adjust_length");
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+ const bool adjust_length = RNA_boolean_get(op->ptr, "adjust_length");
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SELECT) {
- BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
- BKE_sequence_reload_new_file(scene, seq, !adjust_length);
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT) {
+ BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
+ BKE_sequence_reload_new_file(scene, seq, !adjust_length);
- if (adjust_length) {
- if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
- BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
- }
- }
- }
- }
+ if (adjust_length) {
+ if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
+ BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
+ }
+ }
+ }
+ }
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_reload(struct wmOperatorType *ot)
{
- PropertyRNA *prop;
+ PropertyRNA *prop;
- /* identifiers */
- ot->name = "Reload Strips";
- ot->idname = "SEQUENCER_OT_reload";
- ot->description = "Reload strips in the sequencer";
+ /* identifiers */
+ ot->name = "Reload Strips";
+ ot->idname = "SEQUENCER_OT_reload";
+ ot->description = "Reload strips in the sequencer";
- /* api callbacks */
- ot->exec = sequencer_reload_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_reload_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER; /* no undo, the data changed is stored outside 'main' */
+ /* flags */
+ ot->flag = OPTYPE_REGISTER; /* no undo, the data changed is stored outside 'main' */
- prop = RNA_def_boolean(ot->srna, "adjust_length", 0, "Adjust Length",
- "Adjust length of strips to their data length");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna,
+ "adjust_length",
+ 0,
+ "Adjust Length",
+ "Adjust length of strips to their data length");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/* reload operator */
static bool sequencer_refresh_all_poll(bContext *C)
{
- if (G.is_rendering) {
- return 0;
- }
- return sequencer_edit_poll(C);
+ if (G.is_rendering) {
+ return 0;
+ }
+ return sequencer_edit_poll(C);
}
static int sequencer_refresh_all_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
- BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
+ BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_refresh_all(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Refresh Sequencer";
- ot->idname = "SEQUENCER_OT_refresh_all";
- ot->description = "Refresh the sequencer editor";
+ /* identifiers */
+ ot->name = "Refresh Sequencer";
+ ot->idname = "SEQUENCER_OT_refresh_all";
+ ot->description = "Refresh the sequencer editor";
- /* api callbacks */
- ot->exec = sequencer_refresh_all_exec;
- ot->poll = sequencer_refresh_all_poll;
+ /* api callbacks */
+ ot->exec = sequencer_refresh_all_exec;
+ ot->poll = sequencer_refresh_all_poll;
}
static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Sequence *seq1, *seq2, *seq3, *last_seq = BKE_sequencer_active_get(scene);
- const char *error_msg;
+ Scene *scene = CTX_data_scene(C);
+ Sequence *seq1, *seq2, *seq3, *last_seq = BKE_sequencer_active_get(scene);
+ const char *error_msg;
- if (!seq_effect_find_selected(scene, last_seq, last_seq->type, &seq1, &seq2, &seq3, &error_msg)) {
- BKE_report(op->reports, RPT_ERROR, error_msg);
- return OPERATOR_CANCELLED;
- }
- /* see reassigning would create a cycle */
- if (seq_is_predecessor(seq1, last_seq) ||
- seq_is_predecessor(seq2, last_seq) ||
- seq_is_predecessor(seq3, last_seq))
- {
- BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: no cycles allowed");
- return OPERATOR_CANCELLED;
- }
+ if (!seq_effect_find_selected(
+ scene, last_seq, last_seq->type, &seq1, &seq2, &seq3, &error_msg)) {
+ BKE_report(op->reports, RPT_ERROR, error_msg);
+ return OPERATOR_CANCELLED;
+ }
+ /* see reassigning would create a cycle */
+ if (seq_is_predecessor(seq1, last_seq) || seq_is_predecessor(seq2, last_seq) ||
+ seq_is_predecessor(seq3, last_seq)) {
+ BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: no cycles allowed");
+ return OPERATOR_CANCELLED;
+ }
- last_seq->seq1 = seq1;
- last_seq->seq2 = seq2;
- last_seq->seq3 = seq3;
+ last_seq->seq1 = seq1;
+ last_seq->seq2 = seq2;
+ last_seq->seq3 = seq3;
- BKE_sequencer_update_changed_seq_and_deps(scene, last_seq, 1, 1);
+ BKE_sequencer_update_changed_seq_and_deps(scene, last_seq, 1, 1);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
static bool sequencer_effect_poll(bContext *C)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
- if (ed) {
- Sequence *last_seq = BKE_sequencer_active_get(scene);
- if (last_seq && (last_seq->type & SEQ_TYPE_EFFECT)) {
- return 1;
- }
- }
+ if (ed) {
+ Sequence *last_seq = BKE_sequencer_active_get(scene);
+ if (last_seq && (last_seq->type & SEQ_TYPE_EFFECT)) {
+ return 1;
+ }
+ }
- return 0;
+ return 0;
}
void SEQUENCER_OT_reassign_inputs(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Reassign Inputs";
- ot->idname = "SEQUENCER_OT_reassign_inputs";
- ot->description = "Reassign the inputs for the effect strip";
+ /* identifiers */
+ ot->name = "Reassign Inputs";
+ ot->idname = "SEQUENCER_OT_reassign_inputs";
+ ot->description = "Reassign the inputs for the effect strip";
- /* api callbacks */
- ot->exec = sequencer_reassign_inputs_exec;
- ot->poll = sequencer_effect_poll;
+ /* api callbacks */
+ ot->exec = sequencer_reassign_inputs_exec;
+ ot->poll = sequencer_effect_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-
static int sequencer_swap_inputs_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Sequence *seq, *last_seq = BKE_sequencer_active_get(scene);
+ Scene *scene = CTX_data_scene(C);
+ Sequence *seq, *last_seq = BKE_sequencer_active_get(scene);
- if (last_seq->seq1 == NULL || last_seq->seq2 == NULL) {
- BKE_report(op->reports, RPT_ERROR, "No valid inputs to swap");
- return OPERATOR_CANCELLED;
- }
+ if (last_seq->seq1 == NULL || last_seq->seq2 == NULL) {
+ BKE_report(op->reports, RPT_ERROR, "No valid inputs to swap");
+ return OPERATOR_CANCELLED;
+ }
- seq = last_seq->seq1;
- last_seq->seq1 = last_seq->seq2;
- last_seq->seq2 = seq;
+ seq = last_seq->seq1;
+ last_seq->seq1 = last_seq->seq2;
+ last_seq->seq2 = seq;
- BKE_sequencer_update_changed_seq_and_deps(scene, last_seq, 1, 1);
+ BKE_sequencer_update_changed_seq_and_deps(scene, last_seq, 1, 1);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_swap_inputs(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Swap Inputs";
- ot->idname = "SEQUENCER_OT_swap_inputs";
- ot->description = "Swap the first two inputs for the effect strip";
+ /* identifiers */
+ ot->name = "Swap Inputs";
+ ot->idname = "SEQUENCER_OT_swap_inputs";
+ ot->description = "Swap the first two inputs for the effect strip";
- /* api callbacks */
- ot->exec = sequencer_swap_inputs_exec;
- ot->poll = sequencer_effect_poll;
+ /* api callbacks */
+ ot->exec = sequencer_swap_inputs_exec;
+ ot->poll = sequencer_effect_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-
/* cut operator */
static const EnumPropertyItem prop_cut_types[] = {
- {SEQ_CUT_SOFT, "SOFT", 0, "Soft", ""},
- {SEQ_CUT_HARD, "HARD", 0, "Hard", ""},
- {0, NULL, 0, NULL, NULL},
+ {SEQ_CUT_SOFT, "SOFT", 0, "Soft", ""},
+ {SEQ_CUT_HARD, "HARD", 0, "Hard", ""},
+ {0, NULL, 0, NULL, NULL},
};
static int sequencer_cut_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- int cut_side, cut_hard, cut_frame;
-
- bool changed;
-
- cut_frame = RNA_int_get(op->ptr, "frame");
- cut_hard = RNA_enum_get(op->ptr, "type");
- cut_side = RNA_enum_get(op->ptr, "side");
-
- if (cut_hard == SEQ_CUT_HARD) {
- changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_hard);
- }
- else {
- changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_soft);
- }
-
- if (changed) { /* got new strips ? */
- Sequence *seq;
-
- if (cut_side != SEQ_SIDE_BOTH) {
- SEQP_BEGIN (ed, seq)
- {
- if (cut_side == SEQ_SIDE_LEFT) {
- if (seq->startdisp >= cut_frame) {
- seq->flag &= ~SEQ_ALLSEL;
- }
- }
- else {
- if (seq->enddisp <= cut_frame) {
- seq->flag &= ~SEQ_ALLSEL;
- }
- }
- }
- SEQ_END;
- }
-
- SEQP_BEGIN (ed, seq)
- {
- if (seq->seq1 || seq->seq2 || seq->seq3) {
- BKE_sequence_calc(scene, seq);
- }
- }
- SEQ_END;
-
- /* as last: */
- BKE_sequencer_sort(scene);
- }
-
- if (changed) {
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ int cut_side, cut_hard, cut_frame;
+
+ bool changed;
+
+ cut_frame = RNA_int_get(op->ptr, "frame");
+ cut_hard = RNA_enum_get(op->ptr, "type");
+ cut_side = RNA_enum_get(op->ptr, "side");
+
+ if (cut_hard == SEQ_CUT_HARD) {
+ changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_hard);
+ }
+ else {
+ changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_soft);
+ }
+
+ if (changed) { /* got new strips ? */
+ Sequence *seq;
+
+ if (cut_side != SEQ_SIDE_BOTH) {
+ SEQP_BEGIN (ed, seq) {
+ if (cut_side == SEQ_SIDE_LEFT) {
+ if (seq->startdisp >= cut_frame) {
+ seq->flag &= ~SEQ_ALLSEL;
+ }
+ }
+ else {
+ if (seq->enddisp <= cut_frame) {
+ seq->flag &= ~SEQ_ALLSEL;
+ }
+ }
+ }
+ SEQ_END;
+ }
+
+ SEQP_BEGIN (ed, seq) {
+ if (seq->seq1 || seq->seq2 || seq->seq3) {
+ BKE_sequence_calc(scene, seq);
+ }
+ }
+ SEQ_END;
+
+ /* as last: */
+ BKE_sequencer_sort(scene);
+ }
+
+ if (changed) {
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
}
-
static int sequencer_cut_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- Scene *scene = CTX_data_scene(C);
- View2D *v2d = UI_view2d_fromcontext(C);
+ Scene *scene = CTX_data_scene(C);
+ View2D *v2d = UI_view2d_fromcontext(C);
- int cut_side = RNA_enum_get(op->ptr, "side");
- int cut_frame = CFRA;
+ int cut_side = RNA_enum_get(op->ptr, "side");
+ int cut_frame = CFRA;
- if (cut_side == SEQ_SIDE_MOUSE) {
- if (ED_operator_sequencer_active(C) && v2d) {
- cut_side = mouse_frame_side(v2d, event->mval[0], cut_frame);
- }
- else {
- cut_side = SEQ_SIDE_BOTH;
- }
- }
- RNA_int_set(op->ptr, "frame", cut_frame);
- RNA_enum_set(op->ptr, "side", cut_side);
- /*RNA_enum_set(op->ptr, "type", cut_hard); */ /*This type is set from the key shortcut */
- return sequencer_cut_exec(C, op);
+ if (cut_side == SEQ_SIDE_MOUSE) {
+ if (ED_operator_sequencer_active(C) && v2d) {
+ cut_side = mouse_frame_side(v2d, event->mval[0], cut_frame);
+ }
+ else {
+ cut_side = SEQ_SIDE_BOTH;
+ }
+ }
+ RNA_int_set(op->ptr, "frame", cut_frame);
+ RNA_enum_set(op->ptr, "side", cut_side);
+ /*RNA_enum_set(op->ptr, "type", cut_hard); */ /*This type is set from the key shortcut */
+ return sequencer_cut_exec(C, op);
}
-
void SEQUENCER_OT_cut(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Cut Strips";
- ot->idname = "SEQUENCER_OT_cut";
- ot->description = "Cut the selected strips";
-
- /* api callbacks */
- ot->invoke = sequencer_cut_invoke;
- ot->exec = sequencer_cut_exec;
- ot->poll = sequencer_edit_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- PropertyRNA *prop;
- RNA_def_int(ot->srna, "frame", 0, INT_MIN, INT_MAX, "Frame", "Frame where selected strips will be cut", INT_MIN, INT_MAX);
- RNA_def_enum(ot->srna, "type", prop_cut_types, SEQ_CUT_SOFT, "Type", "The type of cut operation to perform on strips");
- prop = RNA_def_enum(ot->srna, "side", prop_side_types, SEQ_SIDE_MOUSE, "Side", "The side that remains selected after cutting");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ /* identifiers */
+ ot->name = "Cut Strips";
+ ot->idname = "SEQUENCER_OT_cut";
+ ot->description = "Cut the selected strips";
+
+ /* api callbacks */
+ ot->invoke = sequencer_cut_invoke;
+ ot->exec = sequencer_cut_exec;
+ ot->poll = sequencer_edit_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ PropertyRNA *prop;
+ RNA_def_int(ot->srna,
+ "frame",
+ 0,
+ INT_MIN,
+ INT_MAX,
+ "Frame",
+ "Frame where selected strips will be cut",
+ INT_MIN,
+ INT_MAX);
+ RNA_def_enum(ot->srna,
+ "type",
+ prop_cut_types,
+ SEQ_CUT_SOFT,
+ "Type",
+ "The type of cut operation to perform on strips");
+ prop = RNA_def_enum(ot->srna,
+ "side",
+ prop_side_types,
+ SEQ_SIDE_MOUSE,
+ "Side",
+ "The side that remains selected after cutting");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
#undef SEQ_SIDE_MOUSE
@@ -2233,1873 +2265,1908 @@ void SEQUENCER_OT_cut(struct wmOperatorType *ot)
/* duplicate operator */
static int apply_unique_name_cb(Sequence *seq, void *arg_pt)
{
- Scene *scene = (Scene *)arg_pt;
- char name[sizeof(seq->name) - 2];
-
- BLI_strncpy_utf8(name, seq->name + 2, sizeof(name));
- BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
- BKE_sequencer_dupe_animdata(scene, name, seq->name + 2);
- return 1;
+ Scene *scene = (Scene *)arg_pt;
+ char name[sizeof(seq->name) - 2];
+ BLI_strncpy_utf8(name, seq->name + 2, sizeof(name));
+ BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
+ BKE_sequencer_dupe_animdata(scene, name, seq->name + 2);
+ return 1;
}
static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
- ListBase nseqbase = {NULL, NULL};
+ ListBase nseqbase = {NULL, NULL};
- if (ed == NULL) {
- return OPERATOR_CANCELLED;
- }
+ if (ed == NULL) {
+ return OPERATOR_CANCELLED;
+ }
- BKE_sequence_base_dupli_recursive(scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT, 0);
+ BKE_sequence_base_dupli_recursive(scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT, 0);
- if (nseqbase.first) {
- Sequence *seq = nseqbase.first;
- /* rely on the nseqbase list being added at the end */
- BLI_movelisttolist(ed->seqbasep, &nseqbase);
+ if (nseqbase.first) {
+ Sequence *seq = nseqbase.first;
+ /* rely on the nseqbase list being added at the end */
+ BLI_movelisttolist(ed->seqbasep, &nseqbase);
- for (; seq; seq = seq->next) {
- BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene);
- }
+ for (; seq; seq = seq->next) {
+ BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene);
+ }
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
- }
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ return OPERATOR_FINISHED;
+ }
- return OPERATOR_CANCELLED;
+ return OPERATOR_CANCELLED;
}
void SEQUENCER_OT_duplicate(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Duplicate Strips";
- ot->idname = "SEQUENCER_OT_duplicate";
- ot->description = "Duplicate the selected strips";
+ /* identifiers */
+ ot->name = "Duplicate Strips";
+ ot->idname = "SEQUENCER_OT_duplicate";
+ ot->description = "Duplicate the selected strips";
- /* api callbacks */
- ot->exec = sequencer_add_duplicate_exec;
- ot->poll = ED_operator_sequencer_active;
+ /* api callbacks */
+ ot->exec = sequencer_add_duplicate_exec;
+ ot->poll = ED_operator_sequencer_active;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* to give to transform */
- RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", "");
+ /* to give to transform */
+ RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", "");
}
/* delete operator */
static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
- MetaStack *ms;
- bool nothing_selected = true;
-
- seq = BKE_sequencer_active_get(scene);
- if (seq && seq->flag & SELECT) { /* avoid a loop since this is likely to be selected */
- nothing_selected = false;
- }
- else {
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SELECT) {
- nothing_selected = false;
- break;
- }
- }
- }
-
- if (nothing_selected) {
- return OPERATOR_FINISHED;
- }
-
- /* for effects and modifiers, try to find a replacement input */
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (!(seq->flag & SELECT)) {
- if ((seq->type & SEQ_TYPE_EFFECT)) {
- del_seq_find_replace_recurs(scene, seq);
- }
- }
- else {
- del_seq_clear_modifiers_recurs(scene, seq);
- }
- }
-
- /* delete all selected strips */
- recurs_del_seq_flag(scene, ed->seqbasep, SELECT, 0);
-
- /* updates lengths etc */
- seq = ed->seqbasep->first;
- while (seq) {
- BKE_sequence_calc(scene, seq);
- seq = seq->next;
- }
-
- /* free parent metas */
- ms = ed->metastack.last;
- while (ms) {
- BKE_sequence_calc(scene, ms->parseq);
- ms = ms->prev;
- }
-
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- return OPERATOR_FINISHED;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+ MetaStack *ms;
+ bool nothing_selected = true;
+
+ seq = BKE_sequencer_active_get(scene);
+ if (seq && seq->flag & SELECT) { /* avoid a loop since this is likely to be selected */
+ nothing_selected = false;
+ }
+ else {
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT) {
+ nothing_selected = false;
+ break;
+ }
+ }
+ }
+
+ if (nothing_selected) {
+ return OPERATOR_FINISHED;
+ }
+
+ /* for effects and modifiers, try to find a replacement input */
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (!(seq->flag & SELECT)) {
+ if ((seq->type & SEQ_TYPE_EFFECT)) {
+ del_seq_find_replace_recurs(scene, seq);
+ }
+ }
+ else {
+ del_seq_clear_modifiers_recurs(scene, seq);
+ }
+ }
+
+ /* delete all selected strips */
+ recurs_del_seq_flag(scene, ed->seqbasep, SELECT, 0);
+
+ /* updates lengths etc */
+ seq = ed->seqbasep->first;
+ while (seq) {
+ BKE_sequence_calc(scene, seq);
+ seq = seq->next;
+ }
+
+ /* free parent metas */
+ ms = ed->metastack.last;
+ while (ms) {
+ BKE_sequence_calc(scene, ms->parseq);
+ ms = ms->prev;
+ }
+
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+
+ return OPERATOR_FINISHED;
}
static int sequencer_delete_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- ARegion *ar = CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
- if (ar->regiontype == RGN_TYPE_WINDOW) {
- /* bounding box of 30 pixels is used for markers shortcuts,
- * prevent conflict with markers shortcuts here
- */
- if (event->mval[1] <= 30) {
- return OPERATOR_PASS_THROUGH;
- }
- }
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ /* bounding box of 30 pixels is used for markers shortcuts,
+ * prevent conflict with markers shortcuts here
+ */
+ if (event->mval[1] <= 30) {
+ return OPERATOR_PASS_THROUGH;
+ }
+ }
- return WM_operator_confirm(C, op, event);
+ return WM_operator_confirm(C, op, event);
}
void SEQUENCER_OT_delete(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Erase Strips";
- ot->idname = "SEQUENCER_OT_delete";
- ot->description = "Erase selected strips from the sequencer";
+ /* identifiers */
+ ot->name = "Erase Strips";
+ ot->idname = "SEQUENCER_OT_delete";
+ ot->description = "Erase selected strips from the sequencer";
- /* api callbacks */
- ot->invoke = sequencer_delete_invoke;
- ot->exec = sequencer_delete_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->invoke = sequencer_delete_invoke;
+ ot->exec = sequencer_delete_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-
/* offset clear operator */
static int sequencer_offset_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
- /* for effects, try to find a replacement input */
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if ((seq->type & SEQ_TYPE_EFFECT) == 0 && (seq->flag & SELECT)) {
- seq->startofs = seq->endofs = seq->startstill = seq->endstill = 0;
- }
- }
+ /* for effects, try to find a replacement input */
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if ((seq->type & SEQ_TYPE_EFFECT) == 0 && (seq->flag & SELECT)) {
+ seq->startofs = seq->endofs = seq->startstill = seq->endstill = 0;
+ }
+ }
- /* updates lengths etc */
- seq = ed->seqbasep->first;
- while (seq) {
- BKE_sequence_calc(scene, seq);
- seq = seq->next;
- }
+ /* updates lengths etc */
+ seq = ed->seqbasep->first;
+ while (seq) {
+ BKE_sequence_calc(scene, seq);
+ seq = seq->next;
+ }
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if ((seq->type & SEQ_TYPE_EFFECT) == 0 && (seq->flag & SELECT)) {
- if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
- BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
- }
- }
- }
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if ((seq->type & SEQ_TYPE_EFFECT) == 0 && (seq->flag & SELECT)) {
+ if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
+ BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
+ }
+ }
+ }
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
-
void SEQUENCER_OT_offset_clear(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Clear Strip Offset";
- ot->idname = "SEQUENCER_OT_offset_clear";
- ot->description = "Clear strip offsets from the start and end frames";
+ /* identifiers */
+ ot->name = "Clear Strip Offset";
+ ot->idname = "SEQUENCER_OT_offset_clear";
+ ot->description = "Clear strip offsets from the start and end frames";
- /* api callbacks */
- ot->exec = sequencer_offset_clear_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_offset_clear_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-
/* separate_images operator */
static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq, *seq_new;
- Strip *strip_new;
- StripElem *se, *se_new;
- int start_ofs, cfra, frame_end;
- int step = RNA_int_get(op->ptr, "length");
+ Sequence *seq, *seq_new;
+ Strip *strip_new;
+ StripElem *se, *se_new;
+ int start_ofs, cfra, frame_end;
+ int step = RNA_int_get(op->ptr, "length");
- seq = ed->seqbasep->first; /* poll checks this is valid */
+ seq = ed->seqbasep->first; /* poll checks this is valid */
- while (seq) {
- if ((seq->flag & SELECT) && (seq->type == SEQ_TYPE_IMAGE) && (seq->len > 1)) {
- Sequence *seq_next;
+ while (seq) {
+ if ((seq->flag & SELECT) && (seq->type == SEQ_TYPE_IMAGE) && (seq->len > 1)) {
+ Sequence *seq_next;
- /* remove seq so overlap tests don't conflict,
- * see seq_free_sequence below for the real freeing. */
- BLI_remlink(ed->seqbasep, seq);
- /* if (seq->ipo) id_us_min(&seq->ipo->id); */
- /* XXX, remove fcurve and assign to split image strips */
+ /* remove seq so overlap tests don't conflict,
+ * see seq_free_sequence below for the real freeing. */
+ BLI_remlink(ed->seqbasep, seq);
+ /* if (seq->ipo) id_us_min(&seq->ipo->id); */
+ /* XXX, remove fcurve and assign to split image strips */
- start_ofs = cfra = BKE_sequence_tx_get_final_left(seq, false);
- frame_end = BKE_sequence_tx_get_final_right(seq, false);
+ start_ofs = cfra = BKE_sequence_tx_get_final_left(seq, false);
+ frame_end = BKE_sequence_tx_get_final_right(seq, false);
- while (cfra < frame_end) {
- /* new seq */
- se = BKE_sequencer_give_stripelem(seq, cfra);
+ while (cfra < frame_end) {
+ /* new seq */
+ se = BKE_sequencer_give_stripelem(seq, cfra);
- seq_new = BKE_sequence_dupli_recursive(scene, scene, ed->seqbasep, seq, SEQ_DUPE_UNIQUE_NAME);
+ seq_new = BKE_sequence_dupli_recursive(
+ scene, scene, ed->seqbasep, seq, SEQ_DUPE_UNIQUE_NAME);
- seq_new->start = start_ofs;
- seq_new->type = SEQ_TYPE_IMAGE;
- seq_new->len = 1;
- seq_new->endstill = step - 1;
+ seq_new->start = start_ofs;
+ seq_new->type = SEQ_TYPE_IMAGE;
+ seq_new->len = 1;
+ seq_new->endstill = step - 1;
- /* new strip */
- strip_new = seq_new->strip;
- strip_new->us = 1;
+ /* new strip */
+ strip_new = seq_new->strip;
+ strip_new->us = 1;
- /* new stripdata (only one element now!) */
- /* Note this assume all elements (images) have the same dimension,
- * since we only copy the name here. */
- se_new = MEM_reallocN(strip_new->stripdata, sizeof(*se_new));
- BLI_strncpy(se_new->name, se->name, sizeof(se_new->name));
- strip_new->stripdata = se_new;
+ /* new stripdata (only one element now!) */
+ /* Note this assume all elements (images) have the same dimension,
+ * since we only copy the name here. */
+ se_new = MEM_reallocN(strip_new->stripdata, sizeof(*se_new));
+ BLI_strncpy(se_new->name, se->name, sizeof(se_new->name));
+ strip_new->stripdata = se_new;
- BKE_sequence_calc(scene, seq_new);
+ BKE_sequence_calc(scene, seq_new);
- if (step > 1) {
- seq_new->flag &= ~SEQ_OVERLAP;
- if (BKE_sequence_test_overlap(ed->seqbasep, seq_new)) {
- BKE_sequence_base_shuffle(ed->seqbasep, seq_new, scene);
- }
- }
+ if (step > 1) {
+ seq_new->flag &= ~SEQ_OVERLAP;
+ if (BKE_sequence_test_overlap(ed->seqbasep, seq_new)) {
+ BKE_sequence_base_shuffle(ed->seqbasep, seq_new, scene);
+ }
+ }
- /* XXX, COPY FCURVES */
+ /* XXX, COPY FCURVES */
- cfra++;
- start_ofs += step;
- }
+ cfra++;
+ start_ofs += step;
+ }
- seq_next = seq->next;
- BKE_sequence_free(scene, seq);
- seq = seq_next;
- }
- else {
- seq = seq->next;
- }
- }
+ seq_next = seq->next;
+ BKE_sequence_free(scene, seq);
+ seq = seq_next;
+ }
+ else {
+ seq = seq->next;
+ }
+ }
- /* as last: */
- BKE_sequencer_sort(scene);
+ /* as last: */
+ BKE_sequencer_sort(scene);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
-
void SEQUENCER_OT_images_separate(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Separate Images";
- ot->idname = "SEQUENCER_OT_images_separate";
- ot->description = "On image sequence strips, it returns a strip for each image";
+ /* identifiers */
+ ot->name = "Separate Images";
+ ot->idname = "SEQUENCER_OT_images_separate";
+ ot->description = "On image sequence strips, it returns a strip for each image";
- /* api callbacks */
- ot->exec = sequencer_separate_images_exec;
- ot->invoke = WM_operator_props_popup_confirm;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_separate_images_exec;
+ ot->invoke = WM_operator_props_popup_confirm;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_int(ot->srna, "length", 1, 1, INT_MAX, "Length", "Length of each frame", 1, 1000);
+ RNA_def_int(ot->srna, "length", 1, 1, INT_MAX, "Length", "Length of each frame", 1, 1000);
}
-
/* META Operators */
/* separate_meta_toggle operator */
static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *last_seq = BKE_sequencer_active_get(scene);
- MetaStack *ms;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *last_seq = BKE_sequencer_active_get(scene);
+ MetaStack *ms;
- if (last_seq && last_seq->type == SEQ_TYPE_META && last_seq->flag & SELECT) {
- /* Enter Metastrip */
- ms = MEM_mallocN(sizeof(MetaStack), "metastack");
- BLI_addtail(&ed->metastack, ms);
- ms->parseq = last_seq;
- ms->oldbasep = ed->seqbasep;
- copy_v2_v2_int(ms->disp_range, &ms->parseq->startdisp);
+ if (last_seq && last_seq->type == SEQ_TYPE_META && last_seq->flag & SELECT) {
+ /* Enter Metastrip */
+ ms = MEM_mallocN(sizeof(MetaStack), "metastack");
+ BLI_addtail(&ed->metastack, ms);
+ ms->parseq = last_seq;
+ ms->oldbasep = ed->seqbasep;
+ copy_v2_v2_int(ms->disp_range, &ms->parseq->startdisp);
- ed->seqbasep = &last_seq->seqbase;
+ ed->seqbasep = &last_seq->seqbase;
- BKE_sequencer_active_set(scene, NULL);
+ BKE_sequencer_active_set(scene, NULL);
+ }
+ else {
+ /* Exit Metastrip (if possible) */
- }
- else {
- /* Exit Metastrip (if possible) */
+ Sequence *seq;
- Sequence *seq;
+ if (BLI_listbase_is_empty(&ed->metastack)) {
+ return OPERATOR_CANCELLED;
+ }
- if (BLI_listbase_is_empty(&ed->metastack)) {
- return OPERATOR_CANCELLED;
- }
+ ms = ed->metastack.last;
+ BLI_remlink(&ed->metastack, ms);
- ms = ed->metastack.last;
- BLI_remlink(&ed->metastack, ms);
+ ed->seqbasep = ms->oldbasep;
- ed->seqbasep = ms->oldbasep;
+ /* for old files, update from meta */
+ if (ms->disp_range[0] == ms->disp_range[1]) {
+ copy_v2_v2_int(ms->disp_range, &ms->parseq->startdisp);
+ }
- /* for old files, update from meta */
- if (ms->disp_range[0] == ms->disp_range[1]) {
- copy_v2_v2_int(ms->disp_range, &ms->parseq->startdisp);
- }
+ /* recalc all: the meta can have effects connected to it */
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ BKE_sequence_calc(scene, seq);
+ }
- /* recalc all: the meta can have effects connected to it */
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- BKE_sequence_calc(scene, seq);
- }
-
- /* 2.73+, keeping endpoints is important!
- * moving them around means you can't usefully use metas in a complex edit. */
+ /* 2.73+, keeping endpoints is important!
+ * moving them around means you can't usefully use metas in a complex edit. */
#if 1
- BKE_sequence_tx_set_final_left(ms->parseq, ms->disp_range[0]);
- BKE_sequence_tx_set_final_right(ms->parseq, ms->disp_range[1]);
- BKE_sequence_single_fix(ms->parseq);
- BKE_sequence_calc(scene, ms->parseq);
+ BKE_sequence_tx_set_final_left(ms->parseq, ms->disp_range[0]);
+ BKE_sequence_tx_set_final_right(ms->parseq, ms->disp_range[1]);
+ BKE_sequence_single_fix(ms->parseq);
+ BKE_sequence_calc(scene, ms->parseq);
#else
- if (BKE_sequence_test_overlap(ed->seqbasep, ms->parseq)) {
- BKE_sequence_base_shuffle(ed->seqbasep, ms->parseq, scene);
- }
+ if (BKE_sequence_test_overlap(ed->seqbasep, ms->parseq)) {
+ BKE_sequence_base_shuffle(ed->seqbasep, ms->parseq, scene);
+ }
#endif
- BKE_sequencer_active_set(scene, ms->parseq);
-
- ms->parseq->flag |= SELECT;
- recurs_sel_seq(ms->parseq);
+ BKE_sequencer_active_set(scene, ms->parseq);
- MEM_freeN(ms);
+ ms->parseq->flag |= SELECT;
+ recurs_sel_seq(ms->parseq);
- }
+ MEM_freeN(ms);
+ }
- BKE_sequencer_update_muting(ed);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ BKE_sequencer_update_muting(ed);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_meta_toggle(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Toggle Meta Strip";
- ot->idname = "SEQUENCER_OT_meta_toggle";
- ot->description = "Toggle a metastrip (to edit enclosed strips)";
+ /* identifiers */
+ ot->name = "Toggle Meta Strip";
+ ot->idname = "SEQUENCER_OT_meta_toggle";
+ ot->description = "Toggle a metastrip (to edit enclosed strips)";
- /* api callbacks */
- ot->exec = sequencer_meta_toggle_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_meta_toggle_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-
/* separate_meta_make operator */
static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq, *seqm, *next, *last_seq = BKE_sequencer_active_get(scene);
- int channel_max = 1;
+ Sequence *seq, *seqm, *next, *last_seq = BKE_sequencer_active_get(scene);
+ int channel_max = 1;
- if (BKE_sequence_base_isolated_sel_check(ed->seqbasep) == false) {
- BKE_report(op->reports, RPT_ERROR, "Please select all related strips");
- return OPERATOR_CANCELLED;
- }
+ if (BKE_sequence_base_isolated_sel_check(ed->seqbasep) == false) {
+ BKE_report(op->reports, RPT_ERROR, "Please select all related strips");
+ return OPERATOR_CANCELLED;
+ }
- /* remove all selected from main list, and put in meta */
+ /* remove all selected from main list, and put in meta */
- seqm = BKE_sequence_alloc(ed->seqbasep, 1, 1); /* channel number set later */
- strcpy(seqm->name + 2, "MetaStrip");
- seqm->type = SEQ_TYPE_META;
- seqm->flag = SELECT;
+ seqm = BKE_sequence_alloc(ed->seqbasep, 1, 1); /* channel number set later */
+ strcpy(seqm->name + 2, "MetaStrip");
+ seqm->type = SEQ_TYPE_META;
+ seqm->flag = SELECT;
- seq = ed->seqbasep->first;
- while (seq) {
- next = seq->next;
- if (seq != seqm && (seq->flag & SELECT)) {
- BKE_sequence_invalidate_cache(scene, seq);
- channel_max = max_ii(seq->machine, channel_max);
- BLI_remlink(ed->seqbasep, seq);
- BLI_addtail(&seqm->seqbase, seq);
- }
- seq = next;
- }
- seqm->machine = last_seq ? last_seq->machine : channel_max;
- BKE_sequence_calc(scene, seqm);
+ seq = ed->seqbasep->first;
+ while (seq) {
+ next = seq->next;
+ if (seq != seqm && (seq->flag & SELECT)) {
+ BKE_sequence_invalidate_cache(scene, seq);
+ channel_max = max_ii(seq->machine, channel_max);
+ BLI_remlink(ed->seqbasep, seq);
+ BLI_addtail(&seqm->seqbase, seq);
+ }
+ seq = next;
+ }
+ seqm->machine = last_seq ? last_seq->machine : channel_max;
+ BKE_sequence_calc(scene, seqm);
- seqm->strip = MEM_callocN(sizeof(Strip), "metastrip");
- seqm->strip->us = 1;
+ seqm->strip = MEM_callocN(sizeof(Strip), "metastrip");
+ seqm->strip->us = 1;
- BKE_sequencer_active_set(scene, seqm);
+ BKE_sequencer_active_set(scene, seqm);
- if (BKE_sequence_test_overlap(ed->seqbasep, seqm)) {
- BKE_sequence_base_shuffle(ed->seqbasep, seqm, scene);
- }
+ if (BKE_sequence_test_overlap(ed->seqbasep, seqm)) {
+ BKE_sequence_base_shuffle(ed->seqbasep, seqm, scene);
+ }
- BKE_sequencer_update_muting(ed);
+ BKE_sequencer_update_muting(ed);
- BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seqm);
+ BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seqm);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_meta_make(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Make Meta Strip";
- ot->idname = "SEQUENCER_OT_meta_make";
- ot->description = "Group selected strips into a metastrip";
+ /* identifiers */
+ ot->name = "Make Meta Strip";
+ ot->idname = "SEQUENCER_OT_meta_make";
+ ot->description = "Group selected strips into a metastrip";
- /* api callbacks */
- ot->exec = sequencer_meta_make_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_meta_make_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-
static int seq_depends_on_meta(Sequence *seq, Sequence *seqm)
{
- if (seq == seqm) {
- return 1;
- }
- else if (seq->seq1 && seq_depends_on_meta(seq->seq1, seqm)) {
- return 1;
- }
- else if (seq->seq2 && seq_depends_on_meta(seq->seq2, seqm)) {
- return 1;
- }
- else if (seq->seq3 && seq_depends_on_meta(seq->seq3, seqm)) {
- return 1;
- }
- else {
- return 0;
- }
+ if (seq == seqm) {
+ return 1;
+ }
+ else if (seq->seq1 && seq_depends_on_meta(seq->seq1, seqm)) {
+ return 1;
+ }
+ else if (seq->seq2 && seq_depends_on_meta(seq->seq2, seqm)) {
+ return 1;
+ }
+ else if (seq->seq3 && seq_depends_on_meta(seq->seq3, seqm)) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
}
/* separate_meta_make operator */
static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq, *last_seq = BKE_sequencer_active_get(scene); /* last_seq checks (ed == NULL) */
+ Sequence *seq, *last_seq = BKE_sequencer_active_get(scene); /* last_seq checks (ed == NULL) */
- if (last_seq == NULL || last_seq->type != SEQ_TYPE_META) {
- return OPERATOR_CANCELLED;
- }
+ if (last_seq == NULL || last_seq->type != SEQ_TYPE_META) {
+ return OPERATOR_CANCELLED;
+ }
- for (seq = last_seq->seqbase.first; seq != NULL; seq = seq->next) {
- BKE_sequence_invalidate_cache(scene, seq);
- }
+ for (seq = last_seq->seqbase.first; seq != NULL; seq = seq->next) {
+ BKE_sequence_invalidate_cache(scene, seq);
+ }
- BLI_movelisttolist(ed->seqbasep, &last_seq->seqbase);
+ BLI_movelisttolist(ed->seqbasep, &last_seq->seqbase);
- BLI_listbase_clear(&last_seq->seqbase);
+ BLI_listbase_clear(&last_seq->seqbase);
- BLI_remlink(ed->seqbasep, last_seq);
- BKE_sequence_free(scene, last_seq);
+ BLI_remlink(ed->seqbasep, last_seq);
+ BKE_sequence_free(scene, last_seq);
- /* empty meta strip, delete all effects depending on it */
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if ((seq->type & SEQ_TYPE_EFFECT) && seq_depends_on_meta(seq, last_seq)) {
- seq->flag |= SEQ_FLAG_DELETE;
- }
- }
+ /* empty meta strip, delete all effects depending on it */
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if ((seq->type & SEQ_TYPE_EFFECT) && seq_depends_on_meta(seq, last_seq)) {
+ seq->flag |= SEQ_FLAG_DELETE;
+ }
+ }
- recurs_del_seq_flag(scene, ed->seqbasep, SEQ_FLAG_DELETE, 0);
+ recurs_del_seq_flag(scene, ed->seqbasep, SEQ_FLAG_DELETE, 0);
- /* test for effects and overlap
- * don't use SEQP_BEGIN since that would be recursive */
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SELECT) {
- seq->flag &= ~SEQ_OVERLAP;
- if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
- BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
- }
- }
- }
+ /* test for effects and overlap
+ * don't use SEQP_BEGIN since that would be recursive */
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT) {
+ seq->flag &= ~SEQ_OVERLAP;
+ if (BKE_sequence_test_overlap(ed->seqbasep, seq)) {
+ BKE_sequence_base_shuffle(ed->seqbasep, seq, scene);
+ }
+ }
+ }
- BKE_sequencer_sort(scene);
- BKE_sequencer_update_muting(ed);
+ BKE_sequencer_sort(scene);
+ BKE_sequencer_update_muting(ed);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_meta_separate(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "UnMeta Strip";
- ot->idname = "SEQUENCER_OT_meta_separate";
- ot->description = "Put the contents of a metastrip back in the sequencer";
+ /* identifiers */
+ ot->name = "UnMeta Strip";
+ ot->idname = "SEQUENCER_OT_meta_separate";
+ ot->description = "Put the contents of a metastrip back in the sequencer";
- /* api callbacks */
- ot->exec = sequencer_meta_separate_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_meta_separate_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* view_all operator */
static int sequencer_view_all_exec(bContext *C, wmOperator *op)
{
- ARegion *ar = CTX_wm_region(C);
- View2D *v2d = UI_view2d_fromcontext(C);
- const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+ ARegion *ar = CTX_wm_region(C);
+ View2D *v2d = UI_view2d_fromcontext(C);
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
- UI_view2d_smooth_view(C, ar, &v2d->tot, smooth_viewtx);
- return OPERATOR_FINISHED;
+ UI_view2d_smooth_view(C, ar, &v2d->tot, smooth_viewtx);
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_view_all(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "View All";
- ot->idname = "SEQUENCER_OT_view_all";
- ot->description = "View all the strips in the sequencer";
+ /* identifiers */
+ ot->name = "View All";
+ ot->idname = "SEQUENCER_OT_view_all";
+ ot->description = "View all the strips in the sequencer";
- /* api callbacks */
- ot->exec = sequencer_view_all_exec;
- ot->poll = ED_operator_sequencer_active;
+ /* api callbacks */
+ ot->exec = sequencer_view_all_exec;
+ ot->poll = ED_operator_sequencer_active;
- /* flags */
- ot->flag = OPTYPE_REGISTER;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER;
}
static int sequencer_view_frame_exec(bContext *C, wmOperator *op)
{
- const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
- ANIM_center_frame(C, smooth_viewtx);
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+ ANIM_center_frame(C, smooth_viewtx);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_view_frame(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "View Frame";
- ot->idname = "SEQUENCER_OT_view_frame";
- ot->description = "Reset viewable area to show range around current frame";
+ /* identifiers */
+ ot->name = "View Frame";
+ ot->idname = "SEQUENCER_OT_view_frame";
+ ot->description = "Reset viewable area to show range around current frame";
- /* api callbacks */
- ot->exec = sequencer_view_frame_exec;
- ot->poll = ED_operator_sequencer_active;
+ /* api callbacks */
+ ot->exec = sequencer_view_frame_exec;
+ ot->poll = ED_operator_sequencer_active;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* view_all operator */
static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op))
{
- bScreen *sc = CTX_wm_screen(C);
- ScrArea *area = CTX_wm_area(C);
+ bScreen *sc = CTX_wm_screen(C);
+ ScrArea *area = CTX_wm_area(C);
#if 0
- ARegion *ar = CTX_wm_region(C);
- SpaceSeq *sseq = area->spacedata.first;
- Scene *scene = CTX_data_scene(C);
+ ARegion *ar = CTX_wm_region(C);
+ SpaceSeq *sseq = area->spacedata.first;
+ Scene *scene = CTX_data_scene(C);
#endif
- View2D *v2d = UI_view2d_fromcontext(C);
+ View2D *v2d = UI_view2d_fromcontext(C);
- v2d->cur = v2d->tot;
- UI_view2d_curRect_validate(v2d);
- UI_view2d_sync(sc, area, v2d, V2D_LOCK_COPY);
+ v2d->cur = v2d->tot;
+ UI_view2d_curRect_validate(v2d);
+ UI_view2d_sync(sc, area, v2d, V2D_LOCK_COPY);
#if 0
- /* Like zooming on an image view */
- float zoomX, zoomY;
- int width, height, imgwidth, imgheight;
-
- width = ar->winx;
- height = ar->winy;
-
- seq_reset_imageofs(sseq);
-
- imgwidth = (scene->r.size * scene->r.xsch) / 100;
- imgheight = (scene->r.size * scene->r.ysch) / 100;
-
- /* Apply aspect, dosnt need to be that accurate */
- imgwidth = (int)(imgwidth * (scene->r.xasp / scene->r.yasp));
-
- if (((imgwidth >= width) || (imgheight >= height)) &&
- ((width > 0) && (height > 0)))
- {
- /* Find the zoom value that will fit the image in the image space */
- zoomX = ((float)width) / ((float)imgwidth);
- zoomY = ((float)height) / ((float)imgheight);
- sseq->zoom = (zoomX < zoomY) ? zoomX : zoomY;
-
- sseq->zoom = 1.0f / power_of_2(1 / min_ff(zoomX, zoomY));
- }
- else {
- sseq->zoom = 1.0f;
- }
+ /* Like zooming on an image view */
+ float zoomX, zoomY;
+ int width, height, imgwidth, imgheight;
+
+ width = ar->winx;
+ height = ar->winy;
+
+ seq_reset_imageofs(sseq);
+
+ imgwidth = (scene->r.size * scene->r.xsch) / 100;
+ imgheight = (scene->r.size * scene->r.ysch) / 100;
+
+ /* Apply aspect, dosnt need to be that accurate */
+ imgwidth = (int)(imgwidth * (scene->r.xasp / scene->r.yasp));
+
+ if (((imgwidth >= width) || (imgheight >= height)) &&
+ ((width > 0) && (height > 0)))
+ {
+ /* Find the zoom value that will fit the image in the image space */
+ zoomX = ((float)width) / ((float)imgwidth);
+ zoomY = ((float)height) / ((float)imgheight);
+ sseq->zoom = (zoomX < zoomY) ? zoomX : zoomY;
+
+ sseq->zoom = 1.0f / power_of_2(1 / min_ff(zoomX, zoomY));
+ }
+ else {
+ sseq->zoom = 1.0f;
+ }
#endif
- ED_area_tag_redraw(CTX_wm_area(C));
- return OPERATOR_FINISHED;
+ ED_area_tag_redraw(CTX_wm_area(C));
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_view_all_preview(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "View All";
- ot->idname = "SEQUENCER_OT_view_all_preview";
- ot->description = "Zoom preview to fit in the area";
+ /* identifiers */
+ ot->name = "View All";
+ ot->idname = "SEQUENCER_OT_view_all_preview";
+ ot->description = "Zoom preview to fit in the area";
- /* api callbacks */
- ot->exec = sequencer_view_all_preview_exec;
- ot->poll = ED_operator_sequencer_active;
+ /* api callbacks */
+ ot->exec = sequencer_view_all_preview_exec;
+ ot->poll = ED_operator_sequencer_active;
- /* flags */
- ot->flag = OPTYPE_REGISTER;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER;
}
-
static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op)
{
- RenderData *rd = &CTX_data_scene(C)->r;
- View2D *v2d = UI_view2d_fromcontext(C);
+ RenderData *rd = &CTX_data_scene(C)->r;
+ View2D *v2d = UI_view2d_fromcontext(C);
- float ratio = RNA_float_get(op->ptr, "ratio");
+ float ratio = RNA_float_get(op->ptr, "ratio");
- float winx = (int)(rd->size * rd->xsch) / 100;
- float winy = (int)(rd->size * rd->ysch) / 100;
+ float winx = (int)(rd->size * rd->xsch) / 100;
+ float winy = (int)(rd->size * rd->ysch) / 100;
- float facx = BLI_rcti_size_x(&v2d->mask) / winx;
- float facy = BLI_rcti_size_y(&v2d->mask) / winy;
+ float facx = BLI_rcti_size_x(&v2d->mask) / winx;
+ float facy = BLI_rcti_size_y(&v2d->mask) / winy;
- BLI_rctf_resize(&v2d->cur, ceilf(winx * facx / ratio + 0.5f), ceilf(winy * facy / ratio + 0.5f));
+ BLI_rctf_resize(&v2d->cur, ceilf(winx * facx / ratio + 0.5f), ceilf(winy * facy / ratio + 0.5f));
- ED_region_tag_redraw(CTX_wm_region(C));
+ ED_region_tag_redraw(CTX_wm_region(C));
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_view_zoom_ratio(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Sequencer View Zoom Ratio";
- ot->idname = "SEQUENCER_OT_view_zoom_ratio";
- ot->description = "Change zoom ratio of sequencer preview";
+ /* identifiers */
+ ot->name = "Sequencer View Zoom Ratio";
+ ot->idname = "SEQUENCER_OT_view_zoom_ratio";
+ ot->description = "Change zoom ratio of sequencer preview";
- /* api callbacks */
- ot->exec = sequencer_view_zoom_ratio_exec;
- ot->poll = ED_operator_sequencer_active;
+ /* api callbacks */
+ ot->exec = sequencer_view_zoom_ratio_exec;
+ ot->poll = ED_operator_sequencer_active;
- /* properties */
- RNA_def_float(ot->srna, "ratio", 1.0f, -FLT_MAX, FLT_MAX,
- "Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX);
+ /* properties */
+ RNA_def_float(ot->srna,
+ "ratio",
+ 1.0f,
+ -FLT_MAX,
+ FLT_MAX,
+ "Ratio",
+ "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out",
+ -FLT_MAX,
+ FLT_MAX);
}
-
#if 0
static const EnumPropertyItem view_type_items[] = {
- {SEQ_VIEW_SEQUENCE, "SEQUENCER", ICON_SEQ_SEQUENCER, "Sequencer", ""},
- {SEQ_VIEW_PREVIEW, "PREVIEW", ICON_SEQ_PREVIEW, "Image Preview", ""},
- {SEQ_VIEW_SEQUENCE_PREVIEW, "SEQUENCER_PREVIEW", ICON_SEQ_SEQUENCER, "Sequencer and Image Preview", ""},
- {0, NULL, 0, NULL, NULL},
+ {SEQ_VIEW_SEQUENCE, "SEQUENCER", ICON_SEQ_SEQUENCER, "Sequencer", ""},
+ {SEQ_VIEW_PREVIEW, "PREVIEW", ICON_SEQ_PREVIEW, "Image Preview", ""},
+ {SEQ_VIEW_SEQUENCE_PREVIEW, "SEQUENCER_PREVIEW", ICON_SEQ_SEQUENCER, "Sequencer and Image Preview", ""},
+ {0, NULL, 0, NULL, NULL},
};
#endif
/* view_all operator */
static int sequencer_view_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
- SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C);
+ SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C);
- sseq->view++;
- if (sseq->view > SEQ_VIEW_SEQUENCE_PREVIEW) {
- sseq->view = SEQ_VIEW_SEQUENCE;
- }
+ sseq->view++;
+ if (sseq->view > SEQ_VIEW_SEQUENCE_PREVIEW) {
+ sseq->view = SEQ_VIEW_SEQUENCE;
+ }
- ED_area_tag_refresh(CTX_wm_area(C));
+ ED_area_tag_refresh(CTX_wm_area(C));
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_view_toggle(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "View Toggle";
- ot->idname = "SEQUENCER_OT_view_toggle";
- ot->description = "Toggle between sequencer views (sequence, preview, both)";
+ /* identifiers */
+ ot->name = "View Toggle";
+ ot->idname = "SEQUENCER_OT_view_toggle";
+ ot->description = "Toggle between sequencer views (sequence, preview, both)";
- /* api callbacks */
- ot->exec = sequencer_view_toggle_exec;
- ot->poll = ED_operator_sequencer_active;
+ /* api callbacks */
+ ot->exec = sequencer_view_toggle_exec;
+ ot->poll = ED_operator_sequencer_active;
- /* flags */
- ot->flag = OPTYPE_REGISTER;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER;
}
-
/* view_selected operator */
static int sequencer_view_selected_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- View2D *v2d = UI_view2d_fromcontext(C);
- ARegion *ar = CTX_wm_region(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *last_seq = BKE_sequencer_active_get(scene);
- Sequence *seq;
- rctf cur_new = v2d->cur;
-
- int xmin = MAXFRAME * 2;
- int xmax = -MAXFRAME * 2;
- int ymin = MAXSEQ + 1;
- int ymax = 0;
- int orig_height;
- int ymid;
- int ymargin = 1;
- int xmargin = FPS;
+ Scene *scene = CTX_data_scene(C);
+ View2D *v2d = UI_view2d_fromcontext(C);
+ ARegion *ar = CTX_wm_region(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *last_seq = BKE_sequencer_active_get(scene);
+ Sequence *seq;
+ rctf cur_new = v2d->cur;
- if (ed == NULL) {
- return OPERATOR_CANCELLED;
- }
+ int xmin = MAXFRAME * 2;
+ int xmax = -MAXFRAME * 2;
+ int ymin = MAXSEQ + 1;
+ int ymax = 0;
+ int orig_height;
+ int ymid;
+ int ymargin = 1;
+ int xmargin = FPS;
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if ((seq->flag & SELECT) || (seq == last_seq)) {
- xmin = min_ii(xmin, seq->startdisp);
- xmax = max_ii(xmax, seq->enddisp);
+ if (ed == NULL) {
+ return OPERATOR_CANCELLED;
+ }
- ymin = min_ii(ymin, seq->machine);
- ymax = max_ii(ymax, seq->machine);
- }
- }
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if ((seq->flag & SELECT) || (seq == last_seq)) {
+ xmin = min_ii(xmin, seq->startdisp);
+ xmax = max_ii(xmax, seq->enddisp);
- if (ymax != 0) {
- const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+ ymin = min_ii(ymin, seq->machine);
+ ymax = max_ii(ymax, seq->machine);
+ }
+ }
- xmax += xmargin;
- xmin -= xmargin;
- ymax += ymargin;
- ymin -= ymargin;
+ if (ymax != 0) {
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
- orig_height = BLI_rctf_size_y(&cur_new);
+ xmax += xmargin;
+ xmin -= xmargin;
+ ymax += ymargin;
+ ymin -= ymargin;
- cur_new.xmin = xmin;
- cur_new.xmax = xmax;
+ orig_height = BLI_rctf_size_y(&cur_new);
- cur_new.ymin = ymin;
- cur_new.ymax = ymax;
+ cur_new.xmin = xmin;
+ cur_new.xmax = xmax;
- /* only zoom out vertically */
- if (orig_height > BLI_rctf_size_y(&cur_new)) {
- ymid = BLI_rctf_cent_y(&cur_new);
+ cur_new.ymin = ymin;
+ cur_new.ymax = ymax;
- cur_new.ymin = ymid - (orig_height / 2);
- cur_new.ymax = ymid + (orig_height / 2);
- }
+ /* only zoom out vertically */
+ if (orig_height > BLI_rctf_size_y(&cur_new)) {
+ ymid = BLI_rctf_cent_y(&cur_new);
- UI_view2d_smooth_view(C, ar, &cur_new, smooth_viewtx);
+ cur_new.ymin = ymid - (orig_height / 2);
+ cur_new.ymax = ymid + (orig_height / 2);
+ }
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
+ UI_view2d_smooth_view(C, ar, &cur_new, smooth_viewtx);
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
}
void SEQUENCER_OT_view_selected(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "View Selected";
- ot->idname = "SEQUENCER_OT_view_selected";
- ot->description = "Zoom the sequencer on the selected strips";
+ /* identifiers */
+ ot->name = "View Selected";
+ ot->idname = "SEQUENCER_OT_view_selected";
+ ot->description = "Zoom the sequencer on the selected strips";
- /* api callbacks */
- ot->exec = sequencer_view_selected_exec;
- ot->poll = ED_operator_sequencer_active;
+ /* api callbacks */
+ ot->exec = sequencer_view_selected_exec;
+ ot->poll = ED_operator_sequencer_active;
- /* flags */
- ot->flag = OPTYPE_REGISTER;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER;
}
static bool strip_jump_internal(Scene *scene,
const short side,
- const bool do_skip_mute, const bool do_center)
+ const bool do_skip_mute,
+ const bool do_center)
{
- bool changed = false;
- int cfra = CFRA;
- int nfra = BKE_sequencer_find_next_prev_edit(scene, cfra, side, do_skip_mute, do_center, false);
+ bool changed = false;
+ int cfra = CFRA;
+ int nfra = BKE_sequencer_find_next_prev_edit(scene, cfra, side, do_skip_mute, do_center, false);
- if (nfra != cfra) {
- CFRA = nfra;
- changed = true;
- }
+ if (nfra != cfra) {
+ CFRA = nfra;
+ changed = true;
+ }
- return changed;
+ return changed;
}
static bool sequencer_strip_jump_poll(bContext *C)
{
- /* prevent changes during render */
- if (G.is_rendering) {
- return 0;
- }
+ /* prevent changes during render */
+ if (G.is_rendering) {
+ return 0;
+ }
- return sequencer_edit_poll(C);
+ return sequencer_edit_poll(C);
}
/* jump frame to edit point operator */
static int sequencer_strip_jump_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- const bool next = RNA_boolean_get(op->ptr, "next");
- const bool center = RNA_boolean_get(op->ptr, "center");
+ Scene *scene = CTX_data_scene(C);
+ const bool next = RNA_boolean_get(op->ptr, "next");
+ const bool center = RNA_boolean_get(op->ptr, "center");
- /* currently do_skip_mute is always true */
- if (!strip_jump_internal(scene, next ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT, true, center)) {
- return OPERATOR_CANCELLED;
- }
+ /* currently do_skip_mute is always true */
+ if (!strip_jump_internal(scene, next ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT, true, center)) {
+ return OPERATOR_CANCELLED;
+ }
- WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_strip_jump(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Jump to Strip";
- ot->idname = "SEQUENCER_OT_strip_jump";
- ot->description = "Move frame to previous edit point";
+ /* identifiers */
+ ot->name = "Jump to Strip";
+ ot->idname = "SEQUENCER_OT_strip_jump";
+ ot->description = "Move frame to previous edit point";
- /* api callbacks */
- ot->exec = sequencer_strip_jump_exec;
- ot->poll = sequencer_strip_jump_poll;
+ /* api callbacks */
+ ot->exec = sequencer_strip_jump_exec;
+ ot->poll = sequencer_strip_jump_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
- RNA_def_boolean(ot->srna, "next", true, "Next Strip", "");
- RNA_def_boolean(ot->srna, "center", true, "Use strip center", "");
+ /* properties */
+ RNA_def_boolean(ot->srna, "next", true, "Next Strip", "");
+ RNA_def_boolean(ot->srna, "center", true, "Use strip center", "");
}
static void swap_sequence(Scene *scene, Sequence *seqa, Sequence *seqb)
{
- int gap = seqb->startdisp - seqa->enddisp;
- int seq_a_start;
- int seq_b_start;
+ int gap = seqb->startdisp - seqa->enddisp;
+ int seq_a_start;
+ int seq_b_start;
- seq_b_start = (seqb->start - seqb->startdisp) + seqa->startdisp;
- BKE_sequence_translate(scene, seqb, seq_b_start - seqb->start);
- BKE_sequence_calc(scene, seqb);
+ seq_b_start = (seqb->start - seqb->startdisp) + seqa->startdisp;
+ BKE_sequence_translate(scene, seqb, seq_b_start - seqb->start);
+ BKE_sequence_calc(scene, seqb);
- seq_a_start = (seqa->start - seqa->startdisp) + seqb->enddisp + gap;
- BKE_sequence_translate(scene, seqa, seq_a_start - seqa->start);
- BKE_sequence_calc(scene, seqa);
+ seq_a_start = (seqa->start - seqa->startdisp) + seqb->enddisp + gap;
+ BKE_sequence_translate(scene, seqa, seq_a_start - seqa->start);
+ BKE_sequence_calc(scene, seqa);
}
#if 0
static Sequence *sequence_find_parent(Scene *scene, Sequence *child)
{
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *parent = NULL;
- Sequence *seq;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *parent = NULL;
+ Sequence *seq;
- if (ed == NULL) return NULL;
+ if (ed == NULL) return NULL;
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if ((seq != child) && seq_is_parent(seq, child)) {
- parent = seq;
- break;
- }
- }
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if ((seq != child) && seq_is_parent(seq, child)) {
+ parent = seq;
+ break;
+ }
+ }
- return parent;
+ return parent;
}
#endif
static int sequencer_swap_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *active_seq = BKE_sequencer_active_get(scene);
- Sequence *seq, *iseq;
- int side = RNA_enum_get(op->ptr, "side");
-
- if (active_seq == NULL) {
- return OPERATOR_CANCELLED;
- }
-
- seq = find_next_prev_sequence(scene, active_seq, side, -1);
-
- if (seq) {
-
- /* disallow effect strips */
- if (BKE_sequence_effect_get_num_inputs(seq->type) >= 1 && (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3)) {
- return OPERATOR_CANCELLED;
- }
- if ((BKE_sequence_effect_get_num_inputs(active_seq->type) >= 1) && (active_seq->effectdata || active_seq->seq1 || active_seq->seq2 || active_seq->seq3)) {
- return OPERATOR_CANCELLED;
- }
-
- switch (side) {
- case SEQ_SIDE_LEFT:
- swap_sequence(scene, seq, active_seq);
- break;
- case SEQ_SIDE_RIGHT:
- swap_sequence(scene, active_seq, seq);
- break;
- }
-
- // XXX - should be a generic function
- for (iseq = scene->ed->seqbasep->first; iseq; iseq = iseq->next) {
- if ((iseq->type & SEQ_TYPE_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) {
- BKE_sequence_calc(scene, iseq);
- }
- }
-
- /* do this in a new loop since both effects need to be calculated first */
- for (iseq = scene->ed->seqbasep->first; iseq; iseq = iseq->next) {
- if ((iseq->type & SEQ_TYPE_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) {
- /* this may now overlap */
- if (BKE_sequence_test_overlap(ed->seqbasep, iseq) ) {
- BKE_sequence_base_shuffle(ed->seqbasep, iseq, scene);
- }
- }
- }
-
-
-
- BKE_sequencer_sort(scene);
-
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- return OPERATOR_FINISHED;
- }
-
- return OPERATOR_CANCELLED;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *active_seq = BKE_sequencer_active_get(scene);
+ Sequence *seq, *iseq;
+ int side = RNA_enum_get(op->ptr, "side");
+
+ if (active_seq == NULL) {
+ return OPERATOR_CANCELLED;
+ }
+
+ seq = find_next_prev_sequence(scene, active_seq, side, -1);
+
+ if (seq) {
+
+ /* disallow effect strips */
+ if (BKE_sequence_effect_get_num_inputs(seq->type) >= 1 &&
+ (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3)) {
+ return OPERATOR_CANCELLED;
+ }
+ if ((BKE_sequence_effect_get_num_inputs(active_seq->type) >= 1) &&
+ (active_seq->effectdata || active_seq->seq1 || active_seq->seq2 || active_seq->seq3)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ switch (side) {
+ case SEQ_SIDE_LEFT:
+ swap_sequence(scene, seq, active_seq);
+ break;
+ case SEQ_SIDE_RIGHT:
+ swap_sequence(scene, active_seq, seq);
+ break;
+ }
+
+ // XXX - should be a generic function
+ for (iseq = scene->ed->seqbasep->first; iseq; iseq = iseq->next) {
+ if ((iseq->type & SEQ_TYPE_EFFECT) &&
+ (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) {
+ BKE_sequence_calc(scene, iseq);
+ }
+ }
+
+ /* do this in a new loop since both effects need to be calculated first */
+ for (iseq = scene->ed->seqbasep->first; iseq; iseq = iseq->next) {
+ if ((iseq->type & SEQ_TYPE_EFFECT) &&
+ (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) {
+ /* this may now overlap */
+ if (BKE_sequence_test_overlap(ed->seqbasep, iseq)) {
+ BKE_sequence_base_shuffle(ed->seqbasep, iseq, scene);
+ }
+ }
+ }
+
+ BKE_sequencer_sort(scene);
+
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+
+ return OPERATOR_FINISHED;
+ }
+
+ return OPERATOR_CANCELLED;
}
void SEQUENCER_OT_swap(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Swap Strip";
- ot->idname = "SEQUENCER_OT_swap";
- ot->description = "Swap active strip with strip to the right or left";
+ /* identifiers */
+ ot->name = "Swap Strip";
+ ot->idname = "SEQUENCER_OT_swap";
+ ot->description = "Swap active strip with strip to the right or left";
- /* api callbacks */
- ot->exec = sequencer_swap_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_swap_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
- RNA_def_enum(ot->srna, "side", prop_side_lr_types, SEQ_SIDE_RIGHT, "Side", "Side of the strip to swap");
+ /* properties */
+ RNA_def_enum(
+ ot->srna, "side", prop_side_lr_types, SEQ_SIDE_RIGHT, "Side", "Side of the strip to swap");
}
static int sequencer_rendersize_exec(bContext *C, wmOperator *UNUSED(op))
{
- int retval = OPERATOR_CANCELLED;
- Scene *scene = CTX_data_scene(C);
- Sequence *active_seq = BKE_sequencer_active_get(scene);
- StripElem *se = NULL;
-
- if (active_seq == NULL) {
- return OPERATOR_CANCELLED;
- }
-
-
- if (active_seq->strip) {
- switch (active_seq->type) {
- case SEQ_TYPE_IMAGE:
- se = BKE_sequencer_give_stripelem(active_seq, scene->r.cfra);
- break;
- case SEQ_TYPE_MOVIE:
- se = active_seq->strip->stripdata;
- break;
- case SEQ_TYPE_SCENE:
- case SEQ_TYPE_META:
- case SEQ_TYPE_SOUND_RAM:
- case SEQ_TYPE_SOUND_HD:
- default:
- break;
- }
- }
-
- if (se) {
- // prevent setting the render size if sequence values aren't initialized
- if ((se->orig_width > 0) && (se->orig_height > 0)) {
- scene->r.xsch = se->orig_width;
- scene->r.ysch = se->orig_height;
- WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
- retval = OPERATOR_FINISHED;
- }
- }
-
- return retval;
+ int retval = OPERATOR_CANCELLED;
+ Scene *scene = CTX_data_scene(C);
+ Sequence *active_seq = BKE_sequencer_active_get(scene);
+ StripElem *se = NULL;
+
+ if (active_seq == NULL) {
+ return OPERATOR_CANCELLED;
+ }
+
+ if (active_seq->strip) {
+ switch (active_seq->type) {
+ case SEQ_TYPE_IMAGE:
+ se = BKE_sequencer_give_stripelem(active_seq, scene->r.cfra);
+ break;
+ case SEQ_TYPE_MOVIE:
+ se = active_seq->strip->stripdata;
+ break;
+ case SEQ_TYPE_SCENE:
+ case SEQ_TYPE_META:
+ case SEQ_TYPE_SOUND_RAM:
+ case SEQ_TYPE_SOUND_HD:
+ default:
+ break;
+ }
+ }
+
+ if (se) {
+ // prevent setting the render size if sequence values aren't initialized
+ if ((se->orig_width > 0) && (se->orig_height > 0)) {
+ scene->r.xsch = se->orig_width;
+ scene->r.ysch = se->orig_height;
+ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
+ retval = OPERATOR_FINISHED;
+ }
+ }
+
+ return retval;
}
void SEQUENCER_OT_rendersize(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Set Render Size";
- ot->idname = "SEQUENCER_OT_rendersize";
- ot->description = "Set render size and aspect from active sequence";
+ /* identifiers */
+ ot->name = "Set Render Size";
+ ot->idname = "SEQUENCER_OT_rendersize";
+ ot->description = "Set render size and aspect from active sequence";
- /* api callbacks */
- ot->exec = sequencer_rendersize_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_rendersize_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
+ /* properties */
}
static void seq_copy_del_sound(Scene *scene, Sequence *seq)
{
- if (seq->type == SEQ_TYPE_META) {
- Sequence *iseq;
- for (iseq = seq->seqbase.first; iseq; iseq = iseq->next) {
- seq_copy_del_sound(scene, iseq);
- }
- }
- else if (seq->scene_sound) {
- BKE_sound_remove_scene_sound(scene, seq->scene_sound);
- seq->scene_sound = NULL;
- }
+ if (seq->type == SEQ_TYPE_META) {
+ Sequence *iseq;
+ for (iseq = seq->seqbase.first; iseq; iseq = iseq->next) {
+ seq_copy_del_sound(scene, iseq);
+ }
+ }
+ else if (seq->scene_sound) {
+ BKE_sound_remove_scene_sound(scene, seq->scene_sound);
+ seq->scene_sound = NULL;
+ }
}
static int sequencer_copy_exec(bContext *C, wmOperator *op)
{
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
- ListBase nseqbase = {NULL, NULL};
+ ListBase nseqbase = {NULL, NULL};
- BKE_sequencer_free_clipboard();
+ BKE_sequencer_free_clipboard();
- if (BKE_sequence_base_isolated_sel_check(ed->seqbasep) == false) {
- BKE_report(op->reports, RPT_ERROR, "Please select all related strips");
- return OPERATOR_CANCELLED;
- }
+ if (BKE_sequence_base_isolated_sel_check(ed->seqbasep) == false) {
+ BKE_report(op->reports, RPT_ERROR, "Please select all related strips");
+ return OPERATOR_CANCELLED;
+ }
- BKE_sequence_base_dupli_recursive(scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME, LIB_ID_CREATE_NO_USER_REFCOUNT);
+ BKE_sequence_base_dupli_recursive(
+ scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME, LIB_ID_CREATE_NO_USER_REFCOUNT);
- /* To make sure the copied strips have unique names between each other add
- * them temporarily to the end of the original seqbase. (bug 25932)
- */
- if (nseqbase.first) {
- Sequence *seq, *first_seq = nseqbase.first;
- BLI_movelisttolist(ed->seqbasep, &nseqbase);
+ /* To make sure the copied strips have unique names between each other add
+ * them temporarily to the end of the original seqbase. (bug 25932)
+ */
+ if (nseqbase.first) {
+ Sequence *seq, *first_seq = nseqbase.first;
+ BLI_movelisttolist(ed->seqbasep, &nseqbase);
- for (seq = first_seq; seq; seq = seq->next) {
- BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene);
- }
+ for (seq = first_seq; seq; seq = seq->next) {
+ BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene);
+ }
- seqbase_clipboard.first = first_seq;
- seqbase_clipboard.last = ed->seqbasep->last;
+ seqbase_clipboard.first = first_seq;
+ seqbase_clipboard.last = ed->seqbasep->last;
- if (first_seq->prev) {
- first_seq->prev->next = NULL;
- ed->seqbasep->last = first_seq->prev;
- first_seq->prev = NULL;
- }
- }
+ if (first_seq->prev) {
+ first_seq->prev->next = NULL;
+ ed->seqbasep->last = first_seq->prev;
+ first_seq->prev = NULL;
+ }
+ }
- seqbase_clipboard_frame = scene->r.cfra;
+ seqbase_clipboard_frame = scene->r.cfra;
- /* Need to remove anything that references the current scene */
- for (Sequence *seq = seqbase_clipboard.first; seq; seq = seq->next) {
- seq_copy_del_sound(scene, seq);
- }
+ /* Need to remove anything that references the current scene */
+ for (Sequence *seq = seqbase_clipboard.first; seq; seq = seq->next) {
+ seq_copy_del_sound(scene, seq);
+ }
- /* Replace datablock pointers with copies, to keep things working in case
- * datablocks get deleted or another .blend file is opened. */
- BKE_sequencer_base_clipboard_pointers_store(bmain, &seqbase_clipboard);
+ /* Replace datablock pointers with copies, to keep things working in case
+ * datablocks get deleted or another .blend file is opened. */
+ BKE_sequencer_base_clipboard_pointers_store(bmain, &seqbase_clipboard);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_copy(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Copy";
- ot->idname = "SEQUENCER_OT_copy";
+ /* identifiers */
+ ot->name = "Copy";
+ ot->idname = "SEQUENCER_OT_copy";
- /* api callbacks */
- ot->exec = sequencer_copy_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_copy_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER;
- /* properties */
+ /* properties */
}
static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op))
{
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, true); /* create if needed */
- ListBase nseqbase = {NULL, NULL};
- int ofs;
- Sequence *iseq, *iseq_first;
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, true); /* create if needed */
+ ListBase nseqbase = {NULL, NULL};
+ int ofs;
+ Sequence *iseq, *iseq_first;
- ED_sequencer_deselect_all(scene);
- ofs = scene->r.cfra - seqbase_clipboard_frame;
+ ED_sequencer_deselect_all(scene);
+ ofs = scene->r.cfra - seqbase_clipboard_frame;
- /* Copy strips, temporarily restoring pointers to actual datablocks. This
- * must happen on the clipboard itself, so that copying does user counting
- * on the actual datablocks. */
- BKE_sequencer_base_clipboard_pointers_restore(&seqbase_clipboard, bmain);
- BKE_sequence_base_dupli_recursive(scene, scene, &nseqbase, &seqbase_clipboard, SEQ_DUPE_UNIQUE_NAME, 0);
- BKE_sequencer_base_clipboard_pointers_store(bmain, &seqbase_clipboard);
+ /* Copy strips, temporarily restoring pointers to actual datablocks. This
+ * must happen on the clipboard itself, so that copying does user counting
+ * on the actual datablocks. */
+ BKE_sequencer_base_clipboard_pointers_restore(&seqbase_clipboard, bmain);
+ BKE_sequence_base_dupli_recursive(
+ scene, scene, &nseqbase, &seqbase_clipboard, SEQ_DUPE_UNIQUE_NAME, 0);
+ BKE_sequencer_base_clipboard_pointers_store(bmain, &seqbase_clipboard);
- /* transform pasted strips before adding */
- if (ofs) {
- for (iseq = nseqbase.first; iseq; iseq = iseq->next) {
- BKE_sequence_translate(scene, iseq, ofs);
- }
- }
+ /* transform pasted strips before adding */
+ if (ofs) {
+ for (iseq = nseqbase.first; iseq; iseq = iseq->next) {
+ BKE_sequence_translate(scene, iseq, ofs);
+ }
+ }
- for (iseq = nseqbase.first; iseq; iseq = iseq->next) {
- BKE_sequence_sound_init(scene, iseq);
- }
+ for (iseq = nseqbase.first; iseq; iseq = iseq->next) {
+ BKE_sequence_sound_init(scene, iseq);
+ }
- iseq_first = nseqbase.first;
+ iseq_first = nseqbase.first;
- BLI_movelisttolist(ed->seqbasep, &nseqbase);
+ BLI_movelisttolist(ed->seqbasep, &nseqbase);
- /* make sure the pasted strips have unique names between them */
- for (iseq = iseq_first; iseq; iseq = iseq->next) {
- BKE_sequencer_recursive_apply(iseq, apply_unique_name_cb, scene);
- }
+ /* make sure the pasted strips have unique names between them */
+ for (iseq = iseq_first; iseq; iseq = iseq->next) {
+ BKE_sequencer_recursive_apply(iseq, apply_unique_name_cb, scene);
+ }
- /* ensure pasted strips don't overlap */
- for (iseq = iseq_first; iseq; iseq = iseq->next) {
- if (BKE_sequence_test_overlap(ed->seqbasep, iseq)) {
- BKE_sequence_base_shuffle(ed->seqbasep, iseq, scene);
- }
- }
+ /* ensure pasted strips don't overlap */
+ for (iseq = iseq_first; iseq; iseq = iseq->next) {
+ if (BKE_sequence_test_overlap(ed->seqbasep, iseq)) {
+ BKE_sequence_base_shuffle(ed->seqbasep, iseq, scene);
+ }
+ }
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_paste(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Paste";
- ot->idname = "SEQUENCER_OT_paste";
+ /* identifiers */
+ ot->name = "Paste";
+ ot->idname = "SEQUENCER_OT_paste";
- /* api callbacks */
- ot->exec = sequencer_paste_exec;
- ot->poll = ED_operator_sequencer_active;
+ /* api callbacks */
+ ot->exec = sequencer_paste_exec;
+ ot->poll = ED_operator_sequencer_active;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
+ /* properties */
}
static int sequencer_swap_data_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Sequence *seq_act;
- Sequence *seq_other;
- const char *error_msg;
+ Scene *scene = CTX_data_scene(C);
+ Sequence *seq_act;
+ Sequence *seq_other;
+ const char *error_msg;
- if (BKE_sequencer_active_get_pair(scene, &seq_act, &seq_other) == 0) {
- BKE_report(op->reports, RPT_ERROR, "Please select two strips");
- return OPERATOR_CANCELLED;
- }
+ if (BKE_sequencer_active_get_pair(scene, &seq_act, &seq_other) == 0) {
+ BKE_report(op->reports, RPT_ERROR, "Please select two strips");
+ return OPERATOR_CANCELLED;
+ }
- if (BKE_sequence_swap(seq_act, seq_other, &error_msg) == 0) {
- BKE_report(op->reports, RPT_ERROR, error_msg);
- return OPERATOR_CANCELLED;
- }
+ if (BKE_sequence_swap(seq_act, seq_other, &error_msg) == 0) {
+ BKE_report(op->reports, RPT_ERROR, error_msg);
+ return OPERATOR_CANCELLED;
+ }
- if (seq_act->scene_sound) {
- BKE_sound_remove_scene_sound(scene, seq_act->scene_sound);
- }
+ if (seq_act->scene_sound) {
+ BKE_sound_remove_scene_sound(scene, seq_act->scene_sound);
+ }
- if (seq_other->scene_sound) {
- BKE_sound_remove_scene_sound(scene, seq_other->scene_sound);
- }
+ if (seq_other->scene_sound) {
+ BKE_sound_remove_scene_sound(scene, seq_other->scene_sound);
+ }
- seq_act->scene_sound = NULL;
- seq_other->scene_sound = NULL;
+ seq_act->scene_sound = NULL;
+ seq_other->scene_sound = NULL;
- BKE_sequence_calc(scene, seq_act);
- BKE_sequence_calc(scene, seq_other);
+ BKE_sequence_calc(scene, seq_act);
+ BKE_sequence_calc(scene, seq_other);
- if (seq_act->sound) {
- BKE_sound_add_scene_sound_defaults(scene, seq_act);
- }
- if (seq_other->sound) {
- BKE_sound_add_scene_sound_defaults(scene, seq_other);
- }
+ if (seq_act->sound) {
+ BKE_sound_add_scene_sound_defaults(scene, seq_act);
+ }
+ if (seq_other->sound) {
+ BKE_sound_add_scene_sound_defaults(scene, seq_other);
+ }
- BKE_sequence_invalidate_cache(scene, seq_act);
- BKE_sequence_invalidate_cache(scene, seq_other);
+ BKE_sequence_invalidate_cache(scene, seq_act);
+ BKE_sequence_invalidate_cache(scene, seq_other);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_swap_data(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Sequencer Swap Data";
- ot->idname = "SEQUENCER_OT_swap_data";
- ot->description = "Swap 2 sequencer strips";
+ /* identifiers */
+ ot->name = "Sequencer Swap Data";
+ ot->idname = "SEQUENCER_OT_swap_data";
+ ot->description = "Swap 2 sequencer strips";
- /* api callbacks */
- ot->exec = sequencer_swap_data_exec;
- ot->poll = ED_operator_sequencer_active;
+ /* api callbacks */
+ ot->exec = sequencer_swap_data_exec;
+ ot->poll = ED_operator_sequencer_active;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
+ /* properties */
}
/* box select operator */
static int view_ghost_border_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- View2D *v2d = UI_view2d_fromcontext(C);
+ Scene *scene = CTX_data_scene(C);
+ View2D *v2d = UI_view2d_fromcontext(C);
- rctf rect;
+ rctf rect;
- /* convert coordinates of rect to 'tot' rect coordinates */
- WM_operator_properties_border_to_rctf(op, &rect);
- UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
+ /* convert coordinates of rect to 'tot' rect coordinates */
+ WM_operator_properties_border_to_rctf(op, &rect);
+ UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
- rect.xmin /= fabsf(BLI_rctf_size_x(&v2d->tot));
- rect.ymin /= fabsf(BLI_rctf_size_y(&v2d->tot));
+ rect.xmin /= fabsf(BLI_rctf_size_x(&v2d->tot));
+ rect.ymin /= fabsf(BLI_rctf_size_y(&v2d->tot));
- rect.xmax /= fabsf(BLI_rctf_size_x(&v2d->tot));
- rect.ymax /= fabsf(BLI_rctf_size_y(&v2d->tot));
+ rect.xmax /= fabsf(BLI_rctf_size_x(&v2d->tot));
+ rect.ymax /= fabsf(BLI_rctf_size_y(&v2d->tot));
- rect.xmin += 0.5f;
- rect.xmax += 0.5f;
- rect.ymin += 0.5f;
- rect.ymax += 0.5f;
+ rect.xmin += 0.5f;
+ rect.xmax += 0.5f;
+ rect.ymin += 0.5f;
+ rect.ymax += 0.5f;
- CLAMP(rect.xmin, 0.0f, 1.0f);
- CLAMP(rect.ymin, 0.0f, 1.0f);
- CLAMP(rect.xmax, 0.0f, 1.0f);
- CLAMP(rect.ymax, 0.0f, 1.0f);
+ CLAMP(rect.xmin, 0.0f, 1.0f);
+ CLAMP(rect.ymin, 0.0f, 1.0f);
+ CLAMP(rect.xmax, 0.0f, 1.0f);
+ CLAMP(rect.ymax, 0.0f, 1.0f);
- scene->ed->over_border = rect;
+ scene->ed->over_border = rect;
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
/* ****** Box Select ****** */
void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Border Offset View";
- ot->idname = "SEQUENCER_OT_view_ghost_border";
- ot->description = "Set the boundaries of the border used for offset-view";
+ /* identifiers */
+ ot->name = "Border Offset View";
+ ot->idname = "SEQUENCER_OT_view_ghost_border";
+ ot->description = "Set the boundaries of the border used for offset-view";
- /* api callbacks */
- ot->invoke = WM_gesture_box_invoke;
- ot->exec = view_ghost_border_exec;
- ot->modal = WM_gesture_box_modal;
- ot->poll = sequencer_view_preview_poll;
- ot->cancel = WM_gesture_box_cancel;
+ /* api callbacks */
+ ot->invoke = WM_gesture_box_invoke;
+ ot->exec = view_ghost_border_exec;
+ ot->modal = WM_gesture_box_modal;
+ ot->poll = sequencer_view_preview_poll;
+ ot->cancel = WM_gesture_box_cancel;
- /* flags */
- ot->flag = 0;
+ /* flags */
+ ot->flag = 0;
- /* rna */
- WM_operator_properties_gesture_box(ot);
+ /* rna */
+ WM_operator_properties_gesture_box(ot);
}
/* rebuild_proxy operator */
-static int sequencer_rebuild_proxy_invoke(bContext *C, wmOperator *UNUSED(op),
+static int sequencer_rebuild_proxy_invoke(bContext *C,
+ wmOperator *UNUSED(op),
const wmEvent *UNUSED(event))
{
- seq_proxy_build_job(C);
+ seq_proxy_build_job(C);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
{
- Main *bmain = CTX_data_main(C);
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
- GSet *file_list;
+ Main *bmain = CTX_data_main(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+ GSet *file_list;
- if (ed == NULL) {
- return OPERATOR_CANCELLED;
- }
+ if (ed == NULL) {
+ return OPERATOR_CANCELLED;
+ }
- file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
+ file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
- SEQP_BEGIN(ed, seq)
- {
- if ((seq->flag & SELECT)) {
- ListBase queue = {NULL, NULL};
- LinkData *link;
- short stop = 0, do_update;
- float progress;
+ SEQP_BEGIN (ed, seq) {
+ if ((seq->flag & SELECT)) {
+ ListBase queue = {NULL, NULL};
+ LinkData *link;
+ short stop = 0, do_update;
+ float progress;
- BKE_sequencer_proxy_rebuild_context(bmain, depsgraph, scene, seq, file_list, &queue);
+ BKE_sequencer_proxy_rebuild_context(bmain, depsgraph, scene, seq, file_list, &queue);
- for (link = queue.first; link; link = link->next) {
- struct SeqIndexBuildContext *context = link->data;
- BKE_sequencer_proxy_rebuild(context, &stop, &do_update, &progress);
- BKE_sequencer_proxy_rebuild_finish(context, 0);
- }
- BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
- }
- } SEQ_END;
+ for (link = queue.first; link; link = link->next) {
+ struct SeqIndexBuildContext *context = link->data;
+ BKE_sequencer_proxy_rebuild(context, &stop, &do_update, &progress);
+ BKE_sequencer_proxy_rebuild_finish(context, 0);
+ }
+ BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
+ }
+ }
+ SEQ_END;
- BLI_gset_free(file_list, MEM_freeN);
+ BLI_gset_free(file_list, MEM_freeN);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_rebuild_proxy(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Rebuild Proxy and Timecode Indices";
- ot->idname = "SEQUENCER_OT_rebuild_proxy";
- ot->description = "Rebuild all selected proxies and timecode indices using the job system";
+ /* identifiers */
+ ot->name = "Rebuild Proxy and Timecode Indices";
+ ot->idname = "SEQUENCER_OT_rebuild_proxy";
+ ot->description = "Rebuild all selected proxies and timecode indices using the job system";
- /* api callbacks */
- ot->invoke = sequencer_rebuild_proxy_invoke;
- ot->exec = sequencer_rebuild_proxy_exec;
+ /* api callbacks */
+ ot->invoke = sequencer_rebuild_proxy_invoke;
+ ot->exec = sequencer_rebuild_proxy_exec;
- /* flags */
- ot->flag = OPTYPE_REGISTER;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER;
}
-static int sequencer_enable_proxies_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+static int sequencer_enable_proxies_invoke(bContext *C,
+ wmOperator *op,
+ const wmEvent *UNUSED(event))
{
- return WM_operator_props_dialog_popup(C, op, 200, 100);
+ return WM_operator_props_dialog_popup(C, op, 200, 100);
}
static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
- bool proxy_25 = RNA_boolean_get(op->ptr, "proxy_25");
- bool proxy_50 = RNA_boolean_get(op->ptr, "proxy_50");
- bool proxy_75 = RNA_boolean_get(op->ptr, "proxy_75");
- bool proxy_100 = RNA_boolean_get(op->ptr, "proxy_100");
- bool overwrite = RNA_boolean_get(op->ptr, "overwrite");
- bool turnon = true;
-
- if (ed == NULL || !(proxy_25 || proxy_50 || proxy_75 || proxy_100)) {
- turnon = false;
- }
-
- SEQP_BEGIN(ed, seq)
- {
- if ((seq->flag & SELECT)) {
- if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE, SEQ_TYPE_META, SEQ_TYPE_SCENE, SEQ_TYPE_MULTICAM)) {
- BKE_sequencer_proxy_set(seq, turnon);
- if (seq->strip->proxy == NULL) {
- continue;
- }
-
- if (proxy_25) {
- seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_25;
- }
- else {
- seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_25;
- }
-
- if (proxy_50) {
- seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_50;
- }
- else {
- seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_50;
- }
-
- if (proxy_75) {
- seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_75;
- }
- else {
- seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_75;
- }
-
- if (proxy_100) {
- seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_100;
- }
- else {
- seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_100;
- }
-
- if (!overwrite) {
- seq->strip->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING;
- }
- else {
- seq->strip->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING;
- }
- }
- }
- } SEQ_END;
-
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- return OPERATOR_FINISHED;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+ bool proxy_25 = RNA_boolean_get(op->ptr, "proxy_25");
+ bool proxy_50 = RNA_boolean_get(op->ptr, "proxy_50");
+ bool proxy_75 = RNA_boolean_get(op->ptr, "proxy_75");
+ bool proxy_100 = RNA_boolean_get(op->ptr, "proxy_100");
+ bool overwrite = RNA_boolean_get(op->ptr, "overwrite");
+ bool turnon = true;
+
+ if (ed == NULL || !(proxy_25 || proxy_50 || proxy_75 || proxy_100)) {
+ turnon = false;
+ }
+
+ SEQP_BEGIN (ed, seq) {
+ if ((seq->flag & SELECT)) {
+ if (ELEM(seq->type,
+ SEQ_TYPE_MOVIE,
+ SEQ_TYPE_IMAGE,
+ SEQ_TYPE_META,
+ SEQ_TYPE_SCENE,
+ SEQ_TYPE_MULTICAM)) {
+ BKE_sequencer_proxy_set(seq, turnon);
+ if (seq->strip->proxy == NULL) {
+ continue;
+ }
+
+ if (proxy_25) {
+ seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_25;
+ }
+ else {
+ seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_25;
+ }
+
+ if (proxy_50) {
+ seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_50;
+ }
+ else {
+ seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_50;
+ }
+
+ if (proxy_75) {
+ seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_75;
+ }
+ else {
+ seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_75;
+ }
+
+ if (proxy_100) {
+ seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_100;
+ }
+ else {
+ seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_100;
+ }
+
+ if (!overwrite) {
+ seq->strip->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING;
+ }
+ else {
+ seq->strip->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING;
+ }
+ }
+ }
+ }
+ SEQ_END;
+
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_enable_proxies(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Set Selected Strip Proxies";
- ot->idname = "SEQUENCER_OT_enable_proxies";
- ot->description = "Enable selected proxies on all selected Movie, Image and Meta strips";
+ /* identifiers */
+ ot->name = "Set Selected Strip Proxies";
+ ot->idname = "SEQUENCER_OT_enable_proxies";
+ ot->description = "Enable selected proxies on all selected Movie, Image and Meta strips";
- /* api callbacks */
- ot->invoke = sequencer_enable_proxies_invoke;
- ot->exec = sequencer_enable_proxies_exec;
+ /* api callbacks */
+ ot->invoke = sequencer_enable_proxies_invoke;
+ ot->exec = sequencer_enable_proxies_exec;
- /* flags */
- ot->flag = OPTYPE_REGISTER;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER;
- RNA_def_boolean(ot->srna, "proxy_25", false, "25%", "");
- RNA_def_boolean(ot->srna, "proxy_50", false, "50%", "");
- RNA_def_boolean(ot->srna, "proxy_75", false, "75%", "");
- RNA_def_boolean(ot->srna, "proxy_100", false, "100%", "");
- RNA_def_boolean(ot->srna, "overwrite", false, "Overwrite", "");
+ RNA_def_boolean(ot->srna, "proxy_25", false, "25%", "");
+ RNA_def_boolean(ot->srna, "proxy_50", false, "50%", "");
+ RNA_def_boolean(ot->srna, "proxy_75", false, "75%", "");
+ RNA_def_boolean(ot->srna, "proxy_100", false, "100%", "");
+ RNA_def_boolean(ot->srna, "overwrite", false, "Overwrite", "");
}
/* change ops */
static const EnumPropertyItem prop_change_effect_input_types[] = {
- {0, "A_B", 0, "A -> B", ""},
- {1, "B_C", 0, "B -> C", ""},
- {2, "A_C", 0, "A -> C", ""},
- {0, NULL, 0, NULL, NULL},
+ {0, "A_B", 0, "A -> B", ""},
+ {1, "B_C", 0, "B -> C", ""},
+ {2, "A_C", 0, "A -> C", ""},
+ {0, NULL, 0, NULL, NULL},
};
static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq = BKE_sequencer_active_get(scene);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq = BKE_sequencer_active_get(scene);
- Sequence **seq_1, **seq_2;
+ Sequence **seq_1, **seq_2;
- switch (RNA_enum_get(op->ptr, "swap")) {
- case 0:
- seq_1 = &seq->seq1;
- seq_2 = &seq->seq2;
- break;
- case 1:
- seq_1 = &seq->seq2;
- seq_2 = &seq->seq3;
- break;
- default: /* 2 */
- seq_1 = &seq->seq1;
- seq_2 = &seq->seq3;
- break;
- }
+ switch (RNA_enum_get(op->ptr, "swap")) {
+ case 0:
+ seq_1 = &seq->seq1;
+ seq_2 = &seq->seq2;
+ break;
+ case 1:
+ seq_1 = &seq->seq2;
+ seq_2 = &seq->seq3;
+ break;
+ default: /* 2 */
+ seq_1 = &seq->seq1;
+ seq_2 = &seq->seq3;
+ break;
+ }
- if (*seq_1 == NULL || *seq_2 == NULL) {
- BKE_report(op->reports, RPT_ERROR, "One of the effect inputs is unset, cannot swap");
- return OPERATOR_CANCELLED;
- }
- else {
- SWAP(Sequence *, *seq_1, *seq_2);
- }
+ if (*seq_1 == NULL || *seq_2 == NULL) {
+ BKE_report(op->reports, RPT_ERROR, "One of the effect inputs is unset, cannot swap");
+ return OPERATOR_CANCELLED;
+ }
+ else {
+ SWAP(Sequence *, *seq_1, *seq_2);
+ }
- BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
+ BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
- /* important else we don't get the imbuf cache flushed */
- BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
+ /* important else we don't get the imbuf cache flushed */
+ BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Change Effect Input";
- ot->idname = "SEQUENCER_OT_change_effect_input";
+ /* identifiers */
+ ot->name = "Change Effect Input";
+ ot->idname = "SEQUENCER_OT_change_effect_input";
- /* api callbacks */
- ot->exec = sequencer_change_effect_input_exec;
- ot->poll = sequencer_effect_poll;
+ /* api callbacks */
+ ot->exec = sequencer_change_effect_input_exec;
+ ot->poll = sequencer_effect_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- ot->prop = RNA_def_enum(ot->srna, "swap", prop_change_effect_input_types, 0, "Swap", "The effect inputs to swap");
+ ot->prop = RNA_def_enum(
+ ot->srna, "swap", prop_change_effect_input_types, 0, "Swap", "The effect inputs to swap");
}
static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq = BKE_sequencer_active_get(scene);
- const int new_type = RNA_enum_get(op->ptr, "type");
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq = BKE_sequencer_active_get(scene);
+ const int new_type = RNA_enum_get(op->ptr, "type");
- /* free previous effect and init new effect */
- struct SeqEffectHandle sh;
+ /* free previous effect and init new effect */
+ struct SeqEffectHandle sh;
- if ((seq->type & SEQ_TYPE_EFFECT) == 0) {
- return OPERATOR_CANCELLED;
- }
+ if ((seq->type & SEQ_TYPE_EFFECT) == 0) {
+ return OPERATOR_CANCELLED;
+ }
- /* can someone explain the logic behind only allowing to increase this,
- * copied from 2.4x - campbell */
- if (BKE_sequence_effect_get_num_inputs(seq->type) <
- BKE_sequence_effect_get_num_inputs(new_type))
- {
- BKE_report(op->reports, RPT_ERROR, "New effect needs more input strips");
- return OPERATOR_CANCELLED;
- }
- else {
- sh = BKE_sequence_get_effect(seq);
- sh.free(seq, true);
+ /* can someone explain the logic behind only allowing to increase this,
+ * copied from 2.4x - campbell */
+ if (BKE_sequence_effect_get_num_inputs(seq->type) <
+ BKE_sequence_effect_get_num_inputs(new_type)) {
+ BKE_report(op->reports, RPT_ERROR, "New effect needs more input strips");
+ return OPERATOR_CANCELLED;
+ }
+ else {
+ sh = BKE_sequence_get_effect(seq);
+ sh.free(seq, true);
- seq->type = new_type;
+ seq->type = new_type;
- sh = BKE_sequence_get_effect(seq);
- sh.init(seq);
- }
+ sh = BKE_sequence_get_effect(seq);
+ sh.init(seq);
+ }
- /* update */
- BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
+ /* update */
+ BKE_sequencer_update_changed_seq_and_deps(scene, seq, 0, 1);
- /* important else we don't get the imbuf cache flushed */
- BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
+ /* important else we don't get the imbuf cache flushed */
+ BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Change Effect Type";
- ot->idname = "SEQUENCER_OT_change_effect_type";
+ /* identifiers */
+ ot->name = "Change Effect Type";
+ ot->idname = "SEQUENCER_OT_change_effect_type";
- /* api callbacks */
- ot->exec = sequencer_change_effect_type_exec;
- ot->poll = sequencer_effect_poll;
+ /* api callbacks */
+ ot->exec = sequencer_change_effect_type_exec;
+ ot->poll = sequencer_effect_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- ot->prop = RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_TYPE_CROSS, "Type", "Sequencer effect type");
+ ot->prop = RNA_def_enum(ot->srna,
+ "type",
+ sequencer_prop_effect_types,
+ SEQ_TYPE_CROSS,
+ "Type",
+ "Sequencer effect type");
}
static int sequencer_change_path_exec(bContext *C, wmOperator *op)
{
- Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq = BKE_sequencer_active_get(scene);
- const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
- const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
- int minframe, numdigits;
-
- if (seq->type == SEQ_TYPE_IMAGE) {
- char directory[FILE_MAX];
- int len;
- StripElem *se;
-
- /* need to find min/max frame for placeholders */
- if (use_placeholders) {
- len = sequencer_image_seq_get_minmax_frame(op, seq->sfra, &minframe, &numdigits);
- }
- else {
- len = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
- }
- if (len == 0) {
- return OPERATOR_CANCELLED;
- }
-
- RNA_string_get(op->ptr, "directory", directory);
- if (is_relative_path) {
- /* TODO, shouldn't this already be relative from the filesel?
- * (as the 'filepath' is) for now just make relative here,
- * but look into changing after 2.60 - campbell */
- BLI_path_rel(directory, BKE_main_blendfile_path(bmain));
- }
- BLI_strncpy(seq->strip->dir, directory, sizeof(seq->strip->dir));
-
- if (seq->strip->stripdata) {
- MEM_freeN(seq->strip->stripdata);
- }
- seq->strip->stripdata = se = MEM_callocN(len * sizeof(StripElem), "stripelem");
-
- if (use_placeholders) {
- sequencer_image_seq_reserve_frames(op, se, len, minframe, numdigits);
- }
- else {
- RNA_BEGIN (op->ptr, itemptr, "files")
- {
- char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
- BLI_strncpy(se->name, filename, sizeof(se->name));
- MEM_freeN(filename);
- se++;
- }
- RNA_END;
- }
-
- /* reset these else we wont see all the images */
- seq->anim_startofs = seq->anim_endofs = 0;
-
- /* correct start/end frames so we don't move
- * important not to set seq->len = len; allow the function to handle it */
- BKE_sequence_reload_new_file(scene, seq, true);
-
- BKE_sequence_calc(scene, seq);
-
- /* important else we don't get the imbuf cache flushed */
- BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
- }
- else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
- bSound *sound = seq->sound;
- if (sound == NULL) {
- return OPERATOR_CANCELLED;
- }
- char filepath[FILE_MAX];
- RNA_string_get(op->ptr, "filepath", filepath);
- BLI_strncpy(sound->name, filepath, sizeof(sound->name));
- BKE_sound_load(bmain, sound);
- }
- else {
- /* lame, set rna filepath */
- PointerRNA seq_ptr;
- PropertyRNA *prop;
- char filepath[FILE_MAX];
-
- RNA_pointer_create(&scene->id, &RNA_Sequence, seq, &seq_ptr);
-
- RNA_string_get(op->ptr, "filepath", filepath);
- prop = RNA_struct_find_property(&seq_ptr, "filepath");
- RNA_property_string_set(&seq_ptr, prop, filepath);
- RNA_property_update(C, &seq_ptr, prop);
- }
-
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- return OPERATOR_FINISHED;
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq = BKE_sequencer_active_get(scene);
+ const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
+ const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders");
+ int minframe, numdigits;
+
+ if (seq->type == SEQ_TYPE_IMAGE) {
+ char directory[FILE_MAX];
+ int len;
+ StripElem *se;
+
+ /* need to find min/max frame for placeholders */
+ if (use_placeholders) {
+ len = sequencer_image_seq_get_minmax_frame(op, seq->sfra, &minframe, &numdigits);
+ }
+ else {
+ len = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
+ }
+ if (len == 0) {
+ return OPERATOR_CANCELLED;
+ }
+
+ RNA_string_get(op->ptr, "directory", directory);
+ if (is_relative_path) {
+ /* TODO, shouldn't this already be relative from the filesel?
+ * (as the 'filepath' is) for now just make relative here,
+ * but look into changing after 2.60 - campbell */
+ BLI_path_rel(directory, BKE_main_blendfile_path(bmain));
+ }
+ BLI_strncpy(seq->strip->dir, directory, sizeof(seq->strip->dir));
+
+ if (seq->strip->stripdata) {
+ MEM_freeN(seq->strip->stripdata);
+ }
+ seq->strip->stripdata = se = MEM_callocN(len * sizeof(StripElem), "stripelem");
+
+ if (use_placeholders) {
+ sequencer_image_seq_reserve_frames(op, se, len, minframe, numdigits);
+ }
+ else {
+ RNA_BEGIN (op->ptr, itemptr, "files") {
+ char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0);
+ BLI_strncpy(se->name, filename, sizeof(se->name));
+ MEM_freeN(filename);
+ se++;
+ }
+ RNA_END;
+ }
+
+ /* reset these else we wont see all the images */
+ seq->anim_startofs = seq->anim_endofs = 0;
+
+ /* correct start/end frames so we don't move
+ * important not to set seq->len = len; allow the function to handle it */
+ BKE_sequence_reload_new_file(scene, seq, true);
+
+ BKE_sequence_calc(scene, seq);
+
+ /* important else we don't get the imbuf cache flushed */
+ BKE_sequencer_free_imbuf(scene, &ed->seqbase, false);
+ }
+ else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
+ bSound *sound = seq->sound;
+ if (sound == NULL) {
+ return OPERATOR_CANCELLED;
+ }
+ char filepath[FILE_MAX];
+ RNA_string_get(op->ptr, "filepath", filepath);
+ BLI_strncpy(sound->name, filepath, sizeof(sound->name));
+ BKE_sound_load(bmain, sound);
+ }
+ else {
+ /* lame, set rna filepath */
+ PointerRNA seq_ptr;
+ PropertyRNA *prop;
+ char filepath[FILE_MAX];
+
+ RNA_pointer_create(&scene->id, &RNA_Sequence, seq, &seq_ptr);
+
+ RNA_string_get(op->ptr, "filepath", filepath);
+ prop = RNA_struct_find_property(&seq_ptr, "filepath");
+ RNA_property_string_set(&seq_ptr, prop, filepath);
+ RNA_property_update(C, &seq_ptr, prop);
+ }
+
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+
+ return OPERATOR_FINISHED;
}
static int sequencer_change_path_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- Scene *scene = CTX_data_scene(C);
- Sequence *seq = BKE_sequencer_active_get(scene);
- char filepath[FILE_MAX];
+ Scene *scene = CTX_data_scene(C);
+ Sequence *seq = BKE_sequencer_active_get(scene);
+ char filepath[FILE_MAX];
- BLI_join_dirfile(filepath, sizeof(filepath), seq->strip->dir, seq->strip->stripdata->name);
+ BLI_join_dirfile(filepath, sizeof(filepath), seq->strip->dir, seq->strip->stripdata->name);
- RNA_string_set(op->ptr, "directory", seq->strip->dir);
- RNA_string_set(op->ptr, "filepath", filepath);
+ RNA_string_set(op->ptr, "directory", seq->strip->dir);
+ RNA_string_set(op->ptr, "filepath", filepath);
- /* set default display depending on seq type */
- if (seq->type == SEQ_TYPE_IMAGE) {
- RNA_boolean_set(op->ptr, "filter_movie", false);
- }
- else {
- RNA_boolean_set(op->ptr, "filter_image", false);
- }
+ /* set default display depending on seq type */
+ if (seq->type == SEQ_TYPE_IMAGE) {
+ RNA_boolean_set(op->ptr, "filter_movie", false);
+ }
+ else {
+ RNA_boolean_set(op->ptr, "filter_image", false);
+ }
- WM_event_add_fileselect(C, op);
+ WM_event_add_fileselect(C, op);
- return OPERATOR_RUNNING_MODAL;
+ return OPERATOR_RUNNING_MODAL;
}
void SEQUENCER_OT_change_path(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Change Data/Files";
- ot->idname = "SEQUENCER_OT_change_path";
+ /* identifiers */
+ ot->name = "Change Data/Files";
+ ot->idname = "SEQUENCER_OT_change_path";
- /* api callbacks */
- ot->exec = sequencer_change_path_exec;
- ot->invoke = sequencer_change_path_invoke;
- ot->poll = sequencer_strip_has_path_poll;
+ /* api callbacks */
+ ot->exec = sequencer_change_path_exec;
+ ot->invoke = sequencer_change_path_invoke;
+ ot->poll = sequencer_strip_has_path_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- WM_operator_properties_filesel(
- ot, FILE_TYPE_FOLDER, FILE_SPECIAL, FILE_OPENFILE,
- WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILEPATH | WM_FILESEL_FILES,
- FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
- RNA_def_boolean(ot->srna, "use_placeholders", false, "Use Placeholders", "Use placeholders for missing frames of the strip");
+ WM_operator_properties_filesel(ot,
+ FILE_TYPE_FOLDER,
+ FILE_SPECIAL,
+ FILE_OPENFILE,
+ WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILEPATH |
+ WM_FILESEL_FILES,
+ FILE_DEFAULTDISPLAY,
+ FILE_SORT_ALPHA);
+ RNA_def_boolean(ot->srna,
+ "use_placeholders",
+ false,
+ "Use Placeholders",
+ "Use placeholders for missing frames of the strip");
}
-static int sequencer_export_subtitles_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+static int sequencer_export_subtitles_invoke(bContext *C,
+ wmOperator *op,
+ const wmEvent *UNUSED(event))
{
- Main *bmain = CTX_data_main(C);
- if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
- char filepath[FILE_MAX];
+ Main *bmain = CTX_data_main(C);
+ if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
+ char filepath[FILE_MAX];
- if (BKE_main_blendfile_path(bmain)[0] == '\0') {
- BLI_strncpy(filepath, "untitled", sizeof(filepath));
- }
- else {
- BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
- }
+ if (BKE_main_blendfile_path(bmain)[0] == '\0') {
+ BLI_strncpy(filepath, "untitled", sizeof(filepath));
+ }
+ else {
+ BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
+ }
- BLI_path_extension_replace(filepath, sizeof(filepath), ".srt");
- RNA_string_set(op->ptr, "filepath", filepath);
- }
+ BLI_path_extension_replace(filepath, sizeof(filepath), ".srt");
+ RNA_string_set(op->ptr, "filepath", filepath);
+ }
- WM_event_add_fileselect(C, op);
+ WM_event_add_fileselect(C, op);
- return OPERATOR_RUNNING_MODAL;
+ return OPERATOR_RUNNING_MODAL;
}
static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Sequence *seq, *seq_next;
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- ListBase text_seq = {0};
- int iter = 0;
- FILE *file;
- char filepath[FILE_MAX];
-
- if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
- BKE_report(op->reports, RPT_ERROR, "No filename given");
- return OPERATOR_CANCELLED;
- }
-
- RNA_string_get(op->ptr, "filepath", filepath);
- BLI_path_extension_ensure(filepath, sizeof(filepath), ".srt");
-
- /* Avoid File write exceptions */
- if (!BLI_exists(filepath)) {
- BLI_make_existing_file(filepath);
- if (!BLI_file_touch(filepath)) {
- BKE_report(op->reports, RPT_ERROR, "Can't create subtitle file");
- return OPERATOR_CANCELLED;
- }
- }
- else if (!BLI_file_is_writable(filepath)) {
- BKE_report(op->reports, RPT_ERROR, "Can't overwrite export file");
- return OPERATOR_CANCELLED;
- }
-
- SEQ_BEGIN(ed, seq)
- {
- if (seq->type == SEQ_TYPE_TEXT) {
- BLI_addtail(&text_seq, MEM_dupallocN(seq));
- }
- } SEQ_END;
-
- if (BLI_listbase_is_empty(&text_seq)) {
- BKE_report(op->reports, RPT_ERROR, "No subtitles (text strips) to export");
- return OPERATOR_CANCELLED;
- }
-
- BLI_listbase_sort(&text_seq, BKE_sequencer_cmp_time_startdisp);
-
- /* time to open and write! */
- file = BLI_fopen(filepath, "w");
-
- for (seq = text_seq.first; seq; seq = seq_next) {
- TextVars *data = seq->effectdata;
- char timecode_str_start[32];
- char timecode_str_end[32];
-
- BLI_timecode_string_from_time(timecode_str_start, sizeof(timecode_str_start),
- -2, FRA2TIME(seq->startdisp), FPS, USER_TIMECODE_SUBRIP);
- BLI_timecode_string_from_time(timecode_str_end, sizeof(timecode_str_end),
- -2, FRA2TIME(seq->enddisp), FPS, USER_TIMECODE_SUBRIP);
-
- fprintf(file, "%d\n%s --> %s\n%s\n\n", iter++, timecode_str_start, timecode_str_end, data->text);
-
- seq_next = seq->next;
- MEM_freeN(seq);
- }
-
- fclose(file);
-
- return OPERATOR_FINISHED;
+ Scene *scene = CTX_data_scene(C);
+ Sequence *seq, *seq_next;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ ListBase text_seq = {0};
+ int iter = 0;
+ FILE *file;
+ char filepath[FILE_MAX];
+
+ if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
+ BKE_report(op->reports, RPT_ERROR, "No filename given");
+ return OPERATOR_CANCELLED;
+ }
+
+ RNA_string_get(op->ptr, "filepath", filepath);
+ BLI_path_extension_ensure(filepath, sizeof(filepath), ".srt");
+
+ /* Avoid File write exceptions */
+ if (!BLI_exists(filepath)) {
+ BLI_make_existing_file(filepath);
+ if (!BLI_file_touch(filepath)) {
+ BKE_report(op->reports, RPT_ERROR, "Can't create subtitle file");
+ return OPERATOR_CANCELLED;
+ }
+ }
+ else if (!BLI_file_is_writable(filepath)) {
+ BKE_report(op->reports, RPT_ERROR, "Can't overwrite export file");
+ return OPERATOR_CANCELLED;
+ }
+
+ SEQ_BEGIN (ed, seq) {
+ if (seq->type == SEQ_TYPE_TEXT) {
+ BLI_addtail(&text_seq, MEM_dupallocN(seq));
+ }
+ }
+ SEQ_END;
+
+ if (BLI_listbase_is_empty(&text_seq)) {
+ BKE_report(op->reports, RPT_ERROR, "No subtitles (text strips) to export");
+ return OPERATOR_CANCELLED;
+ }
+
+ BLI_listbase_sort(&text_seq, BKE_sequencer_cmp_time_startdisp);
+
+ /* time to open and write! */
+ file = BLI_fopen(filepath, "w");
+
+ for (seq = text_seq.first; seq; seq = seq_next) {
+ TextVars *data = seq->effectdata;
+ char timecode_str_start[32];
+ char timecode_str_end[32];
+
+ BLI_timecode_string_from_time(timecode_str_start,
+ sizeof(timecode_str_start),
+ -2,
+ FRA2TIME(seq->startdisp),
+ FPS,
+ USER_TIMECODE_SUBRIP);
+ BLI_timecode_string_from_time(timecode_str_end,
+ sizeof(timecode_str_end),
+ -2,
+ FRA2TIME(seq->enddisp),
+ FPS,
+ USER_TIMECODE_SUBRIP);
+
+ fprintf(
+ file, "%d\n%s --> %s\n%s\n\n", iter++, timecode_str_start, timecode_str_end, data->text);
+
+ seq_next = seq->next;
+ MEM_freeN(seq);
+ }
+
+ fclose(file);
+
+ return OPERATOR_FINISHED;
}
static bool sequencer_strip_is_text_poll(bContext *C)
{
- Editing *ed;
- Sequence *seq;
- return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), false)) != NULL) && ((seq = ed->act_seq) != NULL) && (seq->type == SEQ_TYPE_TEXT));
+ Editing *ed;
+ Sequence *seq;
+ return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), false)) != NULL) &&
+ ((seq = ed->act_seq) != NULL) && (seq->type == SEQ_TYPE_TEXT));
}
void SEQUENCER_OT_export_subtitles(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Export Subtitles";
- ot->idname = "SEQUENCER_OT_export_subtitles";
- ot->description = "Export .srt file containing text strips";
-
- /* api callbacks */
- ot->exec = sequencer_export_subtitles_exec;
- ot->invoke = sequencer_export_subtitles_invoke;
- ot->poll = sequencer_strip_is_text_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- WM_operator_properties_filesel(
- ot, FILE_TYPE_FOLDER, FILE_BLENDER, FILE_SAVE,
- WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
+ /* identifiers */
+ ot->name = "Export Subtitles";
+ ot->idname = "SEQUENCER_OT_export_subtitles";
+ ot->description = "Export .srt file containing text strips";
+
+ /* api callbacks */
+ ot->exec = sequencer_export_subtitles_exec;
+ ot->invoke = sequencer_export_subtitles_invoke;
+ ot->poll = sequencer_strip_is_text_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ WM_operator_properties_filesel(ot,
+ FILE_TYPE_FOLDER,
+ FILE_BLENDER,
+ FILE_SAVE,
+ WM_FILESEL_FILEPATH,
+ FILE_DEFAULTDISPLAY,
+ FILE_SORT_ALPHA);
}
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index ad3ac79171c..a051071ab61 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -45,10 +45,16 @@ struct wmOperator;
/* space_sequencer.c */
struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa);
-
/* sequencer_draw.c */
void draw_timeline_seq(const struct bContext *C, struct ARegion *ar);
-void sequencer_draw_preview(const struct bContext *C, struct Scene *scene, struct ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset, bool draw_overlay, bool draw_backdrop);
+void sequencer_draw_preview(const struct bContext *C,
+ struct Scene *scene,
+ struct ARegion *ar,
+ struct SpaceSeq *sseq,
+ int cfra,
+ int offset,
+ bool draw_overlay,
+ bool draw_backdrop);
void color3ubv_from_seq(struct Scene *curscene, struct Sequence *seq, unsigned char col[3]);
void sequencer_special_update_set(Sequence *seq);
@@ -56,16 +62,34 @@ void sequencer_special_update_set(Sequence *seq);
/* UNUSED */
// void seq_reset_imageofs(struct SpaceSeq *sseq);
-struct ImBuf *sequencer_ibuf_get(struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene, struct SpaceSeq *sseq, int cfra, int frame_ofs, const char *viewname);
+struct ImBuf *sequencer_ibuf_get(struct Main *bmain,
+ struct Depsgraph *depsgraph,
+ struct Scene *scene,
+ struct SpaceSeq *sseq,
+ int cfra,
+ int frame_ofs,
+ const char *viewname);
/* sequencer_edit.c */
struct View2D;
void seq_rectf(struct Sequence *seq, struct rctf *rectf);
void boundbox_seq(struct Scene *scene, struct rctf *rect);
-struct Sequence *find_nearest_seq(struct Scene *scene, struct View2D *v2d, int *hand, const int mval[2]);
-struct Sequence *find_neighboring_sequence(struct Scene *scene, struct Sequence *test, int lr, int sel);
+struct Sequence *find_nearest_seq(struct Scene *scene,
+ struct View2D *v2d,
+ int *hand,
+ const int mval[2]);
+struct Sequence *find_neighboring_sequence(struct Scene *scene,
+ struct Sequence *test,
+ int lr,
+ int sel);
void recurs_sel_seq(struct Sequence *seqm);
-int seq_effect_find_selected(struct Scene *scene, struct Sequence *activeseq, int type, struct Sequence **selseq1, struct Sequence **selseq2, struct Sequence **selseq3, const char **error_str);
+int seq_effect_find_selected(struct Scene *scene,
+ struct Sequence *activeseq,
+ int type,
+ struct Sequence **selseq1,
+ struct Sequence **selseq2,
+ struct Sequence **selseq3,
+ const char **error_str);
/* operator helpers */
bool sequencer_edit_poll(struct bContext *C);
@@ -155,23 +179,23 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot);
void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot);
enum {
- SEQ_CUT_SOFT,
- SEQ_CUT_HARD,
+ SEQ_CUT_SOFT,
+ SEQ_CUT_HARD,
};
enum {
- SEQ_SELECTED,
- SEQ_UNSELECTED,
+ SEQ_SELECTED,
+ SEQ_UNSELECTED,
};
enum {
- SEQ_SELECT_LR_NONE = 0,
- SEQ_SELECT_LR_MOUSE,
- SEQ_SELECT_LR_LEFT,
- SEQ_SELECT_LR_RIGHT,
+ SEQ_SELECT_LR_NONE = 0,
+ SEQ_SELECT_LR_MOUSE,
+ SEQ_SELECT_LR_LEFT,
+ SEQ_SELECT_LR_RIGHT,
};
/* defines used internally */
-#define SCE_MARKERS 0 // XXX - dummy
+#define SCE_MARKERS 0 // XXX - dummy
/* sequencer_ops.c */
void sequencer_operatortypes(void);
@@ -201,7 +225,11 @@ void SEQUENCER_OT_sample(struct wmOperatorType *ot);
void sequencer_preview_add_sound(const struct bContext *C, struct Sequence *seq);
/* sequencer_add */
-int sequencer_image_seq_get_minmax_frame(struct wmOperator *op, int sfra, int *r_minframe, int *r_numdigits);
-void sequencer_image_seq_reserve_frames(struct wmOperator *op, struct StripElem *se, int len, int minframe, int numdigits);
+int sequencer_image_seq_get_minmax_frame(struct wmOperator *op,
+ int sfra,
+ int *r_minframe,
+ int *r_numdigits);
+void sequencer_image_seq_reserve_frames(
+ struct wmOperator *op, struct StripElem *se, int len, int minframe, int numdigits);
#endif /* __SEQUENCER_INTERN_H__ */
diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c
index 41ca52e0431..e00d33853a3 100644
--- a/source/blender/editors/space_sequencer/sequencer_modifier.c
+++ b/source/blender/editors/space_sequencer/sequencer_modifier.c
@@ -17,12 +17,10 @@
* All rights reserved.
*/
-
/** \file
* \ingroup spseq
*/
-
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
@@ -37,7 +35,6 @@
#include "RNA_define.h"
#include "RNA_enum_types.h"
-
/* own include */
#include "sequencer_intern.h"
@@ -45,237 +42,244 @@
static bool strip_modifier_active_poll(bContext *C)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
- if (ed) {
- Sequence *seq = BKE_sequencer_active_get(scene);
+ if (ed) {
+ Sequence *seq = BKE_sequencer_active_get(scene);
- if (seq) {
- return BKE_sequence_supports_modifiers(seq);
- }
- }
+ if (seq) {
+ return BKE_sequence_supports_modifiers(seq);
+ }
+ }
- return false;
+ return false;
}
static int strip_modifier_add_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Sequence *seq = BKE_sequencer_active_get(scene);
- int type = RNA_enum_get(op->ptr, "type");
+ Scene *scene = CTX_data_scene(C);
+ Sequence *seq = BKE_sequencer_active_get(scene);
+ int type = RNA_enum_get(op->ptr, "type");
- BKE_sequence_modifier_new(seq, NULL, type);
+ BKE_sequence_modifier_new(seq, NULL, type);
- BKE_sequence_invalidate_cache(scene, seq);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ BKE_sequence_invalidate_cache(scene, seq);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_strip_modifier_add(wmOperatorType *ot)
{
- PropertyRNA *prop;
-
- /* identifiers */
- ot->name = "Add Strip Modifier";
- ot->idname = "SEQUENCER_OT_strip_modifier_add";
- ot->description = "Add a modifier to the strip";
-
- /* api callbacks */
- ot->exec = strip_modifier_add_exec;
- ot->poll = strip_modifier_active_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- prop = RNA_def_enum(ot->srna, "type", rna_enum_sequence_modifier_type_items, seqModifierType_ColorBalance, "Type", "");
- ot->prop = prop;
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name = "Add Strip Modifier";
+ ot->idname = "SEQUENCER_OT_strip_modifier_add";
+ ot->description = "Add a modifier to the strip";
+
+ /* api callbacks */
+ ot->exec = strip_modifier_add_exec;
+ ot->poll = strip_modifier_active_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ prop = RNA_def_enum(ot->srna,
+ "type",
+ rna_enum_sequence_modifier_type_items,
+ seqModifierType_ColorBalance,
+ "Type",
+ "");
+ ot->prop = prop;
}
/*********************** Remove modifier operator *************************/
static int strip_modifier_remove_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Sequence *seq = BKE_sequencer_active_get(scene);
- char name[MAX_NAME];
- SequenceModifierData *smd;
+ Scene *scene = CTX_data_scene(C);
+ Sequence *seq = BKE_sequencer_active_get(scene);
+ char name[MAX_NAME];
+ SequenceModifierData *smd;
- RNA_string_get(op->ptr, "name", name);
+ RNA_string_get(op->ptr, "name", name);
- smd = BKE_sequence_modifier_find_by_name(seq, name);
- if (!smd) {
- return OPERATOR_CANCELLED;
- }
+ smd = BKE_sequence_modifier_find_by_name(seq, name);
+ if (!smd) {
+ return OPERATOR_CANCELLED;
+ }
- BLI_remlink(&seq->modifiers, smd);
- BKE_sequence_modifier_free(smd);
+ BLI_remlink(&seq->modifiers, smd);
+ BKE_sequence_modifier_free(smd);
- BKE_sequence_invalidate_cache(scene, seq);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ BKE_sequence_invalidate_cache(scene, seq);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_strip_modifier_remove(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Remove Strip Modifier";
- ot->idname = "SEQUENCER_OT_strip_modifier_remove";
- ot->description = "Remove a modifier from the strip";
+ /* identifiers */
+ ot->name = "Remove Strip Modifier";
+ ot->idname = "SEQUENCER_OT_strip_modifier_remove";
+ ot->description = "Remove a modifier from the strip";
- /* api callbacks */
- ot->exec = strip_modifier_remove_exec;
- ot->poll = strip_modifier_active_poll;
+ /* api callbacks */
+ ot->exec = strip_modifier_remove_exec;
+ ot->poll = strip_modifier_active_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
- RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
+ /* properties */
+ RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
}
/*********************** Move operator *************************/
enum {
- SEQ_MODIFIER_MOVE_UP = 0,
- SEQ_MODIFIER_MOVE_DOWN,
+ SEQ_MODIFIER_MOVE_UP = 0,
+ SEQ_MODIFIER_MOVE_DOWN,
};
static int strip_modifier_move_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Sequence *seq = BKE_sequencer_active_get(scene);
- char name[MAX_NAME];
- int direction;
- SequenceModifierData *smd;
-
- RNA_string_get(op->ptr, "name", name);
- direction = RNA_enum_get(op->ptr, "direction");
-
- smd = BKE_sequence_modifier_find_by_name(seq, name);
- if (!smd) {
- return OPERATOR_CANCELLED;
- }
-
- if (direction == SEQ_MODIFIER_MOVE_UP) {
- if (smd->prev) {
- BLI_remlink(&seq->modifiers, smd);
- BLI_insertlinkbefore(&seq->modifiers, smd->prev, smd);
- }
- }
- else if (direction == SEQ_MODIFIER_MOVE_DOWN) {
- if (smd->next) {
- BLI_remlink(&seq->modifiers, smd);
- BLI_insertlinkafter(&seq->modifiers, smd->next, smd);
- }
- }
-
- BKE_sequence_invalidate_cache(scene, seq);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- return OPERATOR_FINISHED;
+ Scene *scene = CTX_data_scene(C);
+ Sequence *seq = BKE_sequencer_active_get(scene);
+ char name[MAX_NAME];
+ int direction;
+ SequenceModifierData *smd;
+
+ RNA_string_get(op->ptr, "name", name);
+ direction = RNA_enum_get(op->ptr, "direction");
+
+ smd = BKE_sequence_modifier_find_by_name(seq, name);
+ if (!smd) {
+ return OPERATOR_CANCELLED;
+ }
+
+ if (direction == SEQ_MODIFIER_MOVE_UP) {
+ if (smd->prev) {
+ BLI_remlink(&seq->modifiers, smd);
+ BLI_insertlinkbefore(&seq->modifiers, smd->prev, smd);
+ }
+ }
+ else if (direction == SEQ_MODIFIER_MOVE_DOWN) {
+ if (smd->next) {
+ BLI_remlink(&seq->modifiers, smd);
+ BLI_insertlinkafter(&seq->modifiers, smd->next, smd);
+ }
+ }
+
+ BKE_sequence_invalidate_cache(scene, seq);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_strip_modifier_move(wmOperatorType *ot)
{
- static const EnumPropertyItem direction_items[] = {
- {SEQ_MODIFIER_MOVE_UP, "UP", 0, "Up", "Move modifier up in the stack"},
- {SEQ_MODIFIER_MOVE_DOWN, "DOWN", 0, "Down", "Move modifier down in the stack"},
- {0, NULL, 0, NULL, NULL},
- };
-
- /* identifiers */
- ot->name = "Move Strip Modifier";
- ot->idname = "SEQUENCER_OT_strip_modifier_move";
- ot->description = "Move modifier up and down in the stack";
-
- /* api callbacks */
- ot->exec = strip_modifier_move_exec;
- ot->poll = strip_modifier_active_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
- RNA_def_enum(ot->srna, "direction", direction_items, SEQ_MODIFIER_MOVE_UP, "Type", "");
+ static const EnumPropertyItem direction_items[] = {
+ {SEQ_MODIFIER_MOVE_UP, "UP", 0, "Up", "Move modifier up in the stack"},
+ {SEQ_MODIFIER_MOVE_DOWN, "DOWN", 0, "Down", "Move modifier down in the stack"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ /* identifiers */
+ ot->name = "Move Strip Modifier";
+ ot->idname = "SEQUENCER_OT_strip_modifier_move";
+ ot->description = "Move modifier up and down in the stack";
+
+ /* api callbacks */
+ ot->exec = strip_modifier_move_exec;
+ ot->poll = strip_modifier_active_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
+ RNA_def_enum(ot->srna, "direction", direction_items, SEQ_MODIFIER_MOVE_UP, "Type", "");
}
/*********************** Copy to selected operator *************************/
enum {
- SEQ_MODIFIER_COPY_REPLACE = 0,
- SEQ_MODIFIER_COPY_APPEND = 1,
+ SEQ_MODIFIER_COPY_REPLACE = 0,
+ SEQ_MODIFIER_COPY_APPEND = 1,
};
static int strip_modifier_copy_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = scene->ed;
- Sequence *seq = BKE_sequencer_active_get(scene);
- Sequence *seq_iter;
- const int type = RNA_enum_get(op->ptr, "type");
-
- if (!seq || !seq->modifiers.first) {
- return OPERATOR_CANCELLED;
- }
-
- SEQP_BEGIN(ed, seq_iter)
- {
- if (seq_iter->flag & SELECT) {
- if (seq_iter == seq) {
- continue;
- }
-
- if (type == SEQ_MODIFIER_COPY_REPLACE) {
- if (seq_iter->modifiers.first) {
- SequenceModifierData *smd_tmp, *smd = seq_iter->modifiers.first;
- while (smd) {
- smd_tmp = smd->next;
- BLI_remlink(&seq_iter->modifiers, smd);
- BKE_sequence_modifier_free(smd);
- smd = smd_tmp;
- }
- BLI_listbase_clear(&seq_iter->modifiers);
- }
- }
-
- BKE_sequence_modifier_list_copy(seq_iter, seq);
- }
- } SEQ_END;
-
- BKE_sequence_invalidate_cache(scene, seq);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-
- return OPERATOR_FINISHED;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = scene->ed;
+ Sequence *seq = BKE_sequencer_active_get(scene);
+ Sequence *seq_iter;
+ const int type = RNA_enum_get(op->ptr, "type");
+
+ if (!seq || !seq->modifiers.first) {
+ return OPERATOR_CANCELLED;
+ }
+
+ SEQP_BEGIN (ed, seq_iter) {
+ if (seq_iter->flag & SELECT) {
+ if (seq_iter == seq) {
+ continue;
+ }
+
+ if (type == SEQ_MODIFIER_COPY_REPLACE) {
+ if (seq_iter->modifiers.first) {
+ SequenceModifierData *smd_tmp, *smd = seq_iter->modifiers.first;
+ while (smd) {
+ smd_tmp = smd->next;
+ BLI_remlink(&seq_iter->modifiers, smd);
+ BKE_sequence_modifier_free(smd);
+ smd = smd_tmp;
+ }
+ BLI_listbase_clear(&seq_iter->modifiers);
+ }
+ }
+
+ BKE_sequence_modifier_list_copy(seq_iter, seq);
+ }
+ }
+ SEQ_END;
+
+ BKE_sequence_invalidate_cache(scene, seq);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_strip_modifier_copy(wmOperatorType *ot)
{
- static const EnumPropertyItem type_items[] = {
- {SEQ_MODIFIER_COPY_REPLACE, "REPLACE", 0, "Replace",
- "Replace modifiers in destination"},
- {SEQ_MODIFIER_COPY_APPEND, "APPEND", 0, "Append",
- "Append active modifiers to selected strips"},
- {0, NULL, 0, NULL, NULL},
- };
-
- /* identifiers */
- ot->name = "Copy to Selected Strips";
- ot->idname = "SEQUENCER_OT_strip_modifier_copy";
- ot->description = "Copy modifiers of the active strip to all selected strips";
-
- /* api callbacks */
- ot->invoke = WM_menu_invoke;
- ot->exec = strip_modifier_copy_exec;
- ot->poll = strip_modifier_active_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- ot->prop = RNA_def_enum(ot->srna, "type", type_items, SEQ_MODIFIER_COPY_REPLACE, "Type", "");
+ static const EnumPropertyItem type_items[] = {
+ {SEQ_MODIFIER_COPY_REPLACE, "REPLACE", 0, "Replace", "Replace modifiers in destination"},
+ {SEQ_MODIFIER_COPY_APPEND,
+ "APPEND",
+ 0,
+ "Append",
+ "Append active modifiers to selected strips"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ /* identifiers */
+ ot->name = "Copy to Selected Strips";
+ ot->idname = "SEQUENCER_OT_strip_modifier_copy";
+ ot->description = "Copy modifiers of the active strip to all selected strips";
+
+ /* api callbacks */
+ ot->invoke = WM_menu_invoke;
+ ot->exec = strip_modifier_copy_exec;
+ ot->poll = strip_modifier_active_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ ot->prop = RNA_def_enum(ot->srna, "type", type_items, SEQ_MODIFIER_COPY_REPLACE, "Type", "");
}
diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c
index 9a619dd0d9b..6adca28a3fa 100644
--- a/source/blender/editors/space_sequencer/sequencer_ops.c
+++ b/source/blender/editors/space_sequencer/sequencer_ops.c
@@ -38,112 +38,111 @@
#include "sequencer_intern.h"
-
/* ************************** registration **********************************/
-
void sequencer_operatortypes(void)
{
- /* sequencer_edit.c */
- WM_operatortype_append(SEQUENCER_OT_cut);
- WM_operatortype_append(SEQUENCER_OT_slip);
- WM_operatortype_append(SEQUENCER_OT_mute);
- WM_operatortype_append(SEQUENCER_OT_unmute);
- WM_operatortype_append(SEQUENCER_OT_lock);
- WM_operatortype_append(SEQUENCER_OT_unlock);
- WM_operatortype_append(SEQUENCER_OT_reload);
- WM_operatortype_append(SEQUENCER_OT_refresh_all);
- WM_operatortype_append(SEQUENCER_OT_reassign_inputs);
- WM_operatortype_append(SEQUENCER_OT_swap_inputs);
- WM_operatortype_append(SEQUENCER_OT_duplicate);
- WM_operatortype_append(SEQUENCER_OT_delete);
- WM_operatortype_append(SEQUENCER_OT_offset_clear);
- WM_operatortype_append(SEQUENCER_OT_images_separate);
- WM_operatortype_append(SEQUENCER_OT_meta_toggle);
- WM_operatortype_append(SEQUENCER_OT_meta_make);
- WM_operatortype_append(SEQUENCER_OT_meta_separate);
-
- WM_operatortype_append(SEQUENCER_OT_gap_remove);
- WM_operatortype_append(SEQUENCER_OT_gap_insert);
- WM_operatortype_append(SEQUENCER_OT_snap);
- WM_operatortype_append(SEQUENCER_OT_strip_jump);
- WM_operatortype_append(SEQUENCER_OT_swap);
- WM_operatortype_append(SEQUENCER_OT_swap_data);
- WM_operatortype_append(SEQUENCER_OT_rendersize);
-
- WM_operatortype_append(SEQUENCER_OT_export_subtitles);
-
- WM_operatortype_append(SEQUENCER_OT_copy);
- WM_operatortype_append(SEQUENCER_OT_paste);
-
- WM_operatortype_append(SEQUENCER_OT_view_all);
- WM_operatortype_append(SEQUENCER_OT_view_selected);
- WM_operatortype_append(SEQUENCER_OT_view_frame);
- WM_operatortype_append(SEQUENCER_OT_view_all_preview);
- WM_operatortype_append(SEQUENCER_OT_view_toggle);
- WM_operatortype_append(SEQUENCER_OT_view_zoom_ratio);
- WM_operatortype_append(SEQUENCER_OT_view_ghost_border);
-
- WM_operatortype_append(SEQUENCER_OT_rebuild_proxy);
- WM_operatortype_append(SEQUENCER_OT_enable_proxies);
- WM_operatortype_append(SEQUENCER_OT_change_effect_input);
- WM_operatortype_append(SEQUENCER_OT_change_effect_type);
- WM_operatortype_append(SEQUENCER_OT_change_path);
-
- /* sequencer_select.c */
- WM_operatortype_append(SEQUENCER_OT_select_all);
- WM_operatortype_append(SEQUENCER_OT_select);
- WM_operatortype_append(SEQUENCER_OT_select_more);
- WM_operatortype_append(SEQUENCER_OT_select_less);
- WM_operatortype_append(SEQUENCER_OT_select_linked_pick);
- WM_operatortype_append(SEQUENCER_OT_select_linked);
- WM_operatortype_append(SEQUENCER_OT_select_handles);
- WM_operatortype_append(SEQUENCER_OT_select_active_side);
- WM_operatortype_append(SEQUENCER_OT_select_box);
- WM_operatortype_append(SEQUENCER_OT_select_grouped);
-
- /* sequencer_add.c */
- WM_operatortype_append(SEQUENCER_OT_scene_strip_add);
- WM_operatortype_append(SEQUENCER_OT_movieclip_strip_add);
- WM_operatortype_append(SEQUENCER_OT_mask_strip_add);
- WM_operatortype_append(SEQUENCER_OT_movie_strip_add);
- WM_operatortype_append(SEQUENCER_OT_sound_strip_add);
- WM_operatortype_append(SEQUENCER_OT_image_strip_add);
- WM_operatortype_append(SEQUENCER_OT_effect_strip_add);
-
- /* sequencer_buttons.c */
- WM_operatortype_append(SEQUENCER_OT_properties);
-
- /* sequencer_modifiers.c */
- WM_operatortype_append(SEQUENCER_OT_strip_modifier_add);
- WM_operatortype_append(SEQUENCER_OT_strip_modifier_remove);
- WM_operatortype_append(SEQUENCER_OT_strip_modifier_move);
- WM_operatortype_append(SEQUENCER_OT_strip_modifier_copy);
-
- /* sequencer_view.h */
- WM_operatortype_append(SEQUENCER_OT_sample);
+ /* sequencer_edit.c */
+ WM_operatortype_append(SEQUENCER_OT_cut);
+ WM_operatortype_append(SEQUENCER_OT_slip);
+ WM_operatortype_append(SEQUENCER_OT_mute);
+ WM_operatortype_append(SEQUENCER_OT_unmute);
+ WM_operatortype_append(SEQUENCER_OT_lock);
+ WM_operatortype_append(SEQUENCER_OT_unlock);
+ WM_operatortype_append(SEQUENCER_OT_reload);
+ WM_operatortype_append(SEQUENCER_OT_refresh_all);
+ WM_operatortype_append(SEQUENCER_OT_reassign_inputs);
+ WM_operatortype_append(SEQUENCER_OT_swap_inputs);
+ WM_operatortype_append(SEQUENCER_OT_duplicate);
+ WM_operatortype_append(SEQUENCER_OT_delete);
+ WM_operatortype_append(SEQUENCER_OT_offset_clear);
+ WM_operatortype_append(SEQUENCER_OT_images_separate);
+ WM_operatortype_append(SEQUENCER_OT_meta_toggle);
+ WM_operatortype_append(SEQUENCER_OT_meta_make);
+ WM_operatortype_append(SEQUENCER_OT_meta_separate);
+
+ WM_operatortype_append(SEQUENCER_OT_gap_remove);
+ WM_operatortype_append(SEQUENCER_OT_gap_insert);
+ WM_operatortype_append(SEQUENCER_OT_snap);
+ WM_operatortype_append(SEQUENCER_OT_strip_jump);
+ WM_operatortype_append(SEQUENCER_OT_swap);
+ WM_operatortype_append(SEQUENCER_OT_swap_data);
+ WM_operatortype_append(SEQUENCER_OT_rendersize);
+
+ WM_operatortype_append(SEQUENCER_OT_export_subtitles);
+
+ WM_operatortype_append(SEQUENCER_OT_copy);
+ WM_operatortype_append(SEQUENCER_OT_paste);
+
+ WM_operatortype_append(SEQUENCER_OT_view_all);
+ WM_operatortype_append(SEQUENCER_OT_view_selected);
+ WM_operatortype_append(SEQUENCER_OT_view_frame);
+ WM_operatortype_append(SEQUENCER_OT_view_all_preview);
+ WM_operatortype_append(SEQUENCER_OT_view_toggle);
+ WM_operatortype_append(SEQUENCER_OT_view_zoom_ratio);
+ WM_operatortype_append(SEQUENCER_OT_view_ghost_border);
+
+ WM_operatortype_append(SEQUENCER_OT_rebuild_proxy);
+ WM_operatortype_append(SEQUENCER_OT_enable_proxies);
+ WM_operatortype_append(SEQUENCER_OT_change_effect_input);
+ WM_operatortype_append(SEQUENCER_OT_change_effect_type);
+ WM_operatortype_append(SEQUENCER_OT_change_path);
+
+ /* sequencer_select.c */
+ WM_operatortype_append(SEQUENCER_OT_select_all);
+ WM_operatortype_append(SEQUENCER_OT_select);
+ WM_operatortype_append(SEQUENCER_OT_select_more);
+ WM_operatortype_append(SEQUENCER_OT_select_less);
+ WM_operatortype_append(SEQUENCER_OT_select_linked_pick);
+ WM_operatortype_append(SEQUENCER_OT_select_linked);
+ WM_operatortype_append(SEQUENCER_OT_select_handles);
+ WM_operatortype_append(SEQUENCER_OT_select_active_side);
+ WM_operatortype_append(SEQUENCER_OT_select_box);
+ WM_operatortype_append(SEQUENCER_OT_select_grouped);
+
+ /* sequencer_add.c */
+ WM_operatortype_append(SEQUENCER_OT_scene_strip_add);
+ WM_operatortype_append(SEQUENCER_OT_movieclip_strip_add);
+ WM_operatortype_append(SEQUENCER_OT_mask_strip_add);
+ WM_operatortype_append(SEQUENCER_OT_movie_strip_add);
+ WM_operatortype_append(SEQUENCER_OT_sound_strip_add);
+ WM_operatortype_append(SEQUENCER_OT_image_strip_add);
+ WM_operatortype_append(SEQUENCER_OT_effect_strip_add);
+
+ /* sequencer_buttons.c */
+ WM_operatortype_append(SEQUENCER_OT_properties);
+
+ /* sequencer_modifiers.c */
+ WM_operatortype_append(SEQUENCER_OT_strip_modifier_add);
+ WM_operatortype_append(SEQUENCER_OT_strip_modifier_remove);
+ WM_operatortype_append(SEQUENCER_OT_strip_modifier_move);
+ WM_operatortype_append(SEQUENCER_OT_strip_modifier_copy);
+
+ /* sequencer_view.h */
+ WM_operatortype_append(SEQUENCER_OT_sample);
}
-
void sequencer_keymap(wmKeyConfig *keyconf)
{
- /* Common items ------------------------------------------------------------------ */
- WM_keymap_ensure(keyconf, "SequencerCommon", SPACE_SEQ, 0);
+ /* Common items ------------------------------------------------------------------ */
+ WM_keymap_ensure(keyconf, "SequencerCommon", SPACE_SEQ, 0);
- /* Strips Region --------------------------------------------------------------- */
- WM_keymap_ensure(keyconf, "Sequencer", SPACE_SEQ, 0);
+ /* Strips Region --------------------------------------------------------------- */
+ WM_keymap_ensure(keyconf, "Sequencer", SPACE_SEQ, 0);
- /* Preview Region ----------------------------------------------------------- */
- WM_keymap_ensure(keyconf, "SequencerPreview", SPACE_SEQ, 0);
+ /* Preview Region ----------------------------------------------------------- */
+ WM_keymap_ensure(keyconf, "SequencerPreview", SPACE_SEQ, 0);
}
void ED_operatormacros_sequencer(void)
{
- wmOperatorType *ot;
+ wmOperatorType *ot;
- ot = WM_operatortype_append_macro("SEQUENCER_OT_duplicate_move", "Duplicate Strips",
- "Duplicate selected strips and move them", OPTYPE_UNDO | OPTYPE_REGISTER);
+ ot = WM_operatortype_append_macro("SEQUENCER_OT_duplicate_move",
+ "Duplicate Strips",
+ "Duplicate selected strips and move them",
+ OPTYPE_UNDO | OPTYPE_REGISTER);
- WM_operatortype_macro_define(ot, "SEQUENCER_OT_duplicate");
- WM_operatortype_macro_define(ot, "TRANSFORM_OT_seq_slide");
+ WM_operatortype_macro_define(ot, "SEQUENCER_OT_duplicate");
+ WM_operatortype_macro_define(ot, "TRANSFORM_OT_seq_slide");
}
diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c
index 640d61a503b..546c2a8a9f0 100644
--- a/source/blender/editors/space_sequencer/sequencer_preview.c
+++ b/source/blender/editors/space_sequencer/sequencer_preview.c
@@ -41,126 +41,129 @@
#include "sequencer_intern.h"
typedef struct PreviewJob {
- ListBase previews;
- ThreadMutex *mutex;
- Scene *scene;
- int total;
- int processed;
+ ListBase previews;
+ ThreadMutex *mutex;
+ Scene *scene;
+ int total;
+ int processed;
} PreviewJob;
typedef struct PreviewJobAudio {
- struct PreviewJobAudio *next, *prev;
- bSound *sound;
- int lr; /* sample left or right */
- int startframe;
- bool waveform; /* reload sound or waveform */
+ struct PreviewJobAudio *next, *prev;
+ bSound *sound;
+ int lr; /* sample left or right */
+ int startframe;
+ bool waveform; /* reload sound or waveform */
} PreviewJobAudio;
static void free_preview_job(void *data)
{
- PreviewJob *pj = (PreviewJob *)data;
+ PreviewJob *pj = (PreviewJob *)data;
- BLI_mutex_free(pj->mutex);
- BLI_freelistN(&pj->previews);
- MEM_freeN(pj);
+ BLI_mutex_free(pj->mutex);
+ BLI_freelistN(&pj->previews);
+ MEM_freeN(pj);
}
/* only this runs inside thread */
static void preview_startjob(void *data, short *stop, short *do_update, float *progress)
{
- PreviewJob *pj = data;
- PreviewJobAudio *previewjb;
-
- BLI_mutex_lock(pj->mutex);
- previewjb = pj->previews.first;
- BLI_mutex_unlock(pj->mutex);
-
- while (previewjb) {
- PreviewJobAudio *preview_next;
- bSound *sound = previewjb->sound;
-
- BKE_sound_read_waveform(sound, stop);
-
- if (*stop || G.is_break) {
- BLI_mutex_lock(pj->mutex);
- previewjb = previewjb->next;
- BLI_mutex_unlock(pj->mutex);
- while (previewjb) {
- sound = previewjb->sound;
-
- /* make sure we cleanup the loading flag! */
- BLI_spin_lock(sound->spinlock);
- sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING;
- BLI_spin_unlock(sound->spinlock);
-
- BLI_mutex_lock(pj->mutex);
- previewjb = previewjb->next;
- BLI_mutex_unlock(pj->mutex);
- }
-
- BLI_mutex_lock(pj->mutex);
- BLI_freelistN(&pj->previews);
- pj->total = 0;
- pj->processed = 0;
- BLI_mutex_unlock(pj->mutex);
- break;
- }
-
- BLI_mutex_lock(pj->mutex);
- preview_next = previewjb->next;
- BLI_freelinkN(&pj->previews, previewjb);
- previewjb = preview_next;
- pj->processed++;
- *progress = (pj->total > 0) ? (float)pj->processed / (float)pj->total : 1.0f;
- *do_update = true;
- BLI_mutex_unlock(pj->mutex);
- }
+ PreviewJob *pj = data;
+ PreviewJobAudio *previewjb;
+
+ BLI_mutex_lock(pj->mutex);
+ previewjb = pj->previews.first;
+ BLI_mutex_unlock(pj->mutex);
+
+ while (previewjb) {
+ PreviewJobAudio *preview_next;
+ bSound *sound = previewjb->sound;
+
+ BKE_sound_read_waveform(sound, stop);
+
+ if (*stop || G.is_break) {
+ BLI_mutex_lock(pj->mutex);
+ previewjb = previewjb->next;
+ BLI_mutex_unlock(pj->mutex);
+ while (previewjb) {
+ sound = previewjb->sound;
+
+ /* make sure we cleanup the loading flag! */
+ BLI_spin_lock(sound->spinlock);
+ sound->tags &= ~SOUND_TAGS_WAVEFORM_LOADING;
+ BLI_spin_unlock(sound->spinlock);
+
+ BLI_mutex_lock(pj->mutex);
+ previewjb = previewjb->next;
+ BLI_mutex_unlock(pj->mutex);
+ }
+
+ BLI_mutex_lock(pj->mutex);
+ BLI_freelistN(&pj->previews);
+ pj->total = 0;
+ pj->processed = 0;
+ BLI_mutex_unlock(pj->mutex);
+ break;
+ }
+
+ BLI_mutex_lock(pj->mutex);
+ preview_next = previewjb->next;
+ BLI_freelinkN(&pj->previews, previewjb);
+ previewjb = preview_next;
+ pj->processed++;
+ *progress = (pj->total > 0) ? (float)pj->processed / (float)pj->total : 1.0f;
+ *do_update = true;
+ BLI_mutex_unlock(pj->mutex);
+ }
}
static void preview_endjob(void *data)
{
- PreviewJob *pj = data;
+ PreviewJob *pj = data;
- WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, pj->scene);
+ WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, pj->scene);
}
-
void sequencer_preview_add_sound(const bContext *C, Sequence *seq)
{
- /* first, get the preview job, if it exists */
- wmJob *wm_job;
- PreviewJob *pj;
- ScrArea *sa = CTX_wm_area(C);
- PreviewJobAudio *audiojob = MEM_callocN(sizeof(PreviewJobAudio), "preview_audio");
- wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Strip Previews",
- WM_JOB_PROGRESS, WM_JOB_TYPE_SEQ_BUILD_PREVIEW);
-
- pj = WM_jobs_customdata_get(wm_job);
-
- if (!pj) {
- pj = MEM_callocN(sizeof(PreviewJob), "preview rebuild job");
-
- pj->mutex = BLI_mutex_alloc();
- pj->scene = CTX_data_scene(C);
-
- WM_jobs_customdata_set(wm_job, pj, free_preview_job);
- WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER);
- WM_jobs_callbacks(wm_job, preview_startjob, NULL, NULL, preview_endjob);
- }
-
- /* attempt to lock mutex of job here */
-
- audiojob->sound = seq->sound;
-
- BLI_mutex_lock(pj->mutex);
- BLI_addtail(&pj->previews, audiojob);
- pj->total++;
- BLI_mutex_unlock(pj->mutex);
-
- if (!WM_jobs_is_running(wm_job)) {
- G.is_break = false;
- WM_jobs_start(CTX_wm_manager(C), wm_job);
- }
-
- ED_area_tag_redraw(sa);
+ /* first, get the preview job, if it exists */
+ wmJob *wm_job;
+ PreviewJob *pj;
+ ScrArea *sa = CTX_wm_area(C);
+ PreviewJobAudio *audiojob = MEM_callocN(sizeof(PreviewJobAudio), "preview_audio");
+ wm_job = WM_jobs_get(CTX_wm_manager(C),
+ CTX_wm_window(C),
+ sa,
+ "Strip Previews",
+ WM_JOB_PROGRESS,
+ WM_JOB_TYPE_SEQ_BUILD_PREVIEW);
+
+ pj = WM_jobs_customdata_get(wm_job);
+
+ if (!pj) {
+ pj = MEM_callocN(sizeof(PreviewJob), "preview rebuild job");
+
+ pj->mutex = BLI_mutex_alloc();
+ pj->scene = CTX_data_scene(C);
+
+ WM_jobs_customdata_set(wm_job, pj, free_preview_job);
+ WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER);
+ WM_jobs_callbacks(wm_job, preview_startjob, NULL, NULL, preview_endjob);
+ }
+
+ /* attempt to lock mutex of job here */
+
+ audiojob->sound = seq->sound;
+
+ BLI_mutex_lock(pj->mutex);
+ BLI_addtail(&pj->previews, audiojob);
+ pj->total++;
+ BLI_mutex_unlock(pj->mutex);
+
+ if (!WM_jobs_is_running(wm_job)) {
+ G.is_break = false;
+ WM_jobs_start(CTX_wm_manager(C), wm_job);
+ }
+
+ ED_area_tag_redraw(sa);
}
diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c
index 5ccd9e86e12..2aebc6c97fb 100644
--- a/source/blender/editors/space_sequencer/sequencer_scopes.c
+++ b/source/blender/editors/space_sequencer/sequencer_scopes.c
@@ -20,7 +20,6 @@
* \ingroup spseq
*/
-
#include <math.h>
#include <string.h>
@@ -39,738 +38,733 @@
* only difference is it does some normalize after, need to double check on this - campbell */
static void rgb_to_yuv_normalized(const float rgb[3], float yuv[3])
{
- yuv[0] = 0.299f * rgb[0] + 0.587f * rgb[1] + 0.114f * rgb[2];
- yuv[1] = 0.492f * (rgb[2] - yuv[0]);
- yuv[2] = 0.877f * (rgb[0] - yuv[0]);
+ yuv[0] = 0.299f * rgb[0] + 0.587f * rgb[1] + 0.114f * rgb[2];
+ yuv[1] = 0.492f * (rgb[2] - yuv[0]);
+ yuv[2] = 0.877f * (rgb[0] - yuv[0]);
- /* Normalize */
- yuv[1] *= 255.0f / (122 * 2.0f);
- yuv[1] += 0.5f;
+ /* Normalize */
+ yuv[1] *= 255.0f / (122 * 2.0f);
+ yuv[1] += 0.5f;
- yuv[2] *= 255.0f / (157 * 2.0f);
- yuv[2] += 0.5f;
+ yuv[2] *= 255.0f / (157 * 2.0f);
+ yuv[2] += 0.5f;
}
static void scope_put_pixel(unsigned char *table, unsigned char *pos)
{
- unsigned char newval = table[*pos];
- pos[0] = pos[1] = pos[2] = newval;
- pos[3] = 255;
+ unsigned char newval = table[*pos];
+ pos[0] = pos[1] = pos[2] = newval;
+ pos[3] = 255;
}
static void scope_put_pixel_single(unsigned char *table, unsigned char *pos, int col)
{
- char newval = table[pos[col]];
- pos[col] = newval;
- pos[3] = 255;
+ char newval = table[pos[col]];
+ pos[col] = newval;
+ pos[3] = 255;
}
static void wform_put_line(int w, unsigned char *last_pos, unsigned char *new_pos)
{
- if (last_pos > new_pos) {
- unsigned char *temp = new_pos;
- new_pos = last_pos;
- last_pos = temp;
- }
-
- while (last_pos < new_pos) {
- if (last_pos[0] == 0) {
- last_pos[0] = last_pos[1] = last_pos[2] = 32;
- last_pos[3] = 255;
- }
- last_pos += 4 * w;
- }
+ if (last_pos > new_pos) {
+ unsigned char *temp = new_pos;
+ new_pos = last_pos;
+ last_pos = temp;
+ }
+
+ while (last_pos < new_pos) {
+ if (last_pos[0] == 0) {
+ last_pos[0] = last_pos[1] = last_pos[2] = 32;
+ last_pos[3] = 255;
+ }
+ last_pos += 4 * w;
+ }
}
static void wform_put_line_single(int w, unsigned char *last_pos, unsigned char *new_pos, int col)
{
- if (last_pos > new_pos) {
- unsigned char *temp = new_pos;
- new_pos = last_pos;
- last_pos = temp;
- }
-
- while (last_pos < new_pos) {
- if (last_pos[col] == 0) {
- last_pos[col] = 32;
- last_pos[3] = 255;
- }
- last_pos += 4 * w;
- }
+ if (last_pos > new_pos) {
+ unsigned char *temp = new_pos;
+ new_pos = last_pos;
+ last_pos = temp;
+ }
+
+ while (last_pos < new_pos) {
+ if (last_pos[col] == 0) {
+ last_pos[col] = 32;
+ last_pos[3] = 255;
+ }
+ last_pos += 4 * w;
+ }
}
static void wform_put_border(unsigned char *tgt, int w, int h)
{
- int x, y;
-
- for (x = 0; x < w; x++) {
- unsigned char *p = tgt + 4 * x;
- p[1] = p[3] = 155;
- p[4 * w + 1] = p[4 * w + 3] = 155;
- p = tgt + 4 * (w * (h - 1) + x);
- p[1] = p[3] = 155;
- p[-4 * w + 1] = p[-4 * w + 3] = 155;
- }
-
- for (y = 0; y < h; y++) {
- unsigned char *p = tgt + 4 * w * y;
- p[1] = p[3] = 155;
- p[4 + 1] = p[4 + 3] = 155;
- p = tgt + 4 * (w * y + w - 1);
- p[1] = p[3] = 155;
- p[-4 + 1] = p[-4 + 3] = 155;
- }
+ int x, y;
+
+ for (x = 0; x < w; x++) {
+ unsigned char *p = tgt + 4 * x;
+ p[1] = p[3] = 155;
+ p[4 * w + 1] = p[4 * w + 3] = 155;
+ p = tgt + 4 * (w * (h - 1) + x);
+ p[1] = p[3] = 155;
+ p[-4 * w + 1] = p[-4 * w + 3] = 155;
+ }
+
+ for (y = 0; y < h; y++) {
+ unsigned char *p = tgt + 4 * w * y;
+ p[1] = p[3] = 155;
+ p[4 + 1] = p[4 + 3] = 155;
+ p = tgt + 4 * (w * y + w - 1);
+ p[1] = p[3] = 155;
+ p[-4 + 1] = p[-4 + 3] = 155;
+ }
}
static void wform_put_gridrow(unsigned char *tgt, float perc, int w, int h)
{
- int i;
+ int i;
- tgt += (int) (perc / 100.0f * h) * w * 4;
+ tgt += (int)(perc / 100.0f * h) * w * 4;
- for (i = 0; i < w * 2; i++) {
- tgt[0] = 255;
+ for (i = 0; i < w * 2; i++) {
+ tgt[0] = 255;
- tgt += 4;
- }
+ tgt += 4;
+ }
}
static void wform_put_grid(unsigned char *tgt, int w, int h)
{
- wform_put_gridrow(tgt, 90.0, w, h);
- wform_put_gridrow(tgt, 70.0, w, h);
- wform_put_gridrow(tgt, 10.0, w, h);
+ wform_put_gridrow(tgt, 90.0, w, h);
+ wform_put_gridrow(tgt, 70.0, w, h);
+ wform_put_gridrow(tgt, 10.0, w, h);
}
static ImBuf *make_waveform_view_from_ibuf_byte(ImBuf *ibuf)
{
- ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect);
- int x, y;
- const unsigned char *src = (unsigned char *)ibuf->rect;
- unsigned char *tgt = (unsigned char *)rval->rect;
- int w = ibuf->x + 3;
- int h = 515;
- float waveform_gamma = 0.2;
- unsigned char wtable[256];
-
- wform_put_grid(tgt, w, h);
- wform_put_border(tgt, w, h);
-
- for (x = 0; x < 256; x++) {
- wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255);
- }
-
- for (y = 0; y < ibuf->y; y++) {
- unsigned char *last_p = NULL;
-
- for (x = 0; x < ibuf->x; x++) {
- const unsigned char *rgb = src + 4 * (ibuf->x * y + x);
- float v = (float)IMB_colormanagement_get_luminance_byte(rgb) / 255.0f;
- unsigned char *p = tgt;
- p += 4 * (w * ((int) (v * (h - 3)) + 1) + x + 1);
-
- scope_put_pixel(wtable, p);
- p += 4 * w;
- scope_put_pixel(wtable, p);
-
- if (last_p != NULL) {
- wform_put_line(w, last_p, p);
- }
- last_p = p;
- }
- }
-
- return rval;
+ ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect);
+ int x, y;
+ const unsigned char *src = (unsigned char *)ibuf->rect;
+ unsigned char *tgt = (unsigned char *)rval->rect;
+ int w = ibuf->x + 3;
+ int h = 515;
+ float waveform_gamma = 0.2;
+ unsigned char wtable[256];
+
+ wform_put_grid(tgt, w, h);
+ wform_put_border(tgt, w, h);
+
+ for (x = 0; x < 256; x++) {
+ wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, waveform_gamma) * 255);
+ }
+
+ for (y = 0; y < ibuf->y; y++) {
+ unsigned char *last_p = NULL;
+
+ for (x = 0; x < ibuf->x; x++) {
+ const unsigned char *rgb = src + 4 * (ibuf->x * y + x);
+ float v = (float)IMB_colormanagement_get_luminance_byte(rgb) / 255.0f;
+ unsigned char *p = tgt;
+ p += 4 * (w * ((int)(v * (h - 3)) + 1) + x + 1);
+
+ scope_put_pixel(wtable, p);
+ p += 4 * w;
+ scope_put_pixel(wtable, p);
+
+ if (last_p != NULL) {
+ wform_put_line(w, last_p, p);
+ }
+ last_p = p;
+ }
+ }
+
+ return rval;
}
static ImBuf *make_waveform_view_from_ibuf_float(ImBuf *ibuf)
{
- ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect);
- int x, y;
- const float *src = ibuf->rect_float;
- unsigned char *tgt = (unsigned char *) rval->rect;
- int w = ibuf->x + 3;
- int h = 515;
- float waveform_gamma = 0.2;
- unsigned char wtable[256];
+ ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect);
+ int x, y;
+ const float *src = ibuf->rect_float;
+ unsigned char *tgt = (unsigned char *)rval->rect;
+ int w = ibuf->x + 3;
+ int h = 515;
+ float waveform_gamma = 0.2;
+ unsigned char wtable[256];
- wform_put_grid(tgt, w, h);
+ wform_put_grid(tgt, w, h);
- for (x = 0; x < 256; x++) {
- wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255);
- }
+ for (x = 0; x < 256; x++) {
+ wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, waveform_gamma) * 255);
+ }
- for (y = 0; y < ibuf->y; y++) {
- unsigned char *last_p = NULL;
+ for (y = 0; y < ibuf->y; y++) {
+ unsigned char *last_p = NULL;
- for (x = 0; x < ibuf->x; x++) {
- const float *rgb = src + 4 * (ibuf->x * y + x);
- float v = IMB_colormanagement_get_luminance(rgb);
- unsigned char *p = tgt;
+ for (x = 0; x < ibuf->x; x++) {
+ const float *rgb = src + 4 * (ibuf->x * y + x);
+ float v = IMB_colormanagement_get_luminance(rgb);
+ unsigned char *p = tgt;
- CLAMP(v, 0.0f, 1.0f);
+ CLAMP(v, 0.0f, 1.0f);
- p += 4 * (w * ((int) (v * (h - 3)) + 1) + x + 1);
+ p += 4 * (w * ((int)(v * (h - 3)) + 1) + x + 1);
- scope_put_pixel(wtable, p);
- p += 4 * w;
- scope_put_pixel(wtable, p);
+ scope_put_pixel(wtable, p);
+ p += 4 * w;
+ scope_put_pixel(wtable, p);
- if (last_p != NULL) {
- wform_put_line(w, last_p, p);
- }
- last_p = p;
- }
- }
+ if (last_p != NULL) {
+ wform_put_line(w, last_p, p);
+ }
+ last_p = p;
+ }
+ }
- wform_put_border(tgt, w, h);
+ wform_put_border(tgt, w, h);
- return rval;
+ return rval;
}
ImBuf *make_waveform_view_from_ibuf(ImBuf *ibuf)
{
- if (ibuf->rect_float) {
- return make_waveform_view_from_ibuf_float(ibuf);
- }
- else {
- return make_waveform_view_from_ibuf_byte(ibuf);
- }
+ if (ibuf->rect_float) {
+ return make_waveform_view_from_ibuf_float(ibuf);
+ }
+ else {
+ return make_waveform_view_from_ibuf_byte(ibuf);
+ }
}
-
static ImBuf *make_sep_waveform_view_from_ibuf_byte(ImBuf *ibuf)
{
- ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect);
- int x, y;
- const unsigned char *src = (const unsigned char *)ibuf->rect;
- unsigned char *tgt = (unsigned char *)rval->rect;
- int w = ibuf->x + 3;
- int sw = ibuf->x / 3;
- int h = 515;
- float waveform_gamma = 0.2;
- unsigned char wtable[256];
-
- wform_put_grid(tgt, w, h);
-
- for (x = 0; x < 256; x++) {
- wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255);
- }
-
- for (y = 0; y < ibuf->y; y++) {
- unsigned char *last_p[3] = {NULL, NULL, NULL};
-
- for (x = 0; x < ibuf->x; x++) {
- int c;
- const unsigned char *rgb = src + 4 * (ibuf->x * y + x);
- for (c = 0; c < 3; c++) {
- unsigned char *p = tgt;
- p += 4 * (w * ((rgb[c] * (h - 3)) / 255 + 1) + c * sw + x / 3 + 1);
-
- scope_put_pixel_single(wtable, p, c);
- p += 4 * w;
- scope_put_pixel_single(wtable, p, c);
-
- if (last_p[c] != NULL) {
- wform_put_line_single(w, last_p[c], p, c);
- }
- last_p[c] = p;
- }
- }
- }
-
- wform_put_border(tgt, w, h);
-
- return rval;
+ ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect);
+ int x, y;
+ const unsigned char *src = (const unsigned char *)ibuf->rect;
+ unsigned char *tgt = (unsigned char *)rval->rect;
+ int w = ibuf->x + 3;
+ int sw = ibuf->x / 3;
+ int h = 515;
+ float waveform_gamma = 0.2;
+ unsigned char wtable[256];
+
+ wform_put_grid(tgt, w, h);
+
+ for (x = 0; x < 256; x++) {
+ wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, waveform_gamma) * 255);
+ }
+
+ for (y = 0; y < ibuf->y; y++) {
+ unsigned char *last_p[3] = {NULL, NULL, NULL};
+
+ for (x = 0; x < ibuf->x; x++) {
+ int c;
+ const unsigned char *rgb = src + 4 * (ibuf->x * y + x);
+ for (c = 0; c < 3; c++) {
+ unsigned char *p = tgt;
+ p += 4 * (w * ((rgb[c] * (h - 3)) / 255 + 1) + c * sw + x / 3 + 1);
+
+ scope_put_pixel_single(wtable, p, c);
+ p += 4 * w;
+ scope_put_pixel_single(wtable, p, c);
+
+ if (last_p[c] != NULL) {
+ wform_put_line_single(w, last_p[c], p, c);
+ }
+ last_p[c] = p;
+ }
+ }
+ }
+
+ wform_put_border(tgt, w, h);
+
+ return rval;
}
static ImBuf *make_sep_waveform_view_from_ibuf_float(ImBuf *ibuf)
{
- ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect);
- int x, y;
- const float *src = ibuf->rect_float;
- unsigned char *tgt = (unsigned char *)rval->rect;
- int w = ibuf->x + 3;
- int sw = ibuf->x / 3;
- int h = 515;
- float waveform_gamma = 0.2;
- unsigned char wtable[256];
-
- wform_put_grid(tgt, w, h);
-
- for (x = 0; x < 256; x++) {
- wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255);
- }
-
- for (y = 0; y < ibuf->y; y++) {
- unsigned char *last_p[3] = {NULL, NULL, NULL};
-
- for (x = 0; x < ibuf->x; x++) {
- int c;
- const float *rgb = src + 4 * (ibuf->x * y + x);
- for (c = 0; c < 3; c++) {
- unsigned char *p = tgt;
- float v = rgb[c];
-
- CLAMP(v, 0.0f, 1.0f);
-
- p += 4 * (w * ((int) (v * (h - 3)) + 1) + c * sw + x / 3 + 1);
-
- scope_put_pixel_single(wtable, p, c);
- p += 4 * w;
- scope_put_pixel_single(wtable, p, c);
-
- if (last_p[c] != NULL) {
- wform_put_line_single(w, last_p[c], p, c);
- }
- last_p[c] = p;
- }
- }
- }
-
- wform_put_border(tgt, w, h);
-
- return rval;
+ ImBuf *rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect);
+ int x, y;
+ const float *src = ibuf->rect_float;
+ unsigned char *tgt = (unsigned char *)rval->rect;
+ int w = ibuf->x + 3;
+ int sw = ibuf->x / 3;
+ int h = 515;
+ float waveform_gamma = 0.2;
+ unsigned char wtable[256];
+
+ wform_put_grid(tgt, w, h);
+
+ for (x = 0; x < 256; x++) {
+ wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, waveform_gamma) * 255);
+ }
+
+ for (y = 0; y < ibuf->y; y++) {
+ unsigned char *last_p[3] = {NULL, NULL, NULL};
+
+ for (x = 0; x < ibuf->x; x++) {
+ int c;
+ const float *rgb = src + 4 * (ibuf->x * y + x);
+ for (c = 0; c < 3; c++) {
+ unsigned char *p = tgt;
+ float v = rgb[c];
+
+ CLAMP(v, 0.0f, 1.0f);
+
+ p += 4 * (w * ((int)(v * (h - 3)) + 1) + c * sw + x / 3 + 1);
+
+ scope_put_pixel_single(wtable, p, c);
+ p += 4 * w;
+ scope_put_pixel_single(wtable, p, c);
+
+ if (last_p[c] != NULL) {
+ wform_put_line_single(w, last_p[c], p, c);
+ }
+ last_p[c] = p;
+ }
+ }
+ }
+
+ wform_put_border(tgt, w, h);
+
+ return rval;
}
ImBuf *make_sep_waveform_view_from_ibuf(ImBuf *ibuf)
{
- if (ibuf->rect_float) {
- return make_sep_waveform_view_from_ibuf_float(ibuf);
- }
- else {
- return make_sep_waveform_view_from_ibuf_byte(ibuf);
- }
+ if (ibuf->rect_float) {
+ return make_sep_waveform_view_from_ibuf_float(ibuf);
+ }
+ else {
+ return make_sep_waveform_view_from_ibuf_byte(ibuf);
+ }
}
static void draw_zebra_byte(ImBuf *src, ImBuf *ibuf, float perc)
{
- unsigned int limit = 255.0f * perc / 100.0f;
- unsigned char *p = (unsigned char *) src->rect;
- unsigned char *o = (unsigned char *) ibuf->rect;
- int x;
- int y;
-
- for (y = 0; y < ibuf->y; y++) {
- for (x = 0; x < ibuf->x; x++) {
- unsigned char r = *p++;
- unsigned char g = *p++;
- unsigned char b = *p++;
- unsigned char a = *p++;
-
- if (r >= limit || g >= limit || b >= limit) {
- if (((x + y) & 0x08) != 0) {
- r = 255 - r;
- g = 255 - g;
- b = 255 - b;
- }
- }
- *o++ = r;
- *o++ = g;
- *o++ = b;
- *o++ = a;
- }
- }
+ unsigned int limit = 255.0f * perc / 100.0f;
+ unsigned char *p = (unsigned char *)src->rect;
+ unsigned char *o = (unsigned char *)ibuf->rect;
+ int x;
+ int y;
+
+ for (y = 0; y < ibuf->y; y++) {
+ for (x = 0; x < ibuf->x; x++) {
+ unsigned char r = *p++;
+ unsigned char g = *p++;
+ unsigned char b = *p++;
+ unsigned char a = *p++;
+
+ if (r >= limit || g >= limit || b >= limit) {
+ if (((x + y) & 0x08) != 0) {
+ r = 255 - r;
+ g = 255 - g;
+ b = 255 - b;
+ }
+ }
+ *o++ = r;
+ *o++ = g;
+ *o++ = b;
+ *o++ = a;
+ }
+ }
}
-
static void draw_zebra_float(ImBuf *src, ImBuf *ibuf, float perc)
{
- float limit = perc / 100.0f;
- const float *p = src->rect_float;
- unsigned char *o = (unsigned char *) ibuf->rect;
- int x;
- int y;
-
- for (y = 0; y < ibuf->y; y++) {
- for (x = 0; x < ibuf->x; x++) {
- float r = *p++;
- float g = *p++;
- float b = *p++;
- float a = *p++;
-
- if (r >= limit || g >= limit || b >= limit) {
- if (((x + y) & 0x08) != 0) {
- r = -r;
- g = -g;
- b = -b;
- }
- }
-
- *o++ = unit_float_to_uchar_clamp(r);
- *o++ = unit_float_to_uchar_clamp(g);
- *o++ = unit_float_to_uchar_clamp(b);
- *o++ = unit_float_to_uchar_clamp(a);
- }
- }
+ float limit = perc / 100.0f;
+ const float *p = src->rect_float;
+ unsigned char *o = (unsigned char *)ibuf->rect;
+ int x;
+ int y;
+
+ for (y = 0; y < ibuf->y; y++) {
+ for (x = 0; x < ibuf->x; x++) {
+ float r = *p++;
+ float g = *p++;
+ float b = *p++;
+ float a = *p++;
+
+ if (r >= limit || g >= limit || b >= limit) {
+ if (((x + y) & 0x08) != 0) {
+ r = -r;
+ g = -g;
+ b = -b;
+ }
+ }
+
+ *o++ = unit_float_to_uchar_clamp(r);
+ *o++ = unit_float_to_uchar_clamp(g);
+ *o++ = unit_float_to_uchar_clamp(b);
+ *o++ = unit_float_to_uchar_clamp(a);
+ }
+ }
}
ImBuf *make_zebra_view_from_ibuf(ImBuf *src, float perc)
{
- ImBuf *ibuf = IMB_allocImBuf(src->x, src->y, 32, IB_rect);
-
- if (src->rect_float) {
- draw_zebra_float(src, ibuf, perc);
- }
- else {
- draw_zebra_byte(src, ibuf, perc);
- }
- return ibuf;
+ ImBuf *ibuf = IMB_allocImBuf(src->x, src->y, 32, IB_rect);
+
+ if (src->rect_float) {
+ draw_zebra_float(src, ibuf, perc);
+ }
+ else {
+ draw_zebra_byte(src, ibuf, perc);
+ }
+ return ibuf;
}
static void draw_histogram_marker(ImBuf *ibuf, int x)
{
- unsigned char *p = (unsigned char *) ibuf->rect;
- int barh = ibuf->y * 0.1;
- int i;
+ unsigned char *p = (unsigned char *)ibuf->rect;
+ int barh = ibuf->y * 0.1;
+ int i;
- p += 4 * (x + ibuf->x * (ibuf->y - barh + 1));
+ p += 4 * (x + ibuf->x * (ibuf->y - barh + 1));
- for (i = 0; i < barh - 1; i++) {
- p[0] = p[1] = p[2] = 255;
- p += ibuf->x * 4;
- }
+ for (i = 0; i < barh - 1; i++) {
+ p[0] = p[1] = p[2] = 255;
+ p += ibuf->x * 4;
+ }
}
static void draw_histogram_bar(ImBuf *ibuf, int x, float val, int col)
{
- unsigned char *p = (unsigned char *) ibuf->rect;
- int barh = ibuf->y * val * 0.9f;
- int i;
+ unsigned char *p = (unsigned char *)ibuf->rect;
+ int barh = ibuf->y * val * 0.9f;
+ int i;
- p += 4 * (x + ibuf->x);
+ p += 4 * (x + ibuf->x);
- for (i = 0; i < barh; i++) {
- p[col] = 255;
- p += ibuf->x * 4;
- }
+ for (i = 0; i < barh; i++) {
+ p[col] = 255;
+ p += ibuf->x * 4;
+ }
}
#define HIS_STEPS 512
typedef struct MakeHistogramViewData {
- const ImBuf *ibuf;
- uint32_t (*bins)[HIS_STEPS];
+ const ImBuf *ibuf;
+ uint32_t (*bins)[HIS_STEPS];
} MakeHistogramViewData;
-static void make_histogram_view_from_ibuf_byte_cb_ex(
- void *__restrict userdata,
- const int y,
- const ParallelRangeTLS *__restrict tls)
+static void make_histogram_view_from_ibuf_byte_cb_ex(void *__restrict userdata,
+ const int y,
+ const ParallelRangeTLS *__restrict tls)
{
- MakeHistogramViewData *data = userdata;
- const ImBuf *ibuf = data->ibuf;
- const unsigned char *src = (unsigned char *)ibuf->rect;
+ MakeHistogramViewData *data = userdata;
+ const ImBuf *ibuf = data->ibuf;
+ const unsigned char *src = (unsigned char *)ibuf->rect;
- uint32_t (*cur_bins)[HIS_STEPS] = tls->userdata_chunk;
+ uint32_t(*cur_bins)[HIS_STEPS] = tls->userdata_chunk;
- for (int x = 0; x < ibuf->x; x++) {
- const unsigned char *pixel = src + (y * ibuf->x + x) * 4;
+ for (int x = 0; x < ibuf->x; x++) {
+ const unsigned char *pixel = src + (y * ibuf->x + x) * 4;
- for (int j = 3; j--;) {
- cur_bins[j][pixel[j]]++;
- }
- }
+ for (int j = 3; j--;) {
+ cur_bins[j][pixel[j]]++;
+ }
+ }
}
static void make_histogram_view_from_ibuf_finalize(void *__restrict userdata,
void *__restrict userdata_chunk)
{
- MakeHistogramViewData *data = userdata;
- uint32_t (*bins)[HIS_STEPS] = data->bins;
+ MakeHistogramViewData *data = userdata;
+ uint32_t(*bins)[HIS_STEPS] = data->bins;
- uint32_t (*cur_bins)[HIS_STEPS] = userdata_chunk;
+ uint32_t(*cur_bins)[HIS_STEPS] = userdata_chunk;
- for (int j = 3; j--;) {
- for (int i = 0; i < HIS_STEPS; i++) {
- bins[j][i] += cur_bins[j][i];
- }
- }
+ for (int j = 3; j--;) {
+ for (int i = 0; i < HIS_STEPS; i++) {
+ bins[j][i] += cur_bins[j][i];
+ }
+ }
}
static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
{
- ImBuf *rval = IMB_allocImBuf(515, 128, 32, IB_rect);
- int x;
- unsigned int nr, ng, nb;
-
- unsigned int bins[3][HIS_STEPS];
-
- memset(bins, 0, sizeof(bins));
-
- MakeHistogramViewData data = { .ibuf = ibuf, .bins = bins, };
- ParallelRangeSettings settings;
- BLI_parallel_range_settings_defaults(&settings);
- settings.use_threading = (ibuf->y >= 256);
- settings.userdata_chunk = bins;
- settings.userdata_chunk_size = sizeof(bins);
- settings.func_finalize = make_histogram_view_from_ibuf_finalize;
- BLI_task_parallel_range(
- 0, ibuf->y,
- &data,
- make_histogram_view_from_ibuf_byte_cb_ex,
- &settings);
-
- nr = nb = ng = 0;
- for (x = 0; x < HIS_STEPS; x++) {
- if (bins[0][x] > nr) {
- nr = bins[0][x];
- }
- if (bins[1][x] > ng) {
- ng = bins[1][x];
- }
- if (bins[2][x] > nb) {
- nb = bins[2][x];
- }
- }
-
- for (x = 0; x < HIS_STEPS; x++) {
- if (nr) {
- draw_histogram_bar(rval, x * 2 + 1, ((float) bins[0][x]) / nr, 0);
- draw_histogram_bar(rval, x * 2 + 2, ((float) bins[0][x]) / nr, 0);
- }
- if (ng) {
- draw_histogram_bar(rval, x * 2 + 1, ((float) bins[1][x]) / ng, 1);
- draw_histogram_bar(rval, x * 2 + 2, ((float) bins[1][x]) / ng, 1);
- }
- if (nb) {
- draw_histogram_bar(rval, x * 2 + 1, ((float) bins[2][x]) / nb, 2);
- draw_histogram_bar(rval, x * 2 + 2, ((float) bins[2][x]) / nb, 2);
- }
- }
-
- wform_put_border((unsigned char *) rval->rect, rval->x, rval->y);
-
- return rval;
+ ImBuf *rval = IMB_allocImBuf(515, 128, 32, IB_rect);
+ int x;
+ unsigned int nr, ng, nb;
+
+ unsigned int bins[3][HIS_STEPS];
+
+ memset(bins, 0, sizeof(bins));
+
+ MakeHistogramViewData data = {
+ .ibuf = ibuf,
+ .bins = bins,
+ };
+ ParallelRangeSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.use_threading = (ibuf->y >= 256);
+ settings.userdata_chunk = bins;
+ settings.userdata_chunk_size = sizeof(bins);
+ settings.func_finalize = make_histogram_view_from_ibuf_finalize;
+ BLI_task_parallel_range(0, ibuf->y, &data, make_histogram_view_from_ibuf_byte_cb_ex, &settings);
+
+ nr = nb = ng = 0;
+ for (x = 0; x < HIS_STEPS; x++) {
+ if (bins[0][x] > nr) {
+ nr = bins[0][x];
+ }
+ if (bins[1][x] > ng) {
+ ng = bins[1][x];
+ }
+ if (bins[2][x] > nb) {
+ nb = bins[2][x];
+ }
+ }
+
+ for (x = 0; x < HIS_STEPS; x++) {
+ if (nr) {
+ draw_histogram_bar(rval, x * 2 + 1, ((float)bins[0][x]) / nr, 0);
+ draw_histogram_bar(rval, x * 2 + 2, ((float)bins[0][x]) / nr, 0);
+ }
+ if (ng) {
+ draw_histogram_bar(rval, x * 2 + 1, ((float)bins[1][x]) / ng, 1);
+ draw_histogram_bar(rval, x * 2 + 2, ((float)bins[1][x]) / ng, 1);
+ }
+ if (nb) {
+ draw_histogram_bar(rval, x * 2 + 1, ((float)bins[2][x]) / nb, 2);
+ draw_histogram_bar(rval, x * 2 + 2, ((float)bins[2][x]) / nb, 2);
+ }
+ }
+
+ wform_put_border((unsigned char *)rval->rect, rval->x, rval->y);
+
+ return rval;
}
BLI_INLINE int get_bin_float(float f)
{
- if (f < -0.25f) {
- return 0;
- }
- else if (f >= 1.25f) {
- return 511;
- }
-
- return (int) (((f + 0.25f) / 1.5f) * 512);
+ if (f < -0.25f) {
+ return 0;
+ }
+ else if (f >= 1.25f) {
+ return 511;
+ }
+
+ return (int)(((f + 0.25f) / 1.5f) * 512);
}
-static void make_histogram_view_from_ibuf_float_cb_ex(
- void *__restrict userdata,
- const int y,
- const ParallelRangeTLS *__restrict tls)
+static void make_histogram_view_from_ibuf_float_cb_ex(void *__restrict userdata,
+ const int y,
+ const ParallelRangeTLS *__restrict tls)
{
- const MakeHistogramViewData *data = userdata;
- const ImBuf *ibuf = data->ibuf;
- const float *src = ibuf->rect_float;
+ const MakeHistogramViewData *data = userdata;
+ const ImBuf *ibuf = data->ibuf;
+ const float *src = ibuf->rect_float;
- uint32_t (*cur_bins)[HIS_STEPS] = tls->userdata_chunk;
+ uint32_t(*cur_bins)[HIS_STEPS] = tls->userdata_chunk;
- for (int x = 0; x < ibuf->x; x++) {
- const float *pixel = src + (y * ibuf->x + x) * 4;
+ for (int x = 0; x < ibuf->x; x++) {
+ const float *pixel = src + (y * ibuf->x + x) * 4;
- for (int j = 3; j--;) {
- cur_bins[j][get_bin_float(pixel[j])]++;
- }
- }
+ for (int j = 3; j--;) {
+ cur_bins[j][get_bin_float(pixel[j])]++;
+ }
+ }
}
static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
{
- ImBuf *rval = IMB_allocImBuf(515, 128, 32, IB_rect);
- int nr, ng, nb;
- int x;
-
- unsigned int bins[3][HIS_STEPS];
-
- memset(bins, 0, sizeof(bins));
-
- MakeHistogramViewData data = { .ibuf = ibuf, .bins = bins, };
- ParallelRangeSettings settings;
- BLI_parallel_range_settings_defaults(&settings);
- settings.use_threading = (ibuf->y >= 256);
- settings.userdata_chunk = bins;
- settings.userdata_chunk_size = sizeof(bins);
- settings.func_finalize = make_histogram_view_from_ibuf_finalize;
- BLI_task_parallel_range(
- 0, ibuf->y,
- &data,
- make_histogram_view_from_ibuf_float_cb_ex,
- &settings);
-
- nr = nb = ng = 0;
- for (x = 0; x < HIS_STEPS; x++) {
- if (bins[0][x] > nr) {
- nr = bins[0][x];
- }
- if (bins[1][x] > ng) {
- ng = bins[1][x];
- }
- if (bins[2][x] > nb) {
- nb = bins[2][x];
- }
- }
-
- for (x = 0; x < HIS_STEPS; x++) {
- if (nr) {
- draw_histogram_bar(rval, x + 1, ((float) bins[0][x]) / nr, 0);
- }
- if (ng) {
- draw_histogram_bar(rval, x + 1, ((float) bins[1][x]) / ng, 1);
- }
- if (nb) {
- draw_histogram_bar(rval, x + 1, ((float) bins[2][x]) / nb, 2);
- }
- }
-
- draw_histogram_marker(rval, get_bin_float(0.0));
- draw_histogram_marker(rval, get_bin_float(1.0));
- wform_put_border((unsigned char *) rval->rect, rval->x, rval->y);
-
- return rval;
+ ImBuf *rval = IMB_allocImBuf(515, 128, 32, IB_rect);
+ int nr, ng, nb;
+ int x;
+
+ unsigned int bins[3][HIS_STEPS];
+
+ memset(bins, 0, sizeof(bins));
+
+ MakeHistogramViewData data = {
+ .ibuf = ibuf,
+ .bins = bins,
+ };
+ ParallelRangeSettings settings;
+ BLI_parallel_range_settings_defaults(&settings);
+ settings.use_threading = (ibuf->y >= 256);
+ settings.userdata_chunk = bins;
+ settings.userdata_chunk_size = sizeof(bins);
+ settings.func_finalize = make_histogram_view_from_ibuf_finalize;
+ BLI_task_parallel_range(0, ibuf->y, &data, make_histogram_view_from_ibuf_float_cb_ex, &settings);
+
+ nr = nb = ng = 0;
+ for (x = 0; x < HIS_STEPS; x++) {
+ if (bins[0][x] > nr) {
+ nr = bins[0][x];
+ }
+ if (bins[1][x] > ng) {
+ ng = bins[1][x];
+ }
+ if (bins[2][x] > nb) {
+ nb = bins[2][x];
+ }
+ }
+
+ for (x = 0; x < HIS_STEPS; x++) {
+ if (nr) {
+ draw_histogram_bar(rval, x + 1, ((float)bins[0][x]) / nr, 0);
+ }
+ if (ng) {
+ draw_histogram_bar(rval, x + 1, ((float)bins[1][x]) / ng, 1);
+ }
+ if (nb) {
+ draw_histogram_bar(rval, x + 1, ((float)bins[2][x]) / nb, 2);
+ }
+ }
+
+ draw_histogram_marker(rval, get_bin_float(0.0));
+ draw_histogram_marker(rval, get_bin_float(1.0));
+ wform_put_border((unsigned char *)rval->rect, rval->x, rval->y);
+
+ return rval;
}
#undef HIS_STEPS
ImBuf *make_histogram_view_from_ibuf(ImBuf *ibuf)
{
- if (ibuf->rect_float) {
- return make_histogram_view_from_ibuf_float(ibuf);
- }
- else {
- return make_histogram_view_from_ibuf_byte(ibuf);
- }
+ if (ibuf->rect_float) {
+ return make_histogram_view_from_ibuf_float(ibuf);
+ }
+ else {
+ return make_histogram_view_from_ibuf_byte(ibuf);
+ }
}
-static void vectorscope_put_cross(unsigned char r, unsigned char g, unsigned char b, char *tgt, int w, int h, int size)
+static void vectorscope_put_cross(
+ unsigned char r, unsigned char g, unsigned char b, char *tgt, int w, int h, int size)
{
- float rgb[3], yuv[3];
- char *p;
- int x = 0;
- int y = 0;
-
- rgb[0] = (float)r / 255.0f;
- rgb[1] = (float)g / 255.0f;
- rgb[2] = (float)b / 255.0f;
- rgb_to_yuv_normalized(rgb, yuv);
-
- p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) +
- (int) ((yuv[1] * (w - 3) + 1)));
-
- if (r == 0 && g == 0 && b == 0) {
- r = 255;
- }
-
- for (y = -size; y <= size; y++) {
- for (x = -size; x <= size; x++) {
- char *q = p + 4 * (y * w + x);
- q[0] = r; q[1] = g; q[2] = b; q[3] = 255;
- }
- }
+ float rgb[3], yuv[3];
+ char *p;
+ int x = 0;
+ int y = 0;
+
+ rgb[0] = (float)r / 255.0f;
+ rgb[1] = (float)g / 255.0f;
+ rgb[2] = (float)b / 255.0f;
+ rgb_to_yuv_normalized(rgb, yuv);
+
+ p = tgt + 4 * (w * (int)((yuv[2] * (h - 3) + 1)) + (int)((yuv[1] * (w - 3) + 1)));
+
+ if (r == 0 && g == 0 && b == 0) {
+ r = 255;
+ }
+
+ for (y = -size; y <= size; y++) {
+ for (x = -size; x <= size; x++) {
+ char *q = p + 4 * (y * w + x);
+ q[0] = r;
+ q[1] = g;
+ q[2] = b;
+ q[3] = 255;
+ }
+ }
}
static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf)
{
- ImBuf *rval = IMB_allocImBuf(515, 515, 32, IB_rect);
- int x, y;
- const char *src = (const char *) ibuf->rect;
- char *tgt = (char *) rval->rect;
- float rgb[3], yuv[3];
- int w = 515;
- int h = 515;
- float scope_gamma = 0.2;
- unsigned char wtable[256];
-
- for (x = 0; x < 256; x++) {
- wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, scope_gamma) * 255);
- }
-
- for (x = 0; x < 256; x++) {
- vectorscope_put_cross(255, 0, 255 - x, tgt, w, h, 1);
- vectorscope_put_cross(255, x, 0, tgt, w, h, 1);
- vectorscope_put_cross(255 - x, 255, 0, tgt, w, h, 1);
- vectorscope_put_cross(0, 255, x, tgt, w, h, 1);
- vectorscope_put_cross(0, 255 - x, 255, tgt, w, h, 1);
- vectorscope_put_cross(x, 0, 255, tgt, w, h, 1);
- }
-
- for (y = 0; y < ibuf->y; y++) {
- for (x = 0; x < ibuf->x; x++) {
- const char *src1 = src + 4 * (ibuf->x * y + x);
- char *p;
-
- rgb[0] = (float)src1[0] / 255.0f;
- rgb[1] = (float)src1[1] / 255.0f;
- rgb[2] = (float)src1[2] / 255.0f;
- rgb_to_yuv_normalized(rgb, yuv);
-
- p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) +
- (int) ((yuv[1] * (w - 3) + 1)));
- scope_put_pixel(wtable, (unsigned char *)p);
- }
- }
-
- vectorscope_put_cross(0, 0, 0, tgt, w, h, 3);
-
- return rval;
+ ImBuf *rval = IMB_allocImBuf(515, 515, 32, IB_rect);
+ int x, y;
+ const char *src = (const char *)ibuf->rect;
+ char *tgt = (char *)rval->rect;
+ float rgb[3], yuv[3];
+ int w = 515;
+ int h = 515;
+ float scope_gamma = 0.2;
+ unsigned char wtable[256];
+
+ for (x = 0; x < 256; x++) {
+ wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, scope_gamma) * 255);
+ }
+
+ for (x = 0; x < 256; x++) {
+ vectorscope_put_cross(255, 0, 255 - x, tgt, w, h, 1);
+ vectorscope_put_cross(255, x, 0, tgt, w, h, 1);
+ vectorscope_put_cross(255 - x, 255, 0, tgt, w, h, 1);
+ vectorscope_put_cross(0, 255, x, tgt, w, h, 1);
+ vectorscope_put_cross(0, 255 - x, 255, tgt, w, h, 1);
+ vectorscope_put_cross(x, 0, 255, tgt, w, h, 1);
+ }
+
+ for (y = 0; y < ibuf->y; y++) {
+ for (x = 0; x < ibuf->x; x++) {
+ const char *src1 = src + 4 * (ibuf->x * y + x);
+ char *p;
+
+ rgb[0] = (float)src1[0] / 255.0f;
+ rgb[1] = (float)src1[1] / 255.0f;
+ rgb[2] = (float)src1[2] / 255.0f;
+ rgb_to_yuv_normalized(rgb, yuv);
+
+ p = tgt + 4 * (w * (int)((yuv[2] * (h - 3) + 1)) + (int)((yuv[1] * (w - 3) + 1)));
+ scope_put_pixel(wtable, (unsigned char *)p);
+ }
+ }
+
+ vectorscope_put_cross(0, 0, 0, tgt, w, h, 3);
+
+ return rval;
}
static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf)
{
- ImBuf *rval = IMB_allocImBuf(515, 515, 32, IB_rect);
- int x, y;
- const float *src = ibuf->rect_float;
- char *tgt = (char *) rval->rect;
- float rgb[3], yuv[3];
- int w = 515;
- int h = 515;
- float scope_gamma = 0.2;
- unsigned char wtable[256];
-
- for (x = 0; x < 256; x++) {
- wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, scope_gamma) * 255);
- }
-
- for (x = 0; x <= 255; x++) {
- vectorscope_put_cross(255, 0, 255 - x, tgt, w, h, 1);
- vectorscope_put_cross(255, x, 0, tgt, w, h, 1);
- vectorscope_put_cross(255 - x, 255, 0, tgt, w, h, 1);
- vectorscope_put_cross(0, 255, x, tgt, w, h, 1);
- vectorscope_put_cross(0, 255 - x, 255, tgt, w, h, 1);
- vectorscope_put_cross(x, 0, 255, tgt, w, h, 1);
- }
-
- for (y = 0; y < ibuf->y; y++) {
- for (x = 0; x < ibuf->x; x++) {
- const float *src1 = src + 4 * (ibuf->x * y + x);
- const char *p;
-
- memcpy(rgb, src1, 3 * sizeof(float));
-
- CLAMP(rgb[0], 0.0f, 1.0f);
- CLAMP(rgb[1], 0.0f, 1.0f);
- CLAMP(rgb[2], 0.0f, 1.0f);
-
- rgb_to_yuv_normalized(rgb, yuv);
-
- p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) +
- (int) ((yuv[1] * (w - 3) + 1)));
- scope_put_pixel(wtable, (unsigned char *)p);
- }
- }
-
- vectorscope_put_cross(0, 0, 0, tgt, w, h, 3);
-
- return rval;
+ ImBuf *rval = IMB_allocImBuf(515, 515, 32, IB_rect);
+ int x, y;
+ const float *src = ibuf->rect_float;
+ char *tgt = (char *)rval->rect;
+ float rgb[3], yuv[3];
+ int w = 515;
+ int h = 515;
+ float scope_gamma = 0.2;
+ unsigned char wtable[256];
+
+ for (x = 0; x < 256; x++) {
+ wtable[x] = (unsigned char)(pow(((float)x + 1) / 256, scope_gamma) * 255);
+ }
+
+ for (x = 0; x <= 255; x++) {
+ vectorscope_put_cross(255, 0, 255 - x, tgt, w, h, 1);
+ vectorscope_put_cross(255, x, 0, tgt, w, h, 1);
+ vectorscope_put_cross(255 - x, 255, 0, tgt, w, h, 1);
+ vectorscope_put_cross(0, 255, x, tgt, w, h, 1);
+ vectorscope_put_cross(0, 255 - x, 255, tgt, w, h, 1);
+ vectorscope_put_cross(x, 0, 255, tgt, w, h, 1);
+ }
+
+ for (y = 0; y < ibuf->y; y++) {
+ for (x = 0; x < ibuf->x; x++) {
+ const float *src1 = src + 4 * (ibuf->x * y + x);
+ const char *p;
+
+ memcpy(rgb, src1, 3 * sizeof(float));
+
+ CLAMP(rgb[0], 0.0f, 1.0f);
+ CLAMP(rgb[1], 0.0f, 1.0f);
+ CLAMP(rgb[2], 0.0f, 1.0f);
+
+ rgb_to_yuv_normalized(rgb, yuv);
+
+ p = tgt + 4 * (w * (int)((yuv[2] * (h - 3) + 1)) + (int)((yuv[1] * (w - 3) + 1)));
+ scope_put_pixel(wtable, (unsigned char *)p);
+ }
+ }
+
+ vectorscope_put_cross(0, 0, 0, tgt, w, h, 3);
+
+ return rval;
}
ImBuf *make_vectorscope_view_from_ibuf(ImBuf *ibuf)
{
- if (ibuf->rect_float) {
- return make_vectorscope_view_from_ibuf_float(ibuf);
- }
- else {
- return make_vectorscope_view_from_ibuf_byte(ibuf);
- }
+ if (ibuf->rect_float) {
+ return make_vectorscope_view_from_ibuf_float(ibuf);
+ }
+ else {
+ return make_vectorscope_view_from_ibuf_byte(ibuf);
+ }
}
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index 6de20e3c4af..a59a3b830e3 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -21,7 +21,6 @@
* \ingroup spseq
*/
-
#include <stdlib.h>
#include <math.h>
#include <string.h>
@@ -52,1183 +51,1191 @@
#include "sequencer_intern.h"
static void *find_nearest_marker(int UNUSED(d1), int UNUSED(d2))
{
- return NULL;
+ return NULL;
}
static void select_surrounding_handles(Scene *scene, Sequence *test) /* XXX BRING BACK */
{
- Sequence *neighbor;
-
- neighbor = find_neighboring_sequence(scene, test, SEQ_SIDE_LEFT, -1);
- if (neighbor) {
- /* Only select neighbor handle if matching handle from test seq is also selected, or if neighbor
- * was not selected at all up till now.
- * Otherwise, we get odd mismatch when shift-alt-rmb selecting neighbor strips... */
- if (!(neighbor->flag & SELECT) || (test->flag & SEQ_LEFTSEL)) {
- neighbor->flag |= SEQ_RIGHTSEL;
- }
- neighbor->flag |= SELECT;
- recurs_sel_seq(neighbor);
- }
- neighbor = find_neighboring_sequence(scene, test, SEQ_SIDE_RIGHT, -1);
- if (neighbor) {
- if (!(neighbor->flag & SELECT) || (test->flag & SEQ_RIGHTSEL)) { /* See comment above. */
- neighbor->flag |= SEQ_LEFTSEL;
- }
- neighbor->flag |= SELECT;
- recurs_sel_seq(neighbor);
- }
+ Sequence *neighbor;
+
+ neighbor = find_neighboring_sequence(scene, test, SEQ_SIDE_LEFT, -1);
+ if (neighbor) {
+ /* Only select neighbor handle if matching handle from test seq is also selected, or if neighbor
+ * was not selected at all up till now.
+ * Otherwise, we get odd mismatch when shift-alt-rmb selecting neighbor strips... */
+ if (!(neighbor->flag & SELECT) || (test->flag & SEQ_LEFTSEL)) {
+ neighbor->flag |= SEQ_RIGHTSEL;
+ }
+ neighbor->flag |= SELECT;
+ recurs_sel_seq(neighbor);
+ }
+ neighbor = find_neighboring_sequence(scene, test, SEQ_SIDE_RIGHT, -1);
+ if (neighbor) {
+ if (!(neighbor->flag & SELECT) || (test->flag & SEQ_RIGHTSEL)) { /* See comment above. */
+ neighbor->flag |= SEQ_LEFTSEL;
+ }
+ neighbor->flag |= SELECT;
+ recurs_sel_seq(neighbor);
+ }
}
/* used for mouse selection and for SEQUENCER_OT_select_active_side() */
static void select_active_side(ListBase *seqbase, int sel_side, int channel, int frame)
{
- Sequence *seq;
-
- for (seq = seqbase->first; seq; seq = seq->next) {
- if (channel == seq->machine) {
- switch (sel_side) {
- case SEQ_SIDE_LEFT:
- if (frame > (seq->startdisp)) {
- seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
- seq->flag |= SELECT;
- }
- break;
- case SEQ_SIDE_RIGHT:
- if (frame < (seq->startdisp)) {
- seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
- seq->flag |= SELECT;
- }
- break;
- case SEQ_SIDE_BOTH:
- seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
- seq->flag |= SELECT;
- break;
- }
- }
- }
+ Sequence *seq;
+
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ if (channel == seq->machine) {
+ switch (sel_side) {
+ case SEQ_SIDE_LEFT:
+ if (frame > (seq->startdisp)) {
+ seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
+ seq->flag |= SELECT;
+ }
+ break;
+ case SEQ_SIDE_RIGHT:
+ if (frame < (seq->startdisp)) {
+ seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
+ seq->flag |= SELECT;
+ }
+ break;
+ case SEQ_SIDE_BOTH:
+ seq->flag &= ~(SEQ_RIGHTSEL | SEQ_LEFTSEL);
+ seq->flag |= SELECT;
+ break;
+ }
+ }
+ }
}
/* used for mouse selection and for SEQUENCER_OT_select_active_side() */
static void select_linked_time(ListBase *seqbase, Sequence *seq_link)
{
- Sequence *seq;
+ Sequence *seq;
- for (seq = seqbase->first; seq; seq = seq->next) {
- if (seq_link->machine != seq->machine) {
- int left_match = (seq->startdisp == seq_link->startdisp) ? 1 : 0;
- int right_match = (seq->enddisp == seq_link->enddisp) ? 1 : 0;
+ for (seq = seqbase->first; seq; seq = seq->next) {
+ if (seq_link->machine != seq->machine) {
+ int left_match = (seq->startdisp == seq_link->startdisp) ? 1 : 0;
+ int right_match = (seq->enddisp == seq_link->enddisp) ? 1 : 0;
- if (left_match && right_match) {
- /* a direct match, copy the selection settinhs */
- seq->flag &= ~(SELECT | SEQ_LEFTSEL | SEQ_RIGHTSEL);
- seq->flag |= seq_link->flag & (SELECT | SEQ_LEFTSEL | SEQ_RIGHTSEL);
+ if (left_match && right_match) {
+ /* a direct match, copy the selection settinhs */
+ seq->flag &= ~(SELECT | SEQ_LEFTSEL | SEQ_RIGHTSEL);
+ seq->flag |= seq_link->flag & (SELECT | SEQ_LEFTSEL | SEQ_RIGHTSEL);
- recurs_sel_seq(seq);
- }
- else if (seq_link->flag & SELECT && (left_match || right_match)) {
+ recurs_sel_seq(seq);
+ }
+ else if (seq_link->flag & SELECT && (left_match || right_match)) {
- /* clear for reselection */
- seq->flag &= ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
+ /* clear for reselection */
+ seq->flag &= ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
- if (left_match && seq_link->flag & SEQ_LEFTSEL) {
- seq->flag |= SELECT | SEQ_LEFTSEL;
- }
+ if (left_match && seq_link->flag & SEQ_LEFTSEL) {
+ seq->flag |= SELECT | SEQ_LEFTSEL;
+ }
- if (right_match && seq_link->flag & SEQ_RIGHTSEL) {
- seq->flag |= SELECT | SEQ_RIGHTSEL;
- }
+ if (right_match && seq_link->flag & SEQ_RIGHTSEL) {
+ seq->flag |= SELECT | SEQ_RIGHTSEL;
+ }
- recurs_sel_seq(seq);
- }
- }
- }
+ recurs_sel_seq(seq);
+ }
+ }
+ }
}
-#if 0 // BRING BACK
+#if 0 // BRING BACK
void select_surround_from_last(Scene *scene)
{
- Sequence *seq = get_last_seq(scene);
+ Sequence *seq = get_last_seq(scene);
- if (seq == NULL)
- return;
+ if (seq == NULL)
+ return;
- select_surrounding_handles(scene, seq);
+ select_surrounding_handles(scene, seq);
}
#endif
void ED_sequencer_select_sequence_single(Scene *scene, Sequence *seq, bool deselect_all)
{
- Editing *ed = BKE_sequencer_editing_get(scene, false);
-
- if (deselect_all) {
- ED_sequencer_deselect_all(scene);
- }
-
- BKE_sequencer_active_set(scene, seq);
-
- if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) {
- if (seq->strip) {
- BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR);
- }
- }
- else if (seq->type == SEQ_TYPE_SOUND_RAM) {
- if (seq->strip) {
- BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR);
- }
- }
- seq->flag |= SELECT;
- recurs_sel_seq(seq);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+
+ if (deselect_all) {
+ ED_sequencer_deselect_all(scene);
+ }
+
+ BKE_sequencer_active_set(scene, seq);
+
+ if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) {
+ if (seq->strip) {
+ BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR);
+ }
+ }
+ else if (seq->type == SEQ_TYPE_SOUND_RAM) {
+ if (seq->strip) {
+ BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR);
+ }
+ }
+ seq->flag |= SELECT;
+ recurs_sel_seq(seq);
}
#if 0
static void select_neighbor_from_last(Scene *scene, int lr)
{
- Sequence *seq = BKE_sequencer_active_get(scene);
- Sequence *neighbor;
- bool changed = false;
- if (seq) {
- neighbor = find_neighboring_sequence(scene, seq, lr, -1);
- if (neighbor) {
- switch (lr) {
- case SEQ_SIDE_LEFT:
- neighbor->flag |= SELECT;
- recurs_sel_seq(neighbor);
- neighbor->flag |= SEQ_RIGHTSEL;
- seq->flag |= SEQ_LEFTSEL;
- break;
- case SEQ_SIDE_RIGHT:
- neighbor->flag |= SELECT;
- recurs_sel_seq(neighbor);
- neighbor->flag |= SEQ_LEFTSEL;
- seq->flag |= SEQ_RIGHTSEL;
- break;
- }
- seq->flag |= SELECT;
- changed = true;
- }
- }
- if (changed) {
- /* pass */
- }
+ Sequence *seq = BKE_sequencer_active_get(scene);
+ Sequence *neighbor;
+ bool changed = false;
+ if (seq) {
+ neighbor = find_neighboring_sequence(scene, seq, lr, -1);
+ if (neighbor) {
+ switch (lr) {
+ case SEQ_SIDE_LEFT:
+ neighbor->flag |= SELECT;
+ recurs_sel_seq(neighbor);
+ neighbor->flag |= SEQ_RIGHTSEL;
+ seq->flag |= SEQ_LEFTSEL;
+ break;
+ case SEQ_SIDE_RIGHT:
+ neighbor->flag |= SELECT;
+ recurs_sel_seq(neighbor);
+ neighbor->flag |= SEQ_LEFTSEL;
+ seq->flag |= SEQ_RIGHTSEL;
+ break;
+ }
+ seq->flag |= SELECT;
+ changed = true;
+ }
+ }
+ if (changed) {
+ /* pass */
+ }
}
#endif
/* (de)select operator */
static int sequencer_de_select_all_exec(bContext *C, wmOperator *op)
{
- int action = RNA_enum_get(op->ptr, "action");
-
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
-
- if (action == SEL_TOGGLE) {
- action = SEL_SELECT;
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SEQ_ALLSEL) {
- action = SEL_DESELECT;
- break;
- }
- }
- }
-
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- switch (action) {
- case SEL_SELECT:
- seq->flag &= ~(SEQ_LEFTSEL + SEQ_RIGHTSEL);
- seq->flag |= SELECT;
- break;
- case SEL_DESELECT:
- seq->flag &= ~SEQ_ALLSEL;
- break;
- case SEL_INVERT:
- if (seq->flag & SEQ_ALLSEL) {
- seq->flag &= ~SEQ_ALLSEL;
- }
- else {
- seq->flag &= ~(SEQ_LEFTSEL + SEQ_RIGHTSEL);
- seq->flag |= SELECT;
- }
- break;
- }
- }
-
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
-
- return OPERATOR_FINISHED;
+ int action = RNA_enum_get(op->ptr, "action");
+
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+
+ if (action == SEL_TOGGLE) {
+ action = SEL_SELECT;
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SEQ_ALLSEL) {
+ action = SEL_DESELECT;
+ break;
+ }
+ }
+ }
+
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ switch (action) {
+ case SEL_SELECT:
+ seq->flag &= ~(SEQ_LEFTSEL + SEQ_RIGHTSEL);
+ seq->flag |= SELECT;
+ break;
+ case SEL_DESELECT:
+ seq->flag &= ~SEQ_ALLSEL;
+ break;
+ case SEL_INVERT:
+ if (seq->flag & SEQ_ALLSEL) {
+ seq->flag &= ~SEQ_ALLSEL;
+ }
+ else {
+ seq->flag &= ~(SEQ_LEFTSEL + SEQ_RIGHTSEL);
+ seq->flag |= SELECT;
+ }
+ break;
+ }
+ }
+
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
+
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_select_all(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "(De)select All";
- ot->idname = "SEQUENCER_OT_select_all";
- ot->description = "Select or deselect all strips";
+ /* identifiers */
+ ot->name = "(De)select All";
+ ot->idname = "SEQUENCER_OT_select_all";
+ ot->description = "Select or deselect all strips";
- /* api callbacks */
- ot->exec = sequencer_de_select_all_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_de_select_all_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- WM_operator_properties_select_all(ot);
+ WM_operator_properties_select_all(ot);
}
-
/* (de)select operator */
static int sequencer_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
-
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SELECT) {
- seq->flag &= ~SEQ_ALLSEL;
- }
- else {
- seq->flag &= ~(SEQ_LEFTSEL + SEQ_RIGHTSEL);
- seq->flag |= SELECT;
- }
- }
-
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
-
- return OPERATOR_FINISHED;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT) {
+ seq->flag &= ~SEQ_ALLSEL;
+ }
+ else {
+ seq->flag &= ~(SEQ_LEFTSEL + SEQ_RIGHTSEL);
+ seq->flag |= SELECT;
+ }
+ }
+
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
+
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_select_inverse(struct wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Select Inverse";
- ot->idname = "SEQUENCER_OT_select_inverse";
- ot->description = "Select unselected strips";
+ /* identifiers */
+ ot->name = "Select Inverse";
+ ot->idname = "SEQUENCER_OT_select_inverse";
+ ot->description = "Select unselected strips";
- /* api callbacks */
- ot->exec = sequencer_select_inverse_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_select_inverse_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- View2D *v2d = UI_view2d_fromcontext(C);
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- const bool extend = RNA_boolean_get(op->ptr, "extend");
- const bool linked_handle = RNA_boolean_get(op->ptr, "linked_handle");
- const bool linked_time = RNA_boolean_get(op->ptr, "linked_time");
- int left_right = RNA_enum_get(op->ptr, "left_right");
-
- Sequence *seq, *neighbor, *act_orig;
- int hand, sel_side;
- TimeMarker *marker;
-
- if (ed == NULL) {
- return OPERATOR_CANCELLED;
- }
-
- marker = find_nearest_marker(SCE_MARKERS, 1); //XXX - dummy function for now
-
- seq = find_nearest_seq(scene, v2d, &hand, event->mval);
-
- // XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip
- if (seq && linked_time && (left_right == SEQ_SELECT_LR_MOUSE)) {
- left_right = SEQ_SELECT_LR_NONE;
- }
-
-
- if (marker) {
- int oldflag;
- /* select timeline marker */
- if (extend) {
- oldflag = marker->flag;
- if (oldflag & SELECT) {
- marker->flag &= ~SELECT;
- }
- else {
- marker->flag |= SELECT;
- }
- }
- else {
- /* XXX, in 2.4x, seq selection used to deselect all, need to re-thnik this for 2.5 */
- /* deselect_markers(0, 0); */
- marker->flag |= SELECT;
- }
-
- }
- else if (left_right != SEQ_SELECT_LR_NONE) {
- /* use different logic for this */
- float x;
- ED_sequencer_deselect_all(scene);
-
- switch (left_right) {
- case SEQ_SELECT_LR_MOUSE:
- x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
- break;
- case SEQ_SELECT_LR_LEFT:
- x = CFRA - 1.0f;
- break;
- case SEQ_SELECT_LR_RIGHT:
- default:
- x = CFRA;
- break;
- }
-
- SEQP_BEGIN (ed, seq)
- {
- if (((x < CFRA) && (seq->enddisp <= CFRA)) ||
- ((x >= CFRA) && (seq->startdisp >= CFRA)))
- {
- seq->flag |= SELECT;
- recurs_sel_seq(seq);
- }
- } SEQ_END;
-
- {
- SpaceSeq *sseq = CTX_wm_space_seq(C);
- if (sseq && sseq->flag & SEQ_MARKER_TRANS) {
- TimeMarker *tmarker;
-
- for (tmarker = scene->markers.first; tmarker; tmarker = tmarker->next) {
- if (((x < CFRA) && (tmarker->frame <= CFRA)) ||
- ((x >= CFRA) && (tmarker->frame >= CFRA)))
- {
- tmarker->flag |= SELECT;
- }
- else {
- tmarker->flag &= ~SELECT;
- }
- }
- }
- }
- }
- else {
- // seq = find_nearest_seq(scene, v2d, &hand, mval);
-
- act_orig = ed->act_seq;
-
- if (extend == 0 && linked_handle == 0) {
- ED_sequencer_deselect_all(scene);
- }
-
- if (seq) {
- BKE_sequencer_active_set(scene, seq);
-
- if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) {
- if (seq->strip) {
- BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR);
- }
- }
- else if (seq->type == SEQ_TYPE_SOUND_RAM) {
- if (seq->strip) {
- BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR);
- }
- }
-
- /* On Alt selection, select the strip and bordering handles */
- if (linked_handle) {
- if (!ELEM(hand, SEQ_SIDE_LEFT, SEQ_SIDE_RIGHT)) {
- /* First click selects the strip and its adjacent handles (if valid).
- * Second click selects the strip, both of its handles and its adjacent handles (if valid).
- */
- const bool is_striponly_selected = ((seq->flag & SEQ_ALLSEL) == SELECT);
-
- if (!extend) {
- ED_sequencer_deselect_all(scene);
- }
- seq->flag &= ~SEQ_ALLSEL;
- seq->flag |= is_striponly_selected ? SEQ_ALLSEL : SELECT;
- select_surrounding_handles(scene, seq);
- }
- else {
- /* always select the strip under the cursor */
- seq->flag |= SELECT;
-
- /* First click selects adjacent handles on that side.
- * Second click selects all strips in that direction.
- * If there are no adjacent strips, it just selects all in that direction.
- */
- sel_side = hand;
- neighbor = find_neighboring_sequence(scene, seq, sel_side, -1);
- if (neighbor) {
- switch (sel_side) {
- case SEQ_SIDE_LEFT:
- if ((seq->flag & SEQ_LEFTSEL) && (neighbor->flag & SEQ_RIGHTSEL)) {
- if (extend == 0) {
- ED_sequencer_deselect_all(scene);
- }
- seq->flag |= SELECT;
-
- select_active_side(ed->seqbasep, SEQ_SIDE_LEFT, seq->machine, seq->startdisp);
- }
- else {
- if (extend == 0) {
- ED_sequencer_deselect_all(scene);
- }
- seq->flag |= SELECT;
-
- neighbor->flag |= SELECT;
- recurs_sel_seq(neighbor);
- neighbor->flag |= SEQ_RIGHTSEL;
- seq->flag |= SEQ_LEFTSEL;
- }
- break;
- case SEQ_SIDE_RIGHT:
- if ((seq->flag & SEQ_RIGHTSEL) && (neighbor->flag & SEQ_LEFTSEL)) {
- if (extend == 0) {
- ED_sequencer_deselect_all(scene);
- }
- seq->flag |= SELECT;
-
- select_active_side(ed->seqbasep, SEQ_SIDE_RIGHT, seq->machine, seq->startdisp);
- }
- else {
- if (extend == 0) {
- ED_sequencer_deselect_all(scene);
- }
- seq->flag |= SELECT;
-
- neighbor->flag |= SELECT;
- recurs_sel_seq(neighbor);
- neighbor->flag |= SEQ_LEFTSEL;
- seq->flag |= SEQ_RIGHTSEL;
- }
- break;
- }
- }
- else {
- if (extend == 0) {
- ED_sequencer_deselect_all(scene);
- }
- select_active_side(ed->seqbasep, sel_side, seq->machine, seq->startdisp);
- }
- }
- }
- else {
- if (extend && (seq->flag & SELECT) && ed->act_seq == act_orig) {
- switch (hand) {
- case SEQ_SIDE_NONE:
- if (linked_handle == 0) {
- seq->flag &= ~SEQ_ALLSEL;
- }
- break;
- case SEQ_SIDE_LEFT:
- seq->flag ^= SEQ_LEFTSEL;
- break;
- case SEQ_SIDE_RIGHT:
- seq->flag ^= SEQ_RIGHTSEL;
- break;
- }
- }
- else {
- seq->flag |= SELECT;
- if (hand == SEQ_SIDE_LEFT) {
- seq->flag |= SEQ_LEFTSEL;
- }
- if (hand == SEQ_SIDE_RIGHT) {
- seq->flag |= SEQ_RIGHTSEL;
- }
- }
- }
-
- recurs_sel_seq(seq);
-
- if (linked_time) {
- select_linked_time(ed->seqbasep, seq);
- }
- }
- }
-
- /* marker transform */
-#if 0 // XXX probably need to redo this differently for 2.5
- if (marker) {
- int mval[2], xo, yo;
-// getmouseco_areawin(mval);
- xo = mval[0];
- yo = mval[1];
-
- while (get_mbut()) {
-// getmouseco_areawin(mval);
- if (abs(mval[0] - xo) + abs(mval[1] - yo) > 4) {
- transform_markers('g', 0);
- return;
- }
- }
- }
+ View2D *v2d = UI_view2d_fromcontext(C);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+ const bool linked_handle = RNA_boolean_get(op->ptr, "linked_handle");
+ const bool linked_time = RNA_boolean_get(op->ptr, "linked_time");
+ int left_right = RNA_enum_get(op->ptr, "left_right");
+
+ Sequence *seq, *neighbor, *act_orig;
+ int hand, sel_side;
+ TimeMarker *marker;
+
+ if (ed == NULL) {
+ return OPERATOR_CANCELLED;
+ }
+
+ marker = find_nearest_marker(SCE_MARKERS, 1); //XXX - dummy function for now
+
+ seq = find_nearest_seq(scene, v2d, &hand, event->mval);
+
+ // XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip
+ if (seq && linked_time && (left_right == SEQ_SELECT_LR_MOUSE)) {
+ left_right = SEQ_SELECT_LR_NONE;
+ }
+
+ if (marker) {
+ int oldflag;
+ /* select timeline marker */
+ if (extend) {
+ oldflag = marker->flag;
+ if (oldflag & SELECT) {
+ marker->flag &= ~SELECT;
+ }
+ else {
+ marker->flag |= SELECT;
+ }
+ }
+ else {
+ /* XXX, in 2.4x, seq selection used to deselect all, need to re-thnik this for 2.5 */
+ /* deselect_markers(0, 0); */
+ marker->flag |= SELECT;
+ }
+ }
+ else if (left_right != SEQ_SELECT_LR_NONE) {
+ /* use different logic for this */
+ float x;
+ ED_sequencer_deselect_all(scene);
+
+ switch (left_right) {
+ case SEQ_SELECT_LR_MOUSE:
+ x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
+ break;
+ case SEQ_SELECT_LR_LEFT:
+ x = CFRA - 1.0f;
+ break;
+ case SEQ_SELECT_LR_RIGHT:
+ default:
+ x = CFRA;
+ break;
+ }
+
+ SEQP_BEGIN (ed, seq) {
+ if (((x < CFRA) && (seq->enddisp <= CFRA)) || ((x >= CFRA) && (seq->startdisp >= CFRA))) {
+ seq->flag |= SELECT;
+ recurs_sel_seq(seq);
+ }
+ }
+ SEQ_END;
+
+ {
+ SpaceSeq *sseq = CTX_wm_space_seq(C);
+ if (sseq && sseq->flag & SEQ_MARKER_TRANS) {
+ TimeMarker *tmarker;
+
+ for (tmarker = scene->markers.first; tmarker; tmarker = tmarker->next) {
+ if (((x < CFRA) && (tmarker->frame <= CFRA)) ||
+ ((x >= CFRA) && (tmarker->frame >= CFRA))) {
+ tmarker->flag |= SELECT;
+ }
+ else {
+ tmarker->flag &= ~SELECT;
+ }
+ }
+ }
+ }
+ }
+ else {
+ // seq = find_nearest_seq(scene, v2d, &hand, mval);
+
+ act_orig = ed->act_seq;
+
+ if (extend == 0 && linked_handle == 0) {
+ ED_sequencer_deselect_all(scene);
+ }
+
+ if (seq) {
+ BKE_sequencer_active_set(scene, seq);
+
+ if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) {
+ if (seq->strip) {
+ BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR);
+ }
+ }
+ else if (seq->type == SEQ_TYPE_SOUND_RAM) {
+ if (seq->strip) {
+ BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR);
+ }
+ }
+
+ /* On Alt selection, select the strip and bordering handles */
+ if (linked_handle) {
+ if (!ELEM(hand, SEQ_SIDE_LEFT, SEQ_SIDE_RIGHT)) {
+ /* First click selects the strip and its adjacent handles (if valid).
+ * Second click selects the strip, both of its handles and its adjacent handles (if valid).
+ */
+ const bool is_striponly_selected = ((seq->flag & SEQ_ALLSEL) == SELECT);
+
+ if (!extend) {
+ ED_sequencer_deselect_all(scene);
+ }
+ seq->flag &= ~SEQ_ALLSEL;
+ seq->flag |= is_striponly_selected ? SEQ_ALLSEL : SELECT;
+ select_surrounding_handles(scene, seq);
+ }
+ else {
+ /* always select the strip under the cursor */
+ seq->flag |= SELECT;
+
+ /* First click selects adjacent handles on that side.
+ * Second click selects all strips in that direction.
+ * If there are no adjacent strips, it just selects all in that direction.
+ */
+ sel_side = hand;
+ neighbor = find_neighboring_sequence(scene, seq, sel_side, -1);
+ if (neighbor) {
+ switch (sel_side) {
+ case SEQ_SIDE_LEFT:
+ if ((seq->flag & SEQ_LEFTSEL) && (neighbor->flag & SEQ_RIGHTSEL)) {
+ if (extend == 0) {
+ ED_sequencer_deselect_all(scene);
+ }
+ seq->flag |= SELECT;
+
+ select_active_side(ed->seqbasep, SEQ_SIDE_LEFT, seq->machine, seq->startdisp);
+ }
+ else {
+ if (extend == 0) {
+ ED_sequencer_deselect_all(scene);
+ }
+ seq->flag |= SELECT;
+
+ neighbor->flag |= SELECT;
+ recurs_sel_seq(neighbor);
+ neighbor->flag |= SEQ_RIGHTSEL;
+ seq->flag |= SEQ_LEFTSEL;
+ }
+ break;
+ case SEQ_SIDE_RIGHT:
+ if ((seq->flag & SEQ_RIGHTSEL) && (neighbor->flag & SEQ_LEFTSEL)) {
+ if (extend == 0) {
+ ED_sequencer_deselect_all(scene);
+ }
+ seq->flag |= SELECT;
+
+ select_active_side(ed->seqbasep, SEQ_SIDE_RIGHT, seq->machine, seq->startdisp);
+ }
+ else {
+ if (extend == 0) {
+ ED_sequencer_deselect_all(scene);
+ }
+ seq->flag |= SELECT;
+
+ neighbor->flag |= SELECT;
+ recurs_sel_seq(neighbor);
+ neighbor->flag |= SEQ_LEFTSEL;
+ seq->flag |= SEQ_RIGHTSEL;
+ }
+ break;
+ }
+ }
+ else {
+ if (extend == 0) {
+ ED_sequencer_deselect_all(scene);
+ }
+ select_active_side(ed->seqbasep, sel_side, seq->machine, seq->startdisp);
+ }
+ }
+ }
+ else {
+ if (extend && (seq->flag & SELECT) && ed->act_seq == act_orig) {
+ switch (hand) {
+ case SEQ_SIDE_NONE:
+ if (linked_handle == 0) {
+ seq->flag &= ~SEQ_ALLSEL;
+ }
+ break;
+ case SEQ_SIDE_LEFT:
+ seq->flag ^= SEQ_LEFTSEL;
+ break;
+ case SEQ_SIDE_RIGHT:
+ seq->flag ^= SEQ_RIGHTSEL;
+ break;
+ }
+ }
+ else {
+ seq->flag |= SELECT;
+ if (hand == SEQ_SIDE_LEFT) {
+ seq->flag |= SEQ_LEFTSEL;
+ }
+ if (hand == SEQ_SIDE_RIGHT) {
+ seq->flag |= SEQ_RIGHTSEL;
+ }
+ }
+ }
+
+ recurs_sel_seq(seq);
+
+ if (linked_time) {
+ select_linked_time(ed->seqbasep, seq);
+ }
+ }
+ }
+
+ /* marker transform */
+#if 0 // XXX probably need to redo this differently for 2.5
+ if (marker) {
+ int mval[2], xo, yo;
+// getmouseco_areawin(mval);
+ xo = mval[0];
+ yo = mval[1];
+
+ while (get_mbut()) {
+// getmouseco_areawin(mval);
+ if (abs(mval[0] - xo) + abs(mval[1] - yo) > 4) {
+ transform_markers('g', 0);
+ return;
+ }
+ }
+ }
#endif
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
- /* allowing tweaks */
- return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+ /* allowing tweaks */
+ return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
}
void SEQUENCER_OT_select(wmOperatorType *ot)
{
- static const EnumPropertyItem sequencer_select_left_right_types[] = {
- {SEQ_SELECT_LR_NONE, "NONE", 0, "None", "Don't do left-right selection"},
- {SEQ_SELECT_LR_MOUSE, "MOUSE", 0, "Mouse", "Use mouse position for selection"},
- {SEQ_SELECT_LR_LEFT, "LEFT", 0, "Left", "Select left"},
- {SEQ_SELECT_LR_RIGHT, "RIGHT", 0, "Right", "Select right"},
- {0, NULL, 0, NULL, NULL},
- };
-
- /* identifiers */
- ot->name = "Select";
- ot->idname = "SEQUENCER_OT_select";
- ot->description = "Select a strip (last selected becomes the \"active strip\")";
-
- /* api callbacks */
- ot->invoke = sequencer_select_invoke;
- ot->poll = ED_operator_sequencer_active;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
- RNA_def_boolean(ot->srna, "linked_handle", 0, "Linked Handle", "Select handles next to the active strip");
- /* for animation this is an enum but atm having an enum isn't useful for us */
- RNA_def_enum(ot->srna, "left_right", sequencer_select_left_right_types, 0, "Left/Right", "Select based on the current frame side the cursor is on");
- RNA_def_boolean(ot->srna, "linked_time", 0, "Linked Time", "Select other strips at the same time");
+ static const EnumPropertyItem sequencer_select_left_right_types[] = {
+ {SEQ_SELECT_LR_NONE, "NONE", 0, "None", "Don't do left-right selection"},
+ {SEQ_SELECT_LR_MOUSE, "MOUSE", 0, "Mouse", "Use mouse position for selection"},
+ {SEQ_SELECT_LR_LEFT, "LEFT", 0, "Left", "Select left"},
+ {SEQ_SELECT_LR_RIGHT, "RIGHT", 0, "Right", "Select right"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ /* identifiers */
+ ot->name = "Select";
+ ot->idname = "SEQUENCER_OT_select";
+ ot->description = "Select a strip (last selected becomes the \"active strip\")";
+
+ /* api callbacks */
+ ot->invoke = sequencer_select_invoke;
+ ot->poll = ED_operator_sequencer_active;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
+ RNA_def_boolean(
+ ot->srna, "linked_handle", 0, "Linked Handle", "Select handles next to the active strip");
+ /* for animation this is an enum but atm having an enum isn't useful for us */
+ RNA_def_enum(ot->srna,
+ "left_right",
+ sequencer_select_left_right_types,
+ 0,
+ "Left/Right",
+ "Select based on the current frame side the cursor is on");
+ RNA_def_boolean(
+ ot->srna, "linked_time", 0, "Linked Time", "Select other strips at the same time");
}
-
/* run recursively to select linked */
static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool linked)
{
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq, *neighbor;
- bool changed = false;
- int isel;
-
- if (ed == NULL) {
- return changed;
- }
-
- if (sel) {
- sel = SELECT;
- isel = 0;
- }
- else {
- sel = 0;
- isel = SELECT;
- }
-
- if (!linked) {
- /* if not linked we only want to touch each seq once, newseq */
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- seq->tmp = NULL;
- }
- }
-
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if ((seq->flag & SELECT) == sel) {
- if (linked || (seq->tmp == NULL)) {
- /* only get unselected neighbors */
- neighbor = find_neighboring_sequence(scene, seq, SEQ_SIDE_LEFT, isel);
- if (neighbor) {
- if (sel) {
- neighbor->flag |= SELECT;
- recurs_sel_seq(neighbor);
- }
- else {
- neighbor->flag &= ~SELECT;
- }
- if (!linked) {
- neighbor->tmp = (Sequence *)1;
- }
- changed = true;
- }
- neighbor = find_neighboring_sequence(scene, seq, SEQ_SIDE_RIGHT, isel);
- if (neighbor) {
- if (sel) {
- neighbor->flag |= SELECT;
- recurs_sel_seq(neighbor);
- }
- else {
- neighbor->flag &= ~SELECT;
- }
- if (!linked) {
- neighbor->tmp = (Sequence *)1;
- }
- changed = true;
- }
- }
- }
- }
-
- return changed;
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq, *neighbor;
+ bool changed = false;
+ int isel;
+
+ if (ed == NULL) {
+ return changed;
+ }
+
+ if (sel) {
+ sel = SELECT;
+ isel = 0;
+ }
+ else {
+ sel = 0;
+ isel = SELECT;
+ }
+
+ if (!linked) {
+ /* if not linked we only want to touch each seq once, newseq */
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ seq->tmp = NULL;
+ }
+ }
+
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if ((seq->flag & SELECT) == sel) {
+ if (linked || (seq->tmp == NULL)) {
+ /* only get unselected neighbors */
+ neighbor = find_neighboring_sequence(scene, seq, SEQ_SIDE_LEFT, isel);
+ if (neighbor) {
+ if (sel) {
+ neighbor->flag |= SELECT;
+ recurs_sel_seq(neighbor);
+ }
+ else {
+ neighbor->flag &= ~SELECT;
+ }
+ if (!linked) {
+ neighbor->tmp = (Sequence *)1;
+ }
+ changed = true;
+ }
+ neighbor = find_neighboring_sequence(scene, seq, SEQ_SIDE_RIGHT, isel);
+ if (neighbor) {
+ if (sel) {
+ neighbor->flag |= SELECT;
+ recurs_sel_seq(neighbor);
+ }
+ else {
+ neighbor->flag &= ~SELECT;
+ }
+ if (!linked) {
+ neighbor->tmp = (Sequence *)1;
+ }
+ changed = true;
+ }
+ }
+ }
+ }
+
+ return changed;
}
-
-
/* select more operator */
static int sequencer_select_more_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
- if (!select_more_less_seq__internal(scene, true, false)) {
- return OPERATOR_CANCELLED;
- }
+ if (!select_more_less_seq__internal(scene, true, false)) {
+ return OPERATOR_CANCELLED;
+ }
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_select_more(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Select More";
- ot->idname = "SEQUENCER_OT_select_more";
- ot->description = "Select more strips adjacent to the current selection";
+ /* identifiers */
+ ot->name = "Select More";
+ ot->idname = "SEQUENCER_OT_select_more";
+ ot->description = "Select more strips adjacent to the current selection";
- /* api callbacks */
- ot->exec = sequencer_select_more_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_select_more_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
+ /* properties */
}
-
/* select less operator */
static int sequencer_select_less_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
- if (!select_more_less_seq__internal(scene, false, false)) {
- return OPERATOR_CANCELLED;
- }
+ if (!select_more_less_seq__internal(scene, false, false)) {
+ return OPERATOR_CANCELLED;
+ }
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_select_less(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Select Less";
- ot->idname = "SEQUENCER_OT_select_less";
- ot->description = "Shrink the current selection of adjacent selected strips";
+ /* identifiers */
+ ot->name = "Select Less";
+ ot->idname = "SEQUENCER_OT_select_less";
+ ot->description = "Shrink the current selection of adjacent selected strips";
- /* api callbacks */
- ot->exec = sequencer_select_less_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_select_less_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
+ /* properties */
}
-
/* select pick linked operator (uses the mouse) */
static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- Scene *scene = CTX_data_scene(C);
- View2D *v2d = UI_view2d_fromcontext(C);
+ Scene *scene = CTX_data_scene(C);
+ View2D *v2d = UI_view2d_fromcontext(C);
- bool extend = RNA_boolean_get(op->ptr, "extend");
+ bool extend = RNA_boolean_get(op->ptr, "extend");
- Sequence *mouse_seq;
- int selected, hand;
+ Sequence *mouse_seq;
+ int selected, hand;
- /* this works like UV, not mesh */
- mouse_seq = find_nearest_seq(scene, v2d, &hand, event->mval);
- if (!mouse_seq) {
- return OPERATOR_FINISHED; /* user error as with mesh?? */
- }
+ /* this works like UV, not mesh */
+ mouse_seq = find_nearest_seq(scene, v2d, &hand, event->mval);
+ if (!mouse_seq) {
+ return OPERATOR_FINISHED; /* user error as with mesh?? */
+ }
- if (extend == 0) {
- ED_sequencer_deselect_all(scene);
- }
+ if (extend == 0) {
+ ED_sequencer_deselect_all(scene);
+ }
- mouse_seq->flag |= SELECT;
- recurs_sel_seq(mouse_seq);
+ mouse_seq->flag |= SELECT;
+ recurs_sel_seq(mouse_seq);
- selected = 1;
- while (selected) {
- selected = select_more_less_seq__internal(scene, 1, 1);
- }
+ selected = 1;
+ while (selected) {
+ selected = select_more_less_seq__internal(scene, 1, 1);
+ }
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_select_linked_pick(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Select Pick Linked";
- ot->idname = "SEQUENCER_OT_select_linked_pick";
- ot->description = "Select a chain of linked strips nearest to the mouse pointer";
+ /* identifiers */
+ ot->name = "Select Pick Linked";
+ ot->idname = "SEQUENCER_OT_select_linked_pick";
+ ot->description = "Select a chain of linked strips nearest to the mouse pointer";
- /* api callbacks */
- ot->invoke = sequencer_select_linked_pick_invoke;
- ot->poll = ED_operator_sequencer_active;
+ /* api callbacks */
+ ot->invoke = sequencer_select_linked_pick_invoke;
+ ot->poll = ED_operator_sequencer_active;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
- RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
+ /* properties */
+ RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
}
-
/* select linked operator */
static int sequencer_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene = CTX_data_scene(C);
- bool selected;
+ Scene *scene = CTX_data_scene(C);
+ bool selected;
- selected = true;
- while (selected) {
- selected = select_more_less_seq__internal(scene, true, true);
- }
+ selected = true;
+ while (selected) {
+ selected = select_more_less_seq__internal(scene, true, true);
+ }
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_select_linked(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Select Linked";
- ot->idname = "SEQUENCER_OT_select_linked";
- ot->description = "Select all strips adjacent to the current selection";
+ /* identifiers */
+ ot->name = "Select Linked";
+ ot->idname = "SEQUENCER_OT_select_linked";
+ ot->description = "Select all strips adjacent to the current selection";
- /* api callbacks */
- ot->exec = sequencer_select_linked_exec;
- ot->poll = sequencer_edit_poll;
+ /* api callbacks */
+ ot->exec = sequencer_select_linked_exec;
+ ot->poll = sequencer_edit_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
+ /* properties */
}
-
/* select handles operator */
static int sequencer_select_handles_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq;
- int sel_side = RNA_enum_get(op->ptr, "side");
-
-
- for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SELECT) {
- switch (sel_side) {
- case SEQ_SIDE_LEFT:
- seq->flag &= ~SEQ_RIGHTSEL;
- seq->flag |= SEQ_LEFTSEL;
- break;
- case SEQ_SIDE_RIGHT:
- seq->flag &= ~SEQ_LEFTSEL;
- seq->flag |= SEQ_RIGHTSEL;
- break;
- case SEQ_SIDE_BOTH:
- seq->flag |= SEQ_LEFTSEL | SEQ_RIGHTSEL;
- break;
- }
- }
- }
-
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
-
- return OPERATOR_FINISHED;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq;
+ int sel_side = RNA_enum_get(op->ptr, "side");
+
+ for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+ if (seq->flag & SELECT) {
+ switch (sel_side) {
+ case SEQ_SIDE_LEFT:
+ seq->flag &= ~SEQ_RIGHTSEL;
+ seq->flag |= SEQ_LEFTSEL;
+ break;
+ case SEQ_SIDE_RIGHT:
+ seq->flag &= ~SEQ_LEFTSEL;
+ seq->flag |= SEQ_RIGHTSEL;
+ break;
+ case SEQ_SIDE_BOTH:
+ seq->flag |= SEQ_LEFTSEL | SEQ_RIGHTSEL;
+ break;
+ }
+ }
+ }
+
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
+
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_select_handles(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Select Handles";
- ot->idname = "SEQUENCER_OT_select_handles";
- ot->description = "Select gizmo handles on the sides of the selected strip";
-
- /* api callbacks */
- ot->exec = sequencer_select_handles_exec;
- ot->poll = sequencer_edit_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- RNA_def_enum(ot->srna, "side", prop_side_types, SEQ_SIDE_BOTH, "Side", "The side of the handle that is selected");
+ /* identifiers */
+ ot->name = "Select Handles";
+ ot->idname = "SEQUENCER_OT_select_handles";
+ ot->description = "Select gizmo handles on the sides of the selected strip";
+
+ /* api callbacks */
+ ot->exec = sequencer_select_handles_exec;
+ ot->poll = sequencer_edit_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_enum(ot->srna,
+ "side",
+ prop_side_types,
+ SEQ_SIDE_BOTH,
+ "Side",
+ "The side of the handle that is selected");
}
/* select side operator */
static int sequencer_select_active_side_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq_act = BKE_sequencer_active_get(scene);
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq_act = BKE_sequencer_active_get(scene);
- if (ed == NULL || seq_act == NULL) {
- return OPERATOR_CANCELLED;
- }
+ if (ed == NULL || seq_act == NULL) {
+ return OPERATOR_CANCELLED;
+ }
- seq_act->flag |= SELECT;
+ seq_act->flag |= SELECT;
- select_active_side(ed->seqbasep, RNA_enum_get(op->ptr, "side"), seq_act->machine, seq_act->startdisp);
+ select_active_side(
+ ed->seqbasep, RNA_enum_get(op->ptr, "side"), seq_act->machine, seq_act->startdisp);
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void SEQUENCER_OT_select_active_side(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Select Active Side";
- ot->idname = "SEQUENCER_OT_select_active_side";
- ot->description = "Select strips on the nominated side of the active strip";
-
- /* api callbacks */
- ot->exec = sequencer_select_active_side_exec;
- ot->poll = sequencer_edit_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- RNA_def_enum(ot->srna, "side", prop_side_types, SEQ_SIDE_BOTH, "Side", "The side of the handle that is selected");
+ /* identifiers */
+ ot->name = "Select Active Side";
+ ot->idname = "SEQUENCER_OT_select_active_side";
+ ot->description = "Select strips on the nominated side of the active strip";
+
+ /* api callbacks */
+ ot->exec = sequencer_select_active_side_exec;
+ ot->poll = sequencer_edit_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_enum(ot->srna,
+ "side",
+ prop_side_types,
+ SEQ_SIDE_BOTH,
+ "Side",
+ "The side of the handle that is selected");
}
-
/* box_select operator */
static int sequencer_box_select_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- if (ed == NULL) {
- return OPERATOR_CANCELLED;
- }
-
- View2D *v2d = UI_view2d_fromcontext(C);
-
- const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
- const bool select = (sel_op != SEL_OP_SUB);
- if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- ED_sequencer_deselect_all(scene);
- }
-
- rctf rectf;
- WM_operator_properties_border_to_rctf(op, &rectf);
- UI_view2d_region_to_view_rctf(v2d, &rectf, &rectf);
-
- for (Sequence *seq = ed->seqbasep->first; seq; seq = seq->next) {
- rctf rq;
- seq_rectf(seq, &rq);
- if (BLI_rctf_isect(&rq, &rectf, NULL)) {
- SET_FLAG_FROM_TEST(seq->flag, select, SELECT);
- recurs_sel_seq(seq);
- }
- }
-
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
-
- return OPERATOR_FINISHED;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ if (ed == NULL) {
+ return OPERATOR_CANCELLED;
+ }
+
+ View2D *v2d = UI_view2d_fromcontext(C);
+
+ const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
+ const bool select = (sel_op != SEL_OP_SUB);
+ if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+ ED_sequencer_deselect_all(scene);
+ }
+
+ rctf rectf;
+ WM_operator_properties_border_to_rctf(op, &rectf);
+ UI_view2d_region_to_view_rctf(v2d, &rectf, &rectf);
+
+ for (Sequence *seq = ed->seqbasep->first; seq; seq = seq->next) {
+ rctf rq;
+ seq_rectf(seq, &rq);
+ if (BLI_rctf_isect(&rq, &rectf, NULL)) {
+ SET_FLAG_FROM_TEST(seq->flag, select, SELECT);
+ recurs_sel_seq(seq);
+ }
+ }
+
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
+
+ return OPERATOR_FINISHED;
}
-
/* ****** Box Select ****** */
void SEQUENCER_OT_select_box(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Box Select";
- ot->idname = "SEQUENCER_OT_select_box";
- ot->description = "Select strips using box selection";
+ /* identifiers */
+ ot->name = "Box Select";
+ ot->idname = "SEQUENCER_OT_select_box";
+ ot->description = "Select strips using box selection";
- /* api callbacks */
- ot->invoke = WM_gesture_box_invoke;
- ot->exec = sequencer_box_select_exec;
- ot->modal = WM_gesture_box_modal;
- ot->cancel = WM_gesture_box_cancel;
+ /* api callbacks */
+ ot->invoke = WM_gesture_box_invoke;
+ ot->exec = sequencer_box_select_exec;
+ ot->modal = WM_gesture_box_modal;
+ ot->cancel = WM_gesture_box_cancel;
- ot->poll = ED_operator_sequencer_active;
+ ot->poll = ED_operator_sequencer_active;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties */
- WM_operator_properties_gesture_box(ot);
- WM_operator_properties_select_operation_simple(ot);
+ /* properties */
+ WM_operator_properties_gesture_box(ot);
+ WM_operator_properties_select_operation_simple(ot);
}
/* ****** Selected Grouped ****** */
enum {
- SEQ_SELECT_GROUP_TYPE,
- SEQ_SELECT_GROUP_TYPE_BASIC,
- SEQ_SELECT_GROUP_TYPE_EFFECT,
- SEQ_SELECT_GROUP_DATA,
- SEQ_SELECT_GROUP_EFFECT,
- SEQ_SELECT_GROUP_EFFECT_LINK,
- SEQ_SELECT_GROUP_OVERLAP,
+ SEQ_SELECT_GROUP_TYPE,
+ SEQ_SELECT_GROUP_TYPE_BASIC,
+ SEQ_SELECT_GROUP_TYPE_EFFECT,
+ SEQ_SELECT_GROUP_DATA,
+ SEQ_SELECT_GROUP_EFFECT,
+ SEQ_SELECT_GROUP_EFFECT_LINK,
+ SEQ_SELECT_GROUP_OVERLAP,
};
static const EnumPropertyItem sequencer_prop_select_grouped_types[] = {
- {SEQ_SELECT_GROUP_TYPE, "TYPE", 0, "Type", "Shared strip type"},
- {SEQ_SELECT_GROUP_TYPE_BASIC, "TYPE_BASIC", 0, "Global Type", "All strips of same basic type (Graphical or Sound)"},
- {SEQ_SELECT_GROUP_TYPE_EFFECT, "TYPE_EFFECT", 0, "Effect Type",
- "Shared strip effect type (if active strip is not an effect one, select all non-effect strips)"},
- {SEQ_SELECT_GROUP_DATA, "DATA", 0, "Data", "Shared data (scene, image, sound, etc.)"},
- {SEQ_SELECT_GROUP_EFFECT, "EFFECT", 0, "Effect", "Shared effects"},
- {SEQ_SELECT_GROUP_EFFECT_LINK, "EFFECT_LINK", 0, "Effect/Linked",
- "Other strips affected by the active one (sharing some time, and below or effect-assigned)"},
- {SEQ_SELECT_GROUP_OVERLAP, "OVERLAP", 0, "Overlap", "Overlapping time"},
- {0, NULL, 0, NULL, NULL},
+ {SEQ_SELECT_GROUP_TYPE, "TYPE", 0, "Type", "Shared strip type"},
+ {SEQ_SELECT_GROUP_TYPE_BASIC,
+ "TYPE_BASIC",
+ 0,
+ "Global Type",
+ "All strips of same basic type (Graphical or Sound)"},
+ {SEQ_SELECT_GROUP_TYPE_EFFECT,
+ "TYPE_EFFECT",
+ 0,
+ "Effect Type",
+ "Shared strip effect type (if active strip is not an effect one, select all non-effect "
+ "strips)"},
+ {SEQ_SELECT_GROUP_DATA, "DATA", 0, "Data", "Shared data (scene, image, sound, etc.)"},
+ {SEQ_SELECT_GROUP_EFFECT, "EFFECT", 0, "Effect", "Shared effects"},
+ {SEQ_SELECT_GROUP_EFFECT_LINK,
+ "EFFECT_LINK",
+ 0,
+ "Effect/Linked",
+ "Other strips affected by the active one (sharing some time, and below or effect-assigned)"},
+ {SEQ_SELECT_GROUP_OVERLAP, "OVERLAP", 0, "Overlap", "Overlapping time"},
+ {0, NULL, 0, NULL, NULL},
};
#define SEQ_IS_SOUND(_seq) ((_seq->type & SEQ_TYPE_SOUND_RAM) && !(_seq->type & SEQ_TYPE_EFFECT))
#define SEQ_IS_EFFECT(_seq) ((_seq->type & SEQ_TYPE_EFFECT) != 0)
-#define SEQ_USE_DATA(_seq) (ELEM(_seq->type, SEQ_TYPE_SCENE, SEQ_TYPE_MOVIECLIP, SEQ_TYPE_MASK) || SEQ_HAS_PATH(_seq))
+#define SEQ_USE_DATA(_seq) \
+ (ELEM(_seq->type, SEQ_TYPE_SCENE, SEQ_TYPE_MOVIECLIP, SEQ_TYPE_MASK) || SEQ_HAS_PATH(_seq))
#define SEQ_CHANNEL_CHECK(_seq, _chan) (ELEM((_chan), 0, (_seq)->machine))
static bool select_grouped_type(Editing *ed, Sequence *actseq, const int channel)
{
- Sequence *seq;
- bool changed = false;
-
- SEQP_BEGIN (ed, seq)
- {
- if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == actseq->type) {
- seq->flag |= SELECT;
- changed = true;
- }
- }
- SEQ_END;
-
- return changed;
+ Sequence *seq;
+ bool changed = false;
+
+ SEQP_BEGIN (ed, seq) {
+ if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == actseq->type) {
+ seq->flag |= SELECT;
+ changed = true;
+ }
+ }
+ SEQ_END;
+
+ return changed;
}
static bool select_grouped_type_basic(Editing *ed, Sequence *actseq, const int channel)
{
- Sequence *seq;
- bool changed = false;
- const bool is_sound = SEQ_IS_SOUND(actseq);
-
- SEQP_BEGIN (ed, seq)
- {
- if (SEQ_CHANNEL_CHECK(seq, channel) && (is_sound ? SEQ_IS_SOUND(seq) : !SEQ_IS_SOUND(seq))) {
- seq->flag |= SELECT;
- changed = true;
- }
- }
- SEQ_END;
-
- return changed;
+ Sequence *seq;
+ bool changed = false;
+ const bool is_sound = SEQ_IS_SOUND(actseq);
+
+ SEQP_BEGIN (ed, seq) {
+ if (SEQ_CHANNEL_CHECK(seq, channel) && (is_sound ? SEQ_IS_SOUND(seq) : !SEQ_IS_SOUND(seq))) {
+ seq->flag |= SELECT;
+ changed = true;
+ }
+ }
+ SEQ_END;
+
+ return changed;
}
static bool select_grouped_type_effect(Editing *ed, Sequence *actseq, const int channel)
{
- Sequence *seq;
- bool changed = false;
- const bool is_effect = SEQ_IS_EFFECT(actseq);
-
- SEQP_BEGIN (ed, seq)
- {
- if (SEQ_CHANNEL_CHECK(seq, channel) && (is_effect ? SEQ_IS_EFFECT(seq) : !SEQ_IS_EFFECT(seq))) {
- seq->flag |= SELECT;
- changed = true;
- }
- }
- SEQ_END;
-
- return changed;
+ Sequence *seq;
+ bool changed = false;
+ const bool is_effect = SEQ_IS_EFFECT(actseq);
+
+ SEQP_BEGIN (ed, seq) {
+ if (SEQ_CHANNEL_CHECK(seq, channel) &&
+ (is_effect ? SEQ_IS_EFFECT(seq) : !SEQ_IS_EFFECT(seq))) {
+ seq->flag |= SELECT;
+ changed = true;
+ }
+ }
+ SEQ_END;
+
+ return changed;
}
static bool select_grouped_data(Editing *ed, Sequence *actseq, const int channel)
{
- Sequence *seq;
- bool changed = false;
- const char *dir = actseq->strip ? actseq->strip->dir : NULL;
-
- if (!SEQ_USE_DATA(actseq)) {
- return changed;
- }
-
- if (SEQ_HAS_PATH(actseq) && dir) {
- SEQP_BEGIN (ed, seq)
- {
- if (SEQ_CHANNEL_CHECK(seq, channel) && SEQ_HAS_PATH(seq) && seq->strip && STREQ(seq->strip->dir, dir)) {
- seq->flag |= SELECT;
- changed = true;
- }
- }
- SEQ_END;
- }
- else if (actseq->type == SEQ_TYPE_SCENE) {
- Scene *sce = actseq->scene;
- SEQP_BEGIN (ed, seq)
- {
- if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_SCENE && seq->scene == sce) {
- seq->flag |= SELECT;
- changed = true;
- }
- }
- SEQ_END;
- }
- else if (actseq->type == SEQ_TYPE_MOVIECLIP) {
- MovieClip *clip = actseq->clip;
- SEQP_BEGIN (ed, seq)
- {
- if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_MOVIECLIP && seq->clip == clip) {
- seq->flag |= SELECT;
- changed = true;
- }
- }
- SEQ_END;
- }
- else if (actseq->type == SEQ_TYPE_MASK) {
- struct Mask *mask = actseq->mask;
- SEQP_BEGIN (ed, seq)
- {
- if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_MASK && seq->mask == mask) {
- seq->flag |= SELECT;
- changed = true;
- }
- }
- SEQ_END;
- }
-
- return changed;
+ Sequence *seq;
+ bool changed = false;
+ const char *dir = actseq->strip ? actseq->strip->dir : NULL;
+
+ if (!SEQ_USE_DATA(actseq)) {
+ return changed;
+ }
+
+ if (SEQ_HAS_PATH(actseq) && dir) {
+ SEQP_BEGIN (ed, seq) {
+ if (SEQ_CHANNEL_CHECK(seq, channel) && SEQ_HAS_PATH(seq) && seq->strip &&
+ STREQ(seq->strip->dir, dir)) {
+ seq->flag |= SELECT;
+ changed = true;
+ }
+ }
+ SEQ_END;
+ }
+ else if (actseq->type == SEQ_TYPE_SCENE) {
+ Scene *sce = actseq->scene;
+ SEQP_BEGIN (ed, seq) {
+ if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_SCENE && seq->scene == sce) {
+ seq->flag |= SELECT;
+ changed = true;
+ }
+ }
+ SEQ_END;
+ }
+ else if (actseq->type == SEQ_TYPE_MOVIECLIP) {
+ MovieClip *clip = actseq->clip;
+ SEQP_BEGIN (ed, seq) {
+ if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_MOVIECLIP &&
+ seq->clip == clip) {
+ seq->flag |= SELECT;
+ changed = true;
+ }
+ }
+ SEQ_END;
+ }
+ else if (actseq->type == SEQ_TYPE_MASK) {
+ struct Mask *mask = actseq->mask;
+ SEQP_BEGIN (ed, seq) {
+ if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_MASK && seq->mask == mask) {
+ seq->flag |= SELECT;
+ changed = true;
+ }
+ }
+ SEQ_END;
+ }
+
+ return changed;
}
static bool select_grouped_effect(Editing *ed, Sequence *actseq, const int channel)
{
- Sequence *seq;
- bool changed = false;
- bool effects[SEQ_TYPE_MAX + 1];
- int i;
-
- for (i = 0; i <= SEQ_TYPE_MAX; i++) {
- effects[i] = false;
- }
-
- SEQP_BEGIN (ed, seq)
- {
- if (SEQ_CHANNEL_CHECK(seq, channel) && (seq->type & SEQ_TYPE_EFFECT) &&
- ELEM(actseq, seq->seq1, seq->seq2, seq->seq3))
- {
- effects[seq->type] = true;
- }
- }
- SEQ_END;
-
- SEQP_BEGIN (ed, seq)
- {
- if (SEQ_CHANNEL_CHECK(seq, channel) && effects[seq->type]) {
- if (seq->seq1) { seq->seq1->flag |= SELECT; }
- if (seq->seq2) { seq->seq2->flag |= SELECT; }
- if (seq->seq3) { seq->seq3->flag |= SELECT; }
- changed = true;
- }
- }
- SEQ_END;
-
- return changed;
+ Sequence *seq;
+ bool changed = false;
+ bool effects[SEQ_TYPE_MAX + 1];
+ int i;
+
+ for (i = 0; i <= SEQ_TYPE_MAX; i++) {
+ effects[i] = false;
+ }
+
+ SEQP_BEGIN (ed, seq) {
+ if (SEQ_CHANNEL_CHECK(seq, channel) && (seq->type & SEQ_TYPE_EFFECT) &&
+ ELEM(actseq, seq->seq1, seq->seq2, seq->seq3)) {
+ effects[seq->type] = true;
+ }
+ }
+ SEQ_END;
+
+ SEQP_BEGIN (ed, seq) {
+ if (SEQ_CHANNEL_CHECK(seq, channel) && effects[seq->type]) {
+ if (seq->seq1) {
+ seq->seq1->flag |= SELECT;
+ }
+ if (seq->seq2) {
+ seq->seq2->flag |= SELECT;
+ }
+ if (seq->seq3) {
+ seq->seq3->flag |= SELECT;
+ }
+ changed = true;
+ }
+ }
+ SEQ_END;
+
+ return changed;
}
static bool select_grouped_time_overlap(Editing *ed, Sequence *actseq)
{
- Sequence *seq;
- bool changed = false;
-
- SEQP_BEGIN (ed, seq)
- {
- if (!((seq->startdisp >= actseq->enddisp) || (seq->enddisp < actseq->startdisp))) {
- seq->flag |= SELECT;
- changed = true;
- }
- }
- SEQ_END;
-
- return changed;
+ Sequence *seq;
+ bool changed = false;
+
+ SEQP_BEGIN (ed, seq) {
+ if (!((seq->startdisp >= actseq->enddisp) || (seq->enddisp < actseq->startdisp))) {
+ seq->flag |= SELECT;
+ changed = true;
+ }
+ }
+ SEQ_END;
+
+ return changed;
}
static bool select_grouped_effect_link(Editing *ed, Sequence *actseq, const int channel)
{
- Sequence *seq = NULL;
- bool changed = false;
- const bool is_audio = ((actseq->type == SEQ_TYPE_META) || SEQ_IS_SOUND(actseq));
- int startdisp = actseq->startdisp;
- int enddisp = actseq->enddisp;
- int machine = actseq->machine;
- SeqIterator iter;
-
- SEQP_BEGIN (ed, seq)
- {
- seq->tmp = NULL;
- }
- SEQ_END;
-
- actseq->tmp = POINTER_FROM_INT(true);
-
- for (BKE_sequence_iterator_begin(ed, &iter, true); iter.valid; BKE_sequence_iterator_next(&iter)) {
- seq = iter.seq;
-
- /* Ignore all seqs already selected! */
- /* Ignore all seqs not sharing some time with active one. */
- /* Ignore all seqs of incompatible types (audio vs video). */
- if (!SEQ_CHANNEL_CHECK(seq, channel) ||
- (seq->flag & SELECT) || (seq->startdisp >= enddisp) || (seq->enddisp < startdisp) ||
- (!is_audio && SEQ_IS_SOUND(seq)) ||
- (is_audio && !((seq->type == SEQ_TYPE_META) || SEQ_IS_SOUND(seq))))
- {
- continue;
- }
-
- /* If the seq is an effect one, we need extra checking! */
- if (SEQ_IS_EFFECT(seq) && ((seq->seq1 && seq->seq1->tmp) ||
- (seq->seq2 && seq->seq2->tmp) ||
- (seq->seq3 && seq->seq3->tmp)))
- {
- if (startdisp > seq->startdisp) {
- startdisp = seq->startdisp;
- }
- if (enddisp < seq->enddisp) {
- enddisp = seq->enddisp;
- }
- if (machine < seq->machine) {
- machine = seq->machine;
- }
-
- seq->tmp = POINTER_FROM_INT(true);
-
- seq->flag |= SELECT;
- changed = true;
-
- /* Unfortunately, we must restart checks from the beginning. */
- BKE_sequence_iterator_end(&iter);
- BKE_sequence_iterator_begin(ed, &iter, true);
- }
-
- /* Video strips below active one, or any strip for audio (order do no matters here!). */
- else if (seq->machine < machine || is_audio) {
- seq->flag |= SELECT;
- changed = true;
- }
- }
- BKE_sequence_iterator_end(&iter);
-
- return changed;
+ Sequence *seq = NULL;
+ bool changed = false;
+ const bool is_audio = ((actseq->type == SEQ_TYPE_META) || SEQ_IS_SOUND(actseq));
+ int startdisp = actseq->startdisp;
+ int enddisp = actseq->enddisp;
+ int machine = actseq->machine;
+ SeqIterator iter;
+
+ SEQP_BEGIN (ed, seq) {
+ seq->tmp = NULL;
+ }
+ SEQ_END;
+
+ actseq->tmp = POINTER_FROM_INT(true);
+
+ for (BKE_sequence_iterator_begin(ed, &iter, true); iter.valid;
+ BKE_sequence_iterator_next(&iter)) {
+ seq = iter.seq;
+
+ /* Ignore all seqs already selected! */
+ /* Ignore all seqs not sharing some time with active one. */
+ /* Ignore all seqs of incompatible types (audio vs video). */
+ if (!SEQ_CHANNEL_CHECK(seq, channel) || (seq->flag & SELECT) || (seq->startdisp >= enddisp) ||
+ (seq->enddisp < startdisp) || (!is_audio && SEQ_IS_SOUND(seq)) ||
+ (is_audio && !((seq->type == SEQ_TYPE_META) || SEQ_IS_SOUND(seq)))) {
+ continue;
+ }
+
+ /* If the seq is an effect one, we need extra checking! */
+ if (SEQ_IS_EFFECT(seq) && ((seq->seq1 && seq->seq1->tmp) || (seq->seq2 && seq->seq2->tmp) ||
+ (seq->seq3 && seq->seq3->tmp))) {
+ if (startdisp > seq->startdisp) {
+ startdisp = seq->startdisp;
+ }
+ if (enddisp < seq->enddisp) {
+ enddisp = seq->enddisp;
+ }
+ if (machine < seq->machine) {
+ machine = seq->machine;
+ }
+
+ seq->tmp = POINTER_FROM_INT(true);
+
+ seq->flag |= SELECT;
+ changed = true;
+
+ /* Unfortunately, we must restart checks from the beginning. */
+ BKE_sequence_iterator_end(&iter);
+ BKE_sequence_iterator_begin(ed, &iter, true);
+ }
+
+ /* Video strips below active one, or any strip for audio (order do no matters here!). */
+ else if (seq->machine < machine || is_audio) {
+ seq->flag |= SELECT;
+ changed = true;
+ }
+ }
+ BKE_sequence_iterator_end(&iter);
+
+ return changed;
}
#undef SEQ_IS_SOUND
@@ -1237,83 +1244,89 @@ static bool select_grouped_effect_link(Editing *ed, Sequence *actseq, const int
static int sequencer_select_grouped_exec(bContext *C, wmOperator *op)
{
- Scene *scene = CTX_data_scene(C);
- Editing *ed = BKE_sequencer_editing_get(scene, false);
- Sequence *seq, *actseq = BKE_sequencer_active_get(scene);
-
- const int type = RNA_enum_get(op->ptr, "type");
- const int channel = RNA_boolean_get(op->ptr, "use_active_channel") ? actseq->machine : 0;
- const bool extend = RNA_boolean_get(op->ptr, "extend");
-
- bool changed = false;
-
- if (actseq == NULL) {
- BKE_report(op->reports, RPT_ERROR, "No active sequence!");
- return OPERATOR_CANCELLED;
- }
-
- if (!extend) {
- SEQP_BEGIN (ed, seq)
- {
- seq->flag &= ~SELECT;
- changed = true;
- }
- SEQ_END;
- }
-
- switch (type) {
- case SEQ_SELECT_GROUP_TYPE:
- changed |= select_grouped_type(ed, actseq, channel);
- break;
- case SEQ_SELECT_GROUP_TYPE_BASIC:
- changed |= select_grouped_type_basic(ed, actseq, channel);
- break;
- case SEQ_SELECT_GROUP_TYPE_EFFECT:
- changed |= select_grouped_type_effect(ed, actseq, channel);
- break;
- case SEQ_SELECT_GROUP_DATA:
- changed |= select_grouped_data(ed, actseq, channel);
- break;
- case SEQ_SELECT_GROUP_EFFECT:
- changed |= select_grouped_effect(ed, actseq, channel);
- break;
- case SEQ_SELECT_GROUP_EFFECT_LINK:
- changed |= select_grouped_effect_link(ed, actseq, channel);
- break;
- case SEQ_SELECT_GROUP_OVERLAP:
- changed |= select_grouped_time_overlap(ed, actseq);
- break;
- default:
- BLI_assert(0);
- break;
- }
-
- if (changed) {
- WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
- return OPERATOR_FINISHED;
- }
-
- return OPERATOR_CANCELLED;
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = BKE_sequencer_editing_get(scene, false);
+ Sequence *seq, *actseq = BKE_sequencer_active_get(scene);
+
+ const int type = RNA_enum_get(op->ptr, "type");
+ const int channel = RNA_boolean_get(op->ptr, "use_active_channel") ? actseq->machine : 0;
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+
+ bool changed = false;
+
+ if (actseq == NULL) {
+ BKE_report(op->reports, RPT_ERROR, "No active sequence!");
+ return OPERATOR_CANCELLED;
+ }
+
+ if (!extend) {
+ SEQP_BEGIN (ed, seq) {
+ seq->flag &= ~SELECT;
+ changed = true;
+ }
+ SEQ_END;
+ }
+
+ switch (type) {
+ case SEQ_SELECT_GROUP_TYPE:
+ changed |= select_grouped_type(ed, actseq, channel);
+ break;
+ case SEQ_SELECT_GROUP_TYPE_BASIC:
+ changed |= select_grouped_type_basic(ed, actseq, channel);
+ break;
+ case SEQ_SELECT_GROUP_TYPE_EFFECT:
+ changed |= select_grouped_type_effect(ed, actseq, channel);
+ break;
+ case SEQ_SELECT_GROUP_DATA:
+ changed |= select_grouped_data(ed, actseq, channel);
+ break;
+ case SEQ_SELECT_GROUP_EFFECT:
+ changed |= select_grouped_effect(ed, actseq, channel);
+ break;
+ case SEQ_SELECT_GROUP_EFFECT_LINK:
+ changed |= select_grouped_effect_link(ed, actseq, channel);
+ break;
+ case SEQ_SELECT_GROUP_OVERLAP:
+ changed |= select_grouped_time_overlap(ed, actseq);
+ break;
+ default:
+ BLI_assert(0);
+ break;
+ }
+
+ if (changed) {
+ WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
+ return OPERATOR_FINISHED;
+ }
+
+ return OPERATOR_CANCELLED;
}
void SEQUENCER_OT_select_grouped(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Select Grouped";
- ot->description = "Select all strips grouped by various properties";
- ot->idname = "SEQUENCER_OT_select_grouped";
-
- /* api callbacks */
- ot->invoke = WM_menu_invoke;
- ot->exec = sequencer_select_grouped_exec;
- ot->poll = sequencer_edit_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- ot->prop = RNA_def_enum(ot->srna, "type", sequencer_prop_select_grouped_types, 0, "Type", "");
- RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first");
- RNA_def_boolean(ot->srna, "use_active_channel", false, "Same Channel",
- "Only consider strips on the same channel as the active one");
+ /* identifiers */
+ ot->name = "Select Grouped";
+ ot->description = "Select all strips grouped by various properties";
+ ot->idname = "SEQUENCER_OT_select_grouped";
+
+ /* api callbacks */
+ ot->invoke = WM_menu_invoke;
+ ot->exec = sequencer_select_grouped_exec;
+ ot->poll = sequencer_edit_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ ot->prop = RNA_def_enum(ot->srna, "type", sequencer_prop_select_grouped_types, 0, "Type", "");
+ RNA_def_boolean(ot->srna,
+ "extend",
+ false,
+ "Extend",
+ "Extend selection instead of deselecting everything first");
+ RNA_def_boolean(ot->srna,
+ "use_active_channel",
+ false,
+ "Same Channel",
+ "Only consider strips on the same channel as the active one");
}
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
index 30f526c0675..e16029395bd 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -17,7 +17,6 @@
* All rights reserved.
*/
-
/** \file
* \ingroup spseq
*/
@@ -53,188 +52,199 @@
/******************** sample backdrop operator ********************/
typedef struct ImageSampleInfo {
- ARegionType *art;
- void *draw_handle;
- int x, y;
- int channels;
+ ARegionType *art;
+ void *draw_handle;
+ int x, y;
+ int channels;
- unsigned char col[4];
- float colf[4];
- float linearcol[4];
+ unsigned char col[4];
+ float colf[4];
+ float linearcol[4];
- unsigned char *colp;
- const float *colfp;
+ unsigned char *colp;
+ const float *colfp;
- int draw;
-int color_manage;
+ int draw;
+ int color_manage;
} ImageSampleInfo;
static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
{
- Scene *scene = CTX_data_scene(C);
- ImageSampleInfo *info = arg_info;
-
- if (info->draw) {
- ED_image_draw_info(scene, ar, info->color_manage, false, info->channels,
- info->x, info->y, info->colp, info->colfp,
- info->linearcol, NULL, NULL);
- }
+ Scene *scene = CTX_data_scene(C);
+ ImageSampleInfo *info = arg_info;
+
+ if (info->draw) {
+ ED_image_draw_info(scene,
+ ar,
+ info->color_manage,
+ false,
+ info->channels,
+ info->x,
+ info->y,
+ info->colp,
+ info->colfp,
+ info->linearcol,
+ NULL,
+ NULL);
+ }
}
static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
{
- Main *bmain = CTX_data_main(C);
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
- Scene *scene = CTX_data_scene(C);
- SpaceSeq *sseq = (SpaceSeq *) CTX_wm_space_data(C);
- ARegion *ar = CTX_wm_region(C);
- ImBuf *ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, sseq, CFRA, 0, NULL);
- ImageSampleInfo *info = op->customdata;
- float fx, fy;
-
- if (ibuf == NULL) {
- IMB_freeImBuf(ibuf);
- info->draw = 0;
- return;
- }
-
- UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy);
-
- fx += (float)scene->r.xsch / 2.0f;
- fy += (float)scene->r.ysch / 2.0f;
- fx *= (float)ibuf->x / (float)scene->r.xsch;
- fy *= (float)ibuf->y / (float)scene->r.ysch;
-
- if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) {
- const float *fp;
- unsigned char *cp;
- int x = (int) fx, y = (int) fy;
-
- info->x = x;
- info->y = y;
- info->draw = 1;
- info->channels = ibuf->channels;
-
- info->colp = NULL;
- info->colfp = NULL;
-
- if (ibuf->rect) {
- cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
-
- info->col[0] = cp[0];
- info->col[1] = cp[1];
- info->col[2] = cp[2];
- info->col[3] = cp[3];
- info->colp = info->col;
-
- info->colf[0] = (float)cp[0] / 255.0f;
- info->colf[1] = (float)cp[1] / 255.0f;
- info->colf[2] = (float)cp[2] / 255.0f;
- info->colf[3] = (float)cp[3] / 255.0f;
- info->colfp = info->colf;
-
- copy_v4_v4(info->linearcol, info->colf);
- IMB_colormanagement_colorspace_to_scene_linear_v4(info->linearcol, false, ibuf->rect_colorspace);
-
- info->color_manage = true;
- }
- if (ibuf->rect_float) {
- fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
-
- info->colf[0] = fp[0];
- info->colf[1] = fp[1];
- info->colf[2] = fp[2];
- info->colf[3] = fp[3];
- info->colfp = info->colf;
-
- /* sequencer's image buffers are in non-linear space, need to make them linear */
- copy_v4_v4(info->linearcol, info->colf);
- BKE_sequencer_pixel_from_sequencer_space_v4(scene, info->linearcol);
-
- info->color_manage = true;
- }
- }
- else {
- info->draw = 0;
- }
-
- IMB_freeImBuf(ibuf);
- ED_area_tag_redraw(CTX_wm_area(C));
+ Main *bmain = CTX_data_main(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Scene *scene = CTX_data_scene(C);
+ SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C);
+ ARegion *ar = CTX_wm_region(C);
+ ImBuf *ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, sseq, CFRA, 0, NULL);
+ ImageSampleInfo *info = op->customdata;
+ float fx, fy;
+
+ if (ibuf == NULL) {
+ IMB_freeImBuf(ibuf);
+ info->draw = 0;
+ return;
+ }
+
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy);
+
+ fx += (float)scene->r.xsch / 2.0f;
+ fy += (float)scene->r.ysch / 2.0f;
+ fx *= (float)ibuf->x / (float)scene->r.xsch;
+ fy *= (float)ibuf->y / (float)scene->r.ysch;
+
+ if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) {
+ const float *fp;
+ unsigned char *cp;
+ int x = (int)fx, y = (int)fy;
+
+ info->x = x;
+ info->y = y;
+ info->draw = 1;
+ info->channels = ibuf->channels;
+
+ info->colp = NULL;
+ info->colfp = NULL;
+
+ if (ibuf->rect) {
+ cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
+
+ info->col[0] = cp[0];
+ info->col[1] = cp[1];
+ info->col[2] = cp[2];
+ info->col[3] = cp[3];
+ info->colp = info->col;
+
+ info->colf[0] = (float)cp[0] / 255.0f;
+ info->colf[1] = (float)cp[1] / 255.0f;
+ info->colf[2] = (float)cp[2] / 255.0f;
+ info->colf[3] = (float)cp[3] / 255.0f;
+ info->colfp = info->colf;
+
+ copy_v4_v4(info->linearcol, info->colf);
+ IMB_colormanagement_colorspace_to_scene_linear_v4(
+ info->linearcol, false, ibuf->rect_colorspace);
+
+ info->color_manage = true;
+ }
+ if (ibuf->rect_float) {
+ fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
+
+ info->colf[0] = fp[0];
+ info->colf[1] = fp[1];
+ info->colf[2] = fp[2];
+ info->colf[3] = fp[3];
+ info->colfp = info->colf;
+
+ /* sequencer's image buffers are in non-linear space, need to make them linear */
+ copy_v4_v4(info->linearcol, info->colf);
+ BKE_sequencer_pixel_from_sequencer_space_v4(scene, info->linearcol);
+
+ info->color_manage = true;
+ }
+ }
+ else {
+ info->draw = 0;
+ }
+
+ IMB_freeImBuf(ibuf);
+ ED_area_tag_redraw(CTX_wm_area(C));
}
static void sample_exit(bContext *C, wmOperator *op)
{
- ImageSampleInfo *info = op->customdata;
+ ImageSampleInfo *info = op->customdata;
- ED_region_draw_cb_exit(info->art, info->draw_handle);
- ED_area_tag_redraw(CTX_wm_area(C));
- MEM_freeN(info);
+ ED_region_draw_cb_exit(info->art, info->draw_handle);
+ ED_area_tag_redraw(CTX_wm_area(C));
+ MEM_freeN(info);
}
static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- ARegion *ar = CTX_wm_region(C);
- SpaceSeq *sseq = CTX_wm_space_seq(C);
- ImageSampleInfo *info;
+ ARegion *ar = CTX_wm_region(C);
+ SpaceSeq *sseq = CTX_wm_space_seq(C);
+ ImageSampleInfo *info;
- if (sseq->mainb != SEQ_DRAW_IMG_IMBUF) {
- return OPERATOR_CANCELLED;
- }
+ if (sseq->mainb != SEQ_DRAW_IMG_IMBUF) {
+ return OPERATOR_CANCELLED;
+ }
- info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
- info->art = ar->type;
- info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL);
- op->customdata = info;
+ info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
+ info->art = ar->type;
+ info->draw_handle = ED_region_draw_cb_activate(
+ ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL);
+ op->customdata = info;
- sample_apply(C, op, event);
+ sample_apply(C, op, event);
- WM_event_add_modal_handler(C, op);
+ WM_event_add_modal_handler(C, op);
- return OPERATOR_RUNNING_MODAL;
+ return OPERATOR_RUNNING_MODAL;
}
static int sample_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
- switch (event->type) {
- case LEFTMOUSE:
- case RIGHTMOUSE: /* XXX hardcoded */
- if (event->val == KM_RELEASE) {
- sample_exit(C, op);
- return OPERATOR_CANCELLED;
- }
- break;
- case MOUSEMOVE:
- sample_apply(C, op, event);
- break;
- }
-
- return OPERATOR_RUNNING_MODAL;
+ switch (event->type) {
+ case LEFTMOUSE:
+ case RIGHTMOUSE: /* XXX hardcoded */
+ if (event->val == KM_RELEASE) {
+ sample_exit(C, op);
+ return OPERATOR_CANCELLED;
+ }
+ break;
+ case MOUSEMOVE:
+ sample_apply(C, op, event);
+ break;
+ }
+
+ return OPERATOR_RUNNING_MODAL;
}
static void sample_cancel(bContext *C, wmOperator *op)
{
- sample_exit(C, op);
+ sample_exit(C, op);
}
static bool sample_poll(bContext *C)
{
- SpaceSeq *sseq = CTX_wm_space_seq(C);
- return sseq && BKE_sequencer_editing_get(CTX_data_scene(C), false) != NULL;
+ SpaceSeq *sseq = CTX_wm_space_seq(C);
+ return sseq && BKE_sequencer_editing_get(CTX_data_scene(C), false) != NULL;
}
void SEQUENCER_OT_sample(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Sample Color";
- ot->idname = "SEQUENCER_OT_sample";
- ot->description = "Use mouse to sample color in current frame";
-
- /* api callbacks */
- ot->invoke = sample_invoke;
- ot->modal = sample_modal;
- ot->cancel = sample_cancel;
- ot->poll = sample_poll;
-
- /* flags */
- ot->flag = OPTYPE_BLOCKING;
+ /* identifiers */
+ ot->name = "Sample Color";
+ ot->idname = "SEQUENCER_OT_sample";
+ ot->description = "Use mouse to sample color in current frame";
+
+ /* api callbacks */
+ ot->invoke = sample_invoke;
+ ot->modal = sample_modal;
+ ot->cancel = sample_cancel;
+ ot->poll = sample_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_BLOCKING;
}
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 561d603ab08..35c031e8bc8 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -21,7 +21,6 @@
* \ingroup spseq
*/
-
#include <string.h>
#include <stdio.h>
@@ -56,684 +55,698 @@
#include "IMB_imbuf.h"
-#include "sequencer_intern.h" // own include
+#include "sequencer_intern.h" // own include
/**************************** common state *****************************/
static void sequencer_scopes_tag_refresh(ScrArea *sa)
{
- SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first;
+ SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first;
- sseq->scopes.reference_ibuf = NULL;
+ sseq->scopes.reference_ibuf = NULL;
}
/* ******************** manage regions ********************* */
ARegion *sequencer_has_buttons_region(ScrArea *sa)
{
- ARegion *ar, *arnew;
+ ARegion *ar, *arnew;
- ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar) {
- return ar;
- }
+ ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ if (ar) {
+ return ar;
+ }
- /* add subdiv level; after header */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+ /* add subdiv level; after header */
+ ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
- /* is error! */
- if (ar == NULL) {
- return NULL;
- }
+ /* is error! */
+ if (ar == NULL) {
+ return NULL;
+ }
- arnew = MEM_callocN(sizeof(ARegion), "buttons for sequencer");
+ arnew = MEM_callocN(sizeof(ARegion), "buttons for sequencer");
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype = RGN_TYPE_UI;
- arnew->alignment = RGN_ALIGN_RIGHT;
+ BLI_insertlinkafter(&sa->regionbase, ar, arnew);
+ arnew->regiontype = RGN_TYPE_UI;
+ arnew->alignment = RGN_ALIGN_RIGHT;
- arnew->flag = RGN_FLAG_HIDDEN;
+ arnew->flag = RGN_FLAG_HIDDEN;
- return arnew;
+ return arnew;
}
static ARegion *sequencer_find_region(ScrArea *sa, short type)
{
- ARegion *ar = NULL;
+ ARegion *ar = NULL;
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == type) {
- return ar;
- }
- }
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == type) {
+ return ar;
+ }
+ }
- return ar;
+ return ar;
}
/* ******************** default callbacks for sequencer space ***************** */
static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene)
{
- ARegion *ar;
- SpaceSeq *sseq;
-
- sseq = MEM_callocN(sizeof(SpaceSeq), "initsequencer");
- sseq->spacetype = SPACE_SEQ;
- sseq->chanshown = 0;
- sseq->view = SEQ_VIEW_SEQUENCE;
- sseq->mainb = SEQ_DRAW_IMG_IMBUF;
- sseq->flag = SEQ_SHOW_GPENCIL | SEQ_USE_ALPHA | SEQ_SHOW_MARKER_LINES;
-
- /* header */
- ar = MEM_callocN(sizeof(ARegion), "header for sequencer");
-
- BLI_addtail(&sseq->regionbase, ar);
- ar->regiontype = RGN_TYPE_HEADER;
- ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
-
- /* buttons/list view */
- ar = MEM_callocN(sizeof(ARegion), "buttons for sequencer");
-
- BLI_addtail(&sseq->regionbase, ar);
- ar->regiontype = RGN_TYPE_UI;
- ar->alignment = RGN_ALIGN_RIGHT;
- ar->flag = RGN_FLAG_HIDDEN;
-
- /* preview region */
- /* NOTE: if you change values here, also change them in sequencer_init_preview_region */
- ar = MEM_callocN(sizeof(ARegion), "preview region for sequencer");
- BLI_addtail(&sseq->regionbase, ar);
- ar->regiontype = RGN_TYPE_PREVIEW;
- ar->alignment = RGN_ALIGN_TOP;
- ar->flag |= RGN_FLAG_HIDDEN;
- /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
- ar->v2d.keepzoom = V2D_KEEPASPECT | V2D_KEEPZOOM | V2D_LIMITZOOM;
- ar->v2d.minzoom = 0.001f;
- ar->v2d.maxzoom = 1000.0f;
- ar->v2d.tot.xmin = -960.0f; /* 1920 width centered */
- ar->v2d.tot.ymin = -540.0f; /* 1080 height centered */
- ar->v2d.tot.xmax = 960.0f;
- ar->v2d.tot.ymax = 540.0f;
- ar->v2d.min[0] = 0.0f;
- ar->v2d.min[1] = 0.0f;
- ar->v2d.max[0] = 12000.0f;
- ar->v2d.max[1] = 12000.0f;
- ar->v2d.cur = ar->v2d.tot;
- ar->v2d.align = V2D_ALIGN_FREE;
- ar->v2d.keeptot = V2D_KEEPTOT_FREE;
-
-
- /* main region */
- ar = MEM_callocN(sizeof(ARegion), "main region for sequencer");
-
- BLI_addtail(&sseq->regionbase, ar);
- ar->regiontype = RGN_TYPE_WINDOW;
-
-
- /* seq space goes from (0,8) to (0, efra) */
-
- ar->v2d.tot.xmin = 0.0f;
- ar->v2d.tot.ymin = 0.0f;
- ar->v2d.tot.xmax = scene->r.efra;
- ar->v2d.tot.ymax = 8.0f;
-
- ar->v2d.cur = ar->v2d.tot;
-
- ar->v2d.min[0] = 10.0f;
- ar->v2d.min[1] = 0.5f;
-
- ar->v2d.max[0] = MAXFRAMEF;
- ar->v2d.max[1] = MAXSEQ;
-
- ar->v2d.minzoom = 0.01f;
- ar->v2d.maxzoom = 100.0f;
-
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
- ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL);
- ar->v2d.keepzoom = 0;
- ar->v2d.keeptot = 0;
- ar->v2d.align = V2D_ALIGN_NO_NEG_Y;
-
- return (SpaceLink *)sseq;
+ ARegion *ar;
+ SpaceSeq *sseq;
+
+ sseq = MEM_callocN(sizeof(SpaceSeq), "initsequencer");
+ sseq->spacetype = SPACE_SEQ;
+ sseq->chanshown = 0;
+ sseq->view = SEQ_VIEW_SEQUENCE;
+ sseq->mainb = SEQ_DRAW_IMG_IMBUF;
+ sseq->flag = SEQ_SHOW_GPENCIL | SEQ_USE_ALPHA | SEQ_SHOW_MARKER_LINES;
+
+ /* header */
+ ar = MEM_callocN(sizeof(ARegion), "header for sequencer");
+
+ BLI_addtail(&sseq->regionbase, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
+
+ /* buttons/list view */
+ ar = MEM_callocN(sizeof(ARegion), "buttons for sequencer");
+
+ BLI_addtail(&sseq->regionbase, ar);
+ ar->regiontype = RGN_TYPE_UI;
+ ar->alignment = RGN_ALIGN_RIGHT;
+ ar->flag = RGN_FLAG_HIDDEN;
+
+ /* preview region */
+ /* NOTE: if you change values here, also change them in sequencer_init_preview_region */
+ ar = MEM_callocN(sizeof(ARegion), "preview region for sequencer");
+ BLI_addtail(&sseq->regionbase, ar);
+ ar->regiontype = RGN_TYPE_PREVIEW;
+ ar->alignment = RGN_ALIGN_TOP;
+ ar->flag |= RGN_FLAG_HIDDEN;
+ /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
+ ar->v2d.keepzoom = V2D_KEEPASPECT | V2D_KEEPZOOM | V2D_LIMITZOOM;
+ ar->v2d.minzoom = 0.001f;
+ ar->v2d.maxzoom = 1000.0f;
+ ar->v2d.tot.xmin = -960.0f; /* 1920 width centered */
+ ar->v2d.tot.ymin = -540.0f; /* 1080 height centered */
+ ar->v2d.tot.xmax = 960.0f;
+ ar->v2d.tot.ymax = 540.0f;
+ ar->v2d.min[0] = 0.0f;
+ ar->v2d.min[1] = 0.0f;
+ ar->v2d.max[0] = 12000.0f;
+ ar->v2d.max[1] = 12000.0f;
+ ar->v2d.cur = ar->v2d.tot;
+ ar->v2d.align = V2D_ALIGN_FREE;
+ ar->v2d.keeptot = V2D_KEEPTOT_FREE;
+
+ /* main region */
+ ar = MEM_callocN(sizeof(ARegion), "main region for sequencer");
+
+ BLI_addtail(&sseq->regionbase, ar);
+ ar->regiontype = RGN_TYPE_WINDOW;
+
+ /* seq space goes from (0,8) to (0, efra) */
+
+ ar->v2d.tot.xmin = 0.0f;
+ ar->v2d.tot.ymin = 0.0f;
+ ar->v2d.tot.xmax = scene->r.efra;
+ ar->v2d.tot.ymax = 8.0f;
+
+ ar->v2d.cur = ar->v2d.tot;
+
+ ar->v2d.min[0] = 10.0f;
+ ar->v2d.min[1] = 0.5f;
+
+ ar->v2d.max[0] = MAXFRAMEF;
+ ar->v2d.max[1] = MAXSEQ;
+
+ ar->v2d.minzoom = 0.01f;
+ ar->v2d.maxzoom = 100.0f;
+
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL);
+ ar->v2d.keepzoom = 0;
+ ar->v2d.keeptot = 0;
+ ar->v2d.align = V2D_ALIGN_NO_NEG_Y;
+
+ return (SpaceLink *)sseq;
}
/* not spacelink itself */
static void sequencer_free(SpaceLink *sl)
{
- SpaceSeq *sseq = (SpaceSeq *) sl;
- SequencerScopes *scopes = &sseq->scopes;
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+ SequencerScopes *scopes = &sseq->scopes;
-// XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd);
+ // XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd);
- if (scopes->zebra_ibuf) {
- IMB_freeImBuf(scopes->zebra_ibuf);
- }
+ if (scopes->zebra_ibuf) {
+ IMB_freeImBuf(scopes->zebra_ibuf);
+ }
- if (scopes->waveform_ibuf) {
- IMB_freeImBuf(scopes->waveform_ibuf);
- }
+ if (scopes->waveform_ibuf) {
+ IMB_freeImBuf(scopes->waveform_ibuf);
+ }
- if (scopes->sep_waveform_ibuf) {
- IMB_freeImBuf(scopes->sep_waveform_ibuf);
- }
+ if (scopes->sep_waveform_ibuf) {
+ IMB_freeImBuf(scopes->sep_waveform_ibuf);
+ }
- if (scopes->vector_ibuf) {
- IMB_freeImBuf(scopes->vector_ibuf);
- }
+ if (scopes->vector_ibuf) {
+ IMB_freeImBuf(scopes->vector_ibuf);
+ }
- if (scopes->histogram_ibuf) {
- IMB_freeImBuf(scopes->histogram_ibuf);
- }
+ if (scopes->histogram_ibuf) {
+ IMB_freeImBuf(scopes->histogram_ibuf);
+ }
}
-
/* spacetype; init callback */
static void sequencer_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
{
-
}
static void sequencer_refresh(const bContext *C, ScrArea *sa)
{
- wmWindowManager *wm = CTX_wm_manager(C);
- wmWindow *window = CTX_wm_window(C);
- SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first;
- ARegion *ar_main = sequencer_find_region(sa, RGN_TYPE_WINDOW);
- ARegion *ar_preview = sequencer_find_region(sa, RGN_TYPE_PREVIEW);
- bool view_changed = false;
-
- switch (sseq->view) {
- case SEQ_VIEW_SEQUENCE:
- if (ar_main && (ar_main->flag & RGN_FLAG_HIDDEN)) {
- ar_main->flag &= ~RGN_FLAG_HIDDEN;
- ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
- view_changed = true;
- }
- if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) {
- ar_preview->flag |= RGN_FLAG_HIDDEN;
- ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
- WM_event_remove_handlers((bContext *)C, &ar_preview->handlers);
- view_changed = true;
- }
- if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
- ar_main->alignment = RGN_ALIGN_NONE;
- view_changed = true;
- }
- if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) {
- ar_preview->alignment = RGN_ALIGN_NONE;
- view_changed = true;
- }
- break;
- case SEQ_VIEW_PREVIEW:
- if (ar_main && !(ar_main->flag & RGN_FLAG_HIDDEN)) {
- ar_main->flag |= RGN_FLAG_HIDDEN;
- ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
- WM_event_remove_handlers((bContext *)C, &ar_main->handlers);
- view_changed = true;
- }
- if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) {
- ar_preview->flag &= ~RGN_FLAG_HIDDEN;
- ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
- ar_preview->v2d.cur = ar_preview->v2d.tot;
- view_changed = true;
- }
- if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
- ar_main->alignment = RGN_ALIGN_NONE;
- view_changed = true;
- }
- if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) {
- ar_preview->alignment = RGN_ALIGN_NONE;
- view_changed = true;
- }
- break;
- case SEQ_VIEW_SEQUENCE_PREVIEW:
- if (ar_main && ar_preview) {
- /* Get available height (without DPI correction). */
- const float height = (sa->winy - ED_area_headersize()) / UI_DPI_FAC;
-
- /* We reuse hidden region's size, allows to find same layout as before if we just switch
- * between one 'full window' view and the combined one. This gets lost if we switch to both
- * 'full window' views before, though... Better than nothing. */
- if (ar_main->flag & RGN_FLAG_HIDDEN) {
- ar_main->flag &= ~RGN_FLAG_HIDDEN;
- ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
- ar_preview->sizey = (int)(height - ar_main->sizey);
- view_changed = true;
- }
- if (ar_preview->flag & RGN_FLAG_HIDDEN) {
- ar_preview->flag &= ~RGN_FLAG_HIDDEN;
- ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
- ar_preview->v2d.cur = ar_preview->v2d.tot;
- ar_main->sizey = (int)(height - ar_preview->sizey);
- view_changed = true;
- }
- if (ar_main->alignment != RGN_ALIGN_NONE) {
- ar_main->alignment = RGN_ALIGN_NONE;
- view_changed = true;
- }
- if (ar_preview->alignment != RGN_ALIGN_TOP) {
- ar_preview->alignment = RGN_ALIGN_TOP;
- view_changed = true;
- }
- /* Final check that both preview and main height are reasonable! */
- if (ar_preview->sizey < 10 || ar_main->sizey < 10 || ar_preview->sizey + ar_main->sizey > height) {
- ar_preview->sizey = (int)(height * 0.4f + 0.5f);
- ar_main->sizey = (int)(height - ar_preview->sizey);
- view_changed = true;
- }
- }
- break;
- }
-
- if (view_changed) {
- ED_area_initialize(wm, window, sa);
- ED_area_tag_redraw(sa);
- }
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *window = CTX_wm_window(C);
+ SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first;
+ ARegion *ar_main = sequencer_find_region(sa, RGN_TYPE_WINDOW);
+ ARegion *ar_preview = sequencer_find_region(sa, RGN_TYPE_PREVIEW);
+ bool view_changed = false;
+
+ switch (sseq->view) {
+ case SEQ_VIEW_SEQUENCE:
+ if (ar_main && (ar_main->flag & RGN_FLAG_HIDDEN)) {
+ ar_main->flag &= ~RGN_FLAG_HIDDEN;
+ ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ view_changed = true;
+ }
+ if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) {
+ ar_preview->flag |= RGN_FLAG_HIDDEN;
+ ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &ar_preview->handlers);
+ view_changed = true;
+ }
+ if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
+ ar_main->alignment = RGN_ALIGN_NONE;
+ view_changed = true;
+ }
+ if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) {
+ ar_preview->alignment = RGN_ALIGN_NONE;
+ view_changed = true;
+ }
+ break;
+ case SEQ_VIEW_PREVIEW:
+ if (ar_main && !(ar_main->flag & RGN_FLAG_HIDDEN)) {
+ ar_main->flag |= RGN_FLAG_HIDDEN;
+ ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &ar_main->handlers);
+ view_changed = true;
+ }
+ if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) {
+ ar_preview->flag &= ~RGN_FLAG_HIDDEN;
+ ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ ar_preview->v2d.cur = ar_preview->v2d.tot;
+ view_changed = true;
+ }
+ if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
+ ar_main->alignment = RGN_ALIGN_NONE;
+ view_changed = true;
+ }
+ if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) {
+ ar_preview->alignment = RGN_ALIGN_NONE;
+ view_changed = true;
+ }
+ break;
+ case SEQ_VIEW_SEQUENCE_PREVIEW:
+ if (ar_main && ar_preview) {
+ /* Get available height (without DPI correction). */
+ const float height = (sa->winy - ED_area_headersize()) / UI_DPI_FAC;
+
+ /* We reuse hidden region's size, allows to find same layout as before if we just switch
+ * between one 'full window' view and the combined one. This gets lost if we switch to both
+ * 'full window' views before, though... Better than nothing. */
+ if (ar_main->flag & RGN_FLAG_HIDDEN) {
+ ar_main->flag &= ~RGN_FLAG_HIDDEN;
+ ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ ar_preview->sizey = (int)(height - ar_main->sizey);
+ view_changed = true;
+ }
+ if (ar_preview->flag & RGN_FLAG_HIDDEN) {
+ ar_preview->flag &= ~RGN_FLAG_HIDDEN;
+ ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ ar_preview->v2d.cur = ar_preview->v2d.tot;
+ ar_main->sizey = (int)(height - ar_preview->sizey);
+ view_changed = true;
+ }
+ if (ar_main->alignment != RGN_ALIGN_NONE) {
+ ar_main->alignment = RGN_ALIGN_NONE;
+ view_changed = true;
+ }
+ if (ar_preview->alignment != RGN_ALIGN_TOP) {
+ ar_preview->alignment = RGN_ALIGN_TOP;
+ view_changed = true;
+ }
+ /* Final check that both preview and main height are reasonable! */
+ if (ar_preview->sizey < 10 || ar_main->sizey < 10 ||
+ ar_preview->sizey + ar_main->sizey > height) {
+ ar_preview->sizey = (int)(height * 0.4f + 0.5f);
+ ar_main->sizey = (int)(height - ar_preview->sizey);
+ view_changed = true;
+ }
+ }
+ break;
+ }
+
+ if (view_changed) {
+ ED_area_initialize(wm, window, sa);
+ ED_area_tag_redraw(sa);
+ }
}
static SpaceLink *sequencer_duplicate(SpaceLink *sl)
{
- SpaceSeq *sseqn = MEM_dupallocN(sl);
+ SpaceSeq *sseqn = MEM_dupallocN(sl);
- /* clear or remove stuff from old */
-// XXX sseq->gpd = gpencil_data_duplicate(sseq->gpd, false);
+ /* clear or remove stuff from old */
+ // XXX sseq->gpd = gpencil_data_duplicate(sseq->gpd, false);
- memset(&sseqn->scopes, 0, sizeof(sseqn->scopes));
+ memset(&sseqn->scopes, 0, sizeof(sseqn->scopes));
- return (SpaceLink *)sseqn;
+ return (SpaceLink *)sseqn;
}
-static void sequencer_listener(
- wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
+static void sequencer_listener(wmWindow *UNUSED(win),
+ ScrArea *sa,
+ wmNotifier *wmn,
+ Scene *UNUSED(scene))
{
- /* context changes */
- switch (wmn->category) {
- case NC_SCENE:
- switch (wmn->data) {
- case ND_FRAME:
- case ND_SEQUENCER:
- sequencer_scopes_tag_refresh(sa);
- break;
- }
- break;
- case NC_WINDOW:
- case NC_SPACE:
- if (wmn->data == ND_SPACE_SEQUENCER) {
- sequencer_scopes_tag_refresh(sa);
- }
- break;
- case NC_GPENCIL:
- if (wmn->data & ND_GPENCIL_EDITMODE) {
- ED_area_tag_redraw(sa);
- }
- break;
- }
+ /* context changes */
+ switch (wmn->category) {
+ case NC_SCENE:
+ switch (wmn->data) {
+ case ND_FRAME:
+ case ND_SEQUENCER:
+ sequencer_scopes_tag_refresh(sa);
+ break;
+ }
+ break;
+ case NC_WINDOW:
+ case NC_SPACE:
+ if (wmn->data == ND_SPACE_SEQUENCER) {
+ sequencer_scopes_tag_refresh(sa);
+ }
+ break;
+ case NC_GPENCIL:
+ if (wmn->data & ND_GPENCIL_EDITMODE) {
+ ED_area_tag_redraw(sa);
+ }
+ break;
+ }
}
/* ************* dropboxes ************* */
-static bool image_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **UNUSED(tooltip))
+static bool image_drop_poll(bContext *C,
+ wmDrag *drag,
+ const wmEvent *event,
+ const char **UNUSED(tooltip))
{
- ARegion *ar = CTX_wm_region(C);
- Scene *scene = CTX_data_scene(C);
- int hand;
-
- if (drag->type == WM_DRAG_PATH) {
- if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) { /* rule might not work? */
- if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) {
- return 1;
- }
- }
- }
-
- return 0;
+ ARegion *ar = CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ int hand;
+
+ if (drag->type == WM_DRAG_PATH) {
+ if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) { /* rule might not work? */
+ if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) {
+ return 1;
+ }
+ }
+ }
+
+ return 0;
}
-static bool movie_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **UNUSED(tooltip))
+static bool movie_drop_poll(bContext *C,
+ wmDrag *drag,
+ const wmEvent *event,
+ const char **UNUSED(tooltip))
{
- ARegion *ar = CTX_wm_region(C);
- Scene *scene = CTX_data_scene(C);
- int hand;
-
- if (drag->type == WM_DRAG_PATH) {
- if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* rule might not work? */
- if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) {
- return 1;
- }
- }
- }
- return 0;
+ ARegion *ar = CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ int hand;
+
+ if (drag->type == WM_DRAG_PATH) {
+ if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* rule might not work? */
+ if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) {
+ return 1;
+ }
+ }
+ }
+ return 0;
}
-static bool sound_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, const char **UNUSED(tooltip))
+static bool sound_drop_poll(bContext *C,
+ wmDrag *drag,
+ const wmEvent *event,
+ const char **UNUSED(tooltip))
{
- ARegion *ar = CTX_wm_region(C);
- Scene *scene = CTX_data_scene(C);
- int hand;
-
- if (drag->type == WM_DRAG_PATH) {
- if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* rule might not work? */
- if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) {
- return 1;
- }
- }
- }
- return 0;
+ ARegion *ar = CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ int hand;
+
+ if (drag->type == WM_DRAG_PATH) {
+ if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* rule might not work? */
+ if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) {
+ return 1;
+ }
+ }
+ }
+ return 0;
}
static void sequencer_drop_copy(wmDrag *drag, wmDropBox *drop)
{
- /* copy drag path to properties */
- if (RNA_struct_find_property(drop->ptr, "filepath")) {
- RNA_string_set(drop->ptr, "filepath", drag->path);
- }
+ /* copy drag path to properties */
+ if (RNA_struct_find_property(drop->ptr, "filepath")) {
+ RNA_string_set(drop->ptr, "filepath", drag->path);
+ }
- if (RNA_struct_find_property(drop->ptr, "directory")) {
- PointerRNA itemptr;
- char dir[FILE_MAX], file[FILE_MAX];
+ if (RNA_struct_find_property(drop->ptr, "directory")) {
+ PointerRNA itemptr;
+ char dir[FILE_MAX], file[FILE_MAX];
- BLI_split_dirfile(drag->path, dir, file, sizeof(dir), sizeof(file));
+ BLI_split_dirfile(drag->path, dir, file, sizeof(dir), sizeof(file));
- RNA_string_set(drop->ptr, "directory", dir);
+ RNA_string_set(drop->ptr, "directory", dir);
- RNA_collection_clear(drop->ptr, "files");
- RNA_collection_add(drop->ptr, "files", &itemptr);
- RNA_string_set(&itemptr, "name", file);
- }
+ RNA_collection_clear(drop->ptr, "files");
+ RNA_collection_add(drop->ptr, "files", &itemptr);
+ RNA_string_set(&itemptr, "name", file);
+ }
}
/* this region dropbox definition */
static void sequencer_dropboxes(void)
{
- ListBase *lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW);
+ ListBase *lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW);
- WM_dropbox_add(lb, "SEQUENCER_OT_image_strip_add", image_drop_poll, sequencer_drop_copy);
- WM_dropbox_add(lb, "SEQUENCER_OT_movie_strip_add", movie_drop_poll, sequencer_drop_copy);
- WM_dropbox_add(lb, "SEQUENCER_OT_sound_strip_add", sound_drop_poll, sequencer_drop_copy);
+ WM_dropbox_add(lb, "SEQUENCER_OT_image_strip_add", image_drop_poll, sequencer_drop_copy);
+ WM_dropbox_add(lb, "SEQUENCER_OT_movie_strip_add", movie_drop_poll, sequencer_drop_copy);
+ WM_dropbox_add(lb, "SEQUENCER_OT_sound_strip_add", sound_drop_poll, sequencer_drop_copy);
}
/* ************* end drop *********** */
/* DO NOT make this static, this hides the symbol and breaks API generation script. */
-extern const char *sequencer_context_dir[]; /* quiet warning. */
+extern const char *sequencer_context_dir[]; /* quiet warning. */
const char *sequencer_context_dir[] = {"edit_mask", NULL};
static int sequencer_context(const bContext *C, const char *member, bContextDataResult *result)
{
- Scene *scene = CTX_data_scene(C);
-
- if (CTX_data_dir(member)) {
- CTX_data_dir_set(result, sequencer_context_dir);
-
- return true;
- }
- else if (CTX_data_equals(member, "edit_mask")) {
- Mask *mask = BKE_sequencer_mask_get(scene);
- if (mask) {
- CTX_data_id_pointer_set(result, &mask->id);
- }
- return true;
- }
-
- return false;
+ Scene *scene = CTX_data_scene(C);
+
+ if (CTX_data_dir(member)) {
+ CTX_data_dir_set(result, sequencer_context_dir);
+
+ return true;
+ }
+ else if (CTX_data_equals(member, "edit_mask")) {
+ Mask *mask = BKE_sequencer_mask_get(scene);
+ if (mask) {
+ CTX_data_id_pointer_set(result, &mask->id);
+ }
+ return true;
+ }
+
+ return false;
}
/* *********************** sequencer (main) region ************************ */
/* add handlers, stuff you only do once or on area/region changes */
static void sequencer_main_region_init(wmWindowManager *wm, ARegion *ar)
{
- wmKeyMap *keymap;
- ListBase *lb;
+ wmKeyMap *keymap;
+ ListBase *lb;
- UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
+ UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
#if 0
- keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0);
+ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
#endif
- keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
+ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
- /* own keymap */
- keymap = WM_keymap_ensure(wm->defaultconf, "Sequencer", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ /* own keymap */
+ keymap = WM_keymap_ensure(wm->defaultconf, "Sequencer", SPACE_SEQ, 0);
+ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
- /* add drop boxes */
- lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW);
+ /* add drop boxes */
+ lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW);
- WM_event_add_dropbox_handler(&ar->handlers, lb);
+ WM_event_add_dropbox_handler(&ar->handlers, lb);
}
static void sequencer_main_region_draw(const bContext *C, ARegion *ar)
{
- /* NLE - strip editing timeline interface */
- draw_timeline_seq(C, ar);
+ /* NLE - strip editing timeline interface */
+ draw_timeline_seq(C, ar);
}
-static void sequencer_main_region_listener(
- wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
- wmNotifier *wmn, const Scene *UNUSED(scene))
+static void sequencer_main_region_listener(wmWindow *UNUSED(win),
+ ScrArea *UNUSED(sa),
+ ARegion *ar,
+ wmNotifier *wmn,
+ const Scene *UNUSED(scene))
{
- /* context changes */
- switch (wmn->category) {
- case NC_SCENE:
- switch (wmn->data) {
- case ND_FRAME:
- case ND_FRAME_RANGE:
- case ND_MARKERS:
- case ND_RENDER_OPTIONS: /* for FPS and FPS Base */
- case ND_SEQUENCER:
- case ND_RENDER_RESULT:
- ED_region_tag_redraw(ar);
- break;
- }
- break;
- case NC_ANIMATION:
- switch (wmn->data) {
- case ND_KEYFRAME:
- ED_region_tag_redraw(ar);
- break;
- }
- break;
- case NC_SPACE:
- if (wmn->data == ND_SPACE_SEQUENCER) {
- ED_region_tag_redraw(ar);
- }
- break;
- case NC_ID:
- if (wmn->action == NA_RENAME) {
- ED_region_tag_redraw(ar);
- }
- break;
- case NC_SCREEN:
- if (ELEM(wmn->data, ND_ANIMPLAY)) {
- ED_region_tag_redraw(ar);
- }
- break;
- }
+ /* context changes */
+ switch (wmn->category) {
+ case NC_SCENE:
+ switch (wmn->data) {
+ case ND_FRAME:
+ case ND_FRAME_RANGE:
+ case ND_MARKERS:
+ case ND_RENDER_OPTIONS: /* for FPS and FPS Base */
+ case ND_SEQUENCER:
+ case ND_RENDER_RESULT:
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ break;
+ case NC_ANIMATION:
+ switch (wmn->data) {
+ case ND_KEYFRAME:
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ break;
+ case NC_SPACE:
+ if (wmn->data == ND_SPACE_SEQUENCER) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ case NC_ID:
+ if (wmn->action == NA_RENAME) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ case NC_SCREEN:
+ if (ELEM(wmn->data, ND_ANIMPLAY)) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ }
}
-static void sequencer_main_region_message_subscribe(
- const struct bContext *UNUSED(C),
- struct WorkSpace *UNUSED(workspace), struct Scene *scene,
- struct bScreen *UNUSED(screen), struct ScrArea *UNUSED(sa), struct ARegion *ar,
- struct wmMsgBus *mbus)
+static void sequencer_main_region_message_subscribe(const struct bContext *UNUSED(C),
+ struct WorkSpace *UNUSED(workspace),
+ struct Scene *scene,
+ struct bScreen *UNUSED(screen),
+ struct ScrArea *UNUSED(sa),
+ struct ARegion *ar,
+ struct wmMsgBus *mbus)
{
- wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
- .owner = ar,
- .user_data = ar,
- .notify = ED_region_do_msg_notify_tag_redraw,
- };
-
- /* Timeline depends on scene properties. */
- {
- bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
- extern PropertyRNA rna_Scene_frame_start;
- extern PropertyRNA rna_Scene_frame_end;
- extern PropertyRNA rna_Scene_frame_preview_start;
- extern PropertyRNA rna_Scene_frame_preview_end;
- extern PropertyRNA rna_Scene_use_preview_range;
- extern PropertyRNA rna_Scene_frame_current;
- const PropertyRNA *props[] = {
- use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
- use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,
- &rna_Scene_use_preview_range,
- &rna_Scene_frame_current,
- };
-
- PointerRNA idptr;
- RNA_id_pointer_create(&scene->id, &idptr);
-
- for (int i = 0; i < ARRAY_SIZE(props); i++) {
- WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
- }
- }
-
- {
- StructRNA *type_array[] = {
- &RNA_SequenceEditor,
-
- &RNA_Sequence,
- /* Members of 'Sequence'. */
- &RNA_SequenceCrop,
- &RNA_SequenceTransform,
- &RNA_SequenceModifier,
- &RNA_SequenceColorBalanceData,
- };
- wmMsgParams_RNA msg_key_params = {{{0}}};
- for (int i = 0; i < ARRAY_SIZE(type_array); i++) {
- msg_key_params.ptr.type = type_array[i];
- WM_msg_subscribe_rna_params(mbus, &msg_key_params, &msg_sub_value_region_tag_redraw, __func__);
- }
- }
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ };
+
+ /* Timeline depends on scene properties. */
+ {
+ bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
+ extern PropertyRNA rna_Scene_frame_start;
+ extern PropertyRNA rna_Scene_frame_end;
+ extern PropertyRNA rna_Scene_frame_preview_start;
+ extern PropertyRNA rna_Scene_frame_preview_end;
+ extern PropertyRNA rna_Scene_use_preview_range;
+ extern PropertyRNA rna_Scene_frame_current;
+ const PropertyRNA *props[] = {
+ use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
+ use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,
+ &rna_Scene_use_preview_range,
+ &rna_Scene_frame_current,
+ };
+
+ PointerRNA idptr;
+ RNA_id_pointer_create(&scene->id, &idptr);
+
+ for (int i = 0; i < ARRAY_SIZE(props); i++) {
+ WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
+ }
+ }
+
+ {
+ StructRNA *type_array[] = {
+ &RNA_SequenceEditor,
+
+ &RNA_Sequence,
+ /* Members of 'Sequence'. */
+ &RNA_SequenceCrop,
+ &RNA_SequenceTransform,
+ &RNA_SequenceModifier,
+ &RNA_SequenceColorBalanceData,
+ };
+ wmMsgParams_RNA msg_key_params = {{{0}}};
+ for (int i = 0; i < ARRAY_SIZE(type_array); i++) {
+ msg_key_params.ptr.type = type_array[i];
+ WM_msg_subscribe_rna_params(
+ mbus, &msg_key_params, &msg_sub_value_region_tag_redraw, __func__);
+ }
+ }
}
/* *********************** header region ************************ */
/* add handlers, stuff you only do once or on area/region changes */
static void sequencer_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
{
- ED_region_header_init(ar);
+ ED_region_header_init(ar);
}
static void sequencer_header_region_draw(const bContext *C, ARegion *ar)
{
- ED_region_header(C, ar);
+ ED_region_header(C, ar);
}
/* *********************** preview region ************************ */
static void sequencer_preview_region_init(wmWindowManager *wm, ARegion *ar)
{
- wmKeyMap *keymap;
+ wmKeyMap *keymap;
- UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
+ UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
#if 0
- keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", 0, 0);
+ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
#endif
- keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
+ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
- /* own keymap */
- keymap = WM_keymap_ensure(wm->defaultconf, "SequencerPreview", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ /* own keymap */
+ keymap = WM_keymap_ensure(wm->defaultconf, "SequencerPreview", SPACE_SEQ, 0);
+ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
static void sequencer_preview_region_draw(const bContext *C, ARegion *ar)
{
- ScrArea *sa = CTX_wm_area(C);
- SpaceSeq *sseq = sa->spacedata.first;
- Scene *scene = CTX_data_scene(C);
- wmWindowManager *wm = CTX_wm_manager(C);
- const bool show_split = (
- scene->ed &&
- (scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) &&
- (sseq->mainb == SEQ_DRAW_IMG_IMBUF));
-
- /* XXX temp fix for wrong setting in sseq->mainb */
- if (sseq->mainb == SEQ_DRAW_SEQUENCE) {
- sseq->mainb = SEQ_DRAW_IMG_IMBUF;
- }
-
- if (!show_split || sseq->overlay_type != SEQ_DRAW_OVERLAY_REFERENCE) {
- sequencer_draw_preview(C, scene, ar, sseq, scene->r.cfra, 0, false, false);
- }
-
- if (show_split && sseq->overlay_type != SEQ_DRAW_OVERLAY_CURRENT) {
- int over_cfra;
-
- if (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) {
- over_cfra = scene->ed->over_cfra;
- }
- else {
- over_cfra = scene->r.cfra + scene->ed->over_ofs;
- }
-
- if (over_cfra != scene->r.cfra || sseq->overlay_type != SEQ_DRAW_OVERLAY_RECT) {
- sequencer_draw_preview(C, scene, ar, sseq, scene->r.cfra, over_cfra - scene->r.cfra, true, false);
- }
- }
-
- if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_no_scrub(wm)) {
- rcti rect;
- ED_region_visible_rect(ar, &rect);
- int xoffset = rect.xmin + U.widget_unit;
- int yoffset = rect.ymax;
- ED_scene_draw_fps(scene, xoffset, &yoffset);
- }
+ ScrArea *sa = CTX_wm_area(C);
+ SpaceSeq *sseq = sa->spacedata.first;
+ Scene *scene = CTX_data_scene(C);
+ wmWindowManager *wm = CTX_wm_manager(C);
+ const bool show_split = (scene->ed && (scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) &&
+ (sseq->mainb == SEQ_DRAW_IMG_IMBUF));
+
+ /* XXX temp fix for wrong setting in sseq->mainb */
+ if (sseq->mainb == SEQ_DRAW_SEQUENCE) {
+ sseq->mainb = SEQ_DRAW_IMG_IMBUF;
+ }
+
+ if (!show_split || sseq->overlay_type != SEQ_DRAW_OVERLAY_REFERENCE) {
+ sequencer_draw_preview(C, scene, ar, sseq, scene->r.cfra, 0, false, false);
+ }
+
+ if (show_split && sseq->overlay_type != SEQ_DRAW_OVERLAY_CURRENT) {
+ int over_cfra;
+
+ if (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) {
+ over_cfra = scene->ed->over_cfra;
+ }
+ else {
+ over_cfra = scene->r.cfra + scene->ed->over_ofs;
+ }
+
+ if (over_cfra != scene->r.cfra || sseq->overlay_type != SEQ_DRAW_OVERLAY_RECT) {
+ sequencer_draw_preview(
+ C, scene, ar, sseq, scene->r.cfra, over_cfra - scene->r.cfra, true, false);
+ }
+ }
+
+ if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_no_scrub(wm)) {
+ rcti rect;
+ ED_region_visible_rect(ar, &rect);
+ int xoffset = rect.xmin + U.widget_unit;
+ int yoffset = rect.ymax;
+ ED_scene_draw_fps(scene, xoffset, &yoffset);
+ }
}
-static void sequencer_preview_region_listener(
- wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
- wmNotifier *wmn, const Scene *UNUSED(scene))
+static void sequencer_preview_region_listener(wmWindow *UNUSED(win),
+ ScrArea *UNUSED(sa),
+ ARegion *ar,
+ wmNotifier *wmn,
+ const Scene *UNUSED(scene))
{
- /* context changes */
- switch (wmn->category) {
- case NC_GPENCIL:
- if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
- ED_region_tag_redraw(ar);
- }
- break;
- case NC_SCENE:
- switch (wmn->data) {
- case ND_FRAME:
- case ND_MARKERS:
- case ND_SEQUENCER:
- case ND_RENDER_OPTIONS:
- case ND_DRAW_RENDER_VIEWPORT:
- ED_region_tag_redraw(ar);
- break;
- }
- break;
- case NC_ANIMATION:
- switch (wmn->data) {
- case ND_KEYFRAME:
- /* Otherwise, often prevents seeing immediately effects of keyframe editing... */
- BKE_sequencer_cache_cleanup();
- ED_region_tag_redraw(ar);
- break;
- }
- break;
- case NC_SPACE:
- if (wmn->data == ND_SPACE_SEQUENCER) {
- ED_region_tag_redraw(ar);
- }
- break;
- case NC_ID:
- switch (wmn->data) {
- case NA_RENAME:
- ED_region_tag_redraw(ar);
- break;
- }
- break;
- case NC_MASK:
- if (wmn->action == NA_EDITED) {
- ED_region_tag_redraw(ar);
- }
- break;
- }
+ /* context changes */
+ switch (wmn->category) {
+ case NC_GPENCIL:
+ if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ case NC_SCENE:
+ switch (wmn->data) {
+ case ND_FRAME:
+ case ND_MARKERS:
+ case ND_SEQUENCER:
+ case ND_RENDER_OPTIONS:
+ case ND_DRAW_RENDER_VIEWPORT:
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ break;
+ case NC_ANIMATION:
+ switch (wmn->data) {
+ case ND_KEYFRAME:
+ /* Otherwise, often prevents seeing immediately effects of keyframe editing... */
+ BKE_sequencer_cache_cleanup();
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ break;
+ case NC_SPACE:
+ if (wmn->data == ND_SPACE_SEQUENCER) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ case NC_ID:
+ switch (wmn->data) {
+ case NA_RENAME:
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ break;
+ case NC_MASK:
+ if (wmn->action == NA_EDITED) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ }
}
/* *********************** buttons region ************************ */
@@ -741,64 +754,66 @@ static void sequencer_preview_region_listener(
/* add handlers, stuff you only do once or on area/region changes */
static void sequencer_buttons_region_init(wmWindowManager *wm, ARegion *ar)
{
- wmKeyMap *keymap;
+ wmKeyMap *keymap;
- keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ keymap = WM_keymap_ensure(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
+ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
- ED_region_panels_init(wm, ar);
+ ED_region_panels_init(wm, ar);
}
static void sequencer_buttons_region_draw(const bContext *C, ARegion *ar)
{
- ED_region_panels(C, ar);
+ ED_region_panels(C, ar);
}
-static void sequencer_buttons_region_listener(
- wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar,
- wmNotifier *wmn, const Scene *UNUSED(scene))
+static void sequencer_buttons_region_listener(wmWindow *UNUSED(win),
+ ScrArea *UNUSED(sa),
+ ARegion *ar,
+ wmNotifier *wmn,
+ const Scene *UNUSED(scene))
{
- /* context changes */
- switch (wmn->category) {
- case NC_GPENCIL:
- if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
- ED_region_tag_redraw(ar);
- }
- break;
- case NC_SCENE:
- switch (wmn->data) {
- case ND_FRAME:
- case ND_SEQUENCER:
- ED_region_tag_redraw(ar);
- break;
- }
- break;
- case NC_SPACE:
- if (wmn->data == ND_SPACE_SEQUENCER) {
- ED_region_tag_redraw(ar);
- }
- break;
- case NC_ID:
- if (wmn->action == NA_RENAME) {
- ED_region_tag_redraw(ar);
- }
- break;
- }
+ /* context changes */
+ switch (wmn->category) {
+ case NC_GPENCIL:
+ if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ case NC_SCENE:
+ switch (wmn->data) {
+ case ND_FRAME:
+ case ND_SEQUENCER:
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ break;
+ case NC_SPACE:
+ if (wmn->data == ND_SPACE_SEQUENCER) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ case NC_ID:
+ if (wmn->action == NA_RENAME) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ }
}
static void sequencer_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
{
- SpaceSeq *sseq = (SpaceSeq *)slink;
+ SpaceSeq *sseq = (SpaceSeq *)slink;
- if (!ELEM(GS(old_id->name), ID_GD)) {
- return;
- }
+ if (!ELEM(GS(old_id->name), ID_GD)) {
+ return;
+ }
- if ((ID *)sseq->gpd == old_id) {
- sseq->gpd = (bGPdata *)new_id;
- id_us_min(old_id);
- id_us_plus(new_id);
- }
+ if ((ID *)sseq->gpd == old_id) {
+ sseq->gpd = (bGPdata *)new_id;
+ id_us_min(old_id);
+ id_us_plus(new_id);
+ }
}
/* ************************************* */
@@ -806,72 +821,72 @@ static void sequencer_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id
/* only called once, from space/spacetypes.c */
void ED_spacetype_sequencer(void)
{
- SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype sequencer");
- ARegionType *art;
-
- st->spaceid = SPACE_SEQ;
- strncpy(st->name, "Sequencer", BKE_ST_MAXNAME);
-
- st->new = sequencer_new;
- st->free = sequencer_free;
- st->init = sequencer_init;
- st->duplicate = sequencer_duplicate;
- st->operatortypes = sequencer_operatortypes;
- st->keymap = sequencer_keymap;
- st->context = sequencer_context;
- st->dropboxes = sequencer_dropboxes;
- st->refresh = sequencer_refresh;
- st->listener = sequencer_listener;
- st->id_remap = sequencer_id_remap;
-
- /* regions: main window */
- art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
- art->regionid = RGN_TYPE_WINDOW;
- art->init = sequencer_main_region_init;
- art->draw = sequencer_main_region_draw;
- art->listener = sequencer_main_region_listener;
- art->message_subscribe = sequencer_main_region_message_subscribe;
- art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_FRAMES | ED_KEYMAP_ANIMATION;
-
- BLI_addhead(&st->regiontypes, art);
-
- /* preview */
- art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
- art->regionid = RGN_TYPE_PREVIEW;
- art->init = sequencer_preview_region_init;
- art->draw = sequencer_preview_region_draw;
- art->listener = sequencer_preview_region_listener;
- art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL;
- BLI_addhead(&st->regiontypes, art);
-
- /* regions: listview/buttons */
- art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
- art->regionid = RGN_TYPE_UI;
- art->prefsizex = 220; // XXX
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
- art->listener = sequencer_buttons_region_listener;
- art->init = sequencer_buttons_region_init;
- art->draw = sequencer_buttons_region_draw;
- BLI_addhead(&st->regiontypes, art);
-
- sequencer_buttons_register(art);
-
- /* regions: header */
- art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
- art->regionid = RGN_TYPE_HEADER;
- art->prefsizey = HEADERY;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
-
- art->init = sequencer_header_region_init;
- art->draw = sequencer_header_region_draw;
- art->listener = sequencer_main_region_listener;
-
- BLI_addhead(&st->regiontypes, art);
-
- BKE_spacetype_register(st);
-
- /* set the sequencer callback when not in background mode */
- if (G.background == 0) {
- sequencer_view3d_cb = ED_view3d_draw_offscreen_imbuf_simple;
- }
+ SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype sequencer");
+ ARegionType *art;
+
+ st->spaceid = SPACE_SEQ;
+ strncpy(st->name, "Sequencer", BKE_ST_MAXNAME);
+
+ st->new = sequencer_new;
+ st->free = sequencer_free;
+ st->init = sequencer_init;
+ st->duplicate = sequencer_duplicate;
+ st->operatortypes = sequencer_operatortypes;
+ st->keymap = sequencer_keymap;
+ st->context = sequencer_context;
+ st->dropboxes = sequencer_dropboxes;
+ st->refresh = sequencer_refresh;
+ st->listener = sequencer_listener;
+ st->id_remap = sequencer_id_remap;
+
+ /* regions: main window */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
+ art->regionid = RGN_TYPE_WINDOW;
+ art->init = sequencer_main_region_init;
+ art->draw = sequencer_main_region_draw;
+ art->listener = sequencer_main_region_listener;
+ art->message_subscribe = sequencer_main_region_message_subscribe;
+ art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_FRAMES | ED_KEYMAP_ANIMATION;
+
+ BLI_addhead(&st->regiontypes, art);
+
+ /* preview */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
+ art->regionid = RGN_TYPE_PREVIEW;
+ art->init = sequencer_preview_region_init;
+ art->draw = sequencer_preview_region_draw;
+ art->listener = sequencer_preview_region_listener;
+ art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL;
+ BLI_addhead(&st->regiontypes, art);
+
+ /* regions: listview/buttons */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
+ art->regionid = RGN_TYPE_UI;
+ art->prefsizex = 220; // XXX
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
+ art->listener = sequencer_buttons_region_listener;
+ art->init = sequencer_buttons_region_init;
+ art->draw = sequencer_buttons_region_draw;
+ BLI_addhead(&st->regiontypes, art);
+
+ sequencer_buttons_register(art);
+
+ /* regions: header */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
+ art->regionid = RGN_TYPE_HEADER;
+ art->prefsizey = HEADERY;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
+
+ art->init = sequencer_header_region_init;
+ art->draw = sequencer_header_region_draw;
+ art->listener = sequencer_main_region_listener;
+
+ BLI_addhead(&st->regiontypes, art);
+
+ BKE_spacetype_register(st);
+
+ /* set the sequencer callback when not in background mode */
+ if (G.background == 0) {
+ sequencer_view3d_cb = ED_view3d_draw_offscreen_imbuf_simple;
+ }
}