diff options
35 files changed, 1119 insertions, 565 deletions
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index b46d3a3e64c..564ca473903 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -58,7 +58,6 @@ set(SRC_DNA_INC ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lightprobe_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_linestyle_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_listBase.h - ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_manipulator_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_material_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_mesh_types.h ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_meshdata_types.h diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index a20d2925564..da5a0cdcf2b 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -161,10 +161,10 @@ void TRANSFORM_WGT_manipulator(struct wmManipulatorGroupType *wgt); void TRANSFORM_WGT_object(struct wmManipulatorGroupType *wgt); -bool WIDGETGROUP_manipulator2d_poll(const struct bContext *C, struct wmManipulatorGroupType *wgrouptype); -void WIDGETGROUP_manipulator2d_init(const struct bContext *C, struct wmManipulatorGroup *wgroup); -void WIDGETGROUP_manipulator2d_refresh(const struct bContext *C, struct wmManipulatorGroup *wgroup); -void WIDGETGROUP_manipulator2d_draw_prepare(const struct bContext *C, struct wmManipulatorGroup *wgroup); +bool ED_widgetgroup_manipulator2d_poll(const struct bContext *C, struct wmManipulatorGroupType *wgt); +void ED_widgetgroup_manipulator2d_setup(const struct bContext *C, struct wmManipulatorGroup *mgroup); +void ED_widgetgroup_manipulator2d_refresh(const struct bContext *C, struct wmManipulatorGroup *mgroup); +void ED_widgetgroup_manipulator2d_draw_prepare(const struct bContext *C, struct wmManipulatorGroup *mgroup); /* Snapping */ diff --git a/source/blender/editors/manipulator_library/CMakeLists.txt b/source/blender/editors/manipulator_library/CMakeLists.txt index 1d1dcf8b725..cb31627e09a 100644 --- a/source/blender/editors/manipulator_library/CMakeLists.txt +++ b/source/blender/editors/manipulator_library/CMakeLists.txt @@ -43,6 +43,7 @@ set(SRC dial3d_manipulator.c geom_arrow_manipulator.c geom_cube_manipulator.c + geom_dial_manipulator.c manipulator_draw_utils.c manipulator_library_presets.c manipulator_library_utils.c diff --git a/source/blender/editors/manipulator_library/arrow2d_manipulator.c b/source/blender/editors/manipulator_library/arrow2d_manipulator.c index 1273710ff69..1798a3dbd6d 100644 --- a/source/blender/editors/manipulator_library/arrow2d_manipulator.c +++ b/source/blender/editors/manipulator_library/arrow2d_manipulator.c @@ -39,7 +39,6 @@ #include "BLI_math.h" #include "BLI_rect.h" -#include "DNA_manipulator_types.h" #include "DNA_windowmanager_types.h" #include "ED_screen.h" diff --git a/source/blender/editors/manipulator_library/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/arrow3d_manipulator.c index a2a2feb811c..c856374661f 100644 --- a/source/blender/editors/manipulator_library/arrow3d_manipulator.c +++ b/source/blender/editors/manipulator_library/arrow3d_manipulator.c @@ -40,7 +40,6 @@ #include "BLI_math.h" -#include "DNA_manipulator_types.h" #include "DNA_view3d_types.h" #include "ED_view3d.h" @@ -90,7 +89,7 @@ typedef struct ArrowManipulator3D { /* -------------------------------------------------------------------- */ -static void manipulator_arrow_get_final_pos(wmManipulator *mpr, float r_pos[3]) +static void manipulator_arrow_position_get(wmManipulator *mpr, float r_pos[3]) { ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; @@ -194,7 +193,7 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons float final_pos[3]; manipulator_color_get(&arrow->manipulator, highlight, col); - manipulator_arrow_get_final_pos(&arrow->manipulator, final_pos); + manipulator_arrow_position_get(&arrow->manipulator, final_pos); if (arrow->flag & ARROW_UP_VECTOR_SET) { copy_v3_v3(rot[2], arrow->direction); @@ -238,7 +237,7 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons } } -static void manipulator_arrow_render_3d_intersect( +static void manipulator_arrow_draw_select( const bContext *UNUSED(C), wmManipulator *mpr, int selectionbase) { @@ -327,14 +326,17 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve normalize_v3(viewvec); if (!use_vertical) { - float fac; /* now find a plane parallel to the view vector so we can intersect with the arrow direction */ cross_v3_v3v3(tangent, viewvec, offset); cross_v3_v3v3(plane, tangent, viewvec); - fac = dot_v3v3(plane, offset) / dot_v3v3(arrow->direction, plane); + const float plane_offset = dot_v3v3(plane, offset); + const float plane_dir = dot_v3v3(plane, arrow->direction); + const float fac = (plane_dir != 0.0f) ? (plane_offset / plane_dir) : 0.0f; facdir = (fac < 0.0) ? -1.0 : 1.0; - mul_v3_v3fl(offset, arrow->direction, fac); + if (isfinite(fac)) { + mul_v3_v3fl(offset, arrow->direction, fac); + } } else { facdir = (m_diff[1] < 0.0) ? -1.0 : 1.0; @@ -344,18 +346,18 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve ManipulatorCommonData *data = &arrow->data; const float ofs_new = facdir * len_v3(offset); - wmManipulatorProperty *mpr_prop = WM_manipulator_get_property(mpr, "offset"); + wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset"); /* set the property for the operator and call its modal function */ - if (mpr_prop->prop != NULL) { + 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; float value = manipulator_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision); - manipulator_property_value_set(C, mpr, mpr_prop, value); + WM_manipulator_property_value_set(C, mpr, mpr_prop, value); /* get clamped value */ - value = manipulator_property_value_get(mpr, mpr_prop); + value = WM_manipulator_property_value_get(mpr, mpr_prop); data->offset = manipulator_offset_from_value(data, value, constrained, inverted); } @@ -374,11 +376,11 @@ static void manipulator_arrow_invoke( { ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); - wmManipulatorProperty *mpr_prop = WM_manipulator_get_property(mpr, "offset"); + wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset"); /* Some manipulators don't use properties. */ - if (mpr_prop && mpr_prop->prop) { - inter->init_value = RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop); + if (mpr_prop && WM_manipulator_property_is_valid(mpr_prop)) { + inter->init_value = WM_manipulator_property_value_get(mpr, mpr_prop); } inter->init_offset = arrow->data.offset; @@ -388,16 +390,16 @@ static void manipulator_arrow_invoke( inter->init_scale = mpr->scale; - manipulator_arrow_get_final_pos(mpr, inter->init_origin); + manipulator_arrow_position_get(mpr, inter->init_origin); mpr->interaction_data = inter; } -static void manipulator_arrow_property_update(wmManipulator *mnp, wmManipulatorProperty *mpr_prop) +static void manipulator_arrow_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) { - ArrowManipulator3D *arrow = (ArrowManipulator3D *)mnp; + ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; manipulator_property_data_update( - mnp, &arrow->data, mpr_prop, + mpr, &arrow->data, mpr_prop, (arrow->style & ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED) != 0, (arrow->style & ED_MANIPULATOR_ARROW_STYLE_INVERTED) != 0); } @@ -411,7 +413,7 @@ static void manipulator_arrow_exit(bContext *C, wmManipulator *mpr, const bool c ManipulatorCommonData *data = &arrow->data; ManipulatorInteraction *inter = mpr->interaction_data; - wmManipulatorProperty *mpr_prop = WM_manipulator_get_property(mpr, "offset"); + wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset"); manipulator_property_value_reset(C, mpr, inter, mpr_prop); data->offset = inter->init_offset; } @@ -486,15 +488,15 @@ void ED_manipulator_arrow3d_set_line_len(wmManipulator *mpr, const float len) /** * Define a custom property UI range * - * \note Needs to be called before WM_manipulator_def_property! + * \note Needs to be called before WM_manipulator_property_def_rna! */ void ED_manipulator_arrow3d_set_ui_range(wmManipulator *mpr, const float min, const float max) { ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; BLI_assert(min < max); - BLI_assert(!(WM_manipulator_get_property(mpr, "offset") && "Make sure this function " - "is called before WM_manipulator_def_property")); + BLI_assert(!(WM_manipulator_property_find(mpr, "offset") && "Make sure this function " + "is called before WM_manipulator_property_def_rna")); arrow->data.range = max - min; arrow->data.min = min; @@ -504,13 +506,13 @@ void ED_manipulator_arrow3d_set_ui_range(wmManipulator *mpr, const float min, co /** * Define a custom factor for arrow min/max distance * - * \note Needs to be called before WM_manipulator_def_property! + * \note Needs to be called before WM_manipulator_property_def_rna! */ void ED_manipulator_arrow3d_set_range_fac(wmManipulator *mpr, const float range_fac) { ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - BLI_assert(!(WM_manipulator_get_property(mpr, "offset") && "Make sure this function " - "is called before WM_manipulator_def_property")); + BLI_assert(!(WM_manipulator_property_find(mpr, "offset") && "Make sure this function " + "is called before WM_manipulator_property_def_rna")); arrow->data.range_fac = range_fac; } @@ -532,8 +534,8 @@ static void MANIPULATOR_WT_arrow_3d(wmManipulatorType *wt) /* api callbacks */ wt->draw = manipulator_arrow_draw; - wt->draw_select = manipulator_arrow_render_3d_intersect; - wt->position_get = manipulator_arrow_get_final_pos; + wt->draw_select = manipulator_arrow_draw_select; + wt->position_get = manipulator_arrow_position_get; wt->modal = manipulator_arrow_modal; wt->invoke = manipulator_arrow_invoke; wt->property_update = manipulator_arrow_property_update; diff --git a/source/blender/editors/manipulator_library/cage2d_manipulator.c b/source/blender/editors/manipulator_library/cage2d_manipulator.c index 6bfa81e056b..5aacf6c8473 100644 --- a/source/blender/editors/manipulator_library/cage2d_manipulator.c +++ b/source/blender/editors/manipulator_library/cage2d_manipulator.c @@ -41,8 +41,6 @@ #include "BLI_math.h" #include "BLI_rect.h" -#include "DNA_manipulator_types.h" - #include "ED_screen.h" #include "ED_manipulator_library.h" @@ -367,7 +365,7 @@ typedef struct RectTransformInteraction { } RectTransformInteraction; static bool manipulator_rect_transform_get_prop_value( - wmManipulator *mnp, wmManipulatorProperty *mpr_prop, float *value) + wmManipulator *mpr, wmManipulatorProperty *mpr_prop, float *value) { PropertyType type = RNA_property_type(mpr_prop->prop); @@ -384,7 +382,7 @@ 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")) { - RectTransformManipulator *cage = (RectTransformManipulator *)mnp; + RectTransformManipulator *cage = (RectTransformManipulator *)mpr; if (cage->style & ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) { *value = RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop); } @@ -488,13 +486,13 @@ static void manipulator_rect_transform_modal( wmManipulatorProperty *mpr_prop; - mpr_prop = WM_manipulator_get_property(mpr, "offset"); + mpr_prop = WM_manipulator_property_find(mpr, "offset"); if (mpr_prop->prop != NULL) { RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, mpr->offset); RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); } - mpr_prop = WM_manipulator_get_property(mpr, "scale"); + 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]); @@ -509,15 +507,15 @@ static void manipulator_rect_transform_modal( ED_region_tag_redraw(CTX_wm_region(C)); } -static void manipulator_rect_transform_property_update(wmManipulator *mnp, wmManipulatorProperty *mpr_prop) +static void manipulator_rect_transform_property_update(wmManipulator *mpr, wmManipulatorProperty *mpr_prop) { - RectTransformManipulator *cage = (RectTransformManipulator *)mnp; + RectTransformManipulator *cage = (RectTransformManipulator *)mpr; if (STREQ(mpr_prop->idname, "offset")) { - manipulator_rect_transform_get_prop_value(mnp, mpr_prop, mnp->offset); + manipulator_rect_transform_get_prop_value(mpr, mpr_prop, mpr->offset); } else if (STREQ(mpr_prop->idname, "scale")) { - manipulator_rect_transform_get_prop_value(mnp, mpr_prop, cage->scale); + manipulator_rect_transform_get_prop_value(mpr, mpr_prop, cage->scale); } else { BLI_assert(0); @@ -535,13 +533,13 @@ static void manipulator_rect_transform_exit(bContext *C, wmManipulator *mpr, con wmManipulatorProperty *mpr_prop; /* reset properties */ - mpr_prop = WM_manipulator_get_property(mpr, "offset"); + mpr_prop = WM_manipulator_property_find(mpr, "offset"); if (mpr_prop->prop != NULL) { RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, data->orig_offset); RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); } - mpr_prop = WM_manipulator_get_property(mpr, "scale"); + 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, data->orig_scale[0]); diff --git a/source/blender/editors/manipulator_library/dial3d_manipulator.c b/source/blender/editors/manipulator_library/dial3d_manipulator.c index 2d5266647e0..1db87ac9a3d 100644 --- a/source/blender/editors/manipulator_library/dial3d_manipulator.c +++ b/source/blender/editors/manipulator_library/dial3d_manipulator.c @@ -41,8 +41,6 @@ #include "BLI_math.h" -#include "DNA_manipulator_types.h" - #include "ED_screen.h" #include "ED_view3d.h" #include "ED_manipulator_library.h" @@ -66,6 +64,8 @@ /* to use custom dials exported to geom_dial_manipulator.c */ // #define USE_MANIPULATOR_CUSTOM_DIAL +static void manipulator_dial_modal(bContext *C, wmManipulator *mpr, const wmEvent *event, const int flag); + typedef struct DialManipulator { wmManipulator manipulator; int style; @@ -79,11 +79,29 @@ typedef struct DialInteraction { float last_angle; /* number of full rotations */ int rotations; + + /* final output values, used for drawing */ + struct { + float angle_ofs; + float angle_delta; + } output; } DialInteraction; #define DIAL_WIDTH 1.0f #define DIAL_RESOLUTION 32 + +static void dial_calc_matrix(const DialManipulator *dial, 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->direction); + copy_m4_m3(mat, rot); + copy_v3_v3(mat[3], dial->manipulator.origin); + mul_mat3_m4_fl(mat, dial->manipulator.scale); +} + /* -------------------------------------------------------------------- */ static void dial_geom_draw( @@ -221,31 +239,36 @@ static void dial_draw_intern( const bContext *C, DialManipulator *dial, const bool select, const bool highlight, float clip_plane[4]) { - float rot[3][3]; float mat[4][4]; - const float up[3] = {0.0f, 0.0f, 1.0f}; float col[4]; BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D); manipulator_color_get(&dial->manipulator, highlight, col); - rotation_between_vecs_to_mat3(rot, up, dial->direction); - copy_m4_m3(mat, rot); - copy_v3_v3(mat[3], dial->manipulator.origin); - mul_mat3_m4_fl(mat, dial->manipulator.scale); + dial_calc_matrix(dial, mat); gpuPushMatrix(); gpuMultMatrix(mat); gpuTranslate3fv(dial->manipulator.offset); /* draw rotation indicator arc first */ - if ((dial->manipulator.flag & WM_MANIPULATOR_DRAW_VALUE) && (dial->manipulator.state & WM_MANIPULATOR_STATE_ACTIVE)) { - wmWindow *win = CTX_wm_window(C); + if ((dial->manipulator.flag & WM_MANIPULATOR_DRAW_VALUE) && + (dial->manipulator.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 */ - float angle_ofs, angle_delta; - dial_ghostarc_get_angles(dial, win->eventstate, CTX_wm_region(C), mat, co_outer, &angle_ofs, &angle_delta); + DialInteraction *inter = dial->manipulator.interaction_data; + + /* XXX, View3D rotation manipulator doesn't call modal. */ + if (dial->manipulator.properties.first == NULL) { + wmWindow *win = CTX_wm_window(C); + manipulator_dial_modal((bContext *)C, &dial->manipulator, win->eventstate, 0); + } + + const float angle_ofs = inter->output.angle_ofs; + const float angle_delta = inter->output.angle_delta; + /* draw! */ dial_ghostarc_draw(dial, angle_ofs, angle_delta, (const float [4]){0.8f, 0.8f, 0.8f, 0.4f}); @@ -259,7 +282,7 @@ static void dial_draw_intern( gpuPopMatrix(); } -static void manipulator_dial_render_3d_intersect(const bContext *C, wmManipulator *mpr, int selectionbase) +static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr, int selectionbase) { DialManipulator *dial = (DialManipulator *)mpr; float clip_plane_buf[4]; @@ -312,6 +335,23 @@ 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]; + + dial_calc_matrix(dial, mat); + + dial_ghostarc_get_angles(dial, event, CTX_wm_region(C), mat, co_outer, &angle_ofs, &angle_delta); + + DialInteraction *inter = dial->manipulator.interaction_data; + inter->output.angle_delta = angle_delta; + inter->output.angle_ofs = angle_ofs; +} + static void manipulator_dial_invoke( bContext *UNUSED(C), wmManipulator *mpr, const wmEvent *event) { @@ -362,8 +402,9 @@ static void MANIPULATOR_WT_dial_3d(wmManipulatorType *wt) /* api callbacks */ wt->draw = manipulator_dial_draw; - wt->draw_select = manipulator_dial_render_3d_intersect; + wt->draw_select = manipulator_dial_draw_select; wt->invoke = manipulator_dial_invoke; + wt->modal = manipulator_dial_modal; wt->struct_size = sizeof(DialManipulator); } diff --git a/source/blender/editors/manipulator_library/manipulator_draw_utils.c b/source/blender/editors/manipulator_library/manipulator_draw_utils.c index fc7b22ac0f0..239d7d68d09 100644 --- a/source/blender/editors/manipulator_library/manipulator_draw_utils.c +++ b/source/blender/editors/manipulator_library/manipulator_draw_utils.c @@ -35,8 +35,6 @@ #include "BLI_string.h" #include "BLI_string_utils.h" -#include "DNA_manipulator_types.h" - #include "ED_screen.h" #include "ED_view3d.h" diff --git a/source/blender/editors/manipulator_library/manipulator_library_intern.h b/source/blender/editors/manipulator_library/manipulator_library_intern.h index 8a187f5f9ba..c21a3046be5 100644 --- a/source/blender/editors/manipulator_library/manipulator_library_intern.h +++ b/source/blender/editors/manipulator_library/manipulator_library_intern.h @@ -76,15 +76,11 @@ float manipulator_value_from_offset( const bool constrained, const bool inverted, const bool use_precision); void manipulator_property_data_update( - struct wmManipulator *mnp, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop, + struct wmManipulator *mpr, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop, const bool constrained, const bool inverted); -void manipulator_property_value_set( - bContext *C, const struct wmManipulator *mnp, wmManipulatorProperty *mpr_prop, const float value); -float manipulator_property_value_get( - const struct wmManipulator *mnp, wmManipulatorProperty *mpr_prop); void manipulator_property_value_reset( - bContext *C, const struct wmManipulator *mnp, ManipulatorInteraction *inter, wmManipulatorProperty *mpr_prop); + bContext *C, const struct wmManipulator *mpr, ManipulatorInteraction *inter, wmManipulatorProperty *mpr_prop); /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/manipulator_library/manipulator_library_presets.c b/source/blender/editors/manipulator_library/manipulator_library_presets.c index fc7b5f88f44..d8e66f40be0 100644 --- a/source/blender/editors/manipulator_library/manipulator_library_presets.c +++ b/source/blender/editors/manipulator_library/manipulator_library_presets.c @@ -32,7 +32,6 @@ #include "BLI_math.h" -#include "DNA_manipulator_types.h" #include "DNA_view3d_types.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/manipulator_library/manipulator_library_utils.c b/source/blender/editors/manipulator_library/manipulator_library_utils.c index be437c0acc1..093842aeb65 100644 --- a/source/blender/editors/manipulator_library/manipulator_library_utils.c +++ b/source/blender/editors/manipulator_library/manipulator_library_utils.c @@ -105,20 +105,25 @@ void manipulator_property_data_update( wmManipulator *mpr, ManipulatorCommonData *data, wmManipulatorProperty *mpr_prop, const bool constrained, const bool inverted) { - if (mpr_prop->prop == NULL) { + if (mpr_prop->custom_func.value_get_fn != NULL) { + /* pass */ + } + else if (mpr_prop->prop != NULL) { + /* pass */ + } + else { data->offset = 0.0f; return; } - float value = manipulator_property_value_get(mpr, mpr_prop); + float value = WM_manipulator_property_value_get(mpr, mpr_prop); if (constrained) { if ((data->flag & MANIPULATOR_CUSTOM_RANGE_SET) == 0) { - float step, precision; - float min, max; - RNA_property_float_ui_range(&mpr_prop->ptr, mpr_prop->prop, &min, &max, &step, &precision); - data->range = max - min; - data->min = min; + float range[2]; + WM_manipulator_property_range_get(mpr, mpr_prop, range); + data->range = range[1] - range[0]; + data->min = range[0]; } data->offset = manipulator_offset_from_value_constr(data->range_fac, data->min, data->range, value, inverted); } @@ -127,40 +132,13 @@ void manipulator_property_data_update( } } -void manipulator_property_value_set( - bContext *C, const wmManipulator *UNUSED(mnp), - wmManipulatorProperty *mpr_prop, const float value) -{ - /* reset property */ - if (mpr_prop->index == -1) { - RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, value); - } - else { - RNA_property_float_set_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index, value); - } - RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); -} - -float manipulator_property_value_get( - const wmManipulator *UNUSED(mnp), - wmManipulatorProperty *mpr_prop) -{ - if (mpr_prop->index == -1) { - return RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop); - } - else { - return RNA_property_float_get_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index); - } -} - void manipulator_property_value_reset( - bContext *C, const wmManipulator *mnp, ManipulatorInteraction *inter, + bContext *C, const wmManipulator *mpr, ManipulatorInteraction *inter, wmManipulatorProperty *mpr_prop) { - manipulator_property_value_set(C, mnp, mpr_prop, inter->init_value); + WM_manipulator_property_value_set(C, mpr, mpr_prop, inter->init_value); } - /* -------------------------------------------------------------------- */ void manipulator_color_get( diff --git a/source/blender/editors/manipulator_library/primitive3d_manipulator.c b/source/blender/editors/manipulator_library/primitive3d_manipulator.c index 63ed4ddf6b8..08fa6766aeb 100644 --- a/source/blender/editors/manipulator_library/primitive3d_manipulator.c +++ b/source/blender/editors/manipulator_library/primitive3d_manipulator.c @@ -36,7 +36,6 @@ #include "BLI_math.h" #include "DNA_view3d_types.h" -#include "DNA_manipulator_types.h" #include "GPU_immediate.h" #include "GPU_matrix.h" @@ -157,7 +156,7 @@ static void manipulator_primitive_draw_intern( } } -static void manipulator_primitive_render_3d_intersect( +static void manipulator_primitive_draw_select( const bContext *UNUSED(C), wmManipulator *mpr, int selectionbase) { @@ -238,7 +237,7 @@ static void MANIPULATOR_WT_primitive3d(wmManipulatorType *wt) /* api callbacks */ wt->draw = manipulator_primitive_draw; - wt->draw_select = manipulator_primitive_render_3d_intersect; + wt->draw_select = manipulator_primitive_draw_select; wt->invoke = manipulator_primitive_invoke; wt->struct_size = sizeof(PrimitiveManipulator); diff --git a/source/blender/editors/space_node/node_manipulators.c b/source/blender/editors/space_node/node_manipulators.c index 6eb03a6eb26..0f3f53c6dca 100644 --- a/source/blender/editors/space_node/node_manipulators.c +++ b/source/blender/editors/space_node/node_manipulators.c @@ -25,8 +25,6 @@ #include "BKE_context.h" #include "BKE_image.h" -#include "DNA_manipulator_types.h" - #include "ED_screen.h" #include "ED_manipulator_library.h" @@ -95,8 +93,8 @@ static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorG SpaceNode *snode = CTX_wm_space_node(C); PointerRNA nodeptr; RNA_pointer_create(snode->id, &RNA_SpaceNodeEditor, snode, &nodeptr); - WM_manipulator_def_property(cage, "offset", &nodeptr, "backdrop_offset", -1); - WM_manipulator_def_property(cage, "scale", &nodeptr, "backdrop_zoom", -1); + WM_manipulator_property_def_rna(cage, "offset", &nodeptr, "backdrop_offset", -1); + WM_manipulator_property_def_rna(cage, "scale", &nodeptr, "backdrop_zoom", -1); } else { WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, true); @@ -110,6 +108,8 @@ void NODE_WGT_backdrop_transform(wmManipulatorGroupType *wgt) wgt->name = "Backdrop Transform Widgets"; wgt->idname = "NODE_WGT_backdrop_transform"; + wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; + wgt->poll = WIDGETGROUP_node_transform_poll; wgt->setup = WIDGETGROUP_node_transform_setup; wgt->refresh = WIDGETGROUP_node_transform_refresh; diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 665808c500f..2f1e6d38d3d 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -646,9 +646,9 @@ static void node_main_region_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* manipulators stay in the background for now - quick patchjob to make sure nodes themselves work */ - if (!ar->manipulator_map) { - ar->manipulator_map = WM_manipulatormap_new_from_type(&(const struct wmManipulatorMapType_Params) { - "Node_Canvas", SPACE_NODE, RGN_TYPE_WINDOW}); + if (ar->manipulator_map == NULL) { + ar->manipulator_map = WM_manipulatormap_new_from_type( + &(const struct wmManipulatorMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW}); } WM_manipulatormap_add_handlers(ar, ar->manipulator_map); @@ -859,9 +859,9 @@ static int node_context(const bContext *C, const char *member, bContextDataResul static void node_widgets(void) { /* create the widgetmap for the area here */ - wmManipulatorMapType *wmaptype = WM_manipulatormaptype_ensure(&(const struct wmManipulatorMapType_Params) { - "Node_Canvas", SPACE_NODE, RGN_TYPE_WINDOW}); - WM_manipulatorgrouptype_append(wmaptype, NODE_WGT_backdrop_transform); + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure( + &(const struct wmManipulatorMapType_Params){SPACE_NODE, RGN_TYPE_WINDOW}); + WM_manipulatorgrouptype_append_and_link(mmap_type, NODE_WGT_backdrop_transform); } static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 65740fe6794..eaf9f73b39c 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -491,9 +491,9 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar) ListBase *lb; wmKeyMap *keymap; - if (!ar->manipulator_map) { - ar->manipulator_map = WM_manipulatormap_new_from_type(&(const struct wmManipulatorMapType_Params) { - "View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW}); + if (ar->manipulator_map == NULL) { + ar->manipulator_map = WM_manipulatormap_new_from_type( + &(const struct wmManipulatorMapType_Params) {SPACE_VIEW3D, RGN_TYPE_WINDOW}); } WM_manipulatormap_add_handlers(ar, ar->manipulator_map); @@ -731,16 +731,13 @@ static void view3d_dropboxes(void) static void view3d_widgets(void) { - const struct wmManipulatorMapType_Params wmap_params = { - .idname = "View3D", - .spaceid = SPACE_VIEW3D, .regionid = RGN_TYPE_WINDOW, - }; - wmManipulatorMapType *wmaptype = WM_manipulatormaptype_ensure(&wmap_params); - - WM_manipulatorgrouptype_append(wmaptype, TRANSFORM_WGT_manipulator); - WM_manipulatorgrouptype_append(wmaptype, VIEW3D_WGT_lamp); - WM_manipulatorgrouptype_append(wmaptype, VIEW3D_WGT_force_field); - WM_manipulatorgrouptype_append(wmaptype, VIEW3D_WGT_camera); + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure( + &(const struct wmManipulatorMapType_Params){SPACE_VIEW3D, RGN_TYPE_WINDOW}); + + WM_manipulatorgrouptype_append_and_link(mmap_type, TRANSFORM_WGT_manipulator); + WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_lamp); + WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_force_field); + WM_manipulatorgrouptype_append_and_link(mmap_type, VIEW3D_WGT_camera); } diff --git a/source/blender/editors/space_view3d/view3d_manipulators.c b/source/blender/editors/space_view3d/view3d_manipulators.c index 7d8c855013b..6ade2828ffa 100644 --- a/source/blender/editors/space_view3d/view3d_manipulators.c +++ b/source/blender/editors/space_view3d/view3d_manipulators.c @@ -39,7 +39,6 @@ #include "DNA_lamp_types.h" #include "DNA_object_types.h" #include "DNA_object_force.h" -#include "DNA_manipulator_types.h" #include "ED_armature.h" #include "ED_screen.h" @@ -103,7 +102,7 @@ static void WIDGETGROUP_lamp_refresh(const bContext *C, wmManipulatorGroup *mgro PointerRNA lamp_ptr; const char *propname = "spot_size"; RNA_pointer_create(&la->id, &RNA_Lamp, la, &lamp_ptr); - WM_manipulator_def_property(wwrapper->manipulator, "offset", &lamp_ptr, propname, -1); + WM_manipulator_property_def_rna(wwrapper->manipulator, "offset", &lamp_ptr, propname, -1); } void VIEW3D_WGT_lamp(wmManipulatorGroupType *wgt) @@ -111,11 +110,13 @@ void VIEW3D_WGT_lamp(wmManipulatorGroupType *wgt) wgt->name = "Lamp Widgets"; wgt->idname = "VIEW3D_WGT_lamp"; + wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | + WM_MANIPULATORGROUPTYPE_3D | + WM_MANIPULATORGROUPTYPE_SCALE_3D); + wgt->poll = WIDGETGROUP_lamp_poll; wgt->setup = WIDGETGROUP_lamp_setup; wgt->refresh = WIDGETGROUP_lamp_refresh; - - wgt->flag |= (WM_MANIPULATORGROUPTYPE_3D | WM_MANIPULATORGROUPTYPE_SCALE_3D); } /** \} */ @@ -230,7 +231,7 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, false); /* need to set property here for undo. TODO would prefer to do this in _init */ - WM_manipulator_def_property(camgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1); + WM_manipulator_property_def_rna(camgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1); } else { WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, true); @@ -273,8 +274,8 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg WM_manipulator_set_scale(widget, drawsize); /* need to set property here for undo. TODO would prefer to do this in _init */ - WM_manipulator_def_property(camgroup->focal_len, "offset", &camera_ptr, "lens", -1); - WM_manipulator_def_property(camgroup->ortho_scale, "offset", &camera_ptr, "ortho_scale", -1); + WM_manipulator_property_def_rna(camgroup->focal_len, "offset", &camera_ptr, "lens", -1); + WM_manipulator_property_def_rna(camgroup->ortho_scale, "offset", &camera_ptr, "ortho_scale", -1); } } @@ -283,11 +284,12 @@ void VIEW3D_WGT_camera(wmManipulatorGroupType *wgt) wgt->name = "Camera Widgets"; wgt->idname = "VIEW3D_WGT_camera"; + wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT | + WM_MANIPULATORGROUPTYPE_3D); + wgt->poll = WIDGETGROUP_camera_poll; wgt->setup = WIDGETGROUP_camera_setup; wgt->refresh = WIDGETGROUP_camera_refresh; - - wgt->flag |= WM_MANIPULATORGROUPTYPE_3D; } /** \} */ @@ -305,7 +307,7 @@ static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmManipulatorGroupTyp return (ob && ob->pd && ob->pd->forcefield); } -static void WIDGETGROUP_forcefield_init(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_forcefield_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) { const float col[4] = {0.8f, 0.8f, 0.45f, 0.5f}; const float col_hi[4] = {0.8f, 0.8f, 0.45f, 1.0f}; @@ -339,7 +341,7 @@ static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmManipulatorGroup WM_manipulator_set_origin(wwrapper->manipulator, ob->obmat[3]); WM_manipulator_set_offset(wwrapper->manipulator, ofs); WM_manipulator_set_flag(wwrapper->manipulator, WM_MANIPULATOR_HIDDEN, false); - WM_manipulator_def_property(wwrapper->manipulator, "offset", &field_ptr, "strength", -1); + WM_manipulator_property_def_rna(wwrapper->manipulator, "offset", &field_ptr, "strength", -1); } else { WM_manipulator_set_flag(wwrapper->manipulator, WM_MANIPULATOR_HIDDEN, true); @@ -351,11 +353,12 @@ void VIEW3D_WGT_force_field(wmManipulatorGroupType *wgt) wgt->name = "Force Field Widgets"; wgt->idname = "VIEW3D_WGT_force_field"; + wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | + WM_MANIPULATORGROUPTYPE_3D); + wgt->poll = WIDGETGROUP_forcefield_poll; - wgt->setup = WIDGETGROUP_forcefield_init; + wgt->setup = WIDGETGROUP_forcefield_setup; wgt->refresh = WIDGETGROUP_forcefield_refresh; - - wgt->flag |= WM_MANIPULATORGROUPTYPE_3D; } /** \} */ diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index eee9919efd4..bd470bd08d9 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -39,7 +39,6 @@ #include "DNA_curve_types.h" #include "DNA_gpencil_types.h" #include "DNA_lattice_types.h" -#include "DNA_manipulator_types.h" #include "DNA_meta_types.h" #include "DNA_screen_types.h" #include "DNA_scene_types.h" @@ -1134,7 +1133,7 @@ static void manipulator_modal( ED_region_tag_redraw(ar); } -static void WIDGETGROUP_manipulator_init(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) { ManipulatorGroup *man = manipulatorgroup_init(mgroup); mgroup->customdata = man; @@ -1345,12 +1344,14 @@ void TRANSFORM_WGT_manipulator(wmManipulatorGroupType *wgt) wgt->name = "Transform Manipulator"; wgt->idname = "TRANSFORM_WGT_manipulator"; + wgt->flag |= (WM_MANIPULATORGROUPTYPE_PERSISTENT | + WM_MANIPULATORGROUPTYPE_3D | + WM_MANIPULATORGROUPTYPE_SCALE_3D); + wgt->poll = WIDGETGROUP_manipulator_poll; - wgt->setup = WIDGETGROUP_manipulator_init; + wgt->setup = WIDGETGROUP_manipulator_setup; wgt->refresh = WIDGETGROUP_manipulator_refresh; wgt->draw_prepare = WIDGETGROUP_manipulator_draw_prepare; - - wgt->flag |= (WM_MANIPULATORGROUPTYPE_3D | WM_MANIPULATORGROUPTYPE_SCALE_3D); } @@ -1365,7 +1366,7 @@ static void WIDGETGROUP_object_manipulator_init(const bContext *C, wmManipulator ob->mgroup = mgroup; } - WIDGETGROUP_manipulator_init(C, mgroup); + WIDGETGROUP_manipulator_setup(C, mgroup); } static bool WIDGETGROUP_object_manipulator_poll(const bContext *C, wmManipulatorGroupType *wgt) diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 490683e9360..6ae1de3fead 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -104,12 +104,15 @@ void ED_editors_init(bContext *C) for (ob = bmain->object.first; ob; ob = ob->id.next) { int mode = ob->mode; - if (!ELEM(mode, OB_MODE_OBJECT, OB_MODE_POSE)) { - ob->mode = OB_MODE_OBJECT; + if (mode == OB_MODE_OBJECT) { + /* pass */ + } + else { data = ob->data; - - if (ob == obact && !ID_IS_LINKED_DATABLOCK(ob) && !(data && ID_IS_LINKED_DATABLOCK(data))) + ob->mode = OB_MODE_OBJECT; + if ((ob == obact) && !ID_IS_LINKED_DATABLOCK(ob) && !(data && ID_IS_LINKED_DATABLOCK(data))) { ED_object_toggle_modes(C, mode); + } } } diff --git a/source/blender/makesdna/DNA_manipulator_types.h b/source/blender/makesdna/DNA_manipulator_types.h deleted file mode 100644 index 006a308162b..00000000000 --- a/source/blender/makesdna/DNA_manipulator_types.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file DNA_manipulator_types.h - * \ingroup DNA - */ - -#ifndef __DNA_MANIPULATOR_TYPES_H__ -#define __DNA_MANIPULATOR_TYPES_H__ - -typedef struct wmManipulatorGroup { - struct wmManipulatorGroup *next, *prev; - - struct wmManipulatorGroupType *type; - ListBase manipulators; - - struct wmManipulatorMap *parent_mmap; - - void *py_instance; /* python stores the class instance here */ - struct ReportList *reports; /* errors and warnings storage */ - - void *customdata; - void (*customdata_free)(void *); /* for freeing customdata from above */ - int flag; /* private */ - int pad; -} wmManipulatorGroup; - -#endif /* __DNA_MANIPULATOR_TYPES_H__ */ diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index c39e63ff8a5..76be857b1af 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -80,7 +80,6 @@ static const char *includefiles[] = { "DNA_image_types.h", "DNA_texture_types.h", "DNA_lamp_types.h", - "DNA_manipulator_types.h", "DNA_material_types.h", "DNA_vfont_types.h", "DNA_meta_types.h", @@ -1308,7 +1307,6 @@ int main(int argc, char **argv) #include "DNA_image_types.h" #include "DNA_texture_types.h" #include "DNA_lamp_types.h" -#include "DNA_manipulator_types.h" #include "DNA_material_types.h" #include "DNA_vfont_types.h" #include "DNA_meta_types.h" diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index a0efe7502c4..a4eefc5b15d 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -72,7 +72,10 @@ set(SRC intern/wm_window.c intern/wm_stereo.c manipulators/intern/wm_manipulator.c + manipulators/intern/wm_manipulator_property.c + manipulators/intern/wm_manipulator_type.c manipulators/intern/wm_manipulatorgroup.c + manipulators/intern/wm_manipulatorgroup_type.c manipulators/intern/wm_manipulatormap.c WM_api.h diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index b7fb757fc5c..06bf6ff2482 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -36,7 +36,6 @@ #include <string.h> #include "DNA_listBase.h" -#include "DNA_manipulator_types.h" #include "DNA_screen_types.h" #include "DNA_scene_types.h" #include "DNA_windowmanager_types.h" @@ -2165,7 +2164,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers /* handle user configurable manipulator-map keymap */ else if (mpr) { /* get user customized keymap from default one */ - const wmManipulatorGroup *highlightgroup = wm_manipulator_get_parent_group(mpr); + const wmManipulatorGroup *highlightgroup = mpr->parent_mgroup; const wmKeyMap *keymap = WM_keymap_active(wm, highlightgroup->type->keymap); wmKeyMapItem *kmi; @@ -2452,6 +2451,7 @@ void wm_event_do_handlers(bContext *C) /* update key configuration before handling events */ WM_keyconfig_update(wm); + WM_manipulatorconfig_update(CTX_data_main(C)); for (win = wm->windows.first; win; win = win->next) { bScreen *screen = WM_window_get_active_screen(win); @@ -2664,6 +2664,7 @@ void wm_event_do_handlers(bContext *C) /* update key configuration after handling events */ WM_keyconfig_update(wm); + WM_manipulatorconfig_update(CTX_data_main(C)); } /* ********** filesector handling ************ */ diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 7d729f22cfe..4c54eacaf26 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -166,6 +166,7 @@ void WM_init(bContext *C, int argc, const char **argv) WM_menutype_init(); WM_uilisttype_init(); wm_manipulatortype_init(); + wm_manipulatorgrouptype_init(); BKE_undo_callback_wm_kill_jobs_set(wm_undo_kill_callback); @@ -488,6 +489,7 @@ void WM_exit_ext(bContext *C, const bool do_python) wm_dropbox_free(); WM_menutype_free(); WM_uilisttype_free(); + wm_manipulatorgrouptype_free(); wm_manipulatortype_free(); /* all non-screen and non-space stuff editors did, like editmode */ diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h index a72830e19d4..c24d1db3ba2 100644 --- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h +++ b/source/blender/windowmanager/manipulators/WM_manipulator_api.h @@ -63,13 +63,6 @@ struct wmManipulator *WM_manipulator_new( void WM_manipulator_free( ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr, struct bContext *C); -struct wmManipulatorGroup *WM_manipulator_get_parent_group(struct wmManipulator *mpr); - -struct wmManipulatorProperty *WM_manipulator_get_property( - struct wmManipulator *mpr, const char *idname); -void WM_manipulator_def_property( - struct wmManipulator *mpr, const char *idname, - struct PointerRNA *ptr, const char *propname, int index); struct PointerRNA *WM_manipulator_set_operator(struct wmManipulator *, const char *opname); @@ -87,7 +80,7 @@ void WM_manipulator_set_color(struct wmManipulator *mpr, const float col[4]); void WM_manipulator_get_color_highlight(const struct wmManipulator *mpr, float col_hi[4]); void WM_manipulator_set_color_highlight(struct wmManipulator *mpr, const float col[4]); -/* wm_manipulator.c */ +/* wm_manipulator_type.c */ const struct wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet); void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *)); void WM_manipulatortype_append_ptr(void (*mnpfunc)(struct wmManipulatorType *, void *), void *userdata); @@ -95,48 +88,59 @@ bool WM_manipulatortype_remove(const char *idname); void WM_manipulatortype_remove_ptr(struct wmManipulatorType *wt); void WM_manipulatortype_iter(struct GHashIterator *ghi); +/* wm_manipulatorgroup_type.c */ +struct wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet); +struct wmManipulatorGroupType *WM_manipulatorgrouptype_append(void (*wtfunc)(struct wmManipulatorGroupType *)); +struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr(void (*mnpfunc)(struct wmManipulatorGroupType *, void *), void *userdata); +bool WM_manipulatorgrouptype_remove(const char *idname); +void WM_manipulatorgrouptype_remove_ptr(struct wmManipulatorGroupType *wt); +void WM_manipulatorgrouptype_iter(struct GHashIterator *ghi); + +struct wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link( + struct wmManipulatorMapType *mmap_type, + void (*wtfunc)(struct wmManipulatorGroupType *)); + +/* wm_manipulatormap.c */ + +/* Dynamic Updates (for RNA runtime registration) */ +void WM_manipulatorconfig_update_tag_init(struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt); +void WM_manipulatorconfig_update(const struct Main *bmain); + + +/* wm_maniulator_property.c */ +struct wmManipulatorProperty *WM_manipulator_property_find( + struct wmManipulator *mpr, const char *idname); + +void WM_manipulator_property_def_rna( + struct wmManipulator *mpr, const char *idname, + struct PointerRNA *ptr, const char *propname, int index); +void WM_manipulator_property_def_func( + struct wmManipulator *mpr, const char *idname, + const struct wmManipulatorPropertyFnParams *params); + +bool WM_manipulator_property_is_valid( + const struct wmManipulatorProperty *mpr_prop); +void WM_manipulator_property_value_set( + struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, const float value); +float WM_manipulator_property_value_get( + const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop); +void WM_manipulator_property_range_get( + const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, + float range[2]); + /* -------------------------------------------------------------------- */ /* wmManipulatorGroup */ -struct wmManipulatorGroupType *WM_manipulatorgrouptype_find( - struct wmManipulatorMapType *mmaptype, - const char *idname); -struct wmManipulatorGroupType *WM_manipulatorgrouptype_append( - struct wmManipulatorMapType *mmaptype, - void (*mgrouptype_func)(struct wmManipulatorGroupType *)); -struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr( - struct wmManipulatorMapType *mmaptype, - void (*mgrouptype_func)(struct wmManipulatorGroupType *, void *), - void *userdata); -struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_runtime( - const struct Main *main, struct wmManipulatorMapType *mmaptype, - void (*mgrouptype_func)(struct wmManipulatorGroupType *)); -struct wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr_runtime( - const struct Main *main, struct wmManipulatorMapType *mmaptype, - void (*mgrouptype_func)(struct wmManipulatorGroupType *, void *), - void *userdata); - -void WM_manipulatorgrouptype_init_runtime( - const struct Main *bmain, struct wmManipulatorMapType *mmaptype, - struct wmManipulatorGroupType *wgt); -void WM_manipulatorgrouptype_free(struct wmManipulatorGroupType *wgt); -void WM_manipulatorgrouptype_remove_ptr( - struct bContext *C, struct Main *bmain, struct wmManipulatorGroupType *mgroup); - +/* Callbacks for 'wmManipulatorGroupType.setup_keymap' */ struct wmKeyMap *WM_manipulatorgroup_keymap_common( const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config); -struct wmKeyMap *WM_manipulatorgroup_keymap_common_sel( +struct wmKeyMap *WM_manipulatorgroup_keymap_common_select( const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config); /* -------------------------------------------------------------------- */ /* wmManipulatorMap */ -struct wmManipulatorMapType *WM_manipulatormaptype_find( - const struct wmManipulatorMapType_Params *mmap_params); -struct wmManipulatorMapType *WM_manipulatormaptype_ensure( - const struct wmManipulatorMapType_Params *mmap_params); - struct wmManipulatorMap *WM_manipulatormap_new_from_type( const struct wmManipulatorMapType_Params *mmap_params); void WM_manipulatormap_tag_refresh(struct wmManipulatorMap *mmap); @@ -145,5 +149,51 @@ void WM_manipulatormap_add_handlers(struct ARegion *ar, struct wmManipulatorMap bool WM_manipulatormap_select_all(struct bContext *C, struct wmManipulatorMap *mmap, const int action); bool WM_manipulatormap_cursor_set(const struct wmManipulatorMap *mmap, struct wmWindow *win); -#endif /* __WM_MANIPULATOR_API_H__ */ +/* -------------------------------------------------------------------- */ +/* wmManipulatorMapType */ +struct wmManipulatorMapType *WM_manipulatormaptype_find( + const struct wmManipulatorMapType_Params *mmap_params); +struct wmManipulatorMapType *WM_manipulatormaptype_ensure( + const struct wmManipulatorMapType_Params *mmap_params); + +struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find( + struct wmManipulatorMapType *mmap_type, + const char *idname); +struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr( + struct wmManipulatorMapType *mmap_type, + const struct wmManipulatorGroupType *wgt); +struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link( + struct wmManipulatorMapType *mmap_type, + const char *idname); +struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr( + struct wmManipulatorMapType *mmap_type, + struct wmManipulatorGroupType *wgt); + +void WM_manipulatormaptype_group_init_runtime( + const struct Main *bmain, struct wmManipulatorMapType *mmap_type, + struct wmManipulatorGroupType *wgt); +void WM_manipulatormaptype_group_unlink( + struct bContext *C, struct Main *bmain, struct wmManipulatorMapType *mmap_type, + const struct wmManipulatorGroupType *wgt); + +void WM_manipulatormaptype_group_free(struct wmManipulatorGroupTypeRef *wgt); + +/* -------------------------------------------------------------------- */ +/* Manipulator Add/Remove (High level API) */ + +void WM_manipulator_group_add_ptr_ex( + struct wmManipulatorGroupType *wgt, + struct wmManipulatorMapType *mmap_type); +void WM_manipulator_group_add_ptr( + struct wmManipulatorGroupType *wgt); +void WM_manipulator_group_add(const char *idname); + +void WM_manipulator_group_remove_ptr_ex( + struct Main *bmain, struct wmManipulatorGroupType *wgt, + struct wmManipulatorMapType *mmap_type); +void WM_manipulator_group_remove_ptr( + struct Main *bmain, struct wmManipulatorGroupType *wgt); +void WM_manipulator_group_remove(struct Main *bmain, const char *idname); + +#endif /* __WM_MANIPULATOR_API_H__ */ diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h index cd6fdcd8a4d..15b00d0a7b0 100644 --- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h +++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h @@ -38,6 +38,7 @@ #include "BLI_compiler_attrs.h" +struct wmManipulatorMapType; struct wmManipulatorGroupType; struct wmManipulatorGroup; struct wmManipulator; @@ -104,12 +105,25 @@ struct wmManipulator { ListBase properties; }; +typedef void (*wmManipulatorGroupFnInit)( + const struct bContext *, struct wmManipulatorGroup *); + /* Similar to PropertyElemRNA, but has an identifier. */ typedef struct wmManipulatorProperty { struct wmManipulatorProperty *next, *prev; PointerRNA ptr; PropertyRNA *prop; int index; + + /* Optional functions for converting to/from RNA */ + struct { + wmManipulatorPropertyFnGet value_get_fn; + wmManipulatorPropertyFnSet value_set_fn; + wmManipulatorPropertyFnRangeGet range_get_fn; + const struct bContext *context; + void *user_data; + } custom_func; + /* over alloc */ char idname[0]; } wmManipulatorProperty; @@ -121,6 +135,12 @@ typedef struct wmManipulatorWrapper { struct wmManipulator *manipulator; } wmManipulatorWrapper; +struct wmManipulatorMapType_Params { + short spaceid; + short regionid; +}; + + /* wmManipulator.flag * Flags for individual manipulators. */ enum { @@ -194,9 +214,13 @@ typedef struct wmManipulatorType { /* wmManipulatorGroup */ /* factory class for a manipulator-group type, gets called every time a new area is spawned */ -typedef struct wmManipulatorGroupType { - struct wmManipulatorGroupType *next, *prev; +typedef struct wmManipulatorGroupTypeRef { + struct wmManipulatorGroupTypeRef *next, *prev; + struct wmManipulatorGroupType *type; +} wmManipulatorGroupTypeRef; +/* factory class for a manipulator-group type, gets called every time a new area is spawned */ +typedef struct wmManipulatorGroupType { const char *idname; /* MAX_NAME */ const char *name; /* manipulator-group name - displayed in UI (keymap editor) */ @@ -211,7 +235,8 @@ typedef struct wmManipulatorGroupType { /* Keymap init callback for this manipulator-group (optional), * will fall back to default tweak keymap when left NULL. */ - struct wmKeyMap *(*setup_keymap)(const struct wmManipulatorGroupType *, struct wmKeyConfig *); + wmManipulatorGroupFnSetupKeymap setup_keymap; + /* keymap created with callback from above */ struct wmKeyMap *keymap; @@ -226,11 +251,39 @@ typedef struct wmManipulatorGroupType { int flag; + /* eManipulatorMapTypeUpdateFlags (so we know which group type to update) */ + uchar type_update_flag; + /* same as manipulator-maps, so registering/unregistering goes to the correct region */ - short spaceid, regionid; - char mapidname[64]; + struct wmManipulatorMapType_Params mmap_params; + } wmManipulatorGroupType; +typedef struct wmManipulatorGroup { + struct wmManipulatorGroup *next, *prev; + + struct wmManipulatorGroupType *type; + ListBase manipulators; + + struct wmManipulatorMap *parent_mmap; + + void *py_instance; /* python stores the class instance here */ + struct ReportList *reports; /* errors and warnings storage */ + + void *customdata; + void (*customdata_free)(void *); /* for freeing customdata from above */ + int flag; /* private */ + int pad; +} wmManipulatorGroup; + +/** + * Manipulator-map type update flag: `wmManipulatorMapType.type_update_flag` + */ +enum eManipulatorMapTypeUpdateFlags { + /* A new type has been added, needs to be initialized for all views. */ + WM_MANIPULATORMAPTYPE_UPDATE_INIT = (1 << 0), +}; + /** * wmManipulatorGroupType.flag * Flags that influence the behavior of all manipulators in the group. @@ -244,18 +297,14 @@ enum { WM_MANIPULATORGROUPTYPE_DEPTH_3D = (1 << 2), /* Manipulators can be selected */ WM_MANIPULATORGROUPTYPE_SELECT = (1 << 3), + /* The manipulator group is to be kept (not removed on loading a new file for eg). */ + WM_MANIPULATORGROUPTYPE_PERSISTENT = (1 << 4), }; /* -------------------------------------------------------------------- */ /* wmManipulatorMap */ -struct wmManipulatorMapType_Params { - const char *idname; - const int spaceid; - const int regionid; -}; - /** * Pass a value of this enum to #WM_manipulatormap_draw to tell it what to draw. */ diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c index 3dba5ab55e2..ae7353971f0 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c @@ -30,13 +30,10 @@ #include "BKE_context.h" #include "BLI_listbase.h" -#include "BLI_ghash.h" #include "BLI_math.h" #include "BLI_string.h" #include "BLI_string_utils.h" -#include "DNA_manipulator_types.h" - #include "ED_screen.h" #include "ED_view3d.h" @@ -65,118 +62,6 @@ static void wm_manipulator_register( wmManipulatorGroup *mgroup, wmManipulator *mpr, const char *name); -/** \name Manipulator Type Append - * - * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends. - * \{ */ - -static GHash *global_manipulatortype_hash = NULL; - -const wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet) -{ - if (idname[0]) { - wmManipulatorType *wt; - - wt = BLI_ghash_lookup(global_manipulatortype_hash, idname); - if (wt) { - return wt; - } - - if (!quiet) { - printf("search for unknown manipulator '%s'\n", idname); - } - } - else { - if (!quiet) { - printf("search for empty manipulator\n"); - } - } - - return NULL; -} - -/* caller must free */ -void WM_manipulatortype_iter(GHashIterator *ghi) -{ - BLI_ghashIterator_init(ghi, global_manipulatortype_hash); -} - -static wmManipulatorType *wm_manipulatortype_append__begin(void) -{ - wmManipulatorType *wt = MEM_callocN(sizeof(wmManipulatorType), "manipulatortype"); - return wt; -} -static void wm_manipulatortype_append__end(wmManipulatorType *wt) -{ - BLI_assert(wt->struct_size >= sizeof(wmManipulator)); - - BLI_ghash_insert(global_manipulatortype_hash, (void *)wt->idname, wt); -} - -void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *)) -{ - wmManipulatorType *wt = wm_manipulatortype_append__begin(); - wtfunc(wt); - wm_manipulatortype_append__end(wt); -} - -void WM_manipulatortype_append_ptr(void (*wtfunc)(struct wmManipulatorType *, void *), void *userdata) -{ - wmManipulatorType *mt = wm_manipulatortype_append__begin(); - wtfunc(mt, userdata); - wm_manipulatortype_append__end(mt); -} - -/** - * Free but don't remove from ghash. - */ -static void manipulatortype_free(wmManipulatorType *wt) -{ - MEM_freeN(wt); -} - -void WM_manipulatortype_remove_ptr(wmManipulatorType *wt) -{ - BLI_assert(wt == WM_manipulatortype_find(wt->idname, false)); - - BLI_ghash_remove(global_manipulatortype_hash, wt->idname, NULL, NULL); - - manipulatortype_free(wt); -} - -bool WM_manipulatortype_remove(const char *idname) -{ - wmManipulatorType *wt = BLI_ghash_lookup(global_manipulatortype_hash, idname); - - if (wt == NULL) { - return false; - } - - WM_manipulatortype_remove_ptr(wt); - - return true; -} - -static void wm_manipulatortype_ghash_free_cb(wmManipulatorType *mt) -{ - manipulatortype_free(mt); -} - -void wm_manipulatortype_free(void) -{ - BLI_ghash_free(global_manipulatortype_hash, NULL, (GHashValFreeFP)wm_manipulatortype_ghash_free_cb); - global_manipulatortype_hash = NULL; -} - -/* called on initialize WM_init() */ -void wm_manipulatortype_init(void) -{ - /* reserve size is set based on blender default setup */ - global_manipulatortype_hash = BLI_ghash_str_new_ex("wm_manipulatortype_init gh", 128); -} - -/** \} */ - /** * \note Follow #wm_operator_create convention. */ @@ -215,11 +100,6 @@ wmManipulator *WM_manipulator_new(const char *idname, wmManipulatorGroup *mgroup return mpr; } -wmManipulatorGroup *WM_manipulator_get_parent_group(wmManipulator *mpr) -{ - return mpr->parent_mgroup; -} - /** * Assign an idname that is unique in \a mgroup to \a manipulator. * @@ -297,12 +177,6 @@ void WM_manipulator_free(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmMa MEM_freeN(mpr); } -wmManipulatorGroup *wm_manipulator_get_parent_group(const wmManipulator *mpr) -{ - return mpr->parent_mgroup; -} - - /* -------------------------------------------------------------------- */ /** \name Manipulator Creation API * @@ -310,34 +184,6 @@ wmManipulatorGroup *wm_manipulator_get_parent_group(const wmManipulator *mpr) * * \{ */ -struct wmManipulatorProperty *WM_manipulator_get_property(wmManipulator *mpr, const char *idname) -{ - return BLI_findstring(&mpr->properties, idname, offsetof(wmManipulatorProperty, idname)); -} - -void WM_manipulator_def_property( - wmManipulator *mpr, const char *idname, - PointerRNA *ptr, const char *propname, int index) -{ - wmManipulatorProperty *mpr_prop = WM_manipulator_get_property(mpr, idname); - - if (mpr_prop == NULL) { - const uint idname_size = strlen(idname) + 1; - mpr_prop = MEM_callocN(sizeof(wmManipulatorProperty) + idname_size, __func__); - memcpy(mpr_prop->idname, idname, idname_size); - BLI_addtail(&mpr->properties, mpr_prop); - } - - /* if manipulator evokes an operator we cannot use it for property manipulation */ - mpr->opname = NULL; - mpr_prop->ptr = *ptr; - mpr_prop->prop = RNA_struct_find_property(ptr, propname); - mpr_prop->index = index; - - if (mpr->type->property_update) { - mpr->type->property_update(mpr, mpr_prop); - } -} PointerRNA *WM_manipulator_set_operator(wmManipulator *mpr, const char *opname) { @@ -533,7 +379,7 @@ static void manipulator_update_prop_data(wmManipulator *mpr) /* manipulator property might have been changed, so update manipulator */ if (mpr->type->property_update && !BLI_listbase_is_empty(&mpr->properties)) { for (wmManipulatorProperty *mpr_prop = mpr->properties.first; mpr_prop; mpr_prop = mpr_prop->next) { - if (mpr_prop->prop != NULL) { + if (WM_manipulator_property_is_valid(mpr_prop)) { mpr->type->property_update(mpr, mpr_prop); } } diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h index 0692b1830db..52c47f74a29 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h @@ -56,7 +56,7 @@ enum { }; struct wmManipulatorGroup *wm_manipulatorgroup_new_from_type( - struct wmManipulatorMap *mmap, struct wmManipulatorGroupType *mgroup_type); + struct wmManipulatorMap *mmap, struct wmManipulatorGroupType *wgt); void wm_manipulatorgroup_free(bContext *C, struct wmManipulatorGroup *mgroup); void wm_manipulatorgroup_manipulator_register(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr); struct wmManipulator *wm_manipulatorgroup_find_intersected_mainpulator( @@ -68,7 +68,8 @@ void wm_manipulatorgroup_ensure_initialized(struct wmManipulatorGroup *mgroup, c bool wm_manipulatorgroup_is_visible(const struct wmManipulatorGroup *mgroup, const struct bContext *C); bool wm_manipulatorgroup_is_visible_in_drawstep(const struct wmManipulatorGroup *mgroup, const int drawstep); -void wm_manipulatorgrouptype_setup_keymap(struct wmManipulatorGroupType *wgt, struct wmKeyConfig *keyconf); +void wm_manipulatorgrouptype_setup_keymap( + struct wmManipulatorGroupType *wgt, struct wmKeyConfig *keyconf); /* -------------------------------------------------------------------- */ @@ -78,7 +79,7 @@ struct wmManipulatorMap { struct wmManipulatorMap *next, *prev; struct wmManipulatorMapType *type; - ListBase manipulator_groups; + ListBase groups; /* wmManipulatorGroup */ char update_flag; /* private, update tagging */ @@ -108,10 +109,12 @@ struct wmManipulatorMap { */ struct wmManipulatorMapType { struct wmManipulatorMapType *next, *prev; - char idname[64]; short spaceid, regionid; /* types of manipulator-groups for this manipulator-map type */ - ListBase manipulator_grouptypes; + ListBase grouptype_refs; + + /* eManipulatorMapTypeUpdateFlags */ + uchar type_update_flag; }; void wm_manipulatormap_selected_clear(struct wmManipulatorMap *mmap); diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c new file mode 100644 index 00000000000..5a8eb1d68dc --- /dev/null +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c @@ -0,0 +1,175 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/manipulators/intern/wm_manipulator_property.c + * \ingroup wm + */ + +#include "BKE_context.h" + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_string.h" +#include "BLI_string_utils.h" + +#include "ED_screen.h" +#include "ED_view3d.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "wm.h" + +/* own includes */ +#include "wm_manipulator_wmapi.h" +#include "wm_manipulator_intern.h" + +/* factor for precision tweaking */ +#define MANIPULATOR_PRECISION_FAC 0.05f + +/* -------------------------------------------------------------------- */ + +/** \name Property Definition + * \{ */ + +wmManipulatorProperty *WM_manipulator_property_find(wmManipulator *mpr, const char *idname) +{ + return BLI_findstring(&mpr->properties, idname, offsetof(wmManipulatorProperty, idname)); +} + +static wmManipulatorProperty *wm_manipulator_property_def_internal( + wmManipulator *mpr, const char *idname) +{ + wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, idname); + + if (mpr_prop == NULL) { + const uint idname_size = strlen(idname) + 1; + mpr_prop = MEM_callocN(sizeof(wmManipulatorProperty) + idname_size, __func__); + memcpy(mpr_prop->idname, idname, idname_size); + BLI_addtail(&mpr->properties, mpr_prop); + } + return mpr_prop; +} + +void WM_manipulator_property_def_rna( + wmManipulator *mpr, const char *idname, + PointerRNA *ptr, const char *propname, int index) +{ + wmManipulatorProperty *mpr_prop = wm_manipulator_property_def_internal(mpr, idname); + + /* if manipulator evokes an operator we cannot use it for property manipulation */ + mpr->opname = NULL; + + mpr_prop->ptr = *ptr; + mpr_prop->prop = RNA_struct_find_property(ptr, propname); + mpr_prop->index = index; + + if (mpr->type->property_update) { + mpr->type->property_update(mpr, mpr_prop); + } +} + +void WM_manipulator_property_def_func( + wmManipulator *mpr, const char *idname, + const wmManipulatorPropertyFnParams *params) +{ + wmManipulatorProperty *mpr_prop = wm_manipulator_property_def_internal(mpr, idname); + + /* if manipulator evokes an operator we cannot use it for property manipulation */ + mpr->opname = NULL; + + mpr_prop->custom_func.value_get_fn = params->value_get_fn; + mpr_prop->custom_func.value_set_fn = params->value_set_fn; + mpr_prop->custom_func.range_get_fn = params->range_get_fn; + mpr_prop->custom_func.user_data = params->user_data; + + if (mpr->type->property_update) { + mpr->type->property_update(mpr, mpr_prop); + } +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name Property Access + * \{ */ + +bool WM_manipulator_property_is_valid(const wmManipulatorProperty *mpr_prop) +{ + return ((mpr_prop->prop != NULL) || + (mpr_prop->custom_func.value_get_fn && mpr_prop->custom_func.value_set_fn)); +} + +void WM_manipulator_property_value_set( + bContext *C, const wmManipulator *mpr, + wmManipulatorProperty *mpr_prop, const float value) +{ + if (mpr_prop->custom_func.value_set_fn) { + mpr_prop->custom_func.value_set_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, &value, 1); + return; + } + + /* reset property */ + if (mpr_prop->index == -1) { + RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, value); + } + else { + RNA_property_float_set_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index, value); + } + RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); +} + +float WM_manipulator_property_value_get( + const wmManipulator *mpr, wmManipulatorProperty *mpr_prop) +{ + if (mpr_prop->custom_func.value_get_fn) { + float value = 0.0f; + mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, &value, 1); + return value; + } + + if (mpr_prop->index == -1) { + return RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop); + } + else { + return RNA_property_float_get_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index); + } +} + +void WM_manipulator_property_range_get( + const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, + float range[2]) +{ + if (mpr_prop->custom_func.range_get_fn) { + mpr_prop->custom_func.range_get_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, range); + return; + } + + float step, precision; + RNA_property_float_ui_range(&mpr_prop->ptr, mpr_prop->prop, &range[0], &range[1], &step, &precision); +} + +/** \} */ diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c new file mode 100644 index 00000000000..e89d4cc6e81 --- /dev/null +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c @@ -0,0 +1,156 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/manipulators/intern/wm_manipulator_type.c + * \ingroup wm + */ + +#include "BKE_context.h" + +#include "BLI_ghash.h" +#include "BLI_string.h" +#include "BLI_string_utils.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */ +#include "wm.h" + +/* own includes */ +#include "wm_manipulator_wmapi.h" +#include "wm_manipulator_intern.h" + + +/** \name Manipulator Type Append + * + * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends. + * \{ */ + +static GHash *global_manipulatortype_hash = NULL; + +const wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet) +{ + if (idname[0]) { + wmManipulatorType *wt; + + wt = BLI_ghash_lookup(global_manipulatortype_hash, idname); + if (wt) { + return wt; + } + + if (!quiet) { + printf("search for unknown manipulator '%s'\n", idname); + } + } + else { + if (!quiet) { + printf("search for empty manipulator\n"); + } + } + + return NULL; +} + +/* caller must free */ +void WM_manipulatortype_iter(GHashIterator *ghi) +{ + BLI_ghashIterator_init(ghi, global_manipulatortype_hash); +} + +static wmManipulatorType *wm_manipulatortype_append__begin(void) +{ + wmManipulatorType *wt = MEM_callocN(sizeof(wmManipulatorType), "manipulatortype"); + return wt; +} +static void wm_manipulatortype_append__end(wmManipulatorType *wt) +{ + BLI_assert(wt->struct_size >= sizeof(wmManipulator)); + + BLI_ghash_insert(global_manipulatortype_hash, (void *)wt->idname, wt); +} + +void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *)) +{ + wmManipulatorType *wt = wm_manipulatortype_append__begin(); + wtfunc(wt); + wm_manipulatortype_append__end(wt); +} + +void WM_manipulatortype_append_ptr(void (*wtfunc)(struct wmManipulatorType *, void *), void *userdata) +{ + wmManipulatorType *mt = wm_manipulatortype_append__begin(); + wtfunc(mt, userdata); + wm_manipulatortype_append__end(mt); +} + +/** + * Free but don't remove from ghash. + */ +static void manipulatortype_free(wmManipulatorType *wt) +{ + MEM_freeN(wt); +} + +void WM_manipulatortype_remove_ptr(wmManipulatorType *wt) +{ + BLI_assert(wt == WM_manipulatortype_find(wt->idname, false)); + + BLI_ghash_remove(global_manipulatortype_hash, wt->idname, NULL, NULL); + + manipulatortype_free(wt); +} + +bool WM_manipulatortype_remove(const char *idname) +{ + wmManipulatorType *wt = BLI_ghash_lookup(global_manipulatortype_hash, idname); + + if (wt == NULL) { + return false; + } + + WM_manipulatortype_remove_ptr(wt); + + return true; +} + +static void wm_manipulatortype_ghash_free_cb(wmManipulatorType *mt) +{ + manipulatortype_free(mt); +} + +void wm_manipulatortype_free(void) +{ + BLI_ghash_free(global_manipulatortype_hash, NULL, (GHashValFreeFP)wm_manipulatortype_ghash_free_cb); + global_manipulatortype_hash = NULL; +} + +/* called on initialize WM_init() */ +void wm_manipulatortype_init(void) +{ + /* reserve size is set based on blender default setup */ + global_manipulatortype_hash = BLI_ghash_str_new_ex("wm_manipulatortype_init gh", 128); +} + +/** \} */
\ No newline at end of file diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c b/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c index ac478fe5e95..3deef0cee5c 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c @@ -44,8 +44,6 @@ #include "BPY_extern.h" -#include "DNA_manipulator_types.h" - #include "ED_screen.h" #include "MEM_guardedalloc.h" @@ -84,7 +82,7 @@ wmManipulatorGroup *wm_manipulatorgroup_new_from_type( /* keep back-link */ mgroup->parent_mmap = mmap; - BLI_addtail(&mmap->manipulator_groups, mgroup); + BLI_addtail(&mmap->groups, mgroup); return mgroup; } @@ -118,7 +116,7 @@ void wm_manipulatorgroup_free(bContext *C, wmManipulatorGroup *mgroup) MEM_SAFE_FREE(mgroup->customdata); } - BLI_remlink(&mmap->manipulator_groups, mgroup); + BLI_remlink(&mmap->groups, mgroup); MEM_freeN(mgroup); } @@ -391,7 +389,11 @@ void MANIPULATORGROUP_OT_manipulator_tweak(wmOperatorType *ot) ot->invoke = manipulator_tweak_invoke; ot->modal = manipulator_tweak_modal; + /* TODO(campbell) This causes problems tweaking settings for operators, + * need to find a way to support this. */ +#if 0 ot->flag = OPTYPE_UNDO; +#endif } /** \} */ // Manipulator operators @@ -442,10 +444,11 @@ static wmKeyMap *manipulatorgroup_tweak_modal_keymap(wmKeyConfig *keyconf, const /** * Common default keymap for manipulator groups */ -wmKeyMap *WM_manipulatorgroup_keymap_common(const struct wmManipulatorGroupType *wgt, wmKeyConfig *config) +wmKeyMap *WM_manipulatorgroup_keymap_common( + const wmManipulatorGroupType *wgt, wmKeyConfig *config) { /* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */ - wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->spaceid, wgt->regionid); + wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid); WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0); manipulatorgroup_tweak_modal_keymap(config, wgt->name); @@ -456,10 +459,11 @@ wmKeyMap *WM_manipulatorgroup_keymap_common(const struct wmManipulatorGroupType /** * Variation of #WM_manipulatorgroup_keymap_common but with keymap items for selection */ -wmKeyMap *WM_manipulatorgroup_keymap_common_sel(const struct wmManipulatorGroupType *wgt, wmKeyConfig *config) +wmKeyMap *WM_manipulatorgroup_keymap_common_select( + const wmManipulatorGroupType *wgt, wmKeyConfig *config) { /* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */ - wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->spaceid, wgt->regionid); + wmKeyMap *km = WM_keymap_find(config, wgt->name, wgt->mmap_params.spaceid, wgt->mmap_params.regionid); WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0); manipulatorgroup_tweak_modal_keymap(config, wgt->name); @@ -483,99 +487,60 @@ wmKeyMap *WM_manipulatorgroup_keymap_common_sel(const struct wmManipulatorGroupT * * \{ */ -struct wmManipulatorGroupType *WM_manipulatorgrouptype_find( - struct wmManipulatorMapType *mmaptype, - const char *idname) +struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr( + struct wmManipulatorMapType *mmap_type, + const wmManipulatorGroupType *wgt) { /* could use hash lookups as operator types do, for now simple search. */ - for (wmManipulatorGroupType *wgt = mmaptype->manipulator_grouptypes.first; - wgt; - wgt = wgt->next) + for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; + wgt_ref; + wgt_ref = wgt_ref->next) { - if (STREQ(idname, wgt->idname)) { - return wgt; + if (wgt_ref->type == wgt) { + return wgt_ref; } } return NULL; } - -static wmManipulatorGroupType *wm_manipulatorgrouptype_append__begin(void) -{ - wmManipulatorGroupType *wgt = MEM_callocN(sizeof(wmManipulatorGroupType), "manipulator-group"); - return wgt; -} -static void wm_manipulatorgrouptype_append__end( - wmManipulatorMapType *mmaptype, wmManipulatorGroupType *wgt) +struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find( + struct wmManipulatorMapType *mmap_type, + const char *idname) { - BLI_assert(wgt->name != NULL); - BLI_assert(wgt->idname != NULL); - - wgt->spaceid = mmaptype->spaceid; - wgt->regionid = mmaptype->regionid; - BLI_strncpy(wgt->mapidname, mmaptype->idname, MAX_NAME); - /* if not set, use default */ - if (!wgt->setup_keymap) { - wgt->setup_keymap = WM_manipulatorgroup_keymap_common; + /* could use hash lookups as operator types do, for now simple search. */ + for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; + wgt_ref; + wgt_ref = wgt_ref->next) + { + if (STREQ(idname, wgt_ref->type->idname)) { + return wgt_ref; + } } - - /* add the type for future created areas of the same type */ - BLI_addtail(&mmaptype->manipulator_grouptypes, wgt); + return NULL; } /** - * Use this for registering manipulators on startup. For runtime, use #WM_manipulatorgrouptype_append_runtime. + * Use this for registering manipulators on startup. For runtime, use #WM_manipulatormaptype_group_link_runtime. */ -wmManipulatorGroupType *WM_manipulatorgrouptype_append( - wmManipulatorMapType *mmaptype, void (*wgt_func)(wmManipulatorGroupType *)) +wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link( + wmManipulatorMapType *mmap_type, const char *idname) { - wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin(); - wgt_func(wgt); - wm_manipulatorgrouptype_append__end(mmaptype, wgt); - return wgt; + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + BLI_assert(wgt != NULL); + return WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); } -wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr( - wmManipulatorMapType *mmaptype, void (*wgt_func)(wmManipulatorGroupType *, void *), - void *userdata) +wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr( + wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) { - wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin(); - wgt_func(wgt, userdata); - wm_manipulatorgrouptype_append__end(mmaptype, wgt); - return wgt; + wmManipulatorGroupTypeRef *wgt_ref = MEM_callocN(sizeof(wmManipulatorGroupTypeRef), "manipulator-group-ref"); + wgt_ref->type = wgt; + BLI_addtail(&mmap_type->grouptype_refs, wgt_ref); + return wgt_ref; } -/** - * Use this for registering manipulators on runtime. - */ -wmManipulatorGroupType *WM_manipulatorgrouptype_append_runtime( - const Main *main, wmManipulatorMapType *mmaptype, - void (*wgt_func)(wmManipulatorGroupType *)) -{ - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append(mmaptype, wgt_func); - - /* Main is missing on startup when we create new areas. - * So this is only called for manipulators initialized on runtime */ - WM_manipulatorgrouptype_init_runtime(main, mmaptype, wgt); - - return wgt; -} -wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr_runtime( - const Main *main, wmManipulatorMapType *mmaptype, - void (*wgt_func)(wmManipulatorGroupType *, void *), - void *userdata) -{ - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append_ptr(mmaptype, wgt_func, userdata); - - /* Main is missing on startup when we create new areas. - * So this is only called for manipulators initialized on runtime */ - WM_manipulatorgrouptype_init_runtime(main, mmaptype, wgt); - - return wgt; -} - -void WM_manipulatorgrouptype_init_runtime( - const Main *bmain, wmManipulatorMapType *mmaptype, +void WM_manipulatormaptype_group_init_runtime( + const Main *bmain, wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) { /* init keymap - on startup there's an extra call to init keymaps for 'permanent' manipulator-groups */ @@ -588,7 +553,7 @@ void WM_manipulatorgrouptype_init_runtime( ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; for (ARegion *ar = lb->first; ar; ar = ar->next) { wmManipulatorMap *mmap = ar->manipulator_map; - if (mmap && mmap->type == mmaptype) { + if (mmap && mmap->type == mmap_type) { wm_manipulatorgroup_new_from_type(mmap, wgt); /* just add here, drawing will occur on next update */ @@ -603,24 +568,27 @@ void WM_manipulatorgrouptype_init_runtime( /** - * Unlike #WM_manipulatorgrouptype_remove_ptr this doesn't maintain correct state, simply free. + * Unlike #WM_manipulatormaptype_group_unlink this doesn't maintain correct state, simply free. */ -void WM_manipulatorgrouptype_free(wmManipulatorGroupType *wgt) +void WM_manipulatormaptype_group_free(wmManipulatorGroupTypeRef *wgt_ref) { - MEM_freeN(wgt); + MEM_freeN(wgt_ref); } -void WM_manipulatorgrouptype_remove_ptr(bContext *C, Main *bmain, wmManipulatorGroupType *wgt) +void WM_manipulatormaptype_group_unlink( + bContext *C, Main *bmain, wmManipulatorMapType *mmap_type, + const wmManipulatorGroupType *wgt) { + /* Free instances. */ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; for (ARegion *ar = lb->first; ar; ar = ar->next) { wmManipulatorMap *mmap = ar->manipulator_map; - if (mmap) { + if (mmap && mmap->type == mmap_type) { wmManipulatorGroup *mgroup, *mgroup_next; - for (mgroup = mmap->manipulator_groups.first; mgroup; mgroup = mgroup_next) { + for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup_next) { mgroup_next = mgroup->next; if (mgroup->type == wgt) { BLI_assert(mgroup->parent_mmap == mmap); @@ -634,19 +602,80 @@ void WM_manipulatorgrouptype_remove_ptr(bContext *C, Main *bmain, wmManipulatorG } } - wmManipulatorMapType *mmaptype = WM_manipulatormaptype_find(&(const struct wmManipulatorMapType_Params) { - wgt->mapidname, wgt->spaceid, - wgt->regionid}); - - BLI_remlink(&mmaptype->manipulator_grouptypes, wgt); - wgt->prev = wgt->next = NULL; - - WM_manipulatorgrouptype_free(wgt); + /* Free types. */ + wmManipulatorGroupTypeRef *wgt_ref = WM_manipulatormaptype_group_find_ptr(mmap_type, wgt); + if (wgt_ref) { + BLI_remlink(&mmap_type->grouptype_refs, wgt_ref); + WM_manipulatormaptype_group_free(wgt_ref); + } + BLI_assert(WM_manipulatormaptype_group_find_ptr(mmap_type, wgt) == NULL); } -void wm_manipulatorgrouptype_setup_keymap(wmManipulatorGroupType *wgt, wmKeyConfig *keyconf) +void wm_manipulatorgrouptype_setup_keymap( + wmManipulatorGroupType *wgt, wmKeyConfig *keyconf) { wgt->keymap = wgt->setup_keymap(wgt, keyconf); } /** \} */ /* wmManipulatorGroupType */ + +/* -------------------------------------------------------------------- */ +/** \name High Level Add/Remove API + * + * For use directly from operators & RNA registration. + * + * \note In context of manipulator API these names are a bit misleading, + * but for general use terms its OK. + * `WM_manipulator_group_add` would be more correctly called: + * `WM_manipulatormaptype_grouptype_reference_link` + * but for general purpose API this is too detailed & annoying. + * + * \note We may want to return a value if there is nothing to remove. + * + * \{ */ + +void WM_manipulator_group_add_ptr_ex( + wmManipulatorGroupType *wgt, + wmManipulatorMapType *mmap_type) +{ + WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); + + WM_manipulatorconfig_update_tag_init(mmap_type, wgt); +} + +void WM_manipulator_group_add_ptr( + wmManipulatorGroupType *wgt) +{ + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); + WM_manipulator_group_add_ptr_ex(wgt, mmap_type); +} + +void WM_manipulator_group_add(const char *idname) +{ + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + BLI_assert(wgt != NULL); + WM_manipulator_group_add_ptr(wgt); +} + +void WM_manipulator_group_remove_ptr_ex( + struct Main *bmain, wmManipulatorGroupType *wgt, + wmManipulatorMapType *mmap_type) +{ + WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt); +} + +void WM_manipulator_group_remove_ptr( + struct Main *bmain, wmManipulatorGroupType *wgt) +{ + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); + WM_manipulator_group_remove_ptr_ex(bmain, wgt, mmap_type); +} + +void WM_manipulator_group_remove(struct Main *bmain, const char *idname) +{ + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + BLI_assert(wgt != NULL); + WM_manipulator_group_remove_ptr(bmain, wgt); +} + +/** \} */ diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup_type.c b/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup_type.c new file mode 100644 index 00000000000..a20aa0ec15f --- /dev/null +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup_type.c @@ -0,0 +1,185 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/windowmanager/manipulators/intern/wm_manipulatorgroup_type.c + * \ingroup wm + */ + +#include "BKE_context.h" + +#include "BLI_ghash.h" +#include "BLI_string.h" +#include "BLI_string_utils.h" + +#include "MEM_guardedalloc.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +/* only for own init/exit calls (wm_manipulatorgrouptype_init/wm_manipulatorgrouptype_free) */ +#include "wm.h" + +/* own includes */ +#include "wm_manipulator_wmapi.h" +#include "wm_manipulator_intern.h" + + +/** \name ManipulatorGroup Type Append + * + * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends. + * \{ */ + +static GHash *global_manipulatorgrouptype_hash = NULL; + +wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet) +{ + if (idname[0]) { + wmManipulatorGroupType *wgt; + + wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname); + if (wgt) { + return wgt; + } + + if (!quiet) { + printf("search for unknown manipulator group '%s'\n", idname); + } + } + else { + if (!quiet) { + printf("search for empty manipulator group\n"); + } + } + + return NULL; +} + +/* caller must free */ +void WM_manipulatorgrouptype_iter(GHashIterator *ghi) +{ + BLI_ghashIterator_init(ghi, global_manipulatorgrouptype_hash); +} + +static wmManipulatorGroupType *wm_manipulatorgrouptype_append__begin(void) +{ + wmManipulatorGroupType *wgt = MEM_callocN(sizeof(wmManipulatorGroupType), "manipulatorgrouptype"); + + return wgt; +} +static void wm_manipulatorgrouptype_append__end(wmManipulatorGroupType *wgt) +{ + BLI_assert(wgt->name != NULL); + BLI_assert(wgt->idname != NULL); + + /* if not set, use default */ + if (wgt->setup_keymap == NULL) { + wgt->setup_keymap = WM_manipulatorgroup_keymap_common; + } + + BLI_ghash_insert(global_manipulatorgrouptype_hash, (void *)wgt->idname, wgt); +} + +wmManipulatorGroupType *WM_manipulatorgrouptype_append( + void (*wtfunc)(struct wmManipulatorGroupType *)) +{ + wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin(); + wtfunc(wgt); + wm_manipulatorgrouptype_append__end(wgt); + return wgt; +} + +wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr( + void (*wtfunc)(struct wmManipulatorGroupType *, void *), void *userdata) +{ + wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin(); + wtfunc(wgt, userdata); + wm_manipulatorgrouptype_append__end(wgt); + return wgt; +} + +/** + * Append and insert into a manipulator typemap. + * This is most common for C manipulators which are enabled by default. + */ +wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link( + wmManipulatorMapType *mmap_type, + void (*wtfunc)(struct wmManipulatorGroupType *)) +{ + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append(wtfunc); + + wgt->mmap_params.spaceid = mmap_type->spaceid; + wgt->mmap_params.regionid = mmap_type->regionid; + + return WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); +} + +/** + * Free but don't remove from ghash. + */ +static void manipulatorgrouptype_free(wmManipulatorGroupType *wgt) +{ + MEM_freeN(wgt); +} + +void WM_manipulatorgrouptype_remove_ptr(wmManipulatorGroupType *wgt) +{ + BLI_assert(wgt == WM_manipulatorgrouptype_find(wgt->idname, false)); + + BLI_ghash_remove(global_manipulatorgrouptype_hash, wgt->idname, NULL, NULL); + + manipulatorgrouptype_free(wgt); + + /* XXX, TODO, update the world! */ +} + +bool WM_manipulatorgrouptype_remove(const char *idname) +{ + wmManipulatorGroupType *wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname); + + if (wgt == NULL) { + return false; + } + + WM_manipulatorgrouptype_remove_ptr(wgt); + + return true; +} + +static void wm_manipulatorgrouptype_ghash_free_cb(wmManipulatorGroupType *mt) +{ + manipulatorgrouptype_free(mt); +} + +void wm_manipulatorgrouptype_free(void) +{ + BLI_ghash_free(global_manipulatorgrouptype_hash, NULL, (GHashValFreeFP)wm_manipulatorgrouptype_ghash_free_cb); + global_manipulatorgrouptype_hash = NULL; +} + +/* called on initialize WM_init() */ +void wm_manipulatorgrouptype_init(void) +{ + /* reserve size is set based on blender default setup */ + global_manipulatorgrouptype_hash = BLI_ghash_str_new_ex("wm_manipulatorgrouptype_init gh", 128); +} + +/** \} */
\ No newline at end of file diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c b/source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c index 51466426d79..123c46f9c50 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c @@ -29,14 +29,13 @@ #include <string.h> -#include "BKE_context.h" - #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_string.h" #include "BLI_ghash.h" -#include "DNA_manipulator_types.h" +#include "BKE_context.h" +#include "BKE_global.h" #include "ED_screen.h" #include "ED_view3d.h" @@ -62,6 +61,16 @@ static ListBase manipulatormaptypes = {NULL, NULL}; /** + * Update when manipulator-map types change. + */ +/* so operator removal can trigger update */ +enum { + WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0), +}; + +static char wm_mmap_type_update_flag = 0; + +/** * Manipulator-map update tagging. */ enum eManipulatorMapUpdateFlags { @@ -80,17 +89,17 @@ enum eManipulatorMapUpdateFlags { */ wmManipulatorMap *WM_manipulatormap_new_from_type(const struct wmManipulatorMapType_Params *mmap_params) { - wmManipulatorMapType *mmaptype = WM_manipulatormaptype_ensure(mmap_params); + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(mmap_params); wmManipulatorMap *mmap; mmap = MEM_callocN(sizeof(wmManipulatorMap), "ManipulatorMap"); - mmap->type = mmaptype; + mmap->type = mmap_type; mmap->update_flag = MANIPULATORMAP_REFRESH; /* create all manipulator-groups for this manipulator-map. We may create an empty one * too in anticipation of manipulators from operators etc */ - for (wmManipulatorGroupType *wgt = mmaptype->manipulator_grouptypes.first; wgt; wgt = wgt->next) { - wm_manipulatorgroup_new_from_type(mmap, wgt); + for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { + wm_manipulatorgroup_new_from_type(mmap, wgt_ref->type); } return mmap; @@ -107,12 +116,12 @@ void wm_manipulatormap_remove(wmManipulatorMap *mmap) if (!mmap) return; - for (wmManipulatorGroup *mgroup = mmap->manipulator_groups.first, *mgroup_next; mgroup; mgroup = mgroup_next) { + for (wmManipulatorGroup *mgroup = mmap->groups.first, *mgroup_next; mgroup; mgroup = mgroup_next) { mgroup_next = mgroup->next; BLI_assert(mgroup->parent_mmap == mmap); wm_manipulatorgroup_free(NULL, mgroup); } - BLI_assert(BLI_listbase_is_empty(&mmap->manipulator_groups)); + BLI_assert(BLI_listbase_is_empty(&mmap->groups)); wm_manipulatormap_selected_clear(mmap); @@ -133,7 +142,7 @@ static GHash *WM_manipulatormap_manipulator_hash_new( GHash *hash = BLI_ghash_str_new(__func__); /* collect manipulators */ - for (wmManipulatorGroup *mgroup = mmap->manipulator_groups.first; mgroup; mgroup = mgroup->next) { + for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { if (!mgroup->type->poll || mgroup->type->poll(C, mgroup->type)) { for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { if ((include_hidden || (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) && @@ -183,7 +192,7 @@ static bool manipulator_prepare_drawing( static void manipulatormap_prepare_drawing( wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators, const int drawstep) { - if (!mmap || BLI_listbase_is_empty(&mmap->manipulator_groups)) + if (!mmap || BLI_listbase_is_empty(&mmap->groups)) return; wmManipulator *active_manipulator = mmap->mmap_context.active; @@ -196,7 +205,7 @@ static void manipulatormap_prepare_drawing( return; } - for (wmManipulatorGroup *mgroup = mmap->manipulator_groups.first; mgroup; mgroup = mgroup->next) { + for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { /* check group visibility - drawstep first to avoid unnecessary call of group poll callback */ if (!wm_manipulatorgroup_is_visible_in_drawstep(mgroup, drawstep) || !wm_manipulatorgroup_is_visible(mgroup, C)) @@ -232,7 +241,7 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext { if (!mmap) return; - BLI_assert(!BLI_listbase_is_empty(&mmap->manipulator_groups)); + BLI_assert(!BLI_listbase_is_empty(&mmap->groups)); const bool draw_multisample = (U.ogl_multisamples != USER_MULTISAMPLE_NONE); @@ -366,7 +375,7 @@ wmManipulator *wm_manipulatormap_highlight_find( wmManipulator *mpr = NULL; ListBase visible_3d_manipulators = {NULL}; - for (wmManipulatorGroup *mgroup = mmap->manipulator_groups.first; mgroup; mgroup = mgroup->next) { + for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { if (wm_manipulatorgroup_is_visible(mgroup, C)) { if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { wm_manipulatorgroup_intersectable_manipulators_to_list(mgroup, &visible_3d_manipulators); @@ -700,12 +709,11 @@ wmManipulator *wm_manipulatormap_active_get(wmManipulatorMap *mmap) wmManipulatorMapType *WM_manipulatormaptype_find( const struct wmManipulatorMapType_Params *mmap_params) { - for (wmManipulatorMapType *mmaptype = manipulatormaptypes.first; mmaptype; mmaptype = mmaptype->next) { - if (mmaptype->spaceid == mmap_params->spaceid && - mmaptype->regionid == mmap_params->regionid && - STREQ(mmaptype->idname, mmap_params->idname)) + for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; mmap_type; mmap_type = mmap_type->next) { + if (mmap_type->spaceid == mmap_params->spaceid && + mmap_type->regionid == mmap_params->regionid) { - return mmaptype; + return mmap_type; } } @@ -715,36 +723,35 @@ wmManipulatorMapType *WM_manipulatormaptype_find( wmManipulatorMapType *WM_manipulatormaptype_ensure( const struct wmManipulatorMapType_Params *mmap_params) { - wmManipulatorMapType *mmaptype = WM_manipulatormaptype_find(mmap_params); + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_find(mmap_params); - if (mmaptype) { - return mmaptype; + if (mmap_type) { + return mmap_type; } - mmaptype = MEM_callocN(sizeof(wmManipulatorMapType), "manipulatortype list"); - mmaptype->spaceid = mmap_params->spaceid; - mmaptype->regionid = mmap_params->regionid; - BLI_strncpy(mmaptype->idname, mmap_params->idname, sizeof(mmaptype->idname)); - BLI_addhead(&manipulatormaptypes, mmaptype); + mmap_type = MEM_callocN(sizeof(wmManipulatorMapType), "manipulatortype list"); + mmap_type->spaceid = mmap_params->spaceid; + mmap_type->regionid = mmap_params->regionid; + BLI_addhead(&manipulatormaptypes, mmap_type); - return mmaptype; + return mmap_type; } void wm_manipulatormaptypes_free(void) { - for (wmManipulatorMapType *mmaptype = manipulatormaptypes.first, *mmaptype_next; - mmaptype; - mmaptype = mmaptype_next) + for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first, *mmap_type_next; + mmap_type; + mmap_type = mmap_type_next) { - mmaptype_next = mmaptype->next; - for (wmManipulatorGroupType *wgt = mmaptype->manipulator_grouptypes.first, *wgt_next; - wgt; - wgt = wgt_next) + mmap_type_next = mmap_type->next; + for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_next; + wgt_ref; + wgt_ref = wgt_next) { - wgt_next = wgt->next; - WM_manipulatorgrouptype_free(wgt); + wgt_next = wgt_ref->next; + WM_manipulatormaptype_group_free(wgt_ref); } - MEM_freeN(mmaptype); + MEM_freeN(mmap_type); } } @@ -753,18 +760,64 @@ void wm_manipulatormaptypes_free(void) */ void wm_manipulators_keymap(wmKeyConfig *keyconf) { - wmManipulatorMapType *mmaptype; - wmManipulatorGroupType *wgt; - /* we add this item-less keymap once and use it to group manipulator-group keymaps into it */ WM_keymap_find(keyconf, "Manipulators", 0, 0); - for (mmaptype = manipulatormaptypes.first; mmaptype; mmaptype = mmaptype->next) { - for (wgt = mmaptype->manipulator_grouptypes.first; wgt; wgt = wgt->next) { - wm_manipulatorgrouptype_setup_keymap(wgt, keyconf); + for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; mmap_type; mmap_type = mmap_type->next) { + for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { + wm_manipulatorgrouptype_setup_keymap(wgt_ref->type, keyconf); } } } /** \} */ /* wmManipulatorMapType */ +/* -------------------------------------------------------------------- */ +/** \name Updates for Dynamic Type Registraion + * + * \{ */ + + +void WM_manipulatorconfig_update_tag_init(wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) +{ + /* tag for update on next use */ + mmap_type->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_INIT; + wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_INIT; + + wm_mmap_type_update_flag |= WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT; +} + +/** + * Run incase new types have been added (runs often, early exit where possible). + * Follows #WM_keyconfig_update concentions. + */ +void WM_manipulatorconfig_update(const struct Main *bmain) +{ + if (G.background) + return; + + if (wm_mmap_type_update_flag == 0) + return; + + if (wm_mmap_type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT) { + for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; + mmap_type; + mmap_type = mmap_type->next) + { + if (mmap_type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_INIT) { + mmap_type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_INIT; + for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; + wgt_ref; + wgt_ref = wgt_ref->next) + { + wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_INIT; + WM_manipulatormaptype_group_init_runtime(bmain, mmap_type, wgt_ref->type); + } + } + } + + wm_mmap_type_update_flag &= ~WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT; + } +} + +/** \} */ diff --git a/source/blender/windowmanager/manipulators/wm_manipulator_fn.h b/source/blender/windowmanager/manipulators/wm_manipulator_fn.h index ce21c90195d..41e603fc521 100644 --- a/source/blender/windowmanager/manipulators/wm_manipulator_fn.h +++ b/source/blender/windowmanager/manipulators/wm_manipulator_fn.h @@ -30,10 +30,18 @@ #include "BLI_compiler_attrs.h" /* wmManipulatorGroup */ -typedef bool (*wmManipulatorGroupFnPoll)(const struct bContext *, struct wmManipulatorGroupType *) ATTR_WARN_UNUSED_RESULT; -typedef void (*wmManipulatorGroupFnInit)(const struct bContext *, struct wmManipulatorGroup *); -typedef void (*wmManipulatorGroupFnRefresh)(const struct bContext *, struct wmManipulatorGroup *); -typedef void (*wmManipulatorGroupFnDrawPrepare)(const struct bContext *, struct wmManipulatorGroup *); +typedef bool (*wmManipulatorGroupFnPoll)( + const struct bContext *, struct wmManipulatorGroupType *) + ATTR_WARN_UNUSED_RESULT; +typedef void (*wmManipulatorGroupFnInit)( + const struct bContext *, struct wmManipulatorGroup *); +typedef void (*wmManipulatorGroupFnRefresh)( + const struct bContext *, struct wmManipulatorGroup *); +typedef void (*wmManipulatorGroupFnDrawPrepare)( + const struct bContext *, struct wmManipulatorGroup *); +typedef struct wmKeyMap *(*wmManipulatorGroupFnSetupKeymap)( + const struct wmManipulatorGroupType *, struct wmKeyConfig *) + ATTR_WARN_UNUSED_RESULT; /* wmManipulator */ /* See: wmManipulatorType for docs on each type. */ @@ -48,4 +56,22 @@ typedef void (*wmManipulatorFnExit)(struct bContext *, struct wmManipulator * typedef int (*wmManipulatorFnCursorGet)(struct wmManipulator *); typedef void (*wmManipulatorFnSelect)(struct bContext *, struct wmManipulator *, const int); +/* wmManipulatorProperty */ +typedef void (*wmManipulatorPropertyFnGet)( + const struct wmManipulator *, struct wmManipulatorProperty *, void *user_data, + float *value, uint value_len); +typedef void (*wmManipulatorPropertyFnSet)( + const struct wmManipulator *, struct wmManipulatorProperty *, void *user_data, + const float *value, uint value_len); +typedef void (*wmManipulatorPropertyFnRangeGet)( + const struct wmManipulator *, struct wmManipulatorProperty *, void *user_data, + float range[2]); + +typedef struct wmManipulatorPropertyFnParams { + wmManipulatorPropertyFnGet value_get_fn; + wmManipulatorPropertyFnSet value_set_fn; + wmManipulatorPropertyFnRangeGet range_get_fn; + void *user_data; +} wmManipulatorPropertyFnParams; + #endif /* __WM_MANIPULATOR_FN_H__ */ diff --git a/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h b/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h index d14d4e169b1..61489b6a730 100644 --- a/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h +++ b/source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h @@ -47,12 +47,14 @@ struct wmOperator; /* -------------------------------------------------------------------- */ /* wmManipulator */ -struct wmManipulatorGroup *wm_manipulator_get_parent_group(const struct wmManipulator *mpr); - -/* wm_manipulator.c, for init/exit */ +/* wm_manipulator_type.c, for init/exit */ void wm_manipulatortype_free(void); void wm_manipulatortype_init(void); +/* wm_manipulatorgroup_type.c, for init/exit */ +void wm_manipulatorgrouptype_free(void); +void wm_manipulatorgrouptype_init(void); + /* -------------------------------------------------------------------- */ /* wmManipulatorGroup */ @@ -63,7 +65,6 @@ void MANIPULATORGROUP_OT_manipulator_tweak(struct wmOperatorType *ot); /* wmManipulatorMap */ void wm_manipulatormap_remove(struct wmManipulatorMap *mmap); -void wm_manipulatormaptypes_free(void); void wm_manipulators_keymap(struct wmKeyConfig *keyconf); @@ -83,5 +84,10 @@ void wm_manipulatormap_active_set( const struct wmEvent *event, struct wmManipulator *mpr); struct wmManipulator *wm_manipulatormap_active_get(struct wmManipulatorMap *mmap); +/* -------------------------------------------------------------------- */ +/* wmManipulatorMapType */ + +void wm_manipulatormaptypes_free(void); + #endif /* __WM_MANIPULATOR_WMAPI_H__ */ diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index cd9c150e38b..255ac28b64e 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -115,6 +115,7 @@ struct bConstraintOb; struct bConstraintTarget; struct bContextDataResult; struct bGPDlayer; +struct bFaceMap; struct bNode; struct bNodeType; struct bNodeSocket; @@ -132,6 +133,7 @@ struct wmOperator; struct wmOperatorType; struct wmWindow; struct wmWindowManager; +struct wmManipulatorMap; /* -------------------------------------------------------------------- */ @@ -359,8 +361,9 @@ void WM_report(ReportType type, const char *message) RET_NONE struct wmManipulatorMapType *WM_manipulatormaptype_find(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL struct wmManipulatorMapType *WM_manipulatormaptype_ensure(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL struct wmManipulatorMap *WM_manipulatormap_new_from_type(const struct wmManipulatorMapType_Params *wmap_params) RET_NULL -void WM_manipulatorgrouptype_init_runtime( - const struct Main *bmain, struct wmManipulatorMapType *wmaptype, struct wmManipulatorGroupType *wgt) RET_NONE +void WM_manipulatormaptype_group_init_runtime( + const struct Main *bmain, struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt) RET_NONE +void WM_manipulatorgrouptype_unregister(struct bContext *C, struct Main *bmain, struct wmManipulatorGroupType *wgt) RET_NONE #ifdef WITH_INPUT_NDOF void WM_ndof_deadzone_set(float deadzone) RET_NONE |