diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-10-14 00:46:02 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-10-14 00:46:02 +0400 |
commit | ee63ef7af17cb793d9c6947e6f47de7c36df58af (patch) | |
tree | e493aacd90fbfa4c91896438b6c1b97bae0299ca | |
parent | 98d66aeb973f91b8dd13ab082b16f3d45e47636b (diff) |
Project Pampa request: option to lock frame selection to the range
This means when you've got "Lock Frame Selection" option (which is
in the timeline next to the preview range button) you're not able
to go to the frames which are out of current frame range with your
mouse.
TODO: Make it so current frame slider also respects this setting?
Not so much important for tonight.
-rw-r--r-- | release/scripts/startup/bl_ui/space_time.py | 4 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_ops.c | 10 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 8 |
4 files changed, 21 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py index de8be9dff99..fb78194d1a4 100644 --- a/release/scripts/startup/bl_ui/space_time.py +++ b/release/scripts/startup/bl_ui/space_time.py @@ -40,7 +40,9 @@ class TIME_HT_header(Header): row.menu("TIME_MT_frame") row.menu("TIME_MT_playback") - layout.prop(scene, "use_preview_range", text="", toggle=True) + row = layout.row(align=True) + row.prop(scene, "use_preview_range", text="", toggle=True) + row.prop(scene, "lock_frame_selection_to_range", text="", toggle=True) row = layout.row(align=True) if not scene.use_preview_range: diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 15a75c57758..af9b58736ef 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -118,13 +118,21 @@ static int change_frame_exec(bContext *C, wmOperator *op) static int frame_from_event(bContext *C, const wmEvent *event) { ARegion *region = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); float viewx; + int frame; /* convert from region coordinates to View2D 'tot' space */ UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], &viewx, NULL); /* round result to nearest int (frames are ints!) */ - return (int)floor(viewx + 0.5f); + frame = (int)floor(viewx + 0.5f); + + if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) { + CLAMP(frame, PSFRA, PEFRA); + } + + return frame; } /* Modal Operator init */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 232fe62df31..6ebc604bc7e 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1212,6 +1212,7 @@ typedef struct Scene { /* flag */ /* use preview range */ #define SCER_PRV_RANGE (1<<0) +#define SCER_LOCK_FRAME_SELECTION (1<<1) /* mode (int now) */ #define R_OSA 0x0001 diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 4d35acc84a0..b37c1326205 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -5220,6 +5220,14 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Current Frame Final", "Current frame with subframe and time remapping applied"); + prop = RNA_def_property(srna, "lock_frame_selection_to_range", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_boolean_sdna(prop, NULL, "r.flag", SCER_LOCK_FRAME_SELECTION); + RNA_def_property_ui_text(prop, "Lock Frame Selection", + "Don't allow frame to be selected with mouse outside of frame range"); + RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL); + RNA_def_property_ui_icon(prop, ICON_LOCKED, 0); + /* Preview Range (frame-range for UI playback) */ prop = RNA_def_property(srna, "use_preview_range", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); |