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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-06-17 03:01:22 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-06-17 03:02:54 +0300
commit8c22d31dccd47102d618dce605c6d5f490575b91 (patch)
treee939f22bc412891a0ced6ca471fe4f89eabce75d /source/blender/editors/manipulator_library/dial3d_manipulator.c
parent71b70b23b36008b4ac03001b7e691a0189b4d158 (diff)
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.
Diffstat (limited to 'source/blender/editors/manipulator_library/dial3d_manipulator.c')
-rw-r--r--source/blender/editors/manipulator_library/dial3d_manipulator.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/source/blender/editors/manipulator_library/dial3d_manipulator.c b/source/blender/editors/manipulator_library/dial3d_manipulator.c
index 55d5f257eb4..ea406590e59 100644
--- a/source/blender/editors/manipulator_library/dial3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/dial3d_manipulator.c
@@ -317,6 +317,8 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
float clip_plane_buf[4];
float *clip_plane = (!active && dial->style == ED_MANIPULATOR_DIAL_STYLE_RING_CLIPPED) ? clip_plane_buf : NULL;
+ BLI_assert(dial->style != -1);
+
/* enable clipping if needed */
if (clip_plane) {
ARegion *ar = CTX_wm_region(C);
@@ -362,6 +364,18 @@ static void manipulator_dial_modal(bContext *C, wmManipulator *mpr, const wmEven
}
}
+
+static void manipulator_dial_setup(wmManipulator *mpr)
+{
+ DialManipulator *dial = (DialManipulator *)mpr;
+ const float dir_default[3] = {0.0f, 0.0f, 1.0f};
+
+ dial->style = -1;
+
+ /* defaults */
+ copy_v3_v3(dial->direction, dir_default);
+}
+
static void manipulator_dial_invoke(
bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event)
{
@@ -378,25 +392,18 @@ static void manipulator_dial_invoke(
mpr->interaction_data = inter;
}
-
/* -------------------------------------------------------------------- */
/** \name Dial Manipulator API
*
* \{ */
-wmManipulator *ED_manipulator_dial3d_new(wmManipulatorGroup *mgroup, const char *name, const int style)
-{
- DialManipulator *dial = (DialManipulator *)WM_manipulator_new(
- "MANIPULATOR_WT_dial", mgroup, name);
-
- const float dir_default[3] = {0.0f, 0.0f, 1.0f};
+#define ASSERT_TYPE_CHECK(mpr) BLI_assert(mpr->type->draw == manipulator_dial_draw)
+void ED_manipulator_dial3d_set_style(struct wmManipulator *mpr, int style)
+{
+ ASSERT_TYPE_CHECK(mpr);
+ DialManipulator *dial = (DialManipulator *)mpr;
dial->style = style;
-
- /* defaults */
- copy_v3_v3(dial->direction, dir_default);
-
- return (wmManipulator *)dial;
}
/**
@@ -404,20 +411,22 @@ wmManipulator *ED_manipulator_dial3d_new(wmManipulatorGroup *mgroup, const char
*/
void ED_manipulator_dial3d_set_up_vector(wmManipulator *mpr, const float direction[3])
{
+ ASSERT_TYPE_CHECK(mpr);
DialManipulator *dial = (DialManipulator *)mpr;
copy_v3_v3(dial->direction, direction);
normalize_v3(dial->direction);
}
-static void MANIPULATOR_WT_dial_3d(wmManipulatorType *wt)
+static void MANIPULATOR_WT_dial_3d_3d(wmManipulatorType *wt)
{
/* identifiers */
- wt->idname = "MANIPULATOR_WT_dial";
+ wt->idname = "MANIPULATOR_WT_dial_3d";
/* api callbacks */
wt->draw = manipulator_dial_draw;
wt->draw_select = manipulator_dial_draw_select;
+ wt->setup = manipulator_dial_setup;
wt->invoke = manipulator_dial_invoke;
wt->modal = manipulator_dial_modal;
@@ -426,7 +435,7 @@ static void MANIPULATOR_WT_dial_3d(wmManipulatorType *wt)
void ED_manipulatortypes_dial_3d(void)
{
- WM_manipulatortype_append(MANIPULATOR_WT_dial_3d);
+ WM_manipulatortype_append(MANIPULATOR_WT_dial_3d_3d);
}
/** \} */ // Dial Manipulator API