Commit: a791153ca5e6f87d50396e188a3664b579884161
Author: Joshua Leung
Date:   Mon Dec 14 03:06:06 2015 +1300
Branches: master
https://developer.blender.org/rBa791153ca5e6f87d50396e188a3664b579884161

3D Cursor: Add option to lock it in place to prevent accidental modification

This option helps users protect themselves from accidentally changing the cursor
location (and not being aware of this until it has already caused problems)
when drawing using Grease Pencil (or with other tools where this is equally 
likely).
It seems to occur most frequently when using a tablet.

Currently, this only affects the use of the mouse to set the cursor, as this is
where most accidental invocations occur.

(I'm aware that this change may turn out to be quite contentious. Fortunately, 
it
should be simple to just revert this commit in that case :)

===================================================================

M       release/scripts/startup/bl_ui/space_view3d.py
M       source/blender/editors/space_view3d/view3d_edit.c
M       source/blender/makesdna/DNA_view3d_types.h
M       source/blender/makesrna/intern/rna_space.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 4dc4b66..da4fb04 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -3005,7 +3005,12 @@ class VIEW3D_PT_view3d_cursor(Panel):
         layout = self.layout
 
         view = context.space_data
-        layout.column().prop(view, "cursor_location", text="Location")
+
+        layout.prop(view, "lock_cursor_location")
+
+        col = layout.column()
+        col.active = not view.lock_cursor_location
+        col.prop(view, "cursor_location", text="Location")
 
 
 class VIEW3D_PT_view3d_name(Panel):
diff --git a/source/blender/editors/space_view3d/view3d_edit.c 
b/source/blender/editors/space_view3d/view3d_edit.c
index b09cbed..1d988e9 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -4679,9 +4679,21 @@ static int view3d_cursor3d_invoke(bContext *C, 
wmOperator *UNUSED(op), const wmE
        return OPERATOR_FINISHED;
 }
 
-void VIEW3D_OT_cursor3d(wmOperatorType *ot)
+static int view3d_cursor3d_poll(bContext *C)
 {
+       if (ED_operator_region_view3d_active(C)) {
+               View3D *v3d = CTX_wm_view3d(C);
+               
+               /* only if not locked */
+               if ((v3d->flag & V3D_LOCK_CURSOR) == 0)
+                       return true;
+       }
+       
+       return false;
+}
 
+void VIEW3D_OT_cursor3d(wmOperatorType *ot)
+{
        /* identifiers */
        ot->name = "Set 3D Cursor";
        ot->description = "Set the location of the 3D cursor";
@@ -4689,8 +4701,7 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot)
 
        /* api callbacks */
        ot->invoke = view3d_cursor3d_invoke;
-
-       ot->poll = ED_operator_region_view3d_active;
+       ot->poll = view3d_cursor3d_poll;
 
        /* flags */
 //     ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
diff --git a/source/blender/makesdna/DNA_view3d_types.h 
b/source/blender/makesdna/DNA_view3d_types.h
index 0ef8f26..176edd5 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -250,6 +250,7 @@ typedef struct View3D {
 #define V3D_DISPBGPICS         2
 #define V3D_HIDE_HELPLINES     4
 #define V3D_INVALID_BACKBUF    8
+#define V3D_LOCK_CURSOR                16
 
 #define V3D_ALIGN                      1024
 #define V3D_SELECT_OUTLINE     2048
diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index ad26891..53b8933 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2392,6 +2392,11 @@ static void rna_def_space_view3d(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "ob_centre_cursor", 1);
        RNA_def_property_ui_text(prop, "Lock to Cursor", "3D View center is 
locked to the cursor's position");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+       
+       prop = RNA_def_property(srna, "lock_cursor_location", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_LOCK_CURSOR);
+       RNA_def_property_ui_text(prop, "Lock Cursor Location", "3D Cursor 
location is locked to prevent it from being accidentally moved");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
 
        prop = RNA_def_property(srna, "viewport_shade", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "drawtype");

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to