[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60733] trunk/blender: Project Pampa request: option to lock frame selection to the range

Sergey Sharybin sergey.vfx at gmail.com
Sun Oct 13 22:46:03 CEST 2013


Revision: 60733
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60733
Author:   nazgul
Date:     2013-10-13 20:46:02 +0000 (Sun, 13 Oct 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_time.py
    trunk/blender/source/blender/editors/animation/anim_ops.c
    trunk/blender/source/blender/makesdna/DNA_scene_types.h
    trunk/blender/source/blender/makesrna/intern/rna_scene.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_time.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_time.py	2013-10-13 18:51:21 UTC (rev 60732)
+++ trunk/blender/release/scripts/startup/bl_ui/space_time.py	2013-10-13 20:46:02 UTC (rev 60733)
@@ -40,7 +40,9 @@
             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:

Modified: trunk/blender/source/blender/editors/animation/anim_ops.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_ops.c	2013-10-13 18:51:21 UTC (rev 60732)
+++ trunk/blender/source/blender/editors/animation/anim_ops.c	2013-10-13 20:46:02 UTC (rev 60733)
@@ -118,13 +118,21 @@
 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(&region->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 */

Modified: trunk/blender/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_scene_types.h	2013-10-13 18:51:21 UTC (rev 60732)
+++ trunk/blender/source/blender/makesdna/DNA_scene_types.h	2013-10-13 20:46:02 UTC (rev 60733)
@@ -1212,6 +1212,7 @@
 /* flag */
 	/* use preview range */
 #define SCER_PRV_RANGE	(1<<0)
+#define SCER_LOCK_FRAME_SELECTION	(1<<1)
 
 /* mode (int now) */
 #define R_OSA			0x0001

Modified: trunk/blender/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_scene.c	2013-10-13 18:51:21 UTC (rev 60732)
+++ trunk/blender/source/blender/makesrna/intern/rna_scene.c	2013-10-13 20:46:02 UTC (rev 60733)
@@ -5220,6 +5220,14 @@
 	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);




More information about the Bf-blender-cvs mailing list