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/manipulator_library/grab3d_manipulator.c | |
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/manipulator_library/grab3d_manipulator.c')
-rw-r--r-- | source/blender/editors/manipulator_library/grab3d_manipulator.c | 86 |
1 files changed, 38 insertions, 48 deletions
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) |