diff options
author | Joshua Leung <aligorith@gmail.com> | 2015-12-13 17:06:06 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2015-12-13 17:06:51 +0300 |
commit | a791153ca5e6f87d50396e188a3664b579884161 (patch) | |
tree | 345a5aa3d51eca6a28567fdc4515d44f34b9810e /source/blender/editors/space_view3d/view3d_edit.c | |
parent | 003523e700252950705944fd707a617139e5faac (diff) |
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 :)
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_edit.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index b09cbedb6fa..1d988e9bcfb 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; |