diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-06-21 06:54:46 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-06-21 07:10:14 +0300 |
commit | b7669ac1c672a92f31735ae9f92b369f9ba30eb1 (patch) | |
tree | 1747e45bcc61cd4c2fc02dd3f006f49b4a18ca2b /source/blender/editors | |
parent | 5b51dcacbc81df6283518317c274bf897010e967 (diff) |
Manipulators: move settings to ID properties
This makes manipulator access closer to operators,
and allows Python access.
This adds RNA for manipulators, but not Python registration yet.
- Split draw style into 2x settings:
`draw_style` (enum) & `draw_options` (enum-flag)
- Rename wmManipulator.properties -> properties_edit,
Use wmManipulator.properties for ID-properties.
Note that this area of the API will need further work since
manipulators now have 2 kinds of properties & API's to access them.
Diffstat (limited to 'source/blender/editors')
14 files changed, 403 insertions, 476 deletions
diff --git a/source/blender/editors/include/ED_manipulator_library.h b/source/blender/editors/include/ED_manipulator_library.h index 421fdbf1212..b1970a7bab3 100644 --- a/source/blender/editors/include/ED_manipulator_library.h +++ b/source/blender/editors/include/ED_manipulator_library.h @@ -64,70 +64,61 @@ void ED_manipulator_draw_preset_facemap( /* 3D Arrow Manipulator */ enum { - ED_MANIPULATOR_ARROW_STYLE_NORMAL = 1, - ED_MANIPULATOR_ARROW_STYLE_NO_AXIS = (1 << 1), - ED_MANIPULATOR_ARROW_STYLE_CROSS = (1 << 2), + ED_MANIPULATOR_ARROW_STYLE_NORMAL = 0, + ED_MANIPULATOR_ARROW_STYLE_CROSS = 1, + ED_MANIPULATOR_ARROW_STYLE_BOX = 2, + ED_MANIPULATOR_ARROW_STYLE_CONE = 3, +}; + +enum { /* inverted offset during interaction - if set it also sets constrained below */ ED_MANIPULATOR_ARROW_STYLE_INVERTED = (1 << 3), /* clamp arrow interaction to property width */ ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED = (1 << 4), - /* use a box for the arrowhead */ - ED_MANIPULATOR_ARROW_STYLE_BOX = (1 << 5), - ED_MANIPULATOR_ARROW_STYLE_CONE = (1 << 6), }; -void ED_manipulator_arrow3d_set_style(struct wmManipulator *mpr, int style); -void ED_manipulator_arrow3d_set_line_len(struct wmManipulator *mpr, const float len); void ED_manipulator_arrow3d_set_ui_range(struct wmManipulator *mpr, const float min, const float max); void ED_manipulator_arrow3d_set_range_fac(struct wmManipulator *mpr, const float range_fac); -void ED_manipulator_arrow3d_cone_set_aspect(struct wmManipulator *mpr, const float aspect[2]); - /* -------------------------------------------------------------------- */ /* 2D Arrow Manipulator */ -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); - +/* none */ /* -------------------------------------------------------------------- */ /* Cage Manipulator */ enum { - ED_MANIPULATOR_RECT_TRANSFORM_STYLE_TRANSLATE = 1, /* Manipulator translates */ - ED_MANIPULATOR_RECT_TRANSFORM_STYLE_ROTATE = (1 << 1), /* Manipulator rotates */ - ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE = (1 << 2), /* Manipulator scales */ - ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM = (1 << 3), /* Manipulator scales uniformly */ + ED_MANIPULATOR_RECT_TRANSFORM_FLAG_TRANSLATE = (1 << 0), /* Manipulator translates */ + ED_MANIPULATOR_RECT_TRANSFORM_FLAG_ROTATE = (1 << 1), /* Manipulator rotates */ + ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE = (1 << 2), /* Manipulator scales */ + ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM = (1 << 3), /* Manipulator scales uniformly */ }; -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); - - /* -------------------------------------------------------------------- */ /* Dial Manipulator */ +/* draw_options */ enum { - ED_MANIPULATOR_DIAL_STYLE_RING = 0, - ED_MANIPULATOR_DIAL_STYLE_RING_CLIPPED = 1, - ED_MANIPULATOR_DIAL_STYLE_RING_FILLED = 2, + ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP = 0, + ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP = (1 << 0), + ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL = (1 << 1), + ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR = (1 << 2), + ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y = (1 << 3), }; -void ED_manipulator_dial3d_set_style(struct wmManipulator *mpr, int style); -void ED_manipulator_dial3d_set_use_start_y_axis( - struct wmManipulator *mpr, const bool enabled); -void ED_manipulator_dial3d_set_use_double_helper( - struct wmManipulator *mpr, const bool enabled); - /* -------------------------------------------------------------------- */ /* Grab Manipulator */ +/* draw_options */ enum { - ED_MANIPULATOR_GRAB_STYLE_RING = 0, + ED_MANIPULATOR_GRAB_DRAW_FLAG_NOP = 0, + ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL = (1 << 0), }; -void ED_manipulator_grab3d_set_style(struct wmManipulator *mpr, int style); +enum { + ED_MANIPULATOR_GRAB_STYLE_RING = 0, +}; /* -------------------------------------------------------------------- */ @@ -137,7 +128,4 @@ enum { ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE = 0, }; -void ED_manipulator_primitive3d_set_style(struct wmManipulator *mpr, int style); - - #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 6e263b86bfa..adc23667d58 100644 --- a/source/blender/editors/manipulator_library/arrow2d_manipulator.c +++ b/source/blender/editors/manipulator_library/arrow2d_manipulator.c @@ -51,6 +51,7 @@ #include "MEM_guardedalloc.h" #include "RNA_access.h" +#include "RNA_define.h" #include "WM_types.h" @@ -59,32 +60,24 @@ #include "manipulator_library_intern.h" - -typedef struct ArrowManipulator2D { - struct wmManipulator manipulator; - - float angle; - float line_len; -} ArrowManipulator2D; - - -static void arrow2d_draw_geom(ArrowManipulator2D *arrow, const float matrix[4][4], const float color[4]) +static void arrow2d_draw_geom(wmManipulator *mpr, const float matrix[4][4], const float color[4]) { const float size = 0.11f; const float size_h = size / 2.0f; - const float len = arrow->line_len; - const float draw_line_ofs = (arrow->manipulator.line_width * 0.5f) / arrow->manipulator.scale; + const float arrow_length = RNA_float_get(mpr->ptr, "length"); + const float arrow_angle = RNA_float_get(mpr->ptr, "angle"); + const float draw_line_ofs = (mpr->line_width * 0.5f) / mpr->scale; uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); gpuPushMatrix(); gpuMultMatrix(matrix); - gpuScaleUniform(arrow->manipulator.scale); - gpuRotate2D(RAD2DEGF(arrow->angle)); + gpuScaleUniform(mpr->scale); + gpuRotate2D(RAD2DEGF(arrow_angle)); /* local offset */ gpuTranslate2f( - arrow->manipulator.matrix_offset[3][0] + draw_line_ofs, - arrow->manipulator.matrix_offset[3][1]); + mpr->matrix_offset[3][0] + draw_line_ofs, + mpr->matrix_offset[3][1]); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -92,13 +85,13 @@ static void arrow2d_draw_geom(ArrowManipulator2D *arrow, const float matrix[4][4 immBegin(GWN_PRIM_LINES, 2); immVertex2f(pos, 0.0f, 0.0f); - immVertex2f(pos, 0.0f, len); + immVertex2f(pos, 0.0f, arrow_length); immEnd(); immBegin(GWN_PRIM_TRIS, 3); - immVertex2f(pos, size_h, len); - immVertex2f(pos, -size_h, len); - immVertex2f(pos, 0.0f, len + size * 1.7f); + immVertex2f(pos, size_h, arrow_length); + immVertex2f(pos, -size_h, arrow_length); + immVertex2f(pos, 0.0f, arrow_length + size * 1.7f); immEnd(); immUnbindProgram(); @@ -106,38 +99,33 @@ static void arrow2d_draw_geom(ArrowManipulator2D *arrow, const float matrix[4][4 gpuPopMatrix(); } -static void manipulator_arrow2d_draw(const bContext *UNUSED(C), struct wmManipulator *mpr) +static void manipulator_arrow2d_draw(const bContext *UNUSED(C), wmManipulator *mpr) { - ArrowManipulator2D *arrow = (ArrowManipulator2D *)mpr; float col[4]; manipulator_color_get(mpr, mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT, col); glLineWidth(mpr->line_width); glEnable(GL_BLEND); - arrow2d_draw_geom(arrow, mpr->matrix, col); + arrow2d_draw_geom(mpr, mpr->matrix, col); glDisable(GL_BLEND); if (mpr->interaction_data) { - ManipulatorInteraction *inter = arrow->manipulator.interaction_data; + ManipulatorInteraction *inter = mpr->interaction_data; glEnable(GL_BLEND); - arrow2d_draw_geom(arrow, inter->init_matrix, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); + arrow2d_draw_geom(mpr, inter->init_matrix, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); glDisable(GL_BLEND); } } static void manipulator_arrow2d_setup(wmManipulator *mpr) { - ArrowManipulator2D *arrow = (ArrowManipulator2D *)mpr; - - arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_ACTIVE; - - arrow->line_len = 1.0f; + mpr->flag |= WM_MANIPULATOR_DRAW_ACTIVE; } static void manipulator_arrow2d_invoke( - bContext *UNUSED(C), struct wmManipulator *mpr, const wmEvent *UNUSED(event)) + bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *UNUSED(event)) { ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); @@ -146,11 +134,12 @@ static void manipulator_arrow2d_invoke( } static int manipulator_arrow2d_test_select( - bContext *UNUSED(C), struct wmManipulator *mpr, const wmEvent *event) + bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) { - ArrowManipulator2D *arrow = (ArrowManipulator2D *)mpr; const float mval[2] = {event->mval[0], event->mval[1]}; - const float line_len = arrow->line_len * mpr->scale; + const float arrow_length = RNA_float_get(mpr->ptr, "length"); + const float arrow_angle = RNA_float_get(mpr->ptr, "angle"); + const float line_len = arrow_length * mpr->scale; float mval_local[2]; copy_v2_v2(mval_local, mval); @@ -161,10 +150,10 @@ static int manipulator_arrow2d_test_select( line[1][1] = line_len; /* rotate only if needed */ - if (arrow->angle != 0.0f) { + if (arrow_angle != 0.0f) { float rot_point[2]; copy_v2_v2(rot_point, line[1]); - rotate_v2_v2fl(line[1], rot_point, arrow->angle); + rotate_v2_v2fl(line[1], rot_point, arrow_angle); } /* arrow line intersection check */ @@ -198,22 +187,6 @@ static int manipulator_arrow2d_test_select( * * \{ */ -#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; -} - static void MANIPULATOR_WT_arrow_2d(wmManipulatorType *wt) { /* identifiers */ @@ -225,7 +198,13 @@ static void MANIPULATOR_WT_arrow_2d(wmManipulatorType *wt) wt->invoke = manipulator_arrow2d_invoke; wt->test_select = manipulator_arrow2d_test_select; - wt->struct_size = sizeof(ArrowManipulator2D); + wt->struct_size = sizeof(wmManipulator); + + /* rna */ + RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); + RNA_def_float_rotation( + wt->srna, "angle", 0, NULL, DEG2RADF(-360.0f), DEG2RADF(360.0f), + "Roll", "", DEG2RADF(-360.0f), DEG2RADF(360.0f)); } void ED_manipulatortypes_arrow_2d(void) diff --git a/source/blender/editors/manipulator_library/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/arrow3d_manipulator.c index 6e7fa3a7269..122248ba8cf 100644 --- a/source/blender/editors/manipulator_library/arrow3d_manipulator.c +++ b/source/blender/editors/manipulator_library/arrow3d_manipulator.c @@ -59,6 +59,7 @@ #include "MEM_guardedalloc.h" #include "RNA_access.h" +#include "RNA_define.h" #include "WM_types.h" #include "WM_api.h" @@ -70,22 +71,9 @@ /* to use custom arrows exported to geom_arrow_manipulator.c */ //#define USE_MANIPULATOR_CUSTOM_ARROWS -/* ArrowManipulator->flag */ -enum { - ARROW_UP_VECTOR_SET = (1 << 0), - ARROW_CUSTOM_RANGE_SET = (1 << 1), -}; - typedef struct ArrowManipulator3D { wmManipulator manipulator; - ManipulatorCommonData data; - - int style; - int flag; - - float len; /* arrow line length */ - float aspect[2]; /* cone style only */ } ArrowManipulator3D; @@ -103,10 +91,11 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, { uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); bool unbind_shader = true; + const int draw_style = RNA_enum_get(arrow->manipulator.ptr, "draw_style"); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - if (arrow->style & ED_MANIPULATOR_ARROW_STYLE_CROSS) { + if (draw_style == ED_MANIPULATOR_ARROW_STYLE_CROSS) { immUniformColor4fv(color); immBegin(GWN_PRIM_LINES, 4); @@ -116,9 +105,11 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, immVertex3f(pos, 0.0f, 1.0f, 0.0f); immEnd(); } - else if (arrow->style & ED_MANIPULATOR_ARROW_STYLE_CONE) { - const float unitx = arrow->aspect[0]; - const float unity = arrow->aspect[1]; + else if (draw_style == ED_MANIPULATOR_ARROW_STYLE_CONE) { + float aspect[2]; + RNA_float_get_array(arrow->manipulator.ptr, "aspect", aspect); + const float unitx = aspect[0]; + const float unity = aspect[1]; const float vec[4][3] = { {-unitx, -unity, 0}, { unitx, -unity, 0}, @@ -133,10 +124,11 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, #ifdef USE_MANIPULATOR_CUSTOM_ARROWS wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_arrow, select, color); #else + const float arrow_length = RNA_float_get(arrow->manipulator.ptr, "length"); const float vec[2][3] = { {0.0f, 0.0f, 0.0f}, - {0.0f, 0.0f, arrow->len}, + {0.0f, 0.0f, RNA_float_get(arrow->manipulator.ptr, "length")}, }; glLineWidth(arrow->manipulator.line_width); @@ -147,11 +139,11 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, gpuPushMatrix(); - if (arrow->style & ED_MANIPULATOR_ARROW_STYLE_BOX) { + if (draw_style == ED_MANIPULATOR_ARROW_STYLE_BOX) { const float size = 0.05f; /* translate to line end with some extra offset so box starts exactly where line ends */ - gpuTranslate3f(0.0f, 0.0f, arrow->len + size); + gpuTranslate3f(0.0f, 0.0f, arrow_length + size); /* scale down to box size */ gpuScale3f(size, size, size); @@ -161,12 +153,14 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_cube, select, color); } else { + BLI_assert(draw_style == ED_MANIPULATOR_ARROW_STYLE_NORMAL); + const float len = 0.25f; const float width = 0.06f; const bool use_lighting = (!select && ((U.manipulator_flag & USER_MANIPULATOR_SHADED) != 0)); /* translate to line end */ - gpuTranslate3f(0.0f, 0.0f, arrow->len); + gpuTranslate3f(0.0f, 0.0f, arrow_length); if (use_lighting) { immUnbindProgram(); @@ -337,9 +331,10 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve /* set the property for the operator and call its modal function */ if (WM_manipulator_property_is_valid(mpr_prop)) { - const bool constrained = arrow->style & ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED; - const bool inverted = arrow->style & ED_MANIPULATOR_ARROW_STYLE_INVERTED; - const bool use_precision = flag & WM_MANIPULATOR_TWEAK_PRECISE; + 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; float value = manipulator_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision); WM_manipulator_property_value_set(C, mpr, mpr_prop, value); @@ -363,8 +358,6 @@ static void manipulator_arrow_setup(wmManipulator *mpr) arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_ACTIVE; - arrow->style = -1; - arrow->len = 1.0f; arrow->data.range_fac = 1.0f; } @@ -395,10 +388,10 @@ static void manipulator_arrow_invoke( static void manipulator_arrow_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) { ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - manipulator_property_data_update( - mpr, &arrow->data, mpr_prop, - (arrow->style & ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED) != 0, - (arrow->style & ED_MANIPULATOR_ARROW_STYLE_INVERTED) != 0); + 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; + manipulator_property_data_update(mpr, &arrow->data, mpr_prop, constrained, inverted); } static void manipulator_arrow_exit(bContext *C, wmManipulator *mpr, const bool cancel) @@ -421,27 +414,6 @@ static void manipulator_arrow_exit(bContext *C, wmManipulator *mpr, const bool c * * \{ */ -void ED_manipulator_arrow3d_set_style(struct wmManipulator *mpr, int style) -{ - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - - /* inverted only makes sense in a constrained arrow */ - if (style & ED_MANIPULATOR_ARROW_STYLE_INVERTED) { - style |= ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED; - } - - arrow->style = style; -} - -/** - * Define a custom arrow line length - */ -void ED_manipulator_arrow3d_set_line_len(wmManipulator *mpr, const float len) -{ - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - arrow->len = len; -} - /** * Define a custom property UI range * @@ -474,16 +446,6 @@ void ED_manipulator_arrow3d_set_range_fac(wmManipulator *mpr, const float range_ arrow->data.range_fac = range_fac; } -/** - * Define xy-aspect for arrow cone - */ -void ED_manipulator_arrow3d_cone_set_aspect(wmManipulator *mpr, const float aspect[2]) -{ - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - - copy_v2_v2(arrow->aspect, aspect); -} - static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt) { /* identifiers */ @@ -500,6 +462,28 @@ static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt) wt->exit = manipulator_arrow_exit; wt->struct_size = sizeof(ArrowManipulator3D); + + /* rna */ + static EnumPropertyItem rna_enum_draw_style[] = { + {ED_MANIPULATOR_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""}, + {ED_MANIPULATOR_ARROW_STYLE_CROSS, "CROSS", 0, "Cross", ""}, + {ED_MANIPULATOR_ARROW_STYLE_BOX, "BOX", 0, "Box", ""}, + {ED_MANIPULATOR_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""}, + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem rna_enum_draw_options[] = { + {ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP, "CLIP", 0, "Clipped", ""}, + {ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""}, + {ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR, "ANGLE_MIRROR", 0, "Angle Mirror", ""}, + {ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""}, + {0, NULL, 0, NULL, NULL} + }; + + RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_ARROW_STYLE_NORMAL, "Draw Style", ""); + RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); + + RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); + RNA_def_float_vector(wt->srna, "aspect", 2, NULL, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX); } void ED_manipulatortypes_arrow_3d(void) diff --git a/source/blender/editors/manipulator_library/cage2d_manipulator.c b/source/blender/editors/manipulator_library/cage2d_manipulator.c index 07667c70bd4..a7e9a89b324 100644 --- a/source/blender/editors/manipulator_library/cage2d_manipulator.c +++ b/source/blender/editors/manipulator_library/cage2d_manipulator.c @@ -51,35 +51,23 @@ #include "MEM_guardedalloc.h" #include "RNA_access.h" +#include "RNA_define.h" #include "WM_api.h" #include "WM_types.h" -/* own includes */ -//#include "wm_manipulator_wmapi.h" -//#include "wm_manipulator_intern.h" - - /* wmManipulator->highlight_part */ enum { ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_TRANSLATE = 1, ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_LEFT = 2, ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_RIGHT = 3, ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_UP = 4, - ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_DOWN = 5 + ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_DOWN = 5, }; #define MANIPULATOR_RECT_MIN_WIDTH 15.0f #define MANIPULATOR_RESIZER_WIDTH 20.0f -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; -} Cage2D; - /* -------------------------------------------------------------------- */ @@ -203,9 +191,16 @@ static void rect_transform_draw_interaction( static void manipulator_rect_transform_draw(const bContext *UNUSED(C), wmManipulator *mpr) { - Cage2D *cage = (Cage2D *)mpr; - float w = cage->w; - float h = cage->h; + float dims[2]; + RNA_float_get_array(mpr->ptr, "dimensions", dims); + float w = dims[0]; + float h = dims[1]; + + float scale[2]; + RNA_float_get_array(mpr->ptr, "scale", scale); + + const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); + float aspx = 1.0f, aspy = 1.0f; const float half_w = w / 2.0f; const float half_h = h / 2.0f; @@ -216,23 +211,25 @@ static void manipulator_rect_transform_draw(const bContext *UNUSED(C), wmManipul .ymax = half_h, }; - BLI_assert(cage->style != -1); - gpuPushMatrix(); gpuMultMatrix(mpr->matrix); gpuMultMatrix(mpr->matrix_offset); - if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) - gpuScaleUniform(cage->scale[0]); - else - gpuScale2fv(cage->scale); + if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) { + gpuScaleUniform(scale[0]); + } + else { + gpuScale2fv(scale); + } - if (w > h) + if (w > h) { aspx = h / w; - else + } + else { aspy = w / h; - w = min_ff(aspx * w / MANIPULATOR_RESIZER_WIDTH, MANIPULATOR_RESIZER_WIDTH / cage->scale[0]); + } + w = min_ff(aspx * w / MANIPULATOR_RESIZER_WIDTH, MANIPULATOR_RESIZER_WIDTH / scale[0]); h = min_ff(aspy * h / MANIPULATOR_RESIZER_WIDTH, MANIPULATOR_RESIZER_WIDTH / - ((cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) ? cage->scale[0] : cage->scale[1])); + ((transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) ? scale[0] : scale[1])); /* corner manipulators */ glLineWidth(mpr->line_width + 3.0f); @@ -270,36 +267,44 @@ static int manipulator_rect_transform_get_cursor(wmManipulator *mpr) static int manipulator_rect_transform_test_select( bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) { - Cage2D *cage = (Cage2D *)mpr; const float mouse[2] = {event->mval[0], event->mval[1]}; //float matrot[2][2]; float point_local[2]; - float w = cage->w; - float h = cage->h; + float scale[2]; + RNA_float_get_array(mpr->ptr, "scale", scale); + float dims[2]; + RNA_float_get_array(mpr->ptr, "dimensions", dims); + float w = dims[0]; + float h = dims[1]; float half_w = w / 2.0f; float half_h = h / 2.0f; float aspx = 1.0f, aspy = 1.0f; + const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); + /* rotate mouse in relation to the center and relocate it */ sub_v2_v2v2(point_local, mouse, mpr->matrix[3]); point_local[0] -= mpr->matrix_offset[3][0]; point_local[1] -= mpr->matrix_offset[3][1]; //rotate_m2(matrot, -cage->transform.rotation); - if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) - mul_v2_fl(point_local, 1.0f / cage->scale[0]); + if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) { + mul_v2_fl(point_local, 1.0f / scale[0]); + } else { - point_local[0] /= cage->scale[0]; - point_local[1] /= cage->scale[0]; + point_local[0] /= scale[0]; + point_local[1] /= scale[0]; } - if (cage->w > cage->h) + if (dims[0] > dims[1]) { aspx = h / w; - else + } + else { aspy = w / h; - w = min_ff(aspx * w / MANIPULATOR_RESIZER_WIDTH, MANIPULATOR_RESIZER_WIDTH / cage->scale[0]); + } + w = min_ff(aspx * w / MANIPULATOR_RESIZER_WIDTH, MANIPULATOR_RESIZER_WIDTH / scale[0]); h = min_ff(aspy * h / MANIPULATOR_RESIZER_WIDTH, MANIPULATOR_RESIZER_WIDTH / - ((cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) ? cage->scale[0] : cage->scale[1])); + ((transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) ? scale[0] : scale[1])); rctf r; @@ -315,7 +320,9 @@ static int manipulator_rect_transform_test_select( return ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_TRANSLATE; /* if manipulator does not have a scale intersection, don't do it */ - if (cage->style & (ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE | ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM)) { + if (transform_flag & + (ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE | ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM)) + { r.xmin = -half_w; r.ymin = -half_h; r.xmax = -half_w + w; @@ -384,8 +391,8 @@ static bool manipulator_rect_transform_get_prop_value( RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value); } else if (STREQ(mpr_prop->idname, "scale")) { - Cage2D *cage = (Cage2D *)mpr; - if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) { + const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); + if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) { *value = RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop); } else { @@ -406,21 +413,19 @@ static bool manipulator_rect_transform_get_prop_value( static void manipulator_rect_transform_setup(wmManipulator *mpr) { - Cage2D *cage = (Cage2D *)mpr; - - cage->manipulator.flag |= WM_MANIPULATOR_DRAW_ACTIVE; - cage->scale[0] = cage->scale[1] = 1.0f; - cage->style = -1; + mpr->flag |= WM_MANIPULATOR_DRAW_ACTIVE; } static void manipulator_rect_transform_invoke( bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) { - Cage2D *cage = (Cage2D *)mpr; RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"); + float scale[2]; + RNA_float_get_array(mpr->ptr, "scale", scale); + copy_v2_v2(data->orig_offset, mpr->matrix_offset[3]); - copy_v2_v2(data->orig_scale, cage->scale); + copy_v2_v2(data->orig_scale, scale); data->orig_mouse[0] = event->mval[0]; data->orig_mouse[1] = event->mval[1]; @@ -432,7 +437,6 @@ static void manipulator_rect_transform_modal( bContext *C, wmManipulator *mpr, const wmEvent *event, const int UNUSED(flag)) { - Cage2D *cage = (Cage2D *)mpr; RectTransformInteraction *data = mpr->interaction_data; /* needed here as well in case clamping occurs */ const float orig_ofx = mpr->matrix_offset[3][0], orig_ofy = mpr->matrix_offset[3][1]; @@ -440,6 +444,13 @@ static void manipulator_rect_transform_modal( const float valuex = (event->mval[0] - data->orig_mouse[0]); const float valuey = (event->mval[1] - data->orig_mouse[1]); + const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); + + float dims[2]; + RNA_float_get_array(mpr->ptr, "dimensions", dims); + + float scale[2]; + RNA_float_get_array(mpr->ptr, "scale", scale); if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_TRANSLATE) { mpr->matrix_offset[3][0] = data->orig_offset[0] + valuex; @@ -447,54 +458,56 @@ static void manipulator_rect_transform_modal( } else if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_LEFT) { mpr->matrix_offset[3][0] = data->orig_offset[0] + valuex / 2.0; - cage->scale[0] = (cage->w * data->orig_scale[0] - valuex) / cage->w; + scale[0] = (dims[0] * data->orig_scale[0] - valuex) / dims[0]; } else if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEX_RIGHT) { mpr->matrix_offset[3][0] = data->orig_offset[0] + valuex / 2.0; - cage->scale[0] = (cage->w * data->orig_scale[0] + valuex) / cage->w; + scale[0] = (dims[0] * data->orig_scale[0] + valuex) / dims[0]; } else if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_DOWN) { mpr->matrix_offset[3][1] = data->orig_offset[1] + valuey / 2.0; - if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) { - cage->scale[0] = (cage->h * data->orig_scale[0] - valuey) / cage->h; + if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) { + scale[0] = (dims[1] * data->orig_scale[0] - valuey) / dims[1]; } else { - cage->scale[1] = (cage->h * data->orig_scale[1] - valuey) / cage->h; + scale[1] = (dims[1] * data->orig_scale[1] - valuey) / dims[1]; } } else if (mpr->highlight_part == ED_MANIPULATOR_RECT_TRANSFORM_INTERSECT_SCALEY_UP) { mpr->matrix_offset[3][1] = data->orig_offset[1] + valuey / 2.0; - if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) { - cage->scale[0] = (cage->h * data->orig_scale[0] + valuey) / cage->h; + if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) { + scale[0] = (dims[1] * data->orig_scale[0] + valuey) / dims[1]; } else { - cage->scale[1] = (cage->h * data->orig_scale[1] + valuey) / cage->h; + scale[1] = (dims[1] * data->orig_scale[1] + valuey) / dims[1]; } } /* clamping - make sure manipulator is at least 5 pixels wide */ - if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) { - if (cage->scale[0] < MANIPULATOR_RECT_MIN_WIDTH / cage->h || - cage->scale[0] < MANIPULATOR_RECT_MIN_WIDTH / cage->w) + if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) { + if (scale[0] < MANIPULATOR_RECT_MIN_WIDTH / dims[1] || + scale[0] < MANIPULATOR_RECT_MIN_WIDTH / dims[0]) { - cage->scale[0] = max_ff(MANIPULATOR_RECT_MIN_WIDTH / cage->h, MANIPULATOR_RECT_MIN_WIDTH / cage->w); + scale[0] = max_ff(MANIPULATOR_RECT_MIN_WIDTH / dims[1], MANIPULATOR_RECT_MIN_WIDTH / dims[0]); mpr->matrix_offset[3][0] = orig_ofx; mpr->matrix_offset[3][1] = orig_ofy; } } else { - if (cage->scale[0] < MANIPULATOR_RECT_MIN_WIDTH / cage->w) { - cage->scale[0] = MANIPULATOR_RECT_MIN_WIDTH / cage->w; + if (scale[0] < MANIPULATOR_RECT_MIN_WIDTH / dims[0]) { + scale[0] = MANIPULATOR_RECT_MIN_WIDTH / dims[0]; mpr->matrix_offset[3][0] = orig_ofx; } - if (cage->scale[1] < MANIPULATOR_RECT_MIN_WIDTH / cage->h) { - cage->scale[1] = MANIPULATOR_RECT_MIN_WIDTH / cage->h; + if (scale[1] < MANIPULATOR_RECT_MIN_WIDTH / dims[1]) { + scale[1] = MANIPULATOR_RECT_MIN_WIDTH / dims[1]; mpr->matrix_offset[3][1] = orig_ofy; } } + RNA_float_set_array(mpr->ptr, "scale", scale); + wmManipulatorProperty *mpr_prop; mpr_prop = WM_manipulator_property_find(mpr, "offset"); @@ -505,11 +518,11 @@ static void manipulator_rect_transform_modal( mpr_prop = WM_manipulator_property_find(mpr, "scale"); if (mpr_prop->prop != NULL) { - if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) { - RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, cage->scale[0]); + if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) { + RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, scale[0]); } else { - RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, cage->scale); + RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, scale); } RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); } @@ -520,13 +533,13 @@ static void manipulator_rect_transform_modal( static void manipulator_rect_transform_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) { - Cage2D *cage = (Cage2D *)mpr; - if (STREQ(mpr_prop->idname, "offset")) { manipulator_rect_transform_get_prop_value(mpr, mpr_prop, mpr->matrix_offset[3]); } else if (STREQ(mpr_prop->idname, "scale")) { - manipulator_rect_transform_get_prop_value(mpr, mpr_prop, cage->scale); + float scale[2]; + RNA_float_get_array(mpr->ptr, "scale", scale); + manipulator_rect_transform_get_prop_value(mpr, mpr_prop, scale); } else { BLI_assert(0); @@ -535,7 +548,6 @@ static void manipulator_rect_transform_property_update(wmManipulator *mpr, wmMan static void manipulator_rect_transform_exit(bContext *C, wmManipulator *mpr, const bool cancel) { - Cage2D *cage = (Cage2D *)mpr; RectTransformInteraction *data = mpr->interaction_data; if (!cancel) @@ -552,7 +564,8 @@ static void manipulator_rect_transform_exit(bContext *C, wmManipulator *mpr, con mpr_prop = WM_manipulator_property_find(mpr, "scale"); if (mpr_prop->prop != NULL) { - if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) { + const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); + if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) { RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, data->orig_scale[0]); } else { @@ -568,23 +581,6 @@ static void manipulator_rect_transform_exit(bContext *C, wmManipulator *mpr, con * * \{ */ -#define ASSERT_TYPE_CHECK(mpr) BLI_assert(mpr->type->draw == manipulator_rect_transform_draw) - -void ED_manipulator_cage2d_transform_set_style(wmManipulator *mpr, int style) -{ - ASSERT_TYPE_CHECK(mpr); - Cage2D *cage = (Cage2D *)mpr; - cage->style = style; -} - -void ED_manipulator_cage2d_transform_set_dims(wmManipulator *mpr, const float width, const float height) -{ - ASSERT_TYPE_CHECK(mpr); - Cage2D *cage = (Cage2D *)mpr; - cage->w = width; - cage->h = height; -} - static void MANIPULATOR_WT_cage_2d(wmManipulatorType *wt) { /* identifiers */ @@ -600,7 +596,20 @@ static void MANIPULATOR_WT_cage_2d(wmManipulatorType *wt) wt->exit = manipulator_rect_transform_exit; wt->cursor_get = manipulator_rect_transform_get_cursor; - wt->struct_size = sizeof(Cage2D); + wt->struct_size = sizeof(wmManipulator); + + /* rna */ + static EnumPropertyItem rna_enum_transform[] = { + {ED_MANIPULATOR_RECT_TRANSFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, + {ED_MANIPULATOR_RECT_TRANSFORM_FLAG_ROTATE, "ROTATE", 0, "Rotate", ""}, + {ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""}, + {ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""}, + {0, NULL, 0, NULL, NULL} + }; + static float scale_default[2] = {1.0f, 1.0f}; + RNA_def_float_vector(wt->srna, "scale", 2, scale_default, 0, FLT_MAX, "Scale", "", 0.0f, FLT_MAX); + RNA_def_float_vector(wt->srna, "dimensions", 2, NULL, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); + RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); } void ED_manipulatortypes_cage_2d(void) diff --git a/source/blender/editors/manipulator_library/dial3d_manipulator.c b/source/blender/editors/manipulator_library/dial3d_manipulator.c index 753cd794fe1..79ad54e44eb 100644 --- a/source/blender/editors/manipulator_library/dial3d_manipulator.c +++ b/source/blender/editors/manipulator_library/dial3d_manipulator.c @@ -58,6 +58,9 @@ #include "MEM_guardedalloc.h" +#include "RNA_access.h" +#include "RNA_define.h" + #include "WM_api.h" #include "WM_types.h" @@ -70,19 +73,6 @@ static void manipulator_dial_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int flag); -typedef struct DialManipulator { - wmManipulator manipulator; - int style; - - /* Optional, for drawing the start of the pie based on on a vector - * instead of the initial mouse location. Only for display. */ - uint use_start_y_axis : 1; - - /* Show 2x helper angles (a mirrored segment). - * Use when the dial represents a plane. */ - uint use_double_helper : 1; -} DialManipulator; - typedef struct DialInteraction { float init_mval[2]; @@ -105,30 +95,31 @@ typedef struct DialInteraction { #define DIAL_RESOLUTION 32 -static void dial_calc_matrix(const DialManipulator *dial, float mat[4][4]) +static void dial_calc_matrix(const wmManipulator *mpr, float mat[4][4]) { float rot[3][3]; const float up[3] = {0.0f, 0.0f, 1.0f}; - rotation_between_vecs_to_mat3(rot, up, dial->manipulator.matrix[2]); + rotation_between_vecs_to_mat3(rot, up, mpr->matrix[2]); copy_m4_m3(mat, rot); - copy_v3_v3(mat[3], dial->manipulator.matrix[3]); - mul_mat3_m4_fl(mat, dial->manipulator.scale); + copy_v3_v3(mat[3], mpr->matrix[3]); + mul_mat3_m4_fl(mat, mpr->scale); } /* -------------------------------------------------------------------- */ static void dial_geom_draw( - const DialManipulator *dial, const float col[4], const bool select, + const wmManipulator *mpr, const float col[4], const bool select, float axis_modal_mat[4][4], float clip_plane[4]) { #ifdef USE_MANIPULATOR_CUSTOM_DIAL UNUSED_VARS(dial, col, axis_modal_mat, clip_plane); wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_dial, select); #else - const bool filled = (dial->style == ED_MANIPULATOR_DIAL_STYLE_RING_FILLED); + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const bool filled = (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL) != 0; - glLineWidth(dial->manipulator.line_width); + glLineWidth(mpr->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -185,9 +176,9 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[ } static void dial_ghostarc_draw( - const DialManipulator *dial, const float angle_ofs, const float angle_delta, const float color[4]) + const wmManipulator *mpr, const float angle_ofs, const float angle_delta, const float color[4]) { - const float width_inner = DIAL_WIDTH - dial->manipulator.line_width * 0.5f / U.manipulator_size; + const float width_inner = DIAL_WIDTH - mpr->line_width * 0.5f / U.manipulator_size; Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -199,23 +190,24 @@ static void dial_ghostarc_draw( } static void dial_ghostarc_get_angles( - const DialManipulator *dial, const wmEvent *event, + const wmManipulator *mpr, + const wmEvent *event, const ARegion *ar, const View3D *v3d, float mat[4][4], const float co_outer[3], float *r_start, float *r_delta) { - DialInteraction *inter = dial->manipulator.interaction_data; + DialInteraction *inter = mpr->interaction_data; const RegionView3D *rv3d = ar->regiondata; const float mval[2] = {event->x - ar->winrct.xmin, event->y - ar->winrct.ymin}; /* we might need to invert the direction of the angles */ float view_vec[3], axis_vec[3]; - ED_view3d_global_to_vector(rv3d, dial->manipulator.matrix[3], view_vec); - normalize_v3_v3(axis_vec, dial->manipulator.matrix[2]); + ED_view3d_global_to_vector(rv3d, mpr->matrix[3], view_vec); + normalize_v3_v3(axis_vec, mpr->matrix[2]); float proj_outer_rel[3]; mul_v3_project_m4_v3(proj_outer_rel, mat, co_outer); - sub_v3_v3(proj_outer_rel, dial->manipulator.matrix[3]); + sub_v3_v3(proj_outer_rel, mpr->matrix[3]); float proj_mval_new_rel[3]; float proj_mval_init_rel[3]; @@ -223,7 +215,7 @@ static void dial_ghostarc_get_angles( float ray_co[3], ray_no[3]; float ray_lambda; - plane_from_point_normal_v3(dial_plane, dial->manipulator.matrix[3], axis_vec); + plane_from_point_normal_v3(dial_plane, mpr->matrix[3], axis_vec); if (!ED_view3d_win_to_ray(ar, v3d, inter->init_mval, ray_co, ray_no, false) || !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false)) @@ -231,7 +223,7 @@ static void dial_ghostarc_get_angles( goto fail; } madd_v3_v3v3fl(proj_mval_init_rel, ray_co, ray_no, ray_lambda); - sub_v3_v3(proj_mval_init_rel, dial->manipulator.matrix[3]); + sub_v3_v3(proj_mval_init_rel, mpr->matrix[3]); if (!ED_view3d_win_to_ray(ar, v3d, mval, ray_co, ray_no, false) || !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false)) @@ -239,10 +231,14 @@ static void dial_ghostarc_get_angles( goto fail; } madd_v3_v3v3fl(proj_mval_new_rel, ray_co, ray_no, ray_lambda); - sub_v3_v3(proj_mval_new_rel, dial->manipulator.matrix[3]); + sub_v3_v3(proj_mval_new_rel, mpr->matrix[3]); + + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); /* Start direction from mouse or set by user */ - const float *proj_init_rel = dial->use_start_y_axis ? dial->manipulator.matrix[1] : proj_mval_init_rel; + const float *proj_init_rel = + (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y) ? + mpr->matrix[1] : proj_mval_init_rel; /* return angles */ const float start = angle_wrap_rad(angle_signed_on_axis_v3v3_v3(proj_outer_rel, proj_init_rel, axis_vec)); @@ -272,7 +268,7 @@ fail: } static void dial_draw_intern( - const bContext *C, DialManipulator *dial, + const bContext *C, wmManipulator *mpr, const bool select, const bool highlight, float clip_plane[4]) { float mat[4][4]; @@ -280,26 +276,26 @@ static void dial_draw_intern( BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D); - manipulator_color_get(&dial->manipulator, highlight, col); + manipulator_color_get(mpr, highlight, col); - dial_calc_matrix(dial, mat); + dial_calc_matrix(mpr, mat); gpuPushMatrix(); gpuMultMatrix(mat); - gpuMultMatrix(dial->manipulator.matrix_offset); + gpuMultMatrix(mpr->matrix_offset); /* draw rotation indicator arc first */ - if ((dial->manipulator.flag & WM_MANIPULATOR_DRAW_VALUE) && - (dial->manipulator.state & WM_MANIPULATOR_STATE_ACTIVE)) + if ((mpr->flag & WM_MANIPULATOR_DRAW_VALUE) && + (mpr->state & WM_MANIPULATOR_STATE_ACTIVE)) { const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */ - DialInteraction *inter = dial->manipulator.interaction_data; + DialInteraction *inter = mpr->interaction_data; /* XXX, View3D rotation manipulator doesn't call modal. */ - if (dial->manipulator.properties.first == NULL) { + if (mpr->properties_edit.first == NULL) { wmWindow *win = CTX_wm_window(C); - manipulator_dial_modal((bContext *)C, &dial->manipulator, win->eventstate, 0); + manipulator_dial_modal((bContext *)C, mpr, win->eventstate, 0); } float angle_ofs = inter->output.angle_ofs; @@ -307,12 +303,16 @@ static void dial_draw_intern( /* draw! */ for (int i = 0; i < 2; i++) { - dial_ghostarc_draw(dial, angle_ofs, angle_delta, (const float [4]){0.8f, 0.8f, 0.8f, 0.4f}); + dial_ghostarc_draw(mpr, angle_ofs, angle_delta, (const float [4]){0.8f, 0.8f, 0.8f, 0.4f}); dial_ghostarc_draw_helpline(angle_ofs, co_outer, col); /* starting position */ dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, col); /* starting position + current value */ - if (dial->use_double_helper == false) { - break; + + if (i == 0) { + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + if ((draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR) == 0) { + break; + } } angle_ofs += M_PI; @@ -320,16 +320,16 @@ static void dial_draw_intern( } /* draw actual dial manipulator */ - dial_geom_draw(dial, col, select, mat, clip_plane); + dial_geom_draw(mpr, col, select, mat, clip_plane); gpuPopMatrix(); } static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr, int selectionbase) { - DialManipulator *dial = (DialManipulator *)mpr; float clip_plane_buf[4]; - float *clip_plane = (dial->style == ED_MANIPULATOR_DIAL_STYLE_RING_CLIPPED) ? clip_plane_buf : NULL; + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + float *clip_plane = (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP) ? clip_plane_buf : NULL; /* enable clipping if needed */ if (clip_plane) { @@ -342,7 +342,7 @@ static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr, } GPU_select_load_id(selectionbase); - dial_draw_intern(C, dial, true, false, clip_plane); + dial_draw_intern(C, mpr, true, false, clip_plane); if (clip_plane) { glDisable(GL_CLIP_DISTANCE0); @@ -351,13 +351,11 @@ static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr, static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr) { - DialManipulator *dial = (DialManipulator *)mpr; const bool active = mpr->state & WM_MANIPULATOR_STATE_ACTIVE; const bool highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; 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); + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + float *clip_plane = (!active && (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP)) ? clip_plane_buf : NULL; /* enable clipping if needed */ if (clip_plane) { @@ -366,13 +364,13 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr) copy_v3_v3(clip_plane, rv3d->viewinv[2]); clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix[3]); - clip_plane[3] -= 0.02 * dial->manipulator.scale; + clip_plane[3] -= 0.02 * mpr->scale; glEnable(GL_CLIP_DISTANCE0); } glEnable(GL_BLEND); - dial_draw_intern(C, dial, false, highlight, clip_plane); + dial_draw_intern(C, mpr, false, highlight, clip_plane); glDisable(GL_BLEND); if (clip_plane) { @@ -382,17 +380,17 @@ 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)) { - DialManipulator *dial = (DialManipulator *)mpr; 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; - float mat[4][4]; + float matrix[4][4]; - dial_calc_matrix(dial, mat); + dial_calc_matrix(mpr, matrix); - dial_ghostarc_get_angles(dial, event, CTX_wm_region(C), CTX_wm_view3d(C), mat, co_outer, &angle_ofs, &angle_delta); + dial_ghostarc_get_angles( + mpr, event, CTX_wm_region(C), CTX_wm_view3d(C), matrix, co_outer, &angle_ofs, &angle_delta); - DialInteraction *inter = dial->manipulator.interaction_data; + DialInteraction *inter = mpr->interaction_data; inter->output.angle_delta = angle_delta; inter->output.angle_ofs = angle_ofs; @@ -407,13 +405,10 @@ 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->manipulator.matrix[2], dir_default); + copy_v3_v3(mpr->matrix[2], dir_default); } static void manipulator_dial_invoke( @@ -439,29 +434,7 @@ static void manipulator_dial_invoke( #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; -} - -void ED_manipulator_dial3d_set_use_start_y_axis(wmManipulator *mpr, const bool enabled) -{ - ASSERT_TYPE_CHECK(mpr); - DialManipulator *dial = (DialManipulator *)mpr; - dial->use_start_y_axis = enabled; -} - -void ED_manipulator_dial3d_set_use_double_helper(wmManipulator *mpr, const bool enabled) -{ - ASSERT_TYPE_CHECK(mpr); - DialManipulator *dial = (DialManipulator *)mpr; - - dial->use_double_helper = enabled; -} - -static void MANIPULATOR_WT_dial_3d_3d(wmManipulatorType *wt) +static void MANIPULATOR_WT_dial_3d(wmManipulatorType *wt) { /* identifiers */ wt->idname = "MANIPULATOR_WT_dial_3d"; @@ -473,12 +446,22 @@ static void MANIPULATOR_WT_dial_3d_3d(wmManipulatorType *wt) wt->invoke = manipulator_dial_invoke; wt->modal = manipulator_dial_modal; - wt->struct_size = sizeof(DialManipulator); + wt->struct_size = sizeof(wmManipulator); + + /* rna */ + static EnumPropertyItem rna_enum_draw_options[] = { + {ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP, "CLIP", 0, "Clipped", ""}, + {ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""}, + {ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR, "ANGLE_MIRROR", 0, "Angle Mirror", ""}, + {ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""}, + {0, NULL, 0, NULL, NULL} + }; + RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); } void ED_manipulatortypes_dial_3d(void) { - WM_manipulatortype_append(MANIPULATOR_WT_dial_3d_3d); + WM_manipulatortype_append(MANIPULATOR_WT_dial_3d); } /** \} */ // Dial Manipulator API diff --git a/source/blender/editors/manipulator_library/grab3d_manipulator.c b/source/blender/editors/manipulator_library/grab3d_manipulator.c index 995ee4e97c4..2a938bcb25a 100644 --- a/source/blender/editors/manipulator_library/grab3d_manipulator.c +++ b/source/blender/editors/manipulator_library/grab3d_manipulator.c @@ -53,6 +53,9 @@ #include "MEM_guardedalloc.h" +#include "RNA_access.h" +#include "RNA_define.h" + #include "WM_api.h" #include "WM_types.h" @@ -62,11 +65,6 @@ static void manipulator_grab_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int flag); -typedef struct GrabManipulator { - wmManipulator manipulator; - int style; -} GrabManipulator; - typedef struct GrabInteraction { float init_mval[2]; @@ -86,15 +84,16 @@ typedef struct GrabInteraction { /* -------------------------------------------------------------------- */ static void grab_geom_draw( - const GrabManipulator *grab3d, const float col[4], const bool select) + const wmManipulator *mpr, const float col[4], const bool select) { #ifdef USE_MANIPULATOR_CUSTOM_DIAL UNUSED_VARS(grab3d, col, axis_modal_mat); wm_manipulator_geometryinfo_draw(&wm_manipulator_geom_data_grab3d, select); #else - const bool filled = (grab3d->style == ED_MANIPULATOR_DIAL_STYLE_RING_FILLED); + const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const bool filled = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL) != 0; - glLineWidth(grab3d->manipulator.line_width); + glLineWidth(mpr->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -117,10 +116,10 @@ static void grab_geom_draw( } static void grab3d_get_translate( - const GrabManipulator *grab, const wmEvent *event, const ARegion *ar, + const wmManipulator *mpr, const wmEvent *event, const ARegion *ar, float co_delta[3]) { - GrabInteraction *inter = grab->manipulator.interaction_data; + GrabInteraction *inter = mpr->interaction_data; const float mval_delta[2] = { event->mval[0] - inter->init_mval[0], event->mval[1] - inter->init_mval[1], @@ -134,7 +133,7 @@ static void grab3d_get_translate( } static void grab3d_draw_intern( - const bContext *C, GrabManipulator *grab, + const bContext *C, wmManipulator *mpr, const bool select, const bool highlight) { float mat[4][4]; @@ -142,29 +141,29 @@ static void grab3d_draw_intern( BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D); - manipulator_color_get(&grab->manipulator, highlight, col); + manipulator_color_get(mpr, highlight, col); - copy_m4_m4(mat, grab->manipulator.matrix); - mul_mat3_m4_fl(mat, grab->manipulator.scale); + copy_m4_m4(mat, mpr->matrix); + mul_mat3_m4_fl(mat, mpr->scale); gpuPushMatrix(); - if (grab->manipulator.interaction_data) { - GrabInteraction *inter = grab->manipulator.interaction_data; + if (mpr->interaction_data) { + GrabInteraction *inter = mpr->interaction_data; gpuTranslate3fv(inter->output.co_ofs); } gpuMultMatrix(mat); - gpuMultMatrix(grab->manipulator.matrix_offset); + gpuMultMatrix(mpr->matrix_offset); glEnable(GL_BLEND); - grab_geom_draw(grab, col, select); + grab_geom_draw(mpr, col, select); glDisable(GL_BLEND); gpuPopMatrix(); - if (grab->manipulator.interaction_data) { + if (mpr->interaction_data) { gpuPushMatrix(); gpuMultMatrix(mat); - gpuMultMatrix(grab->manipulator.matrix_offset); + gpuMultMatrix(mpr->matrix_offset); glEnable(GL_BLEND); - grab_geom_draw(grab, (const float [4]){0.5f, 0.5f, 0.5f, 0.5f}, select); + grab_geom_draw(mpr, (const float [4]){0.5f, 0.5f, 0.5f, 0.5f}, select); glDisable(GL_BLEND); gpuPopMatrix(); } @@ -172,34 +171,27 @@ static void grab3d_draw_intern( static void manipulator_grab_draw_select(const bContext *C, wmManipulator *mpr, int selectionbase) { - GrabManipulator *grab = (GrabManipulator *)mpr; - GPU_select_load_id(selectionbase); - grab3d_draw_intern(C, grab, true, false); + grab3d_draw_intern(C, mpr, true, false); } static void manipulator_grab_draw(const bContext *C, wmManipulator *mpr) { - GrabManipulator *grab = (GrabManipulator *)mpr; const bool active = mpr->state & WM_MANIPULATOR_STATE_ACTIVE; const bool highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; - BLI_assert(grab->style != -1); - (void)active; glEnable(GL_BLEND); - grab3d_draw_intern(C, grab, false, highlight); + grab3d_draw_intern(C, mpr, false, highlight); glDisable(GL_BLEND); } static void manipulator_grab_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int UNUSED(flag)) { - GrabManipulator *grab = (GrabManipulator *)mpr; + GrabInteraction *inter = mpr->interaction_data; - GrabInteraction *inter = grab->manipulator.interaction_data; - - grab3d_get_translate(grab, event, CTX_wm_region(C), inter->output.co_ofs); + grab3d_get_translate(mpr, event, CTX_wm_region(C), inter->output.co_ofs); add_v3_v3v3(inter->output.co_final, inter->init_prop_co, inter->output.co_ofs); @@ -210,13 +202,6 @@ static void manipulator_grab_modal(bContext *C, wmManipulator *mpr, const wmEven } } -static void manipulator_grab_setup(wmManipulator *mpr) -{ - GrabManipulator *grab = (GrabManipulator *)mpr; - - grab->style = -1; -} - static void manipulator_grab_invoke( bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) { @@ -240,13 +225,6 @@ static void manipulator_grab_invoke( #define ASSERT_TYPE_CHECK(mpr) BLI_assert(mpr->type->draw == manipulator_grab_draw) -void ED_manipulator_grab3d_set_style(wmManipulator *mpr, int style) -{ - ASSERT_TYPE_CHECK(mpr); - GrabManipulator *grab = (GrabManipulator *)mpr; - grab->style = style; -} - static void MANIPULATOR_WT_grab_3d(wmManipulatorType *wt) { /* identifiers */ @@ -255,11 +233,23 @@ static void MANIPULATOR_WT_grab_3d(wmManipulatorType *wt) /* api callbacks */ wt->draw = manipulator_grab_draw; wt->draw_select = manipulator_grab_draw_select; - wt->setup = manipulator_grab_setup; wt->invoke = manipulator_grab_invoke; wt->modal = manipulator_grab_modal; - wt->struct_size = sizeof(GrabManipulator); + wt->struct_size = sizeof(wmManipulator); + + /* rna */ + static EnumPropertyItem rna_enum_draw_style[] = { + {ED_MANIPULATOR_GRAB_STYLE_RING, "RING", 0, "Ring", ""}, + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem rna_enum_draw_options[] = { + {ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""}, + {0, NULL, 0, NULL, NULL} + }; + + RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_GRAB_STYLE_RING, "Draw Style", ""); + RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); } void ED_manipulatortypes_grab_3d(void) diff --git a/source/blender/editors/manipulator_library/primitive3d_manipulator.c b/source/blender/editors/manipulator_library/primitive3d_manipulator.c index 75151830109..8f3e2ce1db7 100644 --- a/source/blender/editors/manipulator_library/primitive3d_manipulator.c +++ b/source/blender/editors/manipulator_library/primitive3d_manipulator.c @@ -43,6 +43,9 @@ #include "MEM_guardedalloc.h" +#include "RNA_access.h" +#include "RNA_define.h" + #include "WM_api.h" #include "WM_types.h" @@ -51,12 +54,6 @@ /* own includes */ #include "manipulator_library_intern.h" -typedef struct PrimitiveManipulator { - wmManipulator manipulator; - int style; -} PrimitiveManipulator; - - static float verts_plane[4][3] = { {-1, -1, 0}, { 1, -1, 0}, @@ -68,12 +65,12 @@ static float verts_plane[4][3] = { /* -------------------------------------------------------------------- */ static void manipulator_primitive_draw_geom( - const float col_inner[4], const float col_outer[4], const int style) + const float col_inner[4], const float col_outer[4], const int draw_style) { float (*verts)[3]; uint vert_count = 0; - if (style == ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE) { + if (draw_style == ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE) { verts = verts_plane; vert_count = ARRAY_SIZE(verts_plane); } @@ -88,33 +85,32 @@ static void manipulator_primitive_draw_geom( } static void manipulator_primitive_draw_intern( - PrimitiveManipulator *prim, const bool UNUSED(select), + wmManipulator *mpr, const bool UNUSED(select), const bool highlight) { float col_inner[4], col_outer[4]; float mat[4][4]; + const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); - BLI_assert(prim->style != -1); - - manipulator_color_get(&prim->manipulator, highlight, col_outer); + manipulator_color_get(mpr, highlight, col_outer); copy_v4_v4(col_inner, col_outer); col_inner[3] *= 0.5f; - copy_m4_m4(mat, prim->manipulator.matrix); - mul_mat3_m4_fl(mat, prim->manipulator.scale); + copy_m4_m4(mat, mpr->matrix); + mul_mat3_m4_fl(mat, mpr->scale); gpuPushMatrix(); gpuMultMatrix(mat); glEnable(GL_BLEND); - gpuMultMatrix(prim->manipulator.matrix_offset); - manipulator_primitive_draw_geom(col_inner, col_outer, prim->style); + gpuMultMatrix(mpr->matrix_offset); + manipulator_primitive_draw_geom(col_inner, col_outer, draw_style); glDisable(GL_BLEND); gpuPopMatrix(); - if (prim->manipulator.interaction_data) { - ManipulatorInteraction *inter = prim->manipulator.interaction_data; + if (mpr->interaction_data) { + ManipulatorInteraction *inter = mpr->interaction_data; copy_v4_fl(col_inner, 0.5f); copy_v3_fl(col_outer, 0.5f); @@ -127,8 +123,8 @@ static void manipulator_primitive_draw_intern( gpuMultMatrix(mat); glEnable(GL_BLEND); - gpuMultMatrix(prim->manipulator.matrix_offset); - manipulator_primitive_draw_geom(col_inner, col_outer, prim->style); + gpuMultMatrix(mpr->matrix_offset); + manipulator_primitive_draw_geom(col_inner, col_outer, draw_style); glDisable(GL_BLEND); gpuPopMatrix(); @@ -140,22 +136,19 @@ static void manipulator_primitive_draw_select( int selectionbase) { GPU_select_load_id(selectionbase); - manipulator_primitive_draw_intern((PrimitiveManipulator *)mpr, true, false); + manipulator_primitive_draw_intern(mpr, true, false); } static void manipulator_primitive_draw(const bContext *UNUSED(C), wmManipulator *mpr) { manipulator_primitive_draw_intern( - (PrimitiveManipulator *)mpr, false, - (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT)); + mpr, false, + (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT)); } static void manipulator_primitive_setup(wmManipulator *mpr) { - PrimitiveManipulator *prim = (PrimitiveManipulator *)mpr; - - prim->manipulator.flag |= WM_MANIPULATOR_DRAW_ACTIVE; - prim->style = -1; + mpr->flag |= WM_MANIPULATOR_DRAW_ACTIVE; } static void manipulator_primitive_invoke( @@ -174,15 +167,6 @@ static void manipulator_primitive_invoke( * * \{ */ -#define ASSERT_TYPE_CHECK(mpr) BLI_assert(mpr->type->draw == manipulator_primitive_draw) - -void ED_manipulator_primitive3d_set_style(struct wmManipulator *mpr, int style) -{ - ASSERT_TYPE_CHECK(mpr); - PrimitiveManipulator *prim = (PrimitiveManipulator *)mpr; - prim->style = style; -} - static void MANIPULATOR_WT_primitive_3d(wmManipulatorType *wt) { /* identifiers */ @@ -194,7 +178,13 @@ static void MANIPULATOR_WT_primitive_3d(wmManipulatorType *wt) wt->setup = manipulator_primitive_setup; wt->invoke = manipulator_primitive_invoke; - wt->struct_size = sizeof(PrimitiveManipulator); + wt->struct_size = sizeof(wmManipulator); + + static EnumPropertyItem rna_enum_draw_style[] = { + {ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE, "PLANE", 0, "Plane", ""}, + {0, NULL, 0, NULL, NULL} + }; + RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE, "Draw Style", ""); } void ED_manipulatortypes_primitive_3d(void) diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index 7c55f0033a3..34644bb7fd6 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -448,8 +448,9 @@ static void manipulator_mesh_bisect_update_from_op(ManipulatorGroup *man) cross_v3_v3v3(plane_no_cross, plane_no, man->data.rotate_axis); WM_manipulator_set_matrix_offset_rotation_from_yz_axis(man->rotate_c, plane_no_cross, man->data.rotate_axis); - ED_manipulator_dial3d_set_use_start_y_axis(man->rotate_c, true); - ED_manipulator_dial3d_set_use_double_helper(man->rotate_c, true); + RNA_enum_set(man->rotate_c->ptr, "draw_options", + ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR | + ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y); } } @@ -606,13 +607,12 @@ static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", true); const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true); - man->translate_z = WM_manipulator_new_ptr(wt_arrow, mgroup, "translate_z"); - man->translate_c = WM_manipulator_new_ptr(wt_grab, mgroup, "translate_c"); - man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, "rotate_c"); + man->translate_z = WM_manipulator_new_ptr(wt_arrow, mgroup, "translate_z", NULL); + man->translate_c = WM_manipulator_new_ptr(wt_grab, mgroup, "translate_c", NULL); + man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, "rotate_c", NULL); - ED_manipulator_arrow3d_set_style(man->translate_z, ED_MANIPULATOR_ARROW_STYLE_NORMAL); - ED_manipulator_grab3d_set_style(man->translate_c, ED_MANIPULATOR_GRAB_STYLE_RING); - ED_manipulator_dial3d_set_style(man->rotate_c, ED_MANIPULATOR_DIAL_STYLE_RING); + RNA_enum_set(man->translate_z->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_NORMAL); + RNA_enum_set(man->translate_c->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING); WM_manipulator_set_flag(man->translate_c, WM_MANIPULATOR_DRAW_VALUE, true); WM_manipulator_set_flag(man->rotate_c, WM_MANIPULATOR_DRAW_VALUE, true); diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 4a7ef86635a..cfeff6a65af 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -881,8 +881,10 @@ static void manipulator_mesh_spin_update_from_op(ManipulatorSpinGroup *man) WM_manipulator_set_matrix_rotation_from_yz_axis(man->rotate_c, man->data.rotate_axis, plane_no); /* show the axis instead of mouse cursor */ - ED_manipulator_dial3d_set_use_start_y_axis(man->rotate_c, true); - ED_manipulator_dial3d_set_use_double_helper(man->rotate_c, true); + RNA_enum_set(man->rotate_c->ptr, "draw_options", + ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR | + ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y); + } } @@ -1062,15 +1064,13 @@ static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *m const wmManipulatorType *wt_grab = WM_manipulatortype_find("MANIPULATOR_WT_grab_3d", true); const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true); - man->translate_z = WM_manipulator_new_ptr(wt_arrow, mgroup, "translate_z"); - man->translate_c = WM_manipulator_new_ptr(wt_grab, mgroup, "translate_c"); - man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, "rotate_c"); - man->angle_z = WM_manipulator_new_ptr(wt_dial, mgroup, "angle_z"); + man->translate_z = WM_manipulator_new_ptr(wt_arrow, mgroup, "translate_z", NULL); + man->translate_c = WM_manipulator_new_ptr(wt_grab, mgroup, "translate_c", NULL); + man->rotate_c = WM_manipulator_new_ptr(wt_dial, mgroup, "rotate_c", NULL); + man->angle_z = WM_manipulator_new_ptr(wt_dial, mgroup, "angle_z", NULL); - ED_manipulator_arrow3d_set_style(man->translate_z, ED_MANIPULATOR_ARROW_STYLE_NORMAL); - ED_manipulator_grab3d_set_style(man->translate_c, ED_MANIPULATOR_GRAB_STYLE_RING); - ED_manipulator_dial3d_set_style(man->rotate_c, ED_MANIPULATOR_DIAL_STYLE_RING); - ED_manipulator_dial3d_set_style(man->angle_z, ED_MANIPULATOR_DIAL_STYLE_RING); + RNA_enum_set(man->translate_z->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_NORMAL); + RNA_enum_set(man->translate_c->ptr, "draw_style", ED_MANIPULATOR_GRAB_STYLE_RING); WM_manipulator_set_flag(man->translate_c, WM_MANIPULATOR_DRAW_VALUE, true); WM_manipulator_set_flag(man->rotate_c, WM_MANIPULATOR_DRAW_VALUE, true); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index c882b1b093e..5eb51667988 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1520,8 +1520,9 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) /* default region handlers */ ed_default_handlers(wm, sa, &ar->handlers, ar->type->keymapflag); /* own handlers */ - if (ar->type->init) + if (ar->type->init) { ar->type->init(wm, ar); + } } else { /* prevent uiblocks to run */ diff --git a/source/blender/editors/space_node/node_manipulators.c b/source/blender/editors/space_node/node_manipulators.c index f1369fae94e..e3f699cabdf 100644 --- a/source/blender/editors/space_node/node_manipulators.c +++ b/source/blender/editors/space_node/node_manipulators.c @@ -63,11 +63,10 @@ static void WIDGETGROUP_node_transform_setup(const bContext *UNUSED(C), wmManipu { wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); - wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, "backdrop_cage"); + wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_cage_2d", mgroup, "backdrop_cage", NULL); - ED_manipulator_cage2d_transform_set_style( - wwrapper->manipulator, - ED_MANIPULATOR_RECT_TRANSFORM_STYLE_TRANSLATE | ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM); + RNA_enum_set(wwrapper->manipulator->ptr, "transform", + ED_MANIPULATOR_RECT_TRANSFORM_FLAG_TRANSLATE | ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM); mgroup->customdata = wwrapper; } @@ -84,10 +83,12 @@ static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorG ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (ibuf) { - const float w = (ibuf->x > 0) ? ibuf->x : 64.0f; - const float h = (ibuf->y > 0) ? ibuf->y : 64.0f; + const float dims[2] = { + (ibuf->x > 0) ? ibuf->x : 64.0f, + (ibuf->y > 0) ? ibuf->y : 64.0f, + }; - ED_manipulator_cage2d_transform_set_dims(cage, w, h); + RNA_float_set_array(cage->ptr, "dimensions", dims); WM_manipulator_set_matrix_location(cage, origin); WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, false); diff --git a/source/blender/editors/space_view3d/view3d_manipulators.c b/source/blender/editors/space_view3d/view3d_manipulators.c index 7119ca80581..907fe91009a 100644 --- a/source/blender/editors/space_view3d/view3d_manipulators.c +++ b/source/blender/editors/space_view3d/view3d_manipulators.c @@ -78,8 +78,8 @@ static void WIDGETGROUP_lamp_setup(const bContext *UNUSED(C), wmManipulatorGroup wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); - wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, propname); - ED_manipulator_arrow3d_set_style(wwrapper->manipulator, ED_MANIPULATOR_ARROW_STYLE_INVERTED); + wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, propname, NULL); + RNA_enum_set(wwrapper->manipulator->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_INVERTED); mgroup->customdata = wwrapper; @@ -184,8 +184,8 @@ static void WIDGETGROUP_camera_setup(const bContext *C, wmManipulatorGroup *mgro const float color[4] = {1.0f, 0.3f, 0.0f, 1.0f}; const float color_hi[4] = {1.0f, 0.3f, 0.0f, 1.0f}; - camgroup->dop_dist = WM_manipulator_new_ptr(wt_arrow, mgroup, "dof_distance"); - ED_manipulator_arrow3d_set_style(camgroup->dop_dist, ED_MANIPULATOR_ARROW_STYLE_CROSS); + camgroup->dop_dist = WM_manipulator_new_ptr(wt_arrow, mgroup, "dof_distance", NULL); + RNA_enum_set(camgroup->dop_dist->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CROSS); WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_DRAW_HOVER, true); WM_manipulator_set_color(camgroup->dop_dist, color); WM_manipulator_set_color_highlight(camgroup->dop_dist, color_hi); @@ -197,17 +197,18 @@ static void WIDGETGROUP_camera_setup(const bContext *C, wmManipulatorGroup *mgro const float color[4] = {1.0f, 1.0, 0.27f, 0.5f}; const float color_hi[4] = {1.0f, 1.0, 0.27f, 1.0f}; - camgroup->focal_len = WM_manipulator_new_ptr(wt_arrow, mgroup, "focal_len"); - ED_manipulator_arrow3d_set_style( - camgroup->focal_len, (ED_MANIPULATOR_ARROW_STYLE_CONE | ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED)); + camgroup->focal_len = WM_manipulator_new_ptr(wt_arrow, mgroup, "focal_len", NULL); + RNA_enum_set(camgroup->focal_len->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE); + RNA_enum_set(camgroup->focal_len->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED); WM_manipulator_set_color(camgroup->focal_len, color); WM_manipulator_set_color_highlight(camgroup->focal_len, color_hi); cameragroup_property_setup(camgroup->focal_len, ob, ca, false); - camgroup->ortho_scale = WM_manipulator_new_ptr(wt_arrow, mgroup, "ortho_scale"); - ED_manipulator_arrow3d_set_style( - camgroup->ortho_scale, (ED_MANIPULATOR_ARROW_STYLE_CONE | ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED)); + camgroup->ortho_scale = WM_manipulator_new_ptr(wt_arrow, mgroup, "ortho_scale", NULL); + RNA_enum_set(camgroup->ortho_scale->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE); + RNA_enum_set(camgroup->ortho_scale->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED); + WM_manipulator_set_color(camgroup->ortho_scale, color); WM_manipulator_set_color_highlight(camgroup->ortho_scale, color_hi); cameragroup_property_setup(camgroup->ortho_scale, ob, ca, true); @@ -251,7 +252,7 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg (0.5f * ca->ortho_scale) : (scale_fac / ((scale[0] + scale[1] + scale[2]) / 3.0f)); float offset[3]; - float asp[2]; + float aspect[2]; wmManipulator *widget = is_ortho ? camgroup->ortho_scale : camgroup->focal_len; WM_manipulator_set_flag(widget, WM_MANIPULATOR_HIDDEN, false); @@ -268,13 +269,14 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg const float aspx = (float)scene->r.xsch * scene->r.xasp; const float aspy = (float)scene->r.ysch * scene->r.yasp; const int sensor_fit = BKE_camera_sensor_fit(ca->sensor_fit, aspx, aspy); - asp[0] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? 1.0 : aspx / aspy; - asp[1] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? aspy / aspx : 1.0f; + aspect[0] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? 1.0 : aspx / aspy; + aspect[1] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? aspy / aspx : 1.0f; WM_manipulator_set_matrix_location(widget, ob->obmat[3]); WM_manipulator_set_matrix_rotation_from_yz_axis(widget, ob->obmat[1], dir); - ED_manipulator_arrow3d_cone_set_aspect(widget, asp); + RNA_float_set_array(widget->ptr, "aspect", aspect); + WM_manipulator_set_matrix_offset_location(widget, offset); WM_manipulator_set_scale(widget, drawsize); @@ -321,8 +323,8 @@ static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmManipulato wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__); mgroup->customdata = wwrapper; - wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, "field_strength"); - ED_manipulator_arrow3d_set_style(wwrapper->manipulator, ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED); + wwrapper->manipulator = WM_manipulator_new("MANIPULATOR_WT_arrow_3d", mgroup, "field_strength", NULL); + RNA_enum_set(wwrapper->manipulator->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED); ED_manipulator_arrow3d_set_ui_range(wwrapper->manipulator, -200.0f, 200.0f); ED_manipulator_arrow3d_set_range_fac(wwrapper->manipulator, 6.0f); WM_manipulator_set_color(wwrapper->manipulator, col); diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 83b112066c9..6818de6ad25 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -1090,23 +1090,23 @@ static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup) const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true); const wmManipulatorType *wt_prim = WM_manipulatortype_find("MANIPULATOR_WT_primitive_3d", true); -#define MANIPULATOR_NEW_ARROW(v, name, style) { \ - v = WM_manipulator_new_ptr(wt_arrow, mgroup, name); \ - ED_manipulator_arrow3d_set_style(v, style); \ +#define MANIPULATOR_NEW_ARROW(v, name, draw_style) { \ + v = WM_manipulator_new_ptr(wt_arrow, mgroup, name, NULL); \ + RNA_enum_set((v)->ptr, "draw_style", draw_style); \ } ((void)0) -#define MANIPULATOR_NEW_DIAL(v, name, style) { \ - v = WM_manipulator_new_ptr(wt_dial, mgroup, name); \ - ED_manipulator_dial3d_set_style(v, style); \ +#define MANIPULATOR_NEW_DIAL(v, name, draw_options) { \ + v = WM_manipulator_new_ptr(wt_dial, mgroup, name, NULL); \ + RNA_enum_set((v)->ptr, "draw_options", draw_options); \ } ((void)0) -#define MANIPULATOR_NEW_PRIM(v, name, style) { \ - v = WM_manipulator_new_ptr(wt_prim, mgroup, name); \ - ED_manipulator_primitive3d_set_style(v, style); \ +#define MANIPULATOR_NEW_PRIM(v, name, draw_style) { \ + v = WM_manipulator_new_ptr(wt_prim, mgroup, name, NULL); \ + RNA_enum_set((v)->ptr, "draw_style", draw_style); \ } ((void)0) /* add/init widgets - order matters! */ - MANIPULATOR_NEW_DIAL(man->rotate_t, "rotate_t", ED_MANIPULATOR_DIAL_STYLE_RING_FILLED); + MANIPULATOR_NEW_DIAL(man->rotate_t, "rotate_t", ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL); - MANIPULATOR_NEW_DIAL(man->scale_c, "scale_c", ED_MANIPULATOR_DIAL_STYLE_RING); + MANIPULATOR_NEW_DIAL(man->scale_c, "scale_c", ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); MANIPULATOR_NEW_ARROW(man->scale_x, "scale_x", ED_MANIPULATOR_ARROW_STYLE_BOX); MANIPULATOR_NEW_ARROW(man->scale_y, "scale_y", ED_MANIPULATOR_ARROW_STYLE_BOX); @@ -1116,14 +1116,14 @@ static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup) MANIPULATOR_NEW_PRIM(man->scale_yz, "scale_yz", ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); MANIPULATOR_NEW_PRIM(man->scale_zx, "scale_zx", ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_DIAL(man->rotate_x, "rotate_x", ED_MANIPULATOR_DIAL_STYLE_RING_CLIPPED); - MANIPULATOR_NEW_DIAL(man->rotate_y, "rotate_y", ED_MANIPULATOR_DIAL_STYLE_RING_CLIPPED); - MANIPULATOR_NEW_DIAL(man->rotate_z, "rotate_z", ED_MANIPULATOR_DIAL_STYLE_RING_CLIPPED); + MANIPULATOR_NEW_DIAL(man->rotate_x, "rotate_x", ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); + MANIPULATOR_NEW_DIAL(man->rotate_y, "rotate_y", ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); + MANIPULATOR_NEW_DIAL(man->rotate_z, "rotate_z", ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); /* init screen aligned widget last here, looks better, behaves better */ - MANIPULATOR_NEW_DIAL(man->rotate_c, "rotate_c", ED_MANIPULATOR_DIAL_STYLE_RING); + MANIPULATOR_NEW_DIAL(man->rotate_c, "rotate_c", ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); - MANIPULATOR_NEW_DIAL(man->translate_c, "translate_c", ED_MANIPULATOR_DIAL_STYLE_RING); + MANIPULATOR_NEW_DIAL(man->translate_c, "translate_c", ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); MANIPULATOR_NEW_ARROW(man->translate_x, "translate_x", ED_MANIPULATOR_ARROW_STYLE_NORMAL); MANIPULATOR_NEW_ARROW(man->translate_y, "translate_y", ED_MANIPULATOR_ARROW_STYLE_NORMAL); @@ -1307,7 +1307,7 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou manipulator_line_range(v3d, axis_type, &start_co[2], &len); WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); - ED_manipulator_arrow3d_set_line_len(axis, len); + RNA_float_set(axis->ptr, "length", len); WM_manipulator_set_matrix_offset_location(axis, start_co); break; } diff --git a/source/blender/editors/transform/transform_manipulator2d.c b/source/blender/editors/transform/transform_manipulator2d.c index ba61ae6ad71..697bc7d1f9f 100644 --- a/source/blender/editors/transform/transform_manipulator2d.c +++ b/source/blender/editors/transform/transform_manipulator2d.c @@ -134,8 +134,8 @@ static ManipulatorGroup2D *manipulatorgroup2d_init(wmManipulatorGroup *mgroup) ManipulatorGroup2D *man = MEM_callocN(sizeof(ManipulatorGroup2D), __func__); - man->translate_x = WM_manipulator_new_ptr(wt_arrow, mgroup, "translate_x"); - man->translate_y = WM_manipulator_new_ptr(wt_arrow, mgroup, "translate_y"); + man->translate_x = WM_manipulator_new_ptr(wt_arrow, mgroup, "translate_x", NULL); + man->translate_y = WM_manipulator_new_ptr(wt_arrow, mgroup, "translate_y", NULL); return man; } @@ -196,8 +196,8 @@ void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulator /* custom handler! */ WM_manipulator_set_fn_custom_modal(axis, manipulator2d_modal); /* set up widget data */ - ED_manipulator_arrow2d_set_angle(axis, -M_PI_2 * axis_idx); - ED_manipulator_arrow2d_set_line_len(axis, 0.8f); + RNA_float_set(axis->ptr, "angle", -M_PI_2 * axis_idx); + RNA_float_set(axis->ptr, "length", 0.8f); WM_manipulator_set_matrix_offset_location(axis, offset); WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); WM_manipulator_set_scale(axis, U.manipulator_size); |