[Bf-blender-cvs] [8c22d31dccd] blender2.8: Manipulator: remove type specific 'new' functions
Campbell Barton
noreply at git.blender.org
Sat Jun 17 01:59:35 CEST 2017
Commit: 8c22d31dccd47102d618dce605c6d5f490575b91
Author: Campbell Barton
Date: Sat Jun 17 10:01:22 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB8c22d31dccd47102d618dce605c6d5f490575b91
Manipulator: remove type specific 'new' functions
Instead use generic 'WM_manipulator_new', adding a new 'setup'
callback (like wmManipulatorGroup.setup) used to initialize type vars.
This moves conventions closer to wmOperator and simplifies exposing to
Python.
===================================================================
M source/blender/editors/include/ED_manipulator_library.h
M source/blender/editors/manipulator_library/arrow2d_manipulator.c
M source/blender/editors/manipulator_library/arrow3d_manipulator.c
M source/blender/editors/manipulator_library/cage2d_manipulator.c
M source/blender/editors/manipulator_library/dial3d_manipulator.c
M source/blender/editors/manipulator_library/grab3d_manipulator.c
M source/blender/editors/manipulator_library/primitive3d_manipulator.c
M source/blender/editors/mesh/editmesh_bisect.c
M source/blender/editors/mesh/editmesh_extrude.c
M source/blender/editors/space_node/node_manipulators.c
M source/blender/editors/space_view3d/view3d_manipulators.c
M source/blender/editors/transform/transform_manipulator.c
M source/blender/editors/transform/transform_manipulator2d.c
M source/blender/windowmanager/manipulators/WM_manipulator_types.h
M source/blender/windowmanager/manipulators/intern/wm_manipulator.c
M source/blender/windowmanager/manipulators/wm_manipulator_fn.h
===================================================================
diff --git a/source/blender/editors/include/ED_manipulator_library.h b/source/blender/editors/include/ED_manipulator_library.h
index 692d6cbdcd8..924ba7bf792 100644
--- a/source/blender/editors/include/ED_manipulator_library.h
+++ b/source/blender/editors/include/ED_manipulator_library.h
@@ -76,8 +76,7 @@ enum {
ED_MANIPULATOR_ARROW_STYLE_CONE = (1 << 6),
};
-struct wmManipulator *ED_manipulator_arrow3d_new(
- struct wmManipulatorGroup *mgroup, const char *name, const int style);
+void ED_manipulator_arrow3d_set_style(struct wmManipulator *mpr, int style);
void ED_manipulator_arrow3d_set_direction(struct wmManipulator *mpr, const float direction[3]);
void ED_manipulator_arrow3d_set_up_vector(struct wmManipulator *mpr, const float direction[3]);
void ED_manipulator_arrow3d_set_line_len(struct wmManipulator *mpr, const float len);
@@ -89,7 +88,6 @@ void ED_manipulator_arrow3d_cone_set_aspect(struct wmManipulator *mpr, const flo
/* -------------------------------------------------------------------- */
/* 2D Arrow Manipulator */
-struct wmManipulator *ED_manipulator_arrow2d_new(struct wmManipulatorGroup *mgroup, const char *name);
void ED_manipulator_arrow2d_set_angle(struct wmManipulator *mpr, const float rot_fac);
void ED_manipulator_arrow2d_set_line_len(struct wmManipulator *mpr, const float len);
@@ -104,9 +102,8 @@ enum {
ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM = (1 << 3), /* Manipulator scales uniformly */
};
-struct wmManipulator *ED_manipulator_rect_transform_new(
- struct wmManipulatorGroup *mgroup, const char *name, const int style);
-void ED_manipulator_rect_transform_set_dimensions(
+void ED_manipulator_cage2d_transform_set_style(struct wmManipulator *mpr, int style);
+void ED_manipulator_cage2d_transform_set_dims(
struct wmManipulator *mpr, const float width, const float height);
@@ -119,8 +116,7 @@ enum {
ED_MANIPULATOR_DIAL_STYLE_RING_FILLED = 2,
};
-struct wmManipulator *ED_manipulator_dial3d_new(
- struct wmManipulatorGroup *mgroup, const char *name, const int style);
+void ED_manipulator_dial3d_set_style(struct wmManipulator *mpr, int style);
void ED_manipulator_dial3d_set_up_vector(
struct wmManipulator *mpr, const float direction[3]);
@@ -128,17 +124,17 @@ void ED_manipulator_dial3d_set_up_vector(
/* -------------------------------------------------------------------- */
/* Grab Manipulator */
-struct wmManipulator *ED_manipulator_grab3d_new(
- struct wmManipulatorGroup *mgroup, const char *name, const int style);
+enum {
+ ED_MANIPULATOR_GRAB_STYLE_RING = 0,
+};
+
+void ED_manipulator_grab3d_set_style(struct wmManipulator *mpr, int style);
void ED_manipulator_grab3d_set_up_vector(
struct wmManipulator *mpr, const float direction[3]);
/* -------------------------------------------------------------------- */
/* Facemap Manipulator */
-struct wmManipulator *ED_manipulator_facemap_new(
- struct wmManipulatorGroup *mgroup, const char *name, const int style,
- struct Object *ob, const int facemap);
struct bFaceMap *ED_manipulator_facemap_get_fmap(struct wmManipulator *mpr);
@@ -149,9 +145,9 @@ enum {
ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE = 0,
};
-struct wmManipulator *ED_manipulator_primitive3d_new(
- struct wmManipulatorGroup *mgroup, const char *name, const int style);
+void ED_manipulator_primitive3d_set_style(struct wmManipulator *mpr, int style);
void ED_manipulator_primitive3d_set_direction(struct wmManipulator *mpr, const float direction[3]);
void ED_manipulator_primitive3d_set_up_vector(struct wmManipulator *mpr, const float direction[3]);
+
#endif /* __ED_MANIPULATOR_LIBRARY_H__ */
diff --git a/source/blender/editors/manipulator_library/arrow2d_manipulator.c b/source/blender/editors/manipulator_library/arrow2d_manipulator.c
index 1798a3dbd6d..f7d4926c7ca 100644
--- a/source/blender/editors/manipulator_library/arrow2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/arrow2d_manipulator.c
@@ -125,6 +125,15 @@ static void manipulator_arrow2d_draw(const bContext *UNUSED(C), struct wmManipul
}
}
+static void manipulator_arrow2d_setup(wmManipulator *mpr)
+{
+ ArrowManipulator2D *arrow = (ArrowManipulator2D *)mpr;
+
+ arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_ACTIVE;
+
+ arrow->line_len = 1.0f;
+}
+
static void manipulator_arrow2d_invoke(
bContext *UNUSED(C), struct wmManipulator *mpr, const wmEvent *UNUSED(event))
{
@@ -187,26 +196,18 @@ static int manipulator_arrow2d_test_select(
*
* \{ */
-struct wmManipulator *ED_manipulator_arrow2d_new(wmManipulatorGroup *mgroup, const char *name)
-{
- ArrowManipulator2D *arrow = (ArrowManipulator2D *)WM_manipulator_new(
- "MANIPULATOR_WT_arrow_2d", mgroup, name);
-
- arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_ACTIVE;
-
- arrow->line_len = 1.0f;
-
- return &arrow->manipulator;
-}
+#define ASSERT_TYPE_CHECK(mpr) BLI_assert(mpr->type->draw == manipulator_arrow2d_draw)
void ED_manipulator_arrow2d_set_angle(struct wmManipulator *mpr, const float angle)
{
+ ASSERT_TYPE_CHECK(mpr);
ArrowManipulator2D *arrow = (ArrowManipulator2D *)mpr;
arrow->angle = angle;
}
void ED_manipulator_arrow2d_set_line_len(struct wmManipulator *mpr, const float len)
{
+ ASSERT_TYPE_CHECK(mpr);
ArrowManipulator2D *arrow = (ArrowManipulator2D *)mpr;
arrow->line_len = len;
}
@@ -218,6 +219,7 @@ static void MANIPULATOR_WT_arrow_2d(wmManipulatorType *wt)
/* api callbacks */
wt->draw = manipulator_arrow2d_draw;
+ wt->setup = manipulator_arrow2d_setup;
wt->invoke = manipulator_arrow2d_invoke;
wt->test_select = manipulator_arrow2d_test_select;
diff --git a/source/blender/editors/manipulator_library/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/arrow3d_manipulator.c
index 431bccf379f..10d5295edc5 100644
--- a/source/blender/editors/manipulator_library/arrow3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/arrow3d_manipulator.c
@@ -369,6 +369,19 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
WM_event_add_mousemove(C);
}
+static void manipulator_arrow_setup(wmManipulator *mpr)
+{
+ ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
+
+ const float dir_default[3] = {0.0f, 0.0f, 1.0f};
+
+ arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_ACTIVE;
+
+ arrow->style = -1;
+ arrow->len = 1.0f;
+ arrow->data.range_fac = 1.0f;
+ copy_v3_v3(arrow->direction, dir_default);
+}
static void manipulator_arrow_invoke(
bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
@@ -423,28 +436,16 @@ static void manipulator_arrow_exit(bContext *C, wmManipulator *mpr, const bool c
*
* \{ */
-wmManipulator *ED_manipulator_arrow3d_new(wmManipulatorGroup *mgroup, const char *name, const int style)
+void ED_manipulator_arrow3d_set_style(struct wmManipulator *mpr, int style)
{
- ArrowManipulator3D *arrow = (ArrowManipulator3D *)WM_manipulator_new(
- "MANIPULATOR_WT_arrow_3d", mgroup, name);
-
- int real_style = style;
+ ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
/* inverted only makes sense in a constrained arrow */
- if (real_style & ED_MANIPULATOR_ARROW_STYLE_INVERTED) {
- real_style |= ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED;
+ if (style & ED_MANIPULATOR_ARROW_STYLE_INVERTED) {
+ style |= ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED;
}
- const float dir_default[3] = {0.0f, 0.0f, 1.0f};
-
- arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_ACTIVE;
-
- arrow->style = real_style;
- arrow->len = 1.0f;
- arrow->data.range_fac = 1.0f;
- copy_v3_v3(arrow->direction, dir_default);
-
- return &arrow->manipulator;
+ arrow->style = style;
}
/**
@@ -536,6 +537,7 @@ static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt)
wt->draw_select = manipulator_arrow_draw_select;
wt->position_get = manipulator_arrow_position_get;
wt->modal = manipulator_arrow_modal;
+ wt->setup = manipulator_arrow_setup;
wt->invoke = manipulator_arrow_invoke;
wt->property_update = manipulator_arrow_property_update;
wt->exit = manipulator_arrow_exit;
diff --git a/source/blender/editors/manipulator_library/cage2d_manipulator.c b/source/blender/editors/manipulator_library/cage2d_manipulator.c
index 5aacf6c8473..5030d68bbab 100644
--- a/source/blender/editors/manipulator_library/cage2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/cage2d_manipulator.c
@@ -72,13 +72,13 @@ enum {
#define MANIPULATOR_RECT_MIN_WIDTH 15.0f
#define MANIPULATOR_RESIZER_WIDTH 20.0f
-typedef struct RectTransformManipulator {
+typedef struct Cage2D {
wmManipulator manipulator;
float w, h; /* dimensions of manipulator */
float rotation; /* rotation of the rectangle */
float scale[2]; /* scaling for the manipulator for non-destructive editing. */
int style;
-} RectTransformManipulator;
+} Cage2D;
/* -------------------------------------------------------------------- */
@@ -203,18 +203,20 @@ static void rect_transform_draw_interaction(
static void manipulator_rect_transform_draw(const bContext *UNUSED(C), wmManipulator *mpr)
{
- RectTransformManipulator *cage = (RectTransformManipulator *)mpr;
- rctf r;
+ Cage2D *cage = (Cage2D *)mpr;
float w = cage->w;
float h = cage->h;
float aspx = 1.0f, aspy = 1.0f;
const float half_w = w / 2.0f;
const float half_h = h / 2.0f;
+ const rctf r = {
+ .xmin = -half_w,
+ .ymin = -half_h,
+ .xmax = half_w,
+ .ymax = half_h,
+ };
- r.xmin = -half_w;
- r.ymin = -half_h;
- r.xmax = half_w;
- r.ymax = half_h;
+ BLI_assert(cage->style != -1);
gpuPushMatrix();
gpuTranslate2f(mpr->origin[0] + mpr->offset[0],
@@ -268,7 +270,7 @@ static int manipulator_rect_transform_get_cursor(wmManipulator *mpr)
static int manipulator_rect_transform_test_select(
bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
{
- RectTransformManipulator *cage = (RectTransformManipulator *)mpr;
+ Cage2D *cage = (Cage2D *)mpr;
const float mouse[2] = {event->mval[0], event->mval[1]};
//float matrot[2][2];
float point_local[2];
@@ -382,7 +384,7 @@ static bool manipulator_rect_transform_get_prop_value(
RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list