Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2014-07-03 14:04:29 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-07-03 14:04:29 +0400
commit26eae6315c05526021b93d9e32b064208a9d7ab8 (patch)
treee5702f79be60783cd748dd8a2b803307d24782f8 /source
parentd5297b62834d629600c2d23582b237bb23f5bcd9 (diff)
Make Cursor placement operation a modal operator.
* Allows drag and place workflow in addition to click workflow * Should be compatible with future use of calling operator and placing instead of left-clicking
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 762288acfab..e3260dba485 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -4435,20 +4435,46 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2])
}
}
-static int view3d_cursor3d_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
+static void view3d_cursor3d_update(bContext *C, const int *mval)
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
float *fp = ED_view3d_cursor3d_get(scene, v3d);
- ED_view3d_cursor3d_position(C, fp, event->mval);
-
+ ED_view3d_cursor3d_position(C, fp, mval);
+
if (v3d && v3d->localvd)
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
else
WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
-
- return OPERATOR_FINISHED;
+}
+
+static int view3d_cursor3d_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ view3d_cursor3d_update(C, event->mval);
+ op->customdata = SET_INT_IN_POINTER(event->type);
+ WM_event_add_modal_handler(C, op);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int view3d_cursor3d_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ int event_type = GET_INT_FROM_POINTER(op->customdata);
+
+ if (event->type == event_type) {
+ return OPERATOR_FINISHED;
+ }
+
+ switch (event->type) {
+ case MOUSEMOVE:
+ view3d_cursor3d_update(C, event->mval);
+ break;
+ case LEFTMOUSE:
+ return OPERATOR_FINISHED;
+ }
+
+ return OPERATOR_RUNNING_MODAL;
}
void VIEW3D_OT_cursor3d(wmOperatorType *ot)
@@ -4461,6 +4487,7 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot)
/* api callbacks */
ot->invoke = view3d_cursor3d_invoke;
+ ot->modal = view3d_cursor3d_modal;
ot->poll = ED_operator_view3d_active;