[Bf-blender-cvs] [e6814acf13d] blender2.8: Manipulator: API call to invoke on setup

Campbell Barton noreply at git.blender.org
Wed May 9 22:44:48 CEST 2018


Commit: e6814acf13d37f002f5fe6a20594970fcd186c2e
Author: Campbell Barton
Date:   Wed May 9 22:43:24 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBe6814acf13d37f002f5fe6a20594970fcd186c2e

Manipulator: API call to invoke on setup

Needed for manipulators that start out interactive,
similar use-case to modal operators, except these can be tweaked after.

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

M	source/blender/windowmanager/manipulators/WM_manipulator_api.h
M	source/blender/windowmanager/manipulators/intern/wm_manipulator.c

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

diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
index 97fcb4513be..748cc18480f 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
@@ -76,6 +76,10 @@ bool WM_manipulator_select_unlink(struct wmManipulatorMap *mmap, struct wmManipu
 bool WM_manipulator_select_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select);
 void WM_manipulator_highlight_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr);
 
+void WM_manipulator_modal_set_from_setup(
+        struct wmManipulatorMap *mmap, struct bContext *C,
+        struct wmManipulator *mpr, int part_index, const struct wmEvent *event);
+
 struct wmManipulatorOpElem *WM_manipulator_operator_get(
         struct wmManipulator *mpr, int part_index);
 struct PointerRNA *WM_manipulator_operator_set(
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
index 856b92096dd..42232950cc4 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
@@ -469,6 +469,26 @@ bool wm_manipulator_select_and_highlight(bContext *C, wmManipulatorMap *mmap, wm
 	}
 }
 
+/**
+ * Special function to run from setup so manipulators start out interactive.
+ *
+ * We could do this when linking them, but this complicates things since the window update code needs to run first.
+ */
+void WM_manipulator_modal_set_from_setup(
+        struct wmManipulatorMap *mmap, struct bContext *C,
+        struct wmManipulator *mpr, int part_index, const wmEvent *event)
+{
+	mpr->highlight_part = part_index;
+	WM_manipulator_highlight_set(mmap, mpr);
+	if (false) {
+		wm_manipulatormap_modal_set(mmap, C, mpr, event, true);
+	}
+	else {
+		/* WEAK: but it works. */
+		WM_operator_name_call(C, "MANIPULATORGROUP_OT_manipulator_tweak", WM_OP_INVOKE_DEFAULT, NULL);
+	}
+}
+
 void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C)
 {
 	const RegionView3D *rv3d = CTX_wm_region_view3d(C);



More information about the Bf-blender-cvs mailing list