diff options
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_edit.c')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_edit.c | 242 |
1 files changed, 199 insertions, 43 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 81af6dccc70..8d4a82fc02c 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -37,6 +37,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BLI_ghash.h" #include "BLF_translation.h" @@ -58,12 +59,14 @@ /* for menu/popup icons etc etc*/ +#include "ED_numinput.h" #include "ED_screen.h" #include "ED_transform.h" #include "ED_sequencer.h" #include "ED_space_api.h" #include "UI_view2d.h" +#include "UI_interface.h" /* own include */ @@ -146,11 +149,12 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog struct SeqIndexBuildContext *context = link->data; BKE_sequencer_proxy_rebuild(context, stop, do_update, progress); - } - - if (*stop) { - pj->stop = 1; - fprintf(stderr, "Canceling proxy rebuild on users request...\n"); + + if (*stop) { + pj->stop = 1; + fprintf(stderr, "Canceling proxy rebuild on users request...\n"); + break; + } } } @@ -179,7 +183,8 @@ static void seq_proxy_build_job(const bContext *C) struct SeqIndexBuildContext *context; LinkData *link; Sequence *seq; - + GSet *file_list; + if (ed == NULL) { return; } @@ -200,16 +205,19 @@ static void seq_proxy_build_job(const bContext *C) 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)) { - context = BKE_sequencer_proxy_rebuild_context(pj->main, pj->scene, seq); + context = BKE_sequencer_proxy_rebuild_context(pj->main, pj->scene, seq, file_list); link = BLI_genericNodeN(context); BLI_addtail(&pj->queue, link); } } SEQ_END + 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); @@ -987,13 +995,13 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene *scene) // XXX if (0 == sbutton(to, 0, sizeof(to)-1, "To: ")) // return; - if (strcmp(to, from) == 0) + if (STREQ(to, from)) return; SEQP_BEGIN (ed, seq) { if (seq->flag & SELECT) { - if (strncmp(seq->strip->dir, from, strlen(from)) == 0) { + if (STREQLEN(seq->strip->dir, from, strlen(from))) { printf("found %s\n", seq->strip->dir); /* strip off the beginning */ @@ -1262,6 +1270,7 @@ typedef struct SlipData { bool slow; int slow_offset; /* offset at the point where offset was turned on */ void *draw_handle; + NumInput num_input; } SlipData; static void transseq_backup(TransSeq *ts, Sequence *seq) @@ -1375,6 +1384,13 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve 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; + + slip_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true); for (i = 0; i < num_seq; i++) { @@ -1500,47 +1516,83 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op) } } + +static void sequencer_slip_update_header(Scene *scene, ScrArea *sa, SlipData *data, int offset) +{ +#define HEADER_LENGTH 40 + char msg[HEADER_LENGTH]; + + 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, HEADER_LENGTH, "Trim offset: %s", num_str); + } + else { + BLI_snprintf(msg, HEADER_LENGTH, "Trim offset: %d", offset); + } + } + + ED_area_headerprint(sa, msg); + +#undef HEADER_LENGTH +} + 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); ARegion *ar = CTX_wm_region(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: { - 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]; - } + 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]; + /* 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]; - RNA_int_set(op->ptr, "offset", offset); + sequencer_slip_update_header(scene, sa, data, offset); - if (sa) { -#define HEADER_LENGTH 40 - char msg[HEADER_LENGTH]; - BLI_snprintf(msg, HEADER_LENGTH, "Trim offset: %d", offset); -#undef HEADER_LENGTH - ED_area_headerprint(sa, msg); - } + RNA_int_set(op->ptr, "offset", offset); - if (sequencer_slip_recursively(scene, data, offset)) { - WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); + if (sequencer_slip_recursively(scene, data, offset)) { + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); + } } break; } @@ -1597,19 +1649,36 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even case RIGHTSHIFTKEY: case LEFTSHIFTKEY: - if (event->val == KM_PRESS) { - data->slow = true; - data->slow_offset = event->mval[0]; - } - else if (event->val == KM_RELEASE) { - data->slow = false; + 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; } @@ -3360,18 +3429,21 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) 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; } + file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list"); + SEQP_BEGIN(ed, seq) { if ((seq->flag & SELECT)) { struct SeqIndexBuildContext *context; short stop = 0, do_update; float progress; - context = BKE_sequencer_proxy_rebuild_context(bmain, scene, seq); + context = BKE_sequencer_proxy_rebuild_context(bmain, scene, seq, file_list); BKE_sequencer_proxy_rebuild(context, &stop, &do_update, &progress); BKE_sequencer_proxy_rebuild_finish(context, 0); BKE_sequencer_free_imbuf(scene, &ed->seqbase, false); @@ -3379,6 +3451,8 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) } SEQ_END + BLI_gset_free(file_list, MEM_freeN); + return OPERATOR_FINISHED; } @@ -3397,6 +3471,88 @@ void SEQUENCER_OT_rebuild_proxy(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER; } +static int sequencer_enable_proxies_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 5 * UI_UNIT_Y); +} + +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 override = RNA_boolean_get(op->ptr, "override"); + 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 (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 (!override) + 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 strips"; + + /* api callbacks */ + ot->invoke = sequencer_enable_proxies_invoke; + ot->exec = sequencer_enable_proxies_exec; + + /* 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, "override", false, "Override", ""); +} + /* change ops */ static EnumPropertyItem prop_change_effect_input_types[] = { |