From 85c5c5531e990b12fed60c428b70f887c1bd0c81 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Jun 2017 17:06:24 +1000 Subject: Manipulator: edit_properties -> target_properties Naming was too confusing between properties of a manipulator and properties it edits. --- .../manipulator_library_utils.c | 6 +- .../manipulator_types/arrow3d_manipulator.c | 28 +-- .../manipulator_types/cage2d_manipulator.c | 8 +- .../manipulator_types/dial3d_manipulator.c | 14 +- .../manipulator_types/grab3d_manipulator.c | 12 +- source/blender/editors/mesh/editmesh_bisect.c | 6 +- source/blender/editors/mesh/editmesh_extrude.c | 8 +- .../blender/editors/space_node/node_manipulators.c | 4 +- .../editors/space_view3d/view3d_manipulators.c | 10 +- source/blender/windowmanager/CMakeLists.txt | 2 +- .../manipulators/WM_manipulator_api.h | 20 +- .../manipulators/WM_manipulator_types.h | 2 +- .../manipulators/intern/wm_manipulator.c | 8 +- .../manipulators/intern/wm_manipulator_property.c | 203 --------------------- .../intern/wm_manipulator_target_props.c | 203 +++++++++++++++++++++ 15 files changed, 267 insertions(+), 267 deletions(-) delete mode 100644 source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c create mode 100644 source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c (limited to 'source') diff --git a/source/blender/editors/manipulator_library/manipulator_library_utils.c b/source/blender/editors/manipulator_library/manipulator_library_utils.c index 093842aeb65..9c182fcf4bc 100644 --- a/source/blender/editors/manipulator_library/manipulator_library_utils.c +++ b/source/blender/editors/manipulator_library/manipulator_library_utils.c @@ -116,12 +116,12 @@ void manipulator_property_data_update( return; } - float value = WM_manipulator_property_value_get(mpr, mpr_prop); + float value = WM_manipulator_target_property_value_get(mpr, mpr_prop); if (constrained) { if ((data->flag & MANIPULATOR_CUSTOM_RANGE_SET) == 0) { float range[2]; - WM_manipulator_property_range_get(mpr, mpr_prop, range); + WM_manipulator_target_property_range_get(mpr, mpr_prop, range); data->range = range[1] - range[0]; data->min = range[0]; } @@ -136,7 +136,7 @@ void manipulator_property_value_reset( bContext *C, const wmManipulator *mpr, ManipulatorInteraction *inter, wmManipulatorProperty *mpr_prop) { - WM_manipulator_property_value_set(C, mpr, mpr_prop, inter->init_value); + WM_manipulator_target_property_value_set(C, mpr, mpr_prop, inter->init_value); } /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c index 17e5d53874d..e13815f3997 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c @@ -327,19 +327,19 @@ 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_property_find(mpr, "offset"); + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); /* set the property for the operator and call its modal function */ - if (WM_manipulator_property_is_valid(mpr_prop)) { + if (WM_manipulator_target_property_is_valid(mpr_prop)) { const int draw_options = RNA_enum_get(arrow->manipulator.ptr, "draw_options"); const bool constrained = (draw_options & ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED) != 0; const bool inverted = (draw_options & ED_MANIPULATOR_ARROW_STYLE_INVERTED) != 0; const bool use_precision = (flag & WM_MANIPULATOR_TWEAK_PRECISE) != 0; float value = manipulator_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision); - WM_manipulator_property_value_set(C, mpr, mpr_prop, value); + WM_manipulator_target_property_value_set(C, mpr, mpr_prop, value); /* get clamped value */ - value = WM_manipulator_property_value_get(mpr, mpr_prop); + value = WM_manipulator_target_property_value_get(mpr, mpr_prop); data->offset = manipulator_offset_from_value(data, value, constrained, inverted); } @@ -366,11 +366,11 @@ static void manipulator_arrow_invoke( { ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; ManipulatorInteraction *inter = MEM_callocN(sizeof(ManipulatorInteraction), __func__); - wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset"); + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); /* Some manipulators don't use properties. */ - if (mpr_prop && WM_manipulator_property_is_valid(mpr_prop)) { - inter->init_value = WM_manipulator_property_value_get(mpr, mpr_prop); + if (mpr_prop && WM_manipulator_target_property_is_valid(mpr_prop)) { + inter->init_value = WM_manipulator_target_property_value_get(mpr, mpr_prop); } inter->init_offset = arrow->data.offset; @@ -403,7 +403,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_property_find(mpr, "offset"); + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); manipulator_property_value_reset(C, mpr, inter, mpr_prop); data->offset = inter->init_offset; } @@ -417,15 +417,15 @@ static void manipulator_arrow_exit(bContext *C, wmManipulator *mpr, const bool c /** * Define a custom property UI range * - * \note Needs to be called before WM_manipulator_property_def_rna! + * \note Needs to be called before WM_manipulator_target_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_property_find(mpr, "offset") && "Make sure this function " - "is called before WM_manipulator_property_def_rna")); + BLI_assert(!(WM_manipulator_target_property_find(mpr, "offset") && "Make sure this function " + "is called before WM_manipulator_target_property_def_rna")); arrow->data.range = max - min; arrow->data.min = min; @@ -435,13 +435,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_property_def_rna! + * \note Needs to be called before WM_manipulator_target_property_def_rna! */ void ED_manipulator_arrow3d_set_range_fac(wmManipulator *mpr, const float range_fac) { ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr; - BLI_assert(!(WM_manipulator_property_find(mpr, "offset") && "Make sure this function " - "is called before WM_manipulator_property_def_rna")); + BLI_assert(!(WM_manipulator_target_property_find(mpr, "offset") && "Make sure this function " + "is called before WM_manipulator_target_property_def_rna")); arrow->data.range_fac = range_fac; } diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c index 21e5778d509..f35e3b481a6 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c @@ -510,13 +510,13 @@ static void manipulator_rect_transform_modal( wmManipulatorProperty *mpr_prop; - mpr_prop = WM_manipulator_property_find(mpr, "offset"); + mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); if (mpr_prop->prop != NULL) { RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, mpr->matrix_offset[3]); RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); } - mpr_prop = WM_manipulator_property_find(mpr, "scale"); + mpr_prop = WM_manipulator_target_property_find(mpr, "scale"); if (mpr_prop->prop != NULL) { if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) { RNA_property_float_set(&mpr_prop->ptr, mpr_prop->prop, scale[0]); @@ -556,13 +556,13 @@ static void manipulator_rect_transform_exit(bContext *C, wmManipulator *mpr, con wmManipulatorProperty *mpr_prop; /* reset properties */ - mpr_prop = WM_manipulator_property_find(mpr, "offset"); + mpr_prop = WM_manipulator_target_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_property_find(mpr, "scale"); + mpr_prop = WM_manipulator_target_property_find(mpr, "scale"); if (mpr_prop->prop != NULL) { const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); if (transform_flag & ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) { diff --git a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c index e8b1a583be9..40cf67e1133 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c @@ -293,7 +293,7 @@ static void dial_draw_intern( DialInteraction *inter = mpr->interaction_data; /* XXX, View3D rotation manipulator doesn't call modal. */ - if (mpr->properties_edit.first == NULL) { + if (mpr->target_properties.first == NULL) { wmWindow *win = CTX_wm_window(C); manipulator_dial_modal((bContext *)C, mpr, win->eventstate, 0); } @@ -396,9 +396,9 @@ static void manipulator_dial_modal(bContext *C, wmManipulator *mpr, const wmEven inter->output.angle_ofs = angle_ofs; /* set the property for the operator and call its modal function */ - wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset"); - if (mpr_prop && WM_manipulator_property_is_valid(mpr_prop)) { - WM_manipulator_property_value_set(C, mpr, mpr_prop, inter->init_prop_angle + angle_delta); + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); + if (mpr_prop && WM_manipulator_target_property_is_valid(mpr_prop)) { + WM_manipulator_target_property_value_set(C, mpr, mpr_prop, inter->init_prop_angle + angle_delta); } } @@ -419,9 +419,9 @@ static void manipulator_dial_invoke( inter->init_mval[0] = event->mval[0]; inter->init_mval[1] = event->mval[1]; - wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset"); - if (mpr_prop && WM_manipulator_property_is_valid(mpr_prop)) { - inter->init_prop_angle = WM_manipulator_property_value_get(mpr, mpr_prop); + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); + if (mpr_prop && WM_manipulator_target_property_is_valid(mpr_prop)) { + inter->init_prop_angle = WM_manipulator_target_property_value_get(mpr, mpr_prop); } mpr->interaction_data = inter; diff --git a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c index b5eccaf2699..527e29c79e8 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c @@ -196,9 +196,9 @@ static void manipulator_grab_modal(bContext *C, wmManipulator *mpr, const wmEven add_v3_v3v3(inter->output.co_final, inter->init_prop_co, inter->output.co_ofs); /* set the property for the operator and call its modal function */ - wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset"); - if (mpr_prop && WM_manipulator_property_is_valid(mpr_prop)) { - WM_manipulator_property_value_set_array(C, mpr, mpr_prop, inter->output.co_final, 3); + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); + if (mpr_prop && WM_manipulator_target_property_is_valid(mpr_prop)) { + WM_manipulator_target_property_value_set_array(C, mpr, mpr_prop, inter->output.co_final, 3); } } @@ -210,9 +210,9 @@ static void manipulator_grab_invoke( inter->init_mval[0] = event->mval[0]; inter->init_mval[1] = event->mval[1]; - wmManipulatorProperty *mpr_prop = WM_manipulator_property_find(mpr, "offset"); - if (mpr_prop && WM_manipulator_property_is_valid(mpr_prop)) { - WM_manipulator_property_value_get_array(mpr, mpr_prop, inter->init_prop_co, 3); + wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_find(mpr, "offset"); + if (mpr_prop && WM_manipulator_target_property_is_valid(mpr_prop)) { + WM_manipulator_target_property_value_get_array(mpr, mpr_prop, inter->init_prop_co, 3); } mpr->interaction_data = inter; diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index 34644bb7fd6..4d301c009ee 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -628,7 +628,7 @@ static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup /* Setup property callbacks */ { - WM_manipulator_property_def_func( + WM_manipulator_target_property_def_func( man->translate_z, "offset", &(const struct wmManipulatorPropertyFnParams) { .value_get_fn = manipulator_bisect_prop_depth_get, @@ -637,7 +637,7 @@ static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup .user_data = NULL, }); - WM_manipulator_property_def_func( + WM_manipulator_target_property_def_func( man->translate_c, "offset", &(const struct wmManipulatorPropertyFnParams) { .value_get_fn = manipulator_bisect_prop_translate_get, @@ -646,7 +646,7 @@ static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup .user_data = NULL, }); - WM_manipulator_property_def_func( + WM_manipulator_target_property_def_func( man->rotate_c, "offset", &(const struct wmManipulatorPropertyFnParams) { .value_get_fn = manipulator_bisect_prop_angle_get, diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index cfeff6a65af..32f5dcd5526 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -1090,7 +1090,7 @@ static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *m /* Setup property callbacks */ { - WM_manipulator_property_def_func( + WM_manipulator_target_property_def_func( man->translate_z, "offset", &(const struct wmManipulatorPropertyFnParams) { .value_get_fn = manipulator_spin_prop_depth_get, @@ -1099,7 +1099,7 @@ static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *m .user_data = NULL, }); - WM_manipulator_property_def_func( + WM_manipulator_target_property_def_func( man->translate_c, "offset", &(const struct wmManipulatorPropertyFnParams) { .value_get_fn = manipulator_spin_prop_translate_get, @@ -1108,7 +1108,7 @@ static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *m .user_data = NULL, }); - WM_manipulator_property_def_func( + WM_manipulator_target_property_def_func( man->rotate_c, "offset", &(const struct wmManipulatorPropertyFnParams) { .value_get_fn = manipulator_spin_prop_axis_angle_get, @@ -1117,7 +1117,7 @@ static void manipulator_mesh_spin_setup(const bContext *C, wmManipulatorGroup *m .user_data = NULL, }); - WM_manipulator_property_def_func( + WM_manipulator_target_property_def_func( man->angle_z, "offset", &(const struct wmManipulatorPropertyFnParams) { .value_get_fn = manipulator_spin_prop_angle_get, diff --git a/source/blender/editors/space_node/node_manipulators.c b/source/blender/editors/space_node/node_manipulators.c index e3f699cabdf..8b4ebd70874 100644 --- a/source/blender/editors/space_node/node_manipulators.c +++ b/source/blender/editors/space_node/node_manipulators.c @@ -96,8 +96,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_property_def_rna(cage, "offset", &nodeptr, "backdrop_offset", -1); - WM_manipulator_property_def_rna(cage, "scale", &nodeptr, "backdrop_zoom", -1); + WM_manipulator_target_property_def_rna(cage, "offset", &nodeptr, "backdrop_offset", -1); + WM_manipulator_target_property_def_rna(cage, "scale", &nodeptr, "backdrop_zoom", -1); } else { WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, true); diff --git a/source/blender/editors/space_view3d/view3d_manipulators.c b/source/blender/editors/space_view3d/view3d_manipulators.c index 907fe91009a..4d1357e1297 100644 --- a/source/blender/editors/space_view3d/view3d_manipulators.c +++ b/source/blender/editors/space_view3d/view3d_manipulators.c @@ -104,7 +104,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_property_def_rna(wwrapper->manipulator, "offset", &lamp_ptr, propname, -1); + WM_manipulator_target_property_def_rna(wwrapper->manipulator, "offset", &lamp_ptr, propname, -1); } void VIEW3D_WGT_lamp(wmManipulatorGroupType *wgt) @@ -237,7 +237,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_property_def_rna(camgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1); + WM_manipulator_target_property_def_rna(camgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1); } else { WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, true); @@ -281,8 +281,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_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); + WM_manipulator_target_property_def_rna(camgroup->focal_len, "offset", &camera_ptr, "lens", -1); + WM_manipulator_target_property_def_rna(camgroup->ortho_scale, "offset", &camera_ptr, "ortho_scale", -1); } } @@ -347,7 +347,7 @@ static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmManipulatorGroup WM_manipulator_set_matrix_rotation_from_z_axis(wwrapper->manipulator, ob->obmat[2]); WM_manipulator_set_matrix_offset_location(wwrapper->manipulator, ofs); WM_manipulator_set_flag(wwrapper->manipulator, WM_MANIPULATOR_HIDDEN, false); - WM_manipulator_property_def_rna(wwrapper->manipulator, "offset", &field_ptr, "strength", -1); + WM_manipulator_target_property_def_rna(wwrapper->manipulator, "offset", &field_ptr, "strength", -1); } else { WM_manipulator_set_flag(wwrapper->manipulator, WM_MANIPULATOR_HIDDEN, true); diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index a098fc94591..cfa97a9e177 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -75,7 +75,7 @@ set(SRC manipulators/intern/wm_manipulator_group.c manipulators/intern/wm_manipulator_group_type.c manipulators/intern/wm_manipulator_map.c - manipulators/intern/wm_manipulator_property.c + manipulators/intern/wm_manipulator_target_props.c manipulators/intern/wm_manipulator_type.c WM_api.h diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h index 43a80cb1f80..6a5c2aeef71 100644 --- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h +++ b/source/blender/windowmanager/manipulators/WM_manipulator_api.h @@ -131,33 +131,33 @@ void WM_manipulatorconfig_update_tag_remove(struct wmManipulatorMapType *mmap_ty void WM_manipulatorconfig_update(struct Main *bmain); -/* wm_maniulator_property.c */ -struct wmManipulatorProperty *WM_manipulator_property_find( +/* wm_maniulator_target_props.c */ +struct wmManipulatorProperty *WM_manipulator_target_property_find( struct wmManipulator *mpr, const char *idname); -void WM_manipulator_property_def_rna( +void WM_manipulator_target_property_def_rna( struct wmManipulator *mpr, const char *idname, struct PointerRNA *ptr, const char *propname, int index); -void WM_manipulator_property_def_func( +void WM_manipulator_target_property_def_func( struct wmManipulator *mpr, const char *idname, const struct wmManipulatorPropertyFnParams *params); -bool WM_manipulator_property_is_valid( +bool WM_manipulator_target_property_is_valid( const struct wmManipulatorProperty *mpr_prop); -float WM_manipulator_property_value_get( +float WM_manipulator_target_property_value_get( const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop); -void WM_manipulator_property_value_set( +void WM_manipulator_target_property_value_set( struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, const float value); -void WM_manipulator_property_value_get_array( +void WM_manipulator_target_property_value_get_array( const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, float *value, const int value_len); -void WM_manipulator_property_value_set_array( +void WM_manipulator_target_property_value_set_array( struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, const float *value, const int value_len); -void WM_manipulator_property_range_get( +void WM_manipulator_target_property_range_get( const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, float range[2]); diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h index f3064a62607..dc30a7fa40d 100644 --- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h +++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h @@ -116,7 +116,7 @@ struct wmManipulator { * Public API's should use string names, * private API's can pass 'wmManipulatorProperty' directly. */ - ListBase properties_edit; + ListBase target_properties; struct IDProperty *properties; }; diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c index 938edb56153..1156298c51a 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c @@ -197,7 +197,7 @@ void WM_manipulator_free(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmMa if (mpr->op_data.ptr.data) { WM_operator_properties_free(&mpr->op_data.ptr); } - BLI_freelistN(&mpr->properties_edit); + BLI_freelistN(&mpr->target_properties); if (mpr->ptr != NULL) { WM_manipulator_properties_free(mpr->ptr); @@ -461,9 +461,9 @@ void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C) 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_edit)) { - for (wmManipulatorProperty *mpr_prop = mpr->properties_edit.first; mpr_prop; mpr_prop = mpr_prop->next) { - if (WM_manipulator_property_is_valid(mpr_prop)) { + if (mpr->type->property_update && !BLI_listbase_is_empty(&mpr->target_properties)) { + for (wmManipulatorProperty *mpr_prop = mpr->target_properties.first; mpr_prop; mpr_prop = mpr_prop->next) { + if (WM_manipulator_target_property_is_valid(mpr_prop)) { mpr->type->property_update(mpr, mpr_prop); } } diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c deleted file mode 100644 index beaf2abdc17..00000000000 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c +++ /dev/null @@ -1,203 +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 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_edit, 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_edit, 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->op_data.type = 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->op_data.type = 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)); -} - -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_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); -} - -void WM_manipulator_property_value_get_array( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, - float *value, const int value_len) -{ - if (mpr_prop->custom_func.value_get_fn) { - mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, value, value_len); - return; - } - - BLI_assert(RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop) == value_len); - return RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value); -} - -void WM_manipulator_property_value_set_array( - bContext *C, const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, - const float *value, const int value_len) -{ - 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, value_len); - return; - } - - BLI_assert(RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop) == value_len); - RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, value); - - RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); -} - -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_target_props.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c new file mode 100644 index 00000000000..d43a9b8882d --- /dev/null +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c @@ -0,0 +1,203 @@ +/* + * ***** 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_target_props.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_target_property_find(wmManipulator *mpr, const char *idname) +{ + return BLI_findstring(&mpr->target_properties, idname, offsetof(wmManipulatorProperty, idname)); +} + +static wmManipulatorProperty *wm_manipulator_target_property_def_internal( + wmManipulator *mpr, const char *idname) +{ + wmManipulatorProperty *mpr_prop = WM_manipulator_target_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->target_properties, mpr_prop); + } + return mpr_prop; +} + +void WM_manipulator_target_property_def_rna( + wmManipulator *mpr, const char *idname, + PointerRNA *ptr, const char *propname, int index) +{ + wmManipulatorProperty *mpr_prop = wm_manipulator_target_property_def_internal(mpr, idname); + + /* if manipulator evokes an operator we cannot use it for property manipulation */ + mpr->op_data.type = 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_target_property_def_func( + wmManipulator *mpr, const char *idname, + const wmManipulatorPropertyFnParams *params) +{ + wmManipulatorProperty *mpr_prop = wm_manipulator_target_property_def_internal(mpr, idname); + + /* if manipulator evokes an operator we cannot use it for property manipulation */ + mpr->op_data.type = 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_target_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)); +} + +float WM_manipulator_target_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_target_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); +} + +void WM_manipulator_target_property_value_get_array( + const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, + float *value, const int value_len) +{ + if (mpr_prop->custom_func.value_get_fn) { + mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, value, value_len); + return; + } + + BLI_assert(RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop) == value_len); + return RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value); +} + +void WM_manipulator_target_property_value_set_array( + bContext *C, const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, + const float *value, const int value_len) +{ + 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, value_len); + return; + } + + BLI_assert(RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop) == value_len); + RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, value); + + RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); +} + +void WM_manipulator_target_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); +} + +/** \} */ -- cgit v1.2.3