[Bf-blender-cvs] [2e83897f91f] blender2.8: Cleanup: typedef enums

Campbell Barton noreply at git.blender.org
Wed Jul 26 09:50:54 CEST 2017


Commit: 2e83897f91f0f7e61dd963ab45418551bac22bf2
Author: Campbell Barton
Date:   Wed Jul 26 18:00:26 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB2e83897f91f0f7e61dd963ab45418551bac22bf2

Cleanup: typedef enums

Manipulator enum types are easy to confuse, use typedefs.

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

M	source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
M	source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
M	source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
M	source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/editors/transform/transform_manipulator2d.c
M	source/blender/makesrna/intern/rna_wm_manipulator.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/WM_types.h
M	source/blender/windowmanager/manipulators/WM_manipulator_types.h
M	source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
M	source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
M	source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
M	source/blender/windowmanager/manipulators/wm_manipulator_fn.h

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

diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
index 2d6a513b6ec..dffecd70407 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
@@ -235,7 +235,9 @@ static void manipulator_arrow_draw(const bContext *UNUSED(C), wmManipulator *mpr
  * Calculate arrow offset independent from prop min value,
  * meaning the range will not be offset by min value first.
  */
-static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int flag)
+static void manipulator_arrow_modal(
+        bContext *C, wmManipulator *mpr, const wmEvent *event,
+        eWM_ManipulatorTweak tweak_flag)
 {
 	ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
 	ManipulatorInteraction *inter = mpr->interaction_data;
@@ -334,7 +336,7 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
 		const int draw_options = RNA_enum_get(arrow->manipulator.ptr, "draw_options");
 		const bool constrained = (draw_options & ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED) != 0;
 		const bool inverted = (draw_options & ED_MANIPULATOR_ARROW_STYLE_INVERTED) != 0;
-		const bool use_precision = (flag & WM_MANIPULATOR_TWEAK_PRECISE) != 0;
+		const bool use_precision = (tweak_flag & WM_MANIPULATOR_TWEAK_PRECISE) != 0;
 		float value = manipulator_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision);
 
 		WM_manipulator_target_property_value_set(C, mpr, mpr_prop, value);
diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
index 5fb4f3d54a2..101d940cccf 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
@@ -435,7 +435,7 @@ static void manipulator_rect_transform_invoke(
 
 static void manipulator_rect_transform_modal(
         bContext *C, wmManipulator *mpr, const wmEvent *event,
-        const int UNUSED(flag))
+        eWM_ManipulatorTweak UNUSED(tweak_flag))
 {
 	RectTransformInteraction *data = mpr->interaction_data;
 	/* needed here as well in case clamping occurs */
diff --git a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
index 894c0b6be15..98874e5f2e4 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
@@ -71,7 +71,9 @@
 /* to use custom dials exported to geom_dial_manipulator.c */
 // #define USE_MANIPULATOR_CUSTOM_DIAL
 
-static void manipulator_dial_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int flag);
+static void manipulator_dial_modal(
+        bContext *C, wmManipulator *mpr, const wmEvent *event,
+        eWM_ManipulatorTweak tweak_flag);
 
 typedef struct DialInteraction {
 	float init_mval[2];
@@ -378,7 +380,9 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
 	}
 }
 
-static void manipulator_dial_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int UNUSED(flag))
+static void manipulator_dial_modal(
+        bContext *C, wmManipulator *mpr, const wmEvent *event,
+        eWM_ManipulatorTweak UNUSED(tweak_flag))
 {
 	const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */
 	float angle_ofs, angle_delta;
diff --git a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
index d4b910887d7..20969970802 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
@@ -63,7 +63,9 @@
 #include "../manipulator_geometry.h"
 #include "../manipulator_library_intern.h"
 
-static void manipulator_grab_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int flag);
+static void manipulator_grab_modal(
+        bContext *C, wmManipulator *mpr, const wmEvent *event,
+        eWM_ManipulatorTweak tweak_flag);
 
 typedef struct GrabInteraction {
 	float init_mval[2];
@@ -186,7 +188,9 @@ static void manipulator_grab_draw(const bContext *C, wmManipulator *mpr)
 	glDisable(GL_BLEND);
 }
 
