Commit: b7669ac1c672a92f31735ae9f92b369f9ba30eb1 Author: Campbell Barton Date: Wed Jun 21 13:54:46 2017 +1000 Branches: blender2.8 https://developer.blender.org/rBb7669ac1c672a92f31735ae9f92b369f9ba30eb1
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. =================================================================== 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/screen/area.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/makesrna/RNA_access.h M source/blender/makesrna/intern/CMakeLists.txt M source/blender/makesrna/intern/makesrna.c M source/blender/makesrna/intern/rna_internal.h A source/blender/makesrna/intern/rna_wm_manipulator.c M source/blender/windowmanager/manipulators/WM_manipulator_api.h M source/blender/windowmanager/manipulators/WM_manipulator_types.h M source/blender/windowmanager/manipulators/intern/wm_manipulator.c M source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c M source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c M source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c =================================================================== 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_arr @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs