diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-11-14 17:35:30 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-11-14 17:35:30 +0300 |
commit | e34691194367279163d53a099fc4a52d564b2714 (patch) | |
tree | 71f6ac5551912201b0ebd6ab7b5f34098a4216e5 | |
parent | f5c2b1c2f6aece95c0c8d6348840197fa0809955 (diff) |
Gooseberry request, snap frame marker during frame setting by holdingterrible_consequencer
ctrl key
-rw-r--r-- | source/blender/editors/animation/anim_ops.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 0f202003dd8..2ba2483913d 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" @@ -92,9 +93,15 @@ 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_seq_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; @@ -144,7 +151,7 @@ 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_apply(C, op); /* add temp handler */ @@ -175,6 +182,16 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event->val == KM_RELEASE) return 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; @@ -182,6 +199,8 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event) static void ANIM_OT_change_frame(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Change Frame"; ot->idname = "ANIM_OT_change_frame"; @@ -198,6 +217,8 @@ static void ANIM_OT_change_frame(wmOperatorType *ot) /* 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 ****************************/ |