-static void manipulator_grab_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int UNUSED(flag))
+static void manipulator_grab_modal(
+        bContext *C, wmManipulator *mpr, const wmEvent *event,
+        eWM_ManipulatorTweak UNUSED(tweak_flag))
 {
 	GrabInteraction *inter = mpr->interaction_data;
 
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 0f5f2f02e84..0258b228a71 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -1140,7 +1140,8 @@ static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup)
  * Custom handler for manipulator widgets
  */
 static void manipulator_modal(
-        bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event), const int UNUSED(flag))
+        bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event),
+        eWM_ManipulatorTweak UNUSED(tweak_flag))
 {
 	const ScrArea *sa = CTX_wm_area(C);
 	ARegion *ar = CTX_wm_region(C);
diff --git a/source/blender/editors/transform/transform_manipulator2d.c b/source/blender/editors/transform/transform_manipulator2d.c
index 104675cb1a8..8a9e05af3f8 100644
--- a/source/blender/editors/transform/transform_manipulator2d.c
+++ b/source/blender/editors/transform/transform_manipulator2d.c
@@ -168,7 +168,8 @@ BLI_INLINE void manipulator2d_origin_to_region(ARegion *ar, float *r_origin)
  * Custom handler for manipulator widgets
  */
 static void manipulator2d_modal(
-        bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event), const int UNUSED(flag))
+        bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event),
+        eWM_ManipulatorTweak UNUSED(tweak_flag))
 {
 	ARegion *ar = CTX_wm_region(C);
 	float origin[3];
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c
index 2fa2eaa5075..46d6dcc429b 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator.c
@@ -136,20 +136,22 @@ static int rna_manipulator_test_select_cb(
 }
 
 static void rna_manipulator_modal_cb(
-        struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event, int tweak)
+        struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event,
+        eWM_ManipulatorTweak tweak_flag)
 {
 	extern FunctionRNA rna_Manipulator_modal_func;
 	wmManipulatorGroup *mgroup = mpr->parent_mgroup;
 	PointerRNA mpr_ptr;
 	ParameterList list;
 	FunctionRNA *func;
+	const int tweak_flag_int = tweak_flag;
 	RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
 	/* RNA_struct_find_function(&mpr_ptr, "modal"); */
 	func = &rna_Manipulator_modal_func;
 	RNA_parameter_list_create(&list, &mpr_ptr, func);
 	RNA_parameter_set_lookup(&list, "context", &C);
 	RNA_parameter_set_lookup(&list, "event", &event);
-	RNA_parameter_set_lookup(&list, "tweak", &tweak);
+	RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int);
 	mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
 	RNA_parameter_list_free(&list);
 }
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 4e8e57d3cc3..6e5f11c3062 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -42,9 +42,6 @@
 #include "WM_keymap.h"
 #include "BLI_compiler_attrs.h"
 
-/* Include external manipulator API's */
-#include "manipulators/WM_manipulator_api.h"
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -68,6 +65,7 @@ struct ImBuf;
 struct ImageFormatData;
 struct ARegion;
 struct ScrArea;
+struct Main;
 
 #ifdef WITH_INPUT_NDOF
 struct wmNDOFMotionData;
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index ad8df014902..7fe9f3a8ab4 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -121,6 +121,9 @@ struct ImBuf;
 #include "wm_event_types.h"
 #include "manipulators/WM_manipulator_types.h"
 
+/* Include external manipulator API's */
+#include "manipulators/WM_manipulator_api.h"
+
 /* ************** wmOperatorType ************************ */
 
 /* flag */
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
index d8e391bc31b..57c6039f62c 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
@@ -45,13 +45,86 @@ struct wmManipulator;
 struct wmManipulatorProperty;
 struct wmKeyConfig;
 
-#include "wm_manipulator_fn.h"
-
 #include "DNA_listBase.h"
 
+
+/* -------------------------------------------------------------------- */
+/* Enum Typedef's */
+
+
+/**
+ * #wmManipulator.state
+ */
+typedef enum eWM_ManipulatorState {
+	WM_MANIPULATOR_STATE_HIGHLIGHT   = (1 << 0), /* while hovered */
+	WM_MANIPULATOR_STATE_MODAL       = (1 << 1), /* while dragging */
+	WM_MANIPULATOR_STATE_SELECT      = (1 << 2),
+} eWM_ManipulatorState;
+
+
+/**
+ * #wmManipulator.flag
+ * Flags for individual manipulators.
+ */
+typedef enum eWM_ManipulatorFlag {
+	WM_MANIPULATOR_DRAW_HOVER  = (1 << 0), /* draw *only* while hovering */
+	WM_MANIPULATOR_DRAW_MODAL  = (1 << 1), /* draw while dragging */
+	WM_MANIPULATOR_DRAW_VALUE  = (1 << 2), /* draw an indicator for the current value while dragging */
+	WM_MANIPULATOR_HIDDEN

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list