diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2015-09-24 18:24:20 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2015-09-24 18:24:20 +0300 |
commit | 27b3ea622f8bd313a8e2827dfec752bf2125566c (patch) | |
tree | f212e49d224ce8e1cfc3b17a64ae524711494391 /source/blender/editors/animation/anim_ops.c | |
parent | 372dff8d1dc7e24d4b2cd37de245588ecfce8bfa (diff) | |
parent | de80e687689032cb85179a1f7e89750573631d5d (diff) |
Merge remote-tracking branch 'origin/master' into cycles_camera_nodescycles_camera_nodes
Note: the branch currently crashes in blender_camera_nodes.cpp:
BL::NodeTree b_ntree = b_data.node_groups[nodes_tree_name];
The crash was introduced in:
cb7cf523e5c000609f32a382e2c0fcc57f635a42
Conflicts:
intern/cycles/SConscript
intern/cycles/blender/addon/__init__.py
intern/cycles/blender/addon/properties.py
intern/cycles/blender/blender_camera.cpp
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/svm/svm.h
intern/cycles/kernel/svm/svm_types.h
intern/cycles/render/camera.cpp
intern/cycles/render/camera.h
Diffstat (limited to 'source/blender/editors/animation/anim_ops.c')
-rw-r--r-- | source/blender/editors/animation/anim_ops.c | 89 |
1 files changed, 80 insertions, 9 deletions
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 0f202003dd8..262ce0b9e23 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -41,6 +41,7 @@ #include "DNA_scene_types.h" #include "BKE_context.h" +#include "BKE_sequencer.h" #include "BKE_global.h" #include "BKE_main.h" #include "BKE_sound.h" @@ -55,6 +56,7 @@ #include "ED_anim_api.h" #include "ED_screen.h" +#include "ED_sequencer.h" #include "anim_intern.h" @@ -92,14 +94,20 @@ static void change_frame_apply(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - + int frame = RNA_int_get(op->ptr, "frame"); + bool do_snap = RNA_boolean_get(op->ptr, "snap"); + + if (do_snap && CTX_wm_space_seq(C)) { + frame = BKE_sequencer_find_next_prev_edit(scene, frame, SEQ_SIDE_BOTH, true, false, false); + } + /* set the new frame number */ - CFRA = RNA_int_get(op->ptr, "frame"); + CFRA = frame; FRAMENUMBER_MIN_CLAMP(CFRA); SUBFRA = 0.0f; /* do updates */ - sound_seek_scene(bmain, scene); + BKE_sound_seek_scene(bmain, scene); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } @@ -136,6 +144,41 @@ static int frame_from_event(bContext *C, const wmEvent *event) return frame; } +static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event) +{ + ScrArea *sa = CTX_wm_area(C); + bScreen *screen = CTX_wm_screen(C); + if (sa && sa->spacetype == SPACE_SEQ) { + SpaceSeq *sseq = sa->spacedata.first; + if (ED_space_sequencer_check_show_strip(sseq)) { + ED_sequencer_special_preview_set(C, event->mval); + } + } + if (screen) + screen->scrubbing = true; +} + +static void change_frame_seq_preview_end(bContext *C) +{ + bScreen *screen = CTX_wm_screen(C); + bool notify = false; + + if (screen->scrubbing) { + screen->scrubbing = false; + notify = true; + } + + if (ED_sequencer_special_preview_get() != NULL) { + ED_sequencer_special_preview_clear(); + notify = true; + } + + if (notify) { + Scene *scene = CTX_data_scene(C); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); + } +} + /* Modal Operator init */ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event) { @@ -144,7 +187,9 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event * click-dragging over a range (modal scrubbing). */ RNA_int_set(op->ptr, "frame", frame_from_event(C, event)); - + + change_frame_seq_preview_begin(C, event); + change_frame_apply(C, op); /* add temp handler */ @@ -153,14 +198,21 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event return OPERATOR_RUNNING_MODAL; } +static void change_frame_cancel(bContext *C, wmOperator *UNUSED(op)) +{ + change_frame_seq_preview_end(C); +} + /* Modal event handling of frame changing */ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event) { + int ret = OPERATOR_RUNNING_MODAL; /* execute the events */ switch (event->type) { case ESCKEY: - return OPERATOR_FINISHED; - + ret = OPERATOR_FINISHED; + break; + case MOUSEMOVE: RNA_int_set(op->ptr, "frame", frame_from_event(C, event)); change_frame_apply(C, op); @@ -173,15 +225,31 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event) * the modal op) doesn't work for some reason */ if (event->val == KM_RELEASE) - return OPERATOR_FINISHED; + ret = OPERATOR_FINISHED; + break; + + case LEFTCTRLKEY: + case RIGHTCTRLKEY: + if (event->val == KM_RELEASE) { + RNA_boolean_set(op->ptr, "snap", false); + } + else if (event->val == KM_PRESS) { + RNA_boolean_set(op->ptr, "snap", true); + } break; } - return OPERATOR_RUNNING_MODAL; + if (ret != OPERATOR_RUNNING_MODAL) { + change_frame_seq_preview_end(C); + } + + return ret; } static void ANIM_OT_change_frame(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Change Frame"; ot->idname = "ANIM_OT_change_frame"; @@ -190,14 +258,17 @@ static void ANIM_OT_change_frame(wmOperatorType *ot) /* api callbacks */ ot->exec = change_frame_exec; ot->invoke = change_frame_invoke; + ot->cancel = change_frame_cancel; ot->modal = change_frame_modal; ot->poll = change_frame_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO | OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO | OPTYPE_GRAB_CURSOR; /* rna */ ot->prop = RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME); + prop = RNA_def_boolean(ot->srna, "snap", false, "Snap", ""); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /* ****************** set preview range operator ****************************/ |