diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-07-15 00:49:00 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-07-15 00:49:00 +0300 |
commit | 5ebebcfbfff4c218ab4101ee7f6a66617ee9b01f (patch) | |
tree | 86f319a9291847c2608bfd0b89bae3d504e378cf /source/blender/windowmanager | |
parent | cd1600413246a62156441f6e7910489b19ae5a28 (diff) |
WM: rename manipulator to gizmo internally
Diffstat (limited to 'source/blender/windowmanager')
19 files changed, 1433 insertions, 1433 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 32900b75514..67ca5f8a08a 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -77,9 +77,9 @@ struct wmNDOFMotionData; #endif typedef struct wmJob wmJob; -typedef struct wmManipulator wmManipulator; -typedef struct wmManipulatorMap wmManipulatorMap; -typedef struct wmManipulatorMapType wmManipulatorMapType; +typedef struct wmGizmo wmGizmo; +typedef struct wmGizmoMap wmGizmoMap; +typedef struct wmGizmoMapType wmGizmoMapType; /* general API */ void WM_init_state_size_set (int stax, int stay, int sizx, int sizy); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 486eae0a0ed..a5536dbd652 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -123,7 +123,7 @@ struct ImBuf; #include "wm_event_types.h" #include "gizmo/WM_gizmo_types.h" -/* Include external manipulator API's */ +/* Include external gizmo API's */ #include "gizmo/WM_gizmo_api.h" /* ************** wmOperatorType ************************ */ diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h index ffd18af496e..1d2abab8af4 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h @@ -26,8 +26,8 @@ /** \file blender/windowmanager/gizmos/WM_gizmo_api.h * \ingroup wm * - * \name Manipulator API - * \brief API for external use of wmManipulator types. + * \name Gizmo API + * \brief API for external use of wmGizmo types. * * Only included in WM_api.h */ @@ -42,302 +42,302 @@ struct IDProperty; struct Main; struct PropertyRNA; struct wmKeyConfig; -struct wmManipulator; -struct wmManipulatorProperty; -struct wmManipulatorPropertyType; -struct wmManipulatorType; -struct wmManipulatorGroup; -struct wmManipulatorGroupType; -struct wmManipulatorMap; -struct wmManipulatorMapType; -struct wmManipulatorMapType_Params; +struct wmGizmo; +struct wmGizmoProperty; +struct wmGizmoPropertyType; +struct wmGizmoType; +struct wmGizmoGroup; +struct wmGizmoGroupType; +struct wmGizmoMap; +struct wmGizmoMapType; +struct wmGizmoMapType_Params; struct wmMsgSubscribeKey; struct wmMsgSubscribeValue; #include "wm_gizmo_fn.h" /* -------------------------------------------------------------------- */ -/* wmManipulator */ +/* wmGizmo */ -struct wmManipulator *WM_manipulator_new_ptr( - const struct wmManipulatorType *wt, struct wmManipulatorGroup *mgroup, +struct wmGizmo *WM_gizmo_new_ptr( + const struct wmGizmoType *wt, struct wmGizmoGroup *mgroup, struct PointerRNA *properties); -struct wmManipulator *WM_manipulator_new( - const char *idname, struct wmManipulatorGroup *mgroup, +struct wmGizmo *WM_gizmo_new( + const char *idname, struct wmGizmoGroup *mgroup, struct PointerRNA *properties); -void WM_manipulator_free(struct wmManipulator *mpr); -void WM_manipulator_unlink( - ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr, +void WM_gizmo_free(struct wmGizmo *mpr); +void WM_gizmo_unlink( + ListBase *gizmolist, struct wmGizmoMap *mmap, struct wmGizmo *mpr, struct bContext *C); -void WM_manipulator_name_set(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr, const char *name); +void WM_gizmo_name_set(struct wmGizmoGroup *mgroup, struct wmGizmo *mpr, const char *name); -bool WM_manipulator_select_unlink(struct wmManipulatorMap *mmap, struct wmManipulator *mpr); -bool WM_manipulator_select_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select); -void WM_manipulator_highlight_set(struct wmManipulatorMap *mmap, struct wmManipulator *mpr); +bool WM_gizmo_select_unlink(struct wmGizmoMap *mmap, struct wmGizmo *mpr); +bool WM_gizmo_select_set(struct wmGizmoMap *mmap, struct wmGizmo *mpr, bool select); +void WM_gizmo_highlight_set(struct wmGizmoMap *mmap, struct wmGizmo *mpr); -void WM_manipulator_modal_set_from_setup( - struct wmManipulatorMap *mmap, struct bContext *C, - struct wmManipulator *mpr, int part_index, const struct wmEvent *event); +void WM_gizmo_modal_set_from_setup( + struct wmGizmoMap *mmap, struct bContext *C, + struct wmGizmo *mpr, int part_index, const struct wmEvent *event); -struct wmManipulatorOpElem *WM_manipulator_operator_get( - struct wmManipulator *mpr, int part_index); -struct PointerRNA *WM_manipulator_operator_set( - struct wmManipulator *mpr, int part_index, +struct wmGizmoOpElem *WM_gizmo_operator_get( + struct wmGizmo *mpr, int part_index); +struct PointerRNA *WM_gizmo_operator_set( + struct wmGizmo *mpr, int part_index, struct wmOperatorType *ot, struct IDProperty *properties); /* callbacks */ -void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulatorFnModal fn); - -void WM_manipulator_set_matrix_location( - struct wmManipulator *mpr, const float origin[3]); -void WM_manipulator_set_matrix_rotation_from_z_axis( - struct wmManipulator *mpr, const float z_axis[3]); -void WM_manipulator_set_matrix_rotation_from_yz_axis( - struct wmManipulator *mpr, const float y_axis[3], const float z_axis[3]); - -void WM_manipulator_set_matrix_offset_location( - struct wmManipulator *mpr, const float origin[3]); -void WM_manipulator_set_matrix_offset_rotation_from_z_axis( - struct wmManipulator *mpr, const float z_axis[3]); -void WM_manipulator_set_matrix_offset_rotation_from_yz_axis( - struct wmManipulator *mpr, const float y_axis[3], const float z_axis[3]); - -void WM_manipulator_set_flag(struct wmManipulator *mpr, const int flag, const bool enable); -void WM_manipulator_set_scale(struct wmManipulator *mpr, float scale); -void WM_manipulator_set_line_width(struct wmManipulator *mpr, const float line_width); - -void WM_manipulator_get_color(const struct wmManipulator *mpr, float color[4]); -void WM_manipulator_set_color(struct wmManipulator *mpr, const float color[4]); -void WM_manipulator_get_color_highlight(const struct wmManipulator *mpr, float color_hi[4]); -void WM_manipulator_set_color_highlight(struct wmManipulator *mpr, const float color[4]); +void WM_gizmo_set_fn_custom_modal(struct wmGizmo *mpr, wmGizmoFnModal fn); + +void WM_gizmo_set_matrix_location( + struct wmGizmo *mpr, const float origin[3]); +void WM_gizmo_set_matrix_rotation_from_z_axis( + struct wmGizmo *mpr, const float z_axis[3]); +void WM_gizmo_set_matrix_rotation_from_yz_axis( + struct wmGizmo *mpr, const float y_axis[3], const float z_axis[3]); + +void WM_gizmo_set_matrix_offset_location( + struct wmGizmo *mpr, const float origin[3]); +void WM_gizmo_set_matrix_offset_rotation_from_z_axis( + struct wmGizmo *mpr, const float z_axis[3]); +void WM_gizmo_set_matrix_offset_rotation_from_yz_axis( + struct wmGizmo *mpr, const float y_axis[3], const float z_axis[3]); + +void WM_gizmo_set_flag(struct wmGizmo *mpr, const int flag, const bool enable); +void WM_gizmo_set_scale(struct wmGizmo *mpr, float scale); +void WM_gizmo_set_line_width(struct wmGizmo *mpr, const float line_width); + +void WM_gizmo_get_color(const struct wmGizmo *mpr, float color[4]); +void WM_gizmo_set_color(struct wmGizmo *mpr, const float color[4]); +void WM_gizmo_get_color_highlight(const struct wmGizmo *mpr, float color_hi[4]); +void WM_gizmo_set_color_highlight(struct wmGizmo *mpr, const float color[4]); /** - * Leaving values NULL use values from #wmManipulator. + * Leaving values NULL use values from #wmGizmo. */ -struct WM_ManipulatorMatrixParams { +struct WM_GizmoMatrixParams { const float(*matrix_space)[4]; const float(*matrix_basis)[4]; const float(*matrix_offset)[4]; const float *scale_final; }; -void WM_manipulator_calc_matrix_final_params( - const struct wmManipulator *mpr, const struct WM_ManipulatorMatrixParams *params, +void WM_gizmo_calc_matrix_final_params( + const struct wmGizmo *mpr, const struct WM_GizmoMatrixParams *params, float r_mat[4][4]); -void WM_manipulator_calc_matrix_final_no_offset( - const struct wmManipulator *mpr, float r_mat[4][4]); +void WM_gizmo_calc_matrix_final_no_offset( + const struct wmGizmo *mpr, float r_mat[4][4]); -void WM_manipulator_calc_matrix_final( - const struct wmManipulator *mpr, float r_mat[4][4]); +void WM_gizmo_calc_matrix_final( + const struct wmGizmo *mpr, float r_mat[4][4]); /* properties */ -void WM_manipulator_properties_create_ptr(struct PointerRNA *ptr, struct wmManipulatorType *wt); -void WM_manipulator_properties_create(struct PointerRNA *ptr, const char *opstring); -void WM_manipulator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *wtstring); -void WM_manipulator_properties_sanitize(struct PointerRNA *ptr, const bool no_context); -bool WM_manipulator_properties_default(struct PointerRNA *ptr, const bool do_update); -void WM_manipulator_properties_reset(struct wmManipulator *op); -void WM_manipulator_properties_clear(struct PointerRNA *ptr); -void WM_manipulator_properties_free(struct PointerRNA *ptr); - - -/* 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); -bool WM_manipulatortype_remove(struct bContext *C, struct Main *bmain, const char *idname); -void WM_manipulatortype_remove_ptr(struct bContext *C, struct Main *bmain, struct wmManipulatorType *wt); -void WM_manipulatortype_iter(struct GHashIterator *ghi); - -/* wm_manipulator_group_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_free(const char *idname); -void WM_manipulatorgrouptype_free_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_manipulator_map.c */ +void WM_gizmo_properties_create_ptr(struct PointerRNA *ptr, struct wmGizmoType *wt); +void WM_gizmo_properties_create(struct PointerRNA *ptr, const char *opstring); +void WM_gizmo_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *wtstring); +void WM_gizmo_properties_sanitize(struct PointerRNA *ptr, const bool no_context); +bool WM_gizmo_properties_default(struct PointerRNA *ptr, const bool do_update); +void WM_gizmo_properties_reset(struct wmGizmo *op); +void WM_gizmo_properties_clear(struct PointerRNA *ptr); +void WM_gizmo_properties_free(struct PointerRNA *ptr); + + +/* wm_gizmo_type.c */ +const struct wmGizmoType *WM_gizmotype_find(const char *idname, bool quiet); +void WM_gizmotype_append(void (*wtfunc)(struct wmGizmoType *)); +void WM_gizmotype_append_ptr(void (*mnpfunc)(struct wmGizmoType *, void *), void *userdata); +bool WM_gizmotype_remove(struct bContext *C, struct Main *bmain, const char *idname); +void WM_gizmotype_remove_ptr(struct bContext *C, struct Main *bmain, struct wmGizmoType *wt); +void WM_gizmotype_iter(struct GHashIterator *ghi); + +/* wm_gizmo_group_type.c */ +struct wmGizmoGroupType *WM_gizmogrouptype_find(const char *idname, bool quiet); +struct wmGizmoGroupType *WM_gizmogrouptype_append(void (*wtfunc)(struct wmGizmoGroupType *)); +struct wmGizmoGroupType *WM_gizmogrouptype_append_ptr(void (*mnpfunc)(struct wmGizmoGroupType *, void *), void *userdata); +bool WM_gizmogrouptype_free(const char *idname); +void WM_gizmogrouptype_free_ptr(struct wmGizmoGroupType *wt); +void WM_gizmogrouptype_iter(struct GHashIterator *ghi); + +struct wmGizmoGroupTypeRef *WM_gizmogrouptype_append_and_link( + struct wmGizmoMapType *mmap_type, + void (*wtfunc)(struct wmGizmoGroupType *)); + +/* wm_gizmo_map.c */ /* Dynamic Updates (for RNA runtime registration) */ -void WM_manipulatorconfig_update_tag_init(struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt); -void WM_manipulatorconfig_update_tag_remove(struct wmManipulatorMapType *mmap_type, struct wmManipulatorGroupType *wgt); -void WM_manipulatorconfig_update(struct Main *bmain); +void WM_gizmoconfig_update_tag_init(struct wmGizmoMapType *mmap_type, struct wmGizmoGroupType *wgt); +void WM_gizmoconfig_update_tag_remove(struct wmGizmoMapType *mmap_type, struct wmGizmoGroupType *wgt); +void WM_gizmoconfig_update(struct Main *bmain); /* wm_maniulator_target_props.c */ -struct wmManipulatorProperty *WM_manipulator_target_property_array(struct wmManipulator *mpr); -struct wmManipulatorProperty *WM_manipulator_target_property_at_index( - struct wmManipulator *mpr, int index); -struct wmManipulatorProperty *WM_manipulator_target_property_find( - struct wmManipulator *mpr, const char *idname); - -void WM_manipulator_target_property_def_rna_ptr( - struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type, +struct wmGizmoProperty *WM_gizmo_target_property_array(struct wmGizmo *mpr); +struct wmGizmoProperty *WM_gizmo_target_property_at_index( + struct wmGizmo *mpr, int index); +struct wmGizmoProperty *WM_gizmo_target_property_find( + struct wmGizmo *mpr, const char *idname); + +void WM_gizmo_target_property_def_rna_ptr( + struct wmGizmo *mpr, const struct wmGizmoPropertyType *mpr_prop_type, struct PointerRNA *ptr, struct PropertyRNA *prop, int index); -void WM_manipulator_target_property_def_rna( - struct wmManipulator *mpr, const char *idname, +void WM_gizmo_target_property_def_rna( + struct wmGizmo *mpr, const char *idname, struct PointerRNA *ptr, const char *propname, int index); -void WM_manipulator_target_property_def_func_ptr( - struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type, - const struct wmManipulatorPropertyFnParams *params); -void WM_manipulator_target_property_def_func( - struct wmManipulator *mpr, const char *idname, - const struct wmManipulatorPropertyFnParams *params); - -void WM_manipulator_target_property_clear_rna_ptr( - struct wmManipulator *mpr, const struct wmManipulatorPropertyType *mpr_prop_type); -void WM_manipulator_target_property_clear_rna( - struct wmManipulator *mpr, const char *idname); - -bool WM_manipulator_target_property_is_valid_any(struct wmManipulator *mpr); -bool WM_manipulator_target_property_is_valid( - const struct wmManipulatorProperty *mpr_prop); -float WM_manipulator_target_property_value_get( - const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop); -void WM_manipulator_target_property_value_set( - struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, +void WM_gizmo_target_property_def_func_ptr( + struct wmGizmo *mpr, const struct wmGizmoPropertyType *mpr_prop_type, + const struct wmGizmoPropertyFnParams *params); +void WM_gizmo_target_property_def_func( + struct wmGizmo *mpr, const char *idname, + const struct wmGizmoPropertyFnParams *params); + +void WM_gizmo_target_property_clear_rna_ptr( + struct wmGizmo *mpr, const struct wmGizmoPropertyType *mpr_prop_type); +void WM_gizmo_target_property_clear_rna( + struct wmGizmo *mpr, const char *idname); + +bool WM_gizmo_target_property_is_valid_any(struct wmGizmo *mpr); +bool WM_gizmo_target_property_is_valid( + const struct wmGizmoProperty *mpr_prop); +float WM_gizmo_target_property_value_get( + const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop); +void WM_gizmo_target_property_value_set( + struct bContext *C, const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop, const float value); -void WM_manipulator_target_property_value_get_array( - const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, +void WM_gizmo_target_property_value_get_array( + const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop, float *value); -void WM_manipulator_target_property_value_set_array( - struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, +void WM_gizmo_target_property_value_set_array( + struct bContext *C, const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop, const float *value); -bool WM_manipulator_target_property_range_get( - const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, +bool WM_gizmo_target_property_range_get( + const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop, float range[2]); -int WM_manipulator_target_property_array_length( - const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop); +int WM_gizmo_target_property_array_length( + const struct wmGizmo *mpr, struct wmGizmoProperty *mpr_prop); /* definitions */ -const struct wmManipulatorPropertyType *WM_manipulatortype_target_property_find( - const struct wmManipulatorType *wt, const char *idname); -void WM_manipulatortype_target_property_def( - struct wmManipulatorType *wt, const char *idname, int data_type, int array_length); +const struct wmGizmoPropertyType *WM_gizmotype_target_property_find( + const struct wmGizmoType *wt, const char *idname); +void WM_gizmotype_target_property_def( + struct wmGizmoType *wt, const char *idname, int data_type, int array_length); /* utilities */ -void WM_manipulator_do_msg_notify_tag_refresh( +void WM_gizmo_do_msg_notify_tag_refresh( struct bContext *C, struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValue *msg_val); -void WM_manipulator_target_property_subscribe_all( - struct wmManipulator *mpr, struct wmMsgBus *mbus, struct ARegion *ar); +void WM_gizmo_target_property_subscribe_all( + struct wmGizmo *mpr, struct wmMsgBus *mbus, struct ARegion *ar); /* -------------------------------------------------------------------- */ -/* wmManipulatorGroup */ +/* wmGizmoGroup */ -/* Callbacks for 'wmManipulatorGroupType.setup_keymap' */ -struct wmKeyMap *WM_manipulatorgroup_keymap_common( - const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config); -struct wmKeyMap *WM_manipulatorgroup_keymap_common_select( - const struct wmManipulatorGroupType *wgt, struct wmKeyConfig *config); +/* Callbacks for 'wmGizmoGroupType.setup_keymap' */ +struct wmKeyMap *WM_gizmogroup_keymap_common( + const struct wmGizmoGroupType *wgt, struct wmKeyConfig *config); +struct wmKeyMap *WM_gizmogroup_keymap_common_select( + const struct wmGizmoGroupType *wgt, struct wmKeyConfig *config); /* -------------------------------------------------------------------- */ -/* wmManipulatorMap */ +/* wmGizmoMap */ -struct wmManipulatorMap *WM_manipulatormap_new_from_type( - const struct wmManipulatorMapType_Params *mmap_params); -const struct ListBase *WM_manipulatormap_group_list(struct wmManipulatorMap *mmap); -struct wmManipulatorGroup *WM_manipulatormap_group_find( - struct wmManipulatorMap *mmap, +struct wmGizmoMap *WM_gizmomap_new_from_type( + const struct wmGizmoMapType_Params *mmap_params); +const struct ListBase *WM_gizmomap_group_list(struct wmGizmoMap *mmap); +struct wmGizmoGroup *WM_gizmomap_group_find( + struct wmGizmoMap *mmap, const char *idname); -struct wmManipulatorGroup *WM_manipulatormap_group_find_ptr( - struct wmManipulatorMap *mmap, - const struct wmManipulatorGroupType *wgt); -void WM_manipulatormap_tag_refresh(struct wmManipulatorMap *mmap); -void WM_manipulatormap_draw( - struct wmManipulatorMap *mmap, const struct bContext *C, const eWM_ManipulatorMapDrawStep drawstep); -void WM_manipulatormap_add_handlers(struct ARegion *ar, struct wmManipulatorMap *mmap); -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); -void WM_manipulatormap_message_subscribe( - struct bContext *C, struct wmManipulatorMap *mmap, struct ARegion *ar, struct wmMsgBus *mbus); -bool WM_manipulatormap_is_any_selected(const struct wmManipulatorMap *mmap); -bool WM_manipulatormap_minmax( - const struct wmManipulatorMap *mmap, bool use_hidden, bool use_select, +struct wmGizmoGroup *WM_gizmomap_group_find_ptr( + struct wmGizmoMap *mmap, + const struct wmGizmoGroupType *wgt); +void WM_gizmomap_tag_refresh(struct wmGizmoMap *mmap); +void WM_gizmomap_draw( + struct wmGizmoMap *mmap, const struct bContext *C, const eWM_GizmoFlagMapDrawStep drawstep); +void WM_gizmomap_add_handlers(struct ARegion *ar, struct wmGizmoMap *mmap); +bool WM_gizmomap_select_all(struct bContext *C, struct wmGizmoMap *mmap, const int action); +bool WM_gizmomap_cursor_set(const struct wmGizmoMap *mmap, struct wmWindow *win); +void WM_gizmomap_message_subscribe( + struct bContext *C, struct wmGizmoMap *mmap, struct ARegion *ar, struct wmMsgBus *mbus); +bool WM_gizmomap_is_any_selected(const struct wmGizmoMap *mmap); +bool WM_gizmomap_minmax( + const struct wmGizmoMap *mmap, bool use_hidden, bool use_select, float r_min[3], float r_max[3]); -struct ARegion *WM_manipulatormap_tooltip_init( +struct ARegion *WM_gizmomap_tooltip_init( struct bContext *C, struct ARegion *ar, bool *r_exit_on_event); /* -------------------------------------------------------------------- */ -/* wmManipulatorMapType */ +/* wmGizmoMapType */ -struct wmManipulatorMapType *WM_manipulatormaptype_find( - const struct wmManipulatorMapType_Params *mmap_params); -struct wmManipulatorMapType *WM_manipulatormaptype_ensure( - const struct wmManipulatorMapType_Params *mmap_params); +struct wmGizmoMapType *WM_gizmomaptype_find( + const struct wmGizmoMapType_Params *mmap_params); +struct wmGizmoMapType *WM_gizmomaptype_ensure( + const struct wmGizmoMapType_Params *mmap_params); -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find( - struct wmManipulatorMapType *mmap_type, +struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find( + struct wmGizmoMapType *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, +struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find_ptr( + struct wmGizmoMapType *mmap_type, + const struct wmGizmoGroupType *wgt); +struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_link( + struct wmGizmoMapType *mmap_type, const char *idname); -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr( - struct wmManipulatorMapType *mmap_type, - struct wmManipulatorGroupType *wgt); +struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_link_ptr( + struct wmGizmoMapType *mmap_type, + struct wmGizmoGroupType *wgt); -void WM_manipulatormaptype_group_init_runtime_keymap( +void WM_gizmomaptype_group_init_runtime_keymap( const struct Main *bmain, - 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); + struct wmGizmoGroupType *wgt); +void WM_gizmomaptype_group_init_runtime( + const struct Main *bmain, struct wmGizmoMapType *mmap_type, + struct wmGizmoGroupType *wgt); +void WM_gizmomaptype_group_unlink( + struct bContext *C, struct Main *bmain, struct wmGizmoMapType *mmap_type, + const struct wmGizmoGroupType *wgt); -void WM_manipulatormaptype_group_free(struct wmManipulatorGroupTypeRef *wgt); +void WM_gizmomaptype_group_free(struct wmGizmoGroupTypeRef *wgt); /* -------------------------------------------------------------------- */ -/* ManipulatorGroup */ +/* GizmoGroup */ /* Add/Ensure/Remove (High level API) */ -void WM_manipulator_group_type_add_ptr_ex( - struct wmManipulatorGroupType *wgt, - struct wmManipulatorMapType *mmap_type); -void WM_manipulator_group_type_add_ptr( - struct wmManipulatorGroupType *wgt); -void WM_manipulator_group_type_add(const char *idname); - -void WM_manipulator_group_type_ensure_ptr_ex( - struct wmManipulatorGroupType *wgt, - struct wmManipulatorMapType *mmap_type); -void WM_manipulator_group_type_ensure_ptr( - struct wmManipulatorGroupType *wgt); -void WM_manipulator_group_type_ensure(const char *idname); - -void WM_manipulator_group_type_remove_ptr_ex( - struct Main *bmain, struct wmManipulatorGroupType *wgt, - struct wmManipulatorMapType *mmap_type); -void WM_manipulator_group_type_remove_ptr( - struct Main *bmain, struct wmManipulatorGroupType *wgt); -void WM_manipulator_group_type_remove(struct Main *bmain, const char *idname); - -void WM_manipulator_group_type_unlink_delayed_ptr_ex( - struct wmManipulatorGroupType *wgt, - struct wmManipulatorMapType *mmap_type); -void WM_manipulator_group_type_unlink_delayed_ptr( - struct wmManipulatorGroupType *wgt); -void WM_manipulator_group_type_unlink_delayed(const char *idname); +void WM_gizmo_group_type_add_ptr_ex( + struct wmGizmoGroupType *wgt, + struct wmGizmoMapType *mmap_type); +void WM_gizmo_group_type_add_ptr( + struct wmGizmoGroupType *wgt); +void WM_gizmo_group_type_add(const char *idname); + +void WM_gizmo_group_type_ensure_ptr_ex( + struct wmGizmoGroupType *wgt, + struct wmGizmoMapType *mmap_type); +void WM_gizmo_group_type_ensure_ptr( + struct wmGizmoGroupType *wgt); +void WM_gizmo_group_type_ensure(const char *idname); + +void WM_gizmo_group_type_remove_ptr_ex( + struct Main *bmain, struct wmGizmoGroupType *wgt, + struct wmGizmoMapType *mmap_type); +void WM_gizmo_group_type_remove_ptr( + struct Main *bmain, struct wmGizmoGroupType *wgt); +void WM_gizmo_group_type_remove(struct Main *bmain, const char *idname); + +void WM_gizmo_group_type_unlink_delayed_ptr_ex( + struct wmGizmoGroupType *wgt, + struct wmGizmoMapType *mmap_type); +void WM_gizmo_group_type_unlink_delayed_ptr( + struct wmGizmoGroupType *wgt); +void WM_gizmo_group_type_unlink_delayed(const char *idname); /* Utilities */ -bool WM_manipulator_context_check_drawstep(const struct bContext *C, eWM_ManipulatorMapDrawStep step); +bool WM_gizmo_context_check_drawstep(const struct bContext *C, eWM_GizmoFlagMapDrawStep step); -bool WM_manipulator_group_type_poll(const struct bContext *C, const struct wmManipulatorGroupType *wgt); +bool WM_gizmo_group_type_poll(const struct bContext *C, const struct wmGizmoGroupType *wgt); #endif /* __WM_GIZMO_API_H__ */ diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h index 0f6af6db24c..ecdda256306 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h @@ -26,8 +26,8 @@ /** \file blender/windowmanager/gizmo/WM_gizmo_types.h * \ingroup wm * - * \name Manipulator Types - * \brief Manipulator defines for external use. + * \name Gizmo Types + * \brief Gizmo defines for external use. * * Only included in WM_types.h and lower level files. */ @@ -38,11 +38,11 @@ #include "BLI_compiler_attrs.h" -struct wmManipulatorMapType; -struct wmManipulatorGroupType; -struct wmManipulatorGroup; -struct wmManipulator; -struct wmManipulatorProperty; +struct wmGizmoMapType; +struct wmGizmoGroupType; +struct wmGizmoGroup; +struct wmGizmo; +struct wmGizmoProperty; struct wmKeyConfig; #include "DNA_listBase.h" @@ -53,154 +53,154 @@ struct wmKeyConfig; /** - * #wmManipulator.state + * #wmGizmo.state */ -typedef enum eWM_ManipulatorState { - WM_MANIPULATOR_STATE_HIGHLIGHT = (1 << 0), /* while hovered */ - WM_MANIPULATOR_STATE_MODAL = (1 << 1), /* while dragging */ - WM_MANIPULATOR_STATE_SELECT = (1 << 2), -} eWM_ManipulatorState; +typedef enum eWM_GizmoFlagState { + WM_GIZMO_STATE_HIGHLIGHT = (1 << 0), /* while hovered */ + WM_GIZMO_STATE_MODAL = (1 << 1), /* while dragging */ + WM_GIZMO_STATE_SELECT = (1 << 2), +} eWM_GizmoFlagState; /** - * #wmManipulator.flag - * Flags for individual manipulators. + * #wmGizmo.flag + * Flags for individual gizmos. */ -typedef enum eWM_ManipulatorFlag { - WM_MANIPULATOR_DRAW_HOVER = (1 << 0), /* draw *only* while hovering */ - WM_MANIPULATOR_DRAW_MODAL = (1 << 1), /* draw while dragging */ - WM_MANIPULATOR_DRAW_VALUE = (1 << 2), /* draw an indicator for the current value while dragging */ - WM_MANIPULATOR_HIDDEN = (1 << 3), +typedef enum eWM_GizmoFlagFlag { + WM_GIZMO_DRAW_HOVER = (1 << 0), /* draw *only* while hovering */ + WM_GIZMO_DRAW_MODAL = (1 << 1), /* draw while dragging */ + WM_GIZMO_DRAW_VALUE = (1 << 2), /* draw an indicator for the current value while dragging */ + WM_GIZMO_HIDDEN = (1 << 3), /** * When set 'scale_final' value also scales the offset. * Use when offset is to avoid screen-space overlap instead of absolute positioning. */ - WM_MANIPULATOR_DRAW_OFFSET_SCALE = (1 << 4), + WM_GIZMO_DRAW_OFFSET_SCALE = (1 << 4), /** * User should still use 'scale_final' for any handles and UI elements. * This simply skips scale when calculating the final matrix. - * Needed when the manipulator needs to align with the interface underneath it. */ - WM_MANIPULATOR_DRAW_NO_SCALE = (1 << 5), + * Needed when the gizmo needs to align with the interface underneath it. */ + WM_GIZMO_DRAW_NO_SCALE = (1 << 5), /** - * Hide the cursor and lock it's position while interacting with this manipulator. + * Hide the cursor and lock it's position while interacting with this gizmo. */ - WM_MANIPULATOR_GRAB_CURSOR = (1 << 6), + WM_GIZMO_GRAB_CURSOR = (1 << 6), /** Don't write into the depth buffer when selecting. */ - WM_MANIPULATOR_SELECT_BACKGROUND = (1 << 7), -} eWM_ManipulatorFlag; + WM_GIZMO_SELECT_BACKGROUND = (1 << 7), +} eWM_GizmoFlagFlag; /** - * #wmManipulatorGroupType.flag - * Flags that influence the behavior of all manipulators in the group. + * #wmGizmoGroupType.flag + * Flags that influence the behavior of all gizmos in the group. */ -typedef enum eWM_ManipulatorGroupTypeFlag { - /* Mark manipulator-group as being 3D */ - WM_MANIPULATORGROUPTYPE_3D = (1 << 0), - /* Scale manipulators as 3D object that respects zoom (otherwise zoom independent draw size). +typedef enum eWM_GizmoFlagGroupTypeFlag { + /* Mark gizmo-group as being 3D */ + WM_GIZMOGROUPTYPE_3D = (1 << 0), + /* Scale gizmos as 3D object that respects zoom (otherwise zoom independent draw size). * note: currently only for 3D views, 2D support needs adding. */ - WM_MANIPULATORGROUPTYPE_SCALE = (1 << 1), - /* Manipulators can be depth culled with scene objects (covered by other geometry - TODO) */ - 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), - /* Show all other manipulators when interacting. */ - WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL = (1 << 5), -} eWM_ManipulatorGroupTypeFlag; + WM_GIZMOGROUPTYPE_SCALE = (1 << 1), + /* Gizmos can be depth culled with scene objects (covered by other geometry - TODO) */ + WM_GIZMOGROUPTYPE_DEPTH_3D = (1 << 2), + /* Gizmos can be selected */ + WM_GIZMOGROUPTYPE_SELECT = (1 << 3), + /* The gizmo group is to be kept (not removed on loading a new file for eg). */ + WM_GIZMOGROUPTYPE_PERSISTENT = (1 << 4), + /* Show all other gizmos when interacting. */ + WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL = (1 << 5), +} eWM_GizmoFlagGroupTypeFlag; /** - * #wmManipulatorGroup.init_flag + * #wmGizmoGroup.init_flag */ -typedef enum eWM_ManipulatorGroupInitFlag { +typedef enum eWM_GizmoFlagGroupInitFlag { /* mgroup has been initialized */ - WM_MANIPULATORGROUP_INIT_SETUP = (1 << 0), - WM_MANIPULATORGROUP_INIT_REFRESH = (1 << 1), -} eWM_ManipulatorGroupInitFlag; + WM_GIZMOGROUP_INIT_SETUP = (1 << 0), + WM_GIZMOGROUP_INIT_REFRESH = (1 << 1), +} eWM_GizmoFlagGroupInitFlag; /** - * #wmManipulatorMapType.type_update_flag - * Manipulator-map type update flag + * #wmGizmoMapType.type_update_flag + * Gizmo-map type update flag */ -typedef enum eWM_ManipulatorMapTypeUpdateFlag { +typedef enum eWM_GizmoFlagMapTypeUpdateFlag { /* A new type has been added, needs to be initialized for all views. */ - WM_MANIPULATORMAPTYPE_UPDATE_INIT = (1 << 0), - WM_MANIPULATORMAPTYPE_UPDATE_REMOVE = (1 << 1), + WM_GIZMOMAPTYPE_UPDATE_INIT = (1 << 0), + WM_GIZMOMAPTYPE_UPDATE_REMOVE = (1 << 1), /* Needed because keymap may be registered before and after window initialization. * So we need to keep track of keymap initialization separately. */ - WM_MANIPULATORMAPTYPE_KEYMAP_INIT = (1 << 2), -} eWM_ManipulatorMapTypeUpdateFlag; + WM_GIZMOMAPTYPE_KEYMAP_INIT = (1 << 2), +} eWM_GizmoFlagMapTypeUpdateFlag; /* -------------------------------------------------------------------- */ -/* wmManipulator */ +/* wmGizmo */ /** - * \brief Manipulator tweak flag. - * Bitflag passed to manipulator while tweaking. + * \brief Gizmo tweak flag. + * Bitflag passed to gizmo while tweaking. * - * \note Manipulators are responsible for handling this #wmManipulator.modal callback!. + * \note Gizmos are responsible for handling this #wmGizmo.modal callback!. */ typedef enum { /* Drag with extra precision (Shift). */ - WM_MANIPULATOR_TWEAK_PRECISE = (1 << 0), + WM_GIZMO_TWEAK_PRECISE = (1 << 0), /* Drag with snap enabled (Ctrl). */ - WM_MANIPULATOR_TWEAK_SNAP = (1 << 1), -} eWM_ManipulatorTweak; + WM_GIZMO_TWEAK_SNAP = (1 << 1), +} eWM_GizmoFlagTweak; #include "wm_gizmo_fn.h" -typedef struct wmManipulatorOpElem { +typedef struct wmGizmoOpElem { struct wmOperatorType *type; - /* operator properties if manipulator spawns and controls an operator, - * or owner pointer if manipulator spawns and controls a property */ + /* operator properties if gizmo spawns and controls an operator, + * or owner pointer if gizmo spawns and controls a property */ PointerRNA ptr; bool is_redo; -} wmManipulatorOpElem; +} wmGizmoOpElem; -/* manipulators are set per region by registering them on manipulator-maps */ -struct wmManipulator { - struct wmManipulator *next, *prev; +/* gizmos are set per region by registering them on gizmo-maps */ +struct wmGizmo { + struct wmGizmo *next, *prev; /* While we don't have a real type, use this to put type-like vars. */ - const struct wmManipulatorType *type; + const struct wmGizmoType *type; /* Overrides 'type->modal' when set. * Note that this is a workaround, remove if we can. */ - wmManipulatorFnModal custom_modal; + wmGizmoFnModal custom_modal; - /* pointer back to group this manipulator is in (just for quick access) */ - struct wmManipulatorGroup *parent_mgroup; + /* pointer back to group this gizmo is in (just for quick access) */ + struct wmGizmoGroup *parent_mgroup; void *py_instance; /* rna pointer to access properties */ struct PointerRNA *ptr; - /* flags that influence the behavior or how the manipulators are drawn */ - eWM_ManipulatorFlag flag; + /* flags that influence the behavior or how the gizmos are drawn */ + eWM_GizmoFlagFlag flag; /* state flags (active, highlighted, selected) */ - eWM_ManipulatorState state; + eWM_GizmoFlagState state; - /* Optional ID for highlighting different parts of this manipulator. + /* Optional ID for highlighting different parts of this gizmo. * -1 when unset, otherwise a valid index. (Used as index to 'op_data'). */ int highlight_part; - /* For single click button manipulators, use a different part as a fallback, -1 when unused. */ + /* For single click button gizmos, use a different part as a fallback, -1 when unused. */ int drag_part; - /* Transformation of the manipulator in 2d or 3d space. + /* Transformation of the gizmo in 2d or 3d space. * - Matrix axis are expected to be unit length (scale is applied after). - * - Behavior when axis aren't orthogonal depends on each manipulator. - * - Typically the +Z is the primary axis for manipulators to use. + * - Behavior when axis aren't orthogonal depends on each gizmo. + * - Typically the +Z is the primary axis for gizmos to use. * - 'matrix[3]' must be used for location, - * besides this it's up to the manipulators internal code how the + * besides this it's up to the gizmos internal code how the * rotation components are used for drawing and interaction. */ - /* The space this manipulator is being modified in. */ + /* The space this gizmo is being modified in. */ float matrix_space[4][4]; - /* Transformation of this manipulator. */ + /* Transformation of this gizmo. */ float matrix_basis[4][4]; /* custom offset from origin */ float matrix_offset[4][4]; @@ -210,25 +210,25 @@ struct wmManipulator { float scale_basis; /* user defined width for line drawing */ float line_width; - /* manipulator colors (uses default fallbacks if not defined) */ + /* gizmo colors (uses default fallbacks if not defined) */ float color[4], color_hi[4]; /* data used during interaction */ void *interaction_data; - /* Operator to spawn when activating the manipulator (overrides property editing), - * an array of items (aligned with #wmManipulator.highlight_part). */ - wmManipulatorOpElem *op_data; + /* Operator to spawn when activating the gizmo (overrides property editing), + * an array of items (aligned with #wmGizmo.highlight_part). */ + wmGizmoOpElem *op_data; int op_data_len; struct IDProperty *properties; - /* over alloc target_properties after 'wmManipulatorType.struct_size' */ + /* over alloc target_properties after 'wmGizmoType.struct_size' */ }; /* Similar to PropertyElemRNA, but has an identifier. */ -typedef struct wmManipulatorProperty { - const struct wmManipulatorPropertyType *type; +typedef struct wmGizmoProperty { + const struct wmGizmoPropertyType *type; PointerRNA ptr; PropertyRNA *prop; @@ -237,88 +237,88 @@ typedef struct wmManipulatorProperty { /* Optional functions for converting to/from RNA */ struct { - wmManipulatorPropertyFnGet value_get_fn; - wmManipulatorPropertyFnSet value_set_fn; - wmManipulatorPropertyFnRangeGet range_get_fn; - wmManipulatorPropertyFnFree free_fn; + wmGizmoPropertyFnGet value_get_fn; + wmGizmoPropertyFnSet value_set_fn; + wmGizmoPropertyFnRangeGet range_get_fn; + wmGizmoPropertyFnFree free_fn; void *user_data; } custom_func; -} wmManipulatorProperty; +} wmGizmoProperty; -typedef struct wmManipulatorPropertyType { - struct wmManipulatorPropertyType *next, *prev; +typedef struct wmGizmoPropertyType { + struct wmGizmoPropertyType *next, *prev; /* PropertyType, typically 'PROP_FLOAT' */ int data_type; int array_length; - /* index within 'wmManipulatorType' */ + /* index within 'wmGizmoType' */ int index_in_type; /* over alloc */ char idname[0]; -} wmManipulatorPropertyType; +} wmGizmoPropertyType; /** - * Simple utility wrapper for storing a single manipulator as wmManipulatorGroup.customdata (which gets freed). + * Simple utility wrapper for storing a single gizmo as wmGizmoGroup.customdata (which gets freed). */ -typedef struct wmManipulatorWrapper { - struct wmManipulator *manipulator; -} wmManipulatorWrapper; +typedef struct wmGizmoWrapper { + struct wmGizmo *gizmo; +} wmGizmoWrapper; -struct wmManipulatorMapType_Params { +struct wmGizmoMapType_Params { short spaceid; short regionid; }; -typedef struct wmManipulatorType { +typedef struct wmGizmoType { const char *idname; /* MAX_NAME */ - /* Set to 'sizeof(wmManipulator)' or larger for instances of this type, + /* Set to 'sizeof(wmGizmo)' or larger for instances of this type, * use so we can cant to other types without the hassle of a custom-data pointer. */ uint struct_size; /* Initialize struct (calloc'd 'struct_size' region). */ - wmManipulatorFnSetup setup; + wmGizmoFnSetup setup; - /* draw manipulator */ - wmManipulatorFnDraw draw; + /* draw gizmo */ + wmGizmoFnDraw draw; - /* determines 3d intersection by rendering the manipulator in a selection routine. */ - wmManipulatorFnDrawSelect draw_select; + /* determines 3d intersection by rendering the gizmo in a selection routine. */ + wmGizmoFnDrawSelect draw_select; - /* Determine if the mouse intersects with the manipulator. + /* Determine if the mouse intersects with the gizmo. * The calculation should be done in the callback itself, -1 for no seleciton. */ - wmManipulatorFnTestSelect test_select; + wmGizmoFnTestSelect test_select; - /* handler used by the manipulator. Usually handles interaction tied to a manipulator type */ - wmManipulatorFnModal modal; + /* handler used by the gizmo. Usually handles interaction tied to a gizmo type */ + wmGizmoFnModal modal; - /* manipulator-specific handler to update manipulator attributes based on the property value */ - wmManipulatorFnPropertyUpdate property_update; + /* gizmo-specific handler to update gizmo attributes based on the property value */ + wmGizmoFnPropertyUpdate property_update; /* Returns the final transformation which may be different from the 'matrix', - * depending on the manipulator. + * depending on the gizmo. * Notes: - * - Scale isn't applied (wmManipulator.scale/user_scale). - * - Offset isn't applied (wmManipulator.matrix_offset). + * - Scale isn't applied (wmGizmo.scale/user_scale). + * - Offset isn't applied (wmGizmo.matrix_offset). */ - wmManipulatorFnMatrixBasisGet matrix_basis_get; + wmGizmoFnMatrixBasisGet matrix_basis_get; - /* activate a manipulator state when the user clicks on it */ - wmManipulatorFnInvoke invoke; + /* activate a gizmo state when the user clicks on it */ + wmGizmoFnInvoke invoke; - /* called when manipulator tweaking is done - used to free data and reset property when cancelling */ - wmManipulatorFnExit exit; + /* called when gizmo tweaking is done - used to free data and reset property when cancelling */ + wmGizmoFnExit exit; - wmManipulatorFnCursorGet cursor_get; + wmGizmoFnCursorGet cursor_get; - /* called when manipulator selection state changes */ - wmManipulatorFnSelectRefresh select_refresh; + /* called when gizmo selection state changes */ + wmGizmoFnSelectRefresh select_refresh; - /* Free data (not the manipulator it's self), use when the manipulator allocates it's own members. */ - wmManipulatorFnFree free; + /* Free data (not the gizmo it's self), use when the gizmo allocates it's own members. */ + wmGizmoFnFree free; /* RNA for properties */ struct StructRNA *srna; @@ -329,41 +329,41 @@ typedef struct wmManipulatorType { ListBase target_property_defs; int target_property_defs_len; -} wmManipulatorType; +} wmGizmoType; /* -------------------------------------------------------------------- */ -/* wmManipulatorGroup */ +/* wmGizmoGroup */ -/* factory class for a manipulator-group type, gets called every time a new area is spawned */ -typedef struct wmManipulatorGroupTypeRef { - struct wmManipulatorGroupTypeRef *next, *prev; - struct wmManipulatorGroupType *type; -} wmManipulatorGroupTypeRef; +/* factory class for a gizmo-group type, gets called every time a new area is spawned */ +typedef struct wmGizmoGroupTypeRef { + struct wmGizmoGroupTypeRef *next, *prev; + struct wmGizmoGroupType *type; +} wmGizmoGroupTypeRef; -/* factory class for a manipulator-group type, gets called every time a new area is spawned */ -typedef struct wmManipulatorGroupType { +/* factory class for a gizmo-group type, gets called every time a new area is spawned */ +typedef struct wmGizmoGroupType { const char *idname; /* MAX_NAME */ - const char *name; /* manipulator-group name - displayed in UI (keymap editor) */ + const char *name; /* gizmo-group name - displayed in UI (keymap editor) */ char owner_id[64]; /* MAX_NAME */ - /* poll if manipulator-map should be visible */ - wmManipulatorGroupFnPoll poll; - /* initially create manipulators and set permanent data - stuff you only need to do once */ - wmManipulatorGroupFnInit setup; - /* refresh data, only called if recreate flag is set (WM_manipulatormap_tag_refresh) */ - wmManipulatorGroupFnRefresh refresh; + /* poll if gizmo-map should be visible */ + wmGizmoGroupFnPoll poll; + /* initially create gizmos and set permanent data - stuff you only need to do once */ + wmGizmoGroupFnInit setup; + /* refresh data, only called if recreate flag is set (WM_gizmomap_tag_refresh) */ + wmGizmoGroupFnRefresh refresh; /* refresh data for drawing, called before each redraw */ - wmManipulatorGroupFnDrawPrepare draw_prepare; + wmGizmoGroupFnDrawPrepare draw_prepare; - /* Keymap init callback for this manipulator-group (optional), + /* Keymap init callback for this gizmo-group (optional), * will fall back to default tweak keymap when left NULL. */ - wmManipulatorGroupFnSetupKeymap setup_keymap; + wmGizmoGroupFnSetupKeymap setup_keymap; /* Optionally subscribe to wmMsgBus events, * these are calculated automatically from RNA properties, - * only needed if manipulators depend indirectly on properties. */ - wmManipulatorGroupFnMsgBusSubscribe message_subscribe; + * only needed if gizmos depend indirectly on properties. */ + wmGizmoGroupFnMsgBusSubscribe message_subscribe; /* keymap created with callback from above */ struct wmKeyMap *keymap; @@ -379,44 +379,44 @@ typedef struct wmManipulatorGroupType { /* RNA integration */ ExtensionRNA ext; - eWM_ManipulatorGroupTypeFlag flag; + eWM_GizmoFlagGroupTypeFlag flag; /* So we know which group type to update. */ - eWM_ManipulatorMapTypeUpdateFlag type_update_flag; + eWM_GizmoFlagMapTypeUpdateFlag type_update_flag; - /* same as manipulator-maps, so registering/unregistering goes to the correct region */ - struct wmManipulatorMapType_Params mmap_params; + /* same as gizmo-maps, so registering/unregistering goes to the correct region */ + struct wmGizmoMapType_Params mmap_params; -} wmManipulatorGroupType; +} wmGizmoGroupType; -typedef struct wmManipulatorGroup { - struct wmManipulatorGroup *next, *prev; +typedef struct wmGizmoGroup { + struct wmGizmoGroup *next, *prev; - struct wmManipulatorGroupType *type; - ListBase manipulators; + struct wmGizmoGroupType *type; + ListBase gizmos; - struct wmManipulatorMap *parent_mmap; + struct wmGizmoMap *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 */ - eWM_ManipulatorGroupInitFlag init_flag; -} wmManipulatorGroup; + eWM_GizmoFlagGroupInitFlag init_flag; +} wmGizmoGroup; /* -------------------------------------------------------------------- */ -/* wmManipulatorMap */ +/* wmGizmoMap */ /** - * Pass a value of this enum to #WM_manipulatormap_draw to tell it what to draw. + * Pass a value of this enum to #WM_gizmomap_draw to tell it what to draw. */ -typedef enum eWM_ManipulatorMapDrawStep { - /** Draw 2D manipulator-groups (#WM_MANIPULATORGROUPTYPE_3D not set). */ - WM_MANIPULATORMAP_DRAWSTEP_2D = 0, - /** Draw 3D manipulator-groups (#WM_MANIPULATORGROUPTYPE_3D set). */ - WM_MANIPULATORMAP_DRAWSTEP_3D, -} eWM_ManipulatorMapDrawStep; -#define WM_MANIPULATORMAP_DRAWSTEP_MAX 2 +typedef enum eWM_GizmoFlagMapDrawStep { + /** Draw 2D gizmo-groups (#WM_GIZMOGROUPTYPE_3D not set). */ + WM_GIZMOMAP_DRAWSTEP_2D = 0, + /** Draw 3D gizmo-groups (#WM_GIZMOGROUPTYPE_3D set). */ + WM_GIZMOMAP_DRAWSTEP_3D, +} eWM_GizmoFlagMapDrawStep; +#define WM_GIZMOMAP_DRAWSTEP_MAX 2 #endif /* __WM_GIZMO_TYPES_H__ */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c index bef193f6c56..da8b301b536 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c @@ -59,42 +59,42 @@ #include "BPY_extern.h" #endif -/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */ +/* only for own init/exit calls (wm_gizmotype_init/wm_gizmotype_free) */ #include "wm.h" /* own includes */ #include "wm_gizmo_wmapi.h" #include "wm_gizmo_intern.h" -static void wm_manipulator_register( - wmManipulatorGroup *mgroup, wmManipulator *mpr); +static void wm_gizmo_register( + wmGizmoGroup *mgroup, wmGizmo *mpr); /** * \note Follow #wm_operator_create convention. */ -static wmManipulator *wm_manipulator_create( - const wmManipulatorType *wt, +static wmGizmo *wm_gizmo_create( + const wmGizmoType *wt, PointerRNA *properties) { BLI_assert(wt != NULL); - BLI_assert(wt->struct_size >= sizeof(wmManipulator)); + BLI_assert(wt->struct_size >= sizeof(wmGizmo)); - wmManipulator *mpr = MEM_callocN( - wt->struct_size + (sizeof(wmManipulatorProperty) * wt->target_property_defs_len), __func__); + wmGizmo *mpr = MEM_callocN( + wt->struct_size + (sizeof(wmGizmoProperty) * wt->target_property_defs_len), __func__); mpr->type = wt; /* initialize properties, either copy or create */ - mpr->ptr = MEM_callocN(sizeof(PointerRNA), "wmManipulatorPtrRNA"); + mpr->ptr = MEM_callocN(sizeof(PointerRNA), "wmGizmoPtrRNA"); if (properties && properties->data) { mpr->properties = IDP_CopyProperty(properties->data); } else { IDPropertyTemplate val = {0}; - mpr->properties = IDP_New(IDP_GROUP, &val, "wmManipulatorProperties"); + mpr->properties = IDP_New(IDP_GROUP, &val, "wmGizmoProperties"); } RNA_pointer_create(G_MAIN->wm.first, wt->srna, mpr->properties, mpr->ptr); - WM_manipulator_properties_sanitize(mpr->ptr, 0); + WM_gizmo_properties_sanitize(mpr->ptr, 0); unit_m4(mpr->matrix_space); unit_m4(mpr->matrix_basis); @@ -105,13 +105,13 @@ static wmManipulator *wm_manipulator_create( return mpr; } -wmManipulator *WM_manipulator_new_ptr( - const wmManipulatorType *wt, wmManipulatorGroup *mgroup, +wmGizmo *WM_gizmo_new_ptr( + const wmGizmoType *wt, wmGizmoGroup *mgroup, PointerRNA *properties) { - wmManipulator *mpr = wm_manipulator_create(wt, properties); + wmGizmo *mpr = wm_gizmo_create(wt, properties); - wm_manipulator_register(mgroup, mpr); + wm_gizmo_register(mgroup, mpr); if (mpr->type->setup != NULL) { mpr->type->setup(mpr); @@ -122,21 +122,21 @@ wmManipulator *WM_manipulator_new_ptr( /** * \param wt: Must be valid, - * if you need to check it exists use #WM_manipulator_new_ptr + * if you need to check it exists use #WM_gizmo_new_ptr * because callers of this function don't NULL check the return value. */ -wmManipulator *WM_manipulator_new( - const char *idname, wmManipulatorGroup *mgroup, +wmGizmo *WM_gizmo_new( + const char *idname, wmGizmoGroup *mgroup, PointerRNA *properties) { - const wmManipulatorType *wt = WM_manipulatortype_find(idname, false); - return WM_manipulator_new_ptr(wt, mgroup, properties); + const wmGizmoType *wt = WM_gizmotype_find(idname, false); + return WM_gizmo_new_ptr(wt, mgroup, properties); } /** * Initialize default values and allocate needed memory for members. */ -static void manipulator_init(wmManipulator *mpr) +static void gizmo_init(wmGizmo *mpr) { const float color_default[4] = {1.0f, 1.0f, 1.0f, 1.0f}; @@ -149,24 +149,24 @@ static void manipulator_init(wmManipulator *mpr) } /** - * Register \a manipulator. + * Register \a gizmo. * - * \param name: name used to create a unique idname for \a manipulator in \a mgroup + * \param name: name used to create a unique idname for \a gizmo in \a mgroup * * \note Not to be confused with type registration from RNA. */ -static void wm_manipulator_register(wmManipulatorGroup *mgroup, wmManipulator *mpr) +static void wm_gizmo_register(wmGizmoGroup *mgroup, wmGizmo *mpr) { - manipulator_init(mpr); - wm_manipulatorgroup_manipulator_register(mgroup, mpr); + gizmo_init(mpr); + wm_gizmogroup_gizmo_register(mgroup, mpr); } /** - * \warning this doesn't check #wmManipulatorMap (highlight, selection etc). + * \warning this doesn't check #wmGizmoMap (highlight, selection etc). * Typical use is when freeing the windowing data, * where caller can manage clearing selection, highlight... etc. */ -void WM_manipulator_free(wmManipulator *mpr) +void WM_gizmo_free(wmGizmo *mpr) { if (mpr->type->free != NULL) { mpr->type->free(mpr); @@ -188,14 +188,14 @@ void WM_manipulator_free(wmManipulator *mpr) } if (mpr->ptr != NULL) { - WM_manipulator_properties_free(mpr->ptr); + WM_gizmo_properties_free(mpr->ptr); MEM_freeN(mpr->ptr); } if (mpr->type->target_property_defs_len != 0) { - wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr); + wmGizmoProperty *mpr_prop_array = WM_gizmo_target_property_array(mpr); for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; + wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; if (mpr_prop->custom_func.free_fn) { mpr_prop->custom_func.free_fn(mpr, mpr_prop); } @@ -206,41 +206,41 @@ void WM_manipulator_free(wmManipulator *mpr) } /** - * Free \a manipulator and unlink from \a manipulatorlist. - * \a manipulatorlist is allowed to be NULL. + * Free \a gizmo and unlink from \a gizmolist. + * \a gizmolist is allowed to be NULL. */ -void WM_manipulator_unlink(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmManipulator *mpr, bContext *C) +void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *mmap, wmGizmo *mpr, bContext *C) { - if (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) { - wm_manipulatormap_highlight_set(mmap, C, NULL, 0); + if (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) { + wm_gizmomap_highlight_set(mmap, C, NULL, 0); } - if (mpr->state & WM_MANIPULATOR_STATE_MODAL) { - wm_manipulatormap_modal_set(mmap, C, mpr, NULL, false); + if (mpr->state & WM_GIZMO_STATE_MODAL) { + wm_gizmomap_modal_set(mmap, C, mpr, NULL, false); } /* Unlink instead of setting so we don't run callbacks. */ - if (mpr->state & WM_MANIPULATOR_STATE_SELECT) { - WM_manipulator_select_unlink(mmap, mpr); + if (mpr->state & WM_GIZMO_STATE_SELECT) { + WM_gizmo_select_unlink(mmap, mpr); } - if (manipulatorlist) { - BLI_remlink(manipulatorlist, mpr); + if (gizmolist) { + BLI_remlink(gizmolist, mpr); } BLI_assert(mmap->mmap_context.highlight != mpr); BLI_assert(mmap->mmap_context.modal != mpr); - WM_manipulator_free(mpr); + WM_gizmo_free(mpr); } /* -------------------------------------------------------------------- */ -/** \name Manipulator Creation API +/** \name Gizmo Creation API * - * API for defining data on manipulator creation. + * API for defining data on gizmo creation. * * \{ */ -struct wmManipulatorOpElem *WM_manipulator_operator_get( - wmManipulator *mpr, int part_index) +struct wmGizmoOpElem *WM_gizmo_operator_get( + wmGizmo *mpr, int part_index) { if (mpr->op_data && ((part_index >= 0) && (part_index < mpr->op_data_len))) { return &mpr->op_data[part_index]; @@ -248,8 +248,8 @@ struct wmManipulatorOpElem *WM_manipulator_operator_get( return NULL; } -PointerRNA *WM_manipulator_operator_set( - wmManipulator *mpr, int part_index, +PointerRNA *WM_gizmo_operator_set( + wmGizmo *mpr, int part_index, wmOperatorType *ot, IDProperty *properties) { BLI_assert(part_index < 255); @@ -258,7 +258,7 @@ PointerRNA *WM_manipulator_operator_set( mpr->op_data_len = part_index + 1; mpr->op_data = MEM_recallocN(mpr->op_data, sizeof(*mpr->op_data) * mpr->op_data_len); } - wmManipulatorOpElem *mpop = &mpr->op_data[part_index]; + wmGizmoOpElem *mpop = &mpr->op_data[part_index]; mpop->type = ot; if (mpop->ptr.data) { @@ -273,7 +273,7 @@ PointerRNA *WM_manipulator_operator_set( return &mpop->ptr; } -static void wm_manipulator_set_matrix_rotation_from_z_axis__internal( +static void wm_gizmo_set_matrix_rotation_from_z_axis__internal( float matrix[4][4], const float z_axis[3]) { /* old code, seems we can use simpler method */ @@ -292,7 +292,7 @@ static void wm_manipulator_set_matrix_rotation_from_z_axis__internal( } -static void wm_manipulator_set_matrix_rotation_from_yz_axis__internal( +static void wm_gizmo_set_matrix_rotation_from_yz_axis__internal( float matrix[4][4], const float y_axis[3], const float z_axis[3]) { normalize_v3_v3(matrix[1], y_axis); @@ -302,42 +302,42 @@ static void wm_manipulator_set_matrix_rotation_from_yz_axis__internal( } /** - * wmManipulator.matrix utils. + * wmGizmo.matrix utils. */ -void WM_manipulator_set_matrix_rotation_from_z_axis( - wmManipulator *mpr, const float z_axis[3]) +void WM_gizmo_set_matrix_rotation_from_z_axis( + wmGizmo *mpr, const float z_axis[3]) { - wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix_basis, z_axis); + wm_gizmo_set_matrix_rotation_from_z_axis__internal(mpr->matrix_basis, z_axis); } -void WM_manipulator_set_matrix_rotation_from_yz_axis( - wmManipulator *mpr, const float y_axis[3], const float z_axis[3]) +void WM_gizmo_set_matrix_rotation_from_yz_axis( + wmGizmo *mpr, const float y_axis[3], const float z_axis[3]) { - wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_basis, y_axis, z_axis); + wm_gizmo_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_basis, y_axis, z_axis); } -void WM_manipulator_set_matrix_location(wmManipulator *mpr, const float origin[3]) +void WM_gizmo_set_matrix_location(wmGizmo *mpr, const float origin[3]) { copy_v3_v3(mpr->matrix_basis[3], origin); } /** - * wmManipulator.matrix_offset utils. + * wmGizmo.matrix_offset utils. */ -void WM_manipulator_set_matrix_offset_rotation_from_z_axis( - wmManipulator *mpr, const float z_axis[3]) +void WM_gizmo_set_matrix_offset_rotation_from_z_axis( + wmGizmo *mpr, const float z_axis[3]) { - wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix_offset, z_axis); + wm_gizmo_set_matrix_rotation_from_z_axis__internal(mpr->matrix_offset, z_axis); } -void WM_manipulator_set_matrix_offset_rotation_from_yz_axis( - wmManipulator *mpr, const float y_axis[3], const float z_axis[3]) +void WM_gizmo_set_matrix_offset_rotation_from_yz_axis( + wmGizmo *mpr, const float y_axis[3], const float z_axis[3]) { - wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_offset, y_axis, z_axis); + wm_gizmo_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_offset, y_axis, z_axis); } -void WM_manipulator_set_matrix_offset_location(wmManipulator *mpr, const float offset[3]) +void WM_gizmo_set_matrix_offset_location(wmGizmo *mpr, const float offset[3]) { copy_v3_v3(mpr->matrix_offset[3], offset); } -void WM_manipulator_set_flag(wmManipulator *mpr, const int flag, const bool enable) +void WM_gizmo_set_flag(wmGizmo *mpr, const int flag, const bool enable) { if (enable) { mpr->flag |= flag; @@ -347,50 +347,50 @@ void WM_manipulator_set_flag(wmManipulator *mpr, const int flag, const bool enab } } -void WM_manipulator_set_scale(wmManipulator *mpr, const float scale) +void WM_gizmo_set_scale(wmGizmo *mpr, const float scale) { mpr->scale_basis = scale; } -void WM_manipulator_set_line_width(wmManipulator *mpr, const float line_width) +void WM_gizmo_set_line_width(wmGizmo *mpr, const float line_width) { mpr->line_width = line_width; } /** - * Set manipulator rgba colors. + * Set gizmo rgba colors. * * \param col Normal state color. * \param col_hi Highlighted state color. */ -void WM_manipulator_get_color(const wmManipulator *mpr, float color[4]) +void WM_gizmo_get_color(const wmGizmo *mpr, float color[4]) { copy_v4_v4(color, mpr->color); } -void WM_manipulator_set_color(wmManipulator *mpr, const float color[4]) +void WM_gizmo_set_color(wmGizmo *mpr, const float color[4]) { copy_v4_v4(mpr->color, color); } -void WM_manipulator_get_color_highlight(const wmManipulator *mpr, float color_hi[4]) +void WM_gizmo_get_color_highlight(const wmGizmo *mpr, float color_hi[4]) { copy_v4_v4(color_hi, mpr->color_hi); } -void WM_manipulator_set_color_highlight(wmManipulator *mpr, const float color_hi[4]) +void WM_gizmo_set_color_highlight(wmGizmo *mpr, const float color_hi[4]) { copy_v4_v4(mpr->color_hi, color_hi); } -/** \} */ // Manipulator Creation API +/** \} */ // Gizmo Creation API /* -------------------------------------------------------------------- */ -/** \name Manipulator Callback Assignment +/** \name Gizmo Callback Assignment * * \{ */ -void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulatorFnModal fn) +void WM_gizmo_set_fn_custom_modal(struct wmGizmo *mpr, wmGizmoFnModal fn) { mpr->custom_modal = fn; } @@ -401,32 +401,32 @@ void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulator /* -------------------------------------------------------------------- */ /** - * Add/Remove \a manipulator to selection. - * Reallocates memory for selected manipulators so better not call for selecting multiple ones. + * Add/Remove \a gizmo to selection. + * Reallocates memory for selected gizmos so better not call for selecting multiple ones. * * \return if the selection has changed. */ -bool wm_manipulator_select_set_ex( - wmManipulatorMap *mmap, wmManipulator *mpr, bool select, +bool wm_gizmo_select_set_ex( + wmGizmoMap *mmap, wmGizmo *mpr, bool select, bool use_array, bool use_callback) { bool changed = false; if (select) { - if ((mpr->state & WM_MANIPULATOR_STATE_SELECT) == 0) { + if ((mpr->state & WM_GIZMO_STATE_SELECT) == 0) { if (use_array) { - wm_manipulatormap_select_array_push_back(mmap, mpr); + wm_gizmomap_select_array_push_back(mmap, mpr); } - mpr->state |= WM_MANIPULATOR_STATE_SELECT; + mpr->state |= WM_GIZMO_STATE_SELECT; changed = true; } } else { - if (mpr->state & WM_MANIPULATOR_STATE_SELECT) { + if (mpr->state & WM_GIZMO_STATE_SELECT) { if (use_array) { - wm_manipulatormap_select_array_remove(mmap, mpr); + wm_gizmomap_select_array_remove(mmap, mpr); } - mpr->state &= ~WM_MANIPULATOR_STATE_SELECT; + mpr->state &= ~WM_GIZMO_STATE_SELECT; changed = true; } } @@ -443,25 +443,25 @@ bool wm_manipulator_select_set_ex( } /* Remove from selection array without running callbacks. */ -bool WM_manipulator_select_unlink(wmManipulatorMap *mmap, wmManipulator *mpr) +bool WM_gizmo_select_unlink(wmGizmoMap *mmap, wmGizmo *mpr) { - return wm_manipulator_select_set_ex(mmap, mpr, false, true, false); + return wm_gizmo_select_set_ex(mmap, mpr, false, true, false); } -bool WM_manipulator_select_set(wmManipulatorMap *mmap, wmManipulator *mpr, bool select) +bool WM_gizmo_select_set(wmGizmoMap *mmap, wmGizmo *mpr, bool select) { - return wm_manipulator_select_set_ex(mmap, mpr, select, true, true); + return wm_gizmo_select_set_ex(mmap, mpr, select, true, true); } -void WM_manipulator_highlight_set(wmManipulatorMap *mmap, wmManipulator *mpr) +void WM_gizmo_highlight_set(wmGizmoMap *mmap, wmGizmo *mpr) { - wm_manipulatormap_highlight_set(mmap, NULL, mpr, mpr ? mpr->highlight_part : 0); + wm_gizmomap_highlight_set(mmap, NULL, mpr, mpr ? mpr->highlight_part : 0); } -bool wm_manipulator_select_and_highlight(bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr) +bool wm_gizmo_select_and_highlight(bContext *C, wmGizmoMap *mmap, wmGizmo *mpr) { - if (WM_manipulator_select_set(mmap, mpr, true)) { - wm_manipulatormap_highlight_set(mmap, C, mpr, mpr->highlight_part); + if (WM_gizmo_select_set(mmap, mpr, true)) { + wm_gizmomap_highlight_set(mmap, C, mpr, mpr->highlight_part); return true; } else { @@ -470,32 +470,32 @@ bool wm_manipulator_select_and_highlight(bContext *C, wmManipulatorMap *mmap, wm } /** - * Special function to run from setup so manipulators start out interactive. + * Special function to run from setup so gizmos start out interactive. * * We could do this when linking them, but this complicates things since the window update code needs to run first. */ -void WM_manipulator_modal_set_from_setup( - struct wmManipulatorMap *mmap, struct bContext *C, - struct wmManipulator *mpr, int part_index, const wmEvent *event) +void WM_gizmo_modal_set_from_setup( + struct wmGizmoMap *mmap, struct bContext *C, + struct wmGizmo *mpr, int part_index, const wmEvent *event) { mpr->highlight_part = part_index; - WM_manipulator_highlight_set(mmap, mpr); + WM_gizmo_highlight_set(mmap, mpr); if (false) { - wm_manipulatormap_modal_set(mmap, C, mpr, event, true); + wm_gizmomap_modal_set(mmap, C, mpr, event, true); } else { /* WEAK: but it works. */ - WM_operator_name_call(C, "MANIPULATORGROUP_OT_manipulator_tweak", WM_OP_INVOKE_DEFAULT, NULL); + WM_operator_name_call(C, "GIZMOGROUP_OT_gizmo_tweak", WM_OP_INVOKE_DEFAULT, NULL); } } -void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C) +void wm_gizmo_calculate_scale(wmGizmo *mpr, const bContext *C) { const RegionView3D *rv3d = CTX_wm_region_view3d(C); float scale = UI_DPI_FAC; - if ((mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SCALE) == 0) { - scale *= U.manipulator_size; + if ((mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_SCALE) == 0) { + scale *= U.gizmo_size; if (rv3d) { /* 'ED_view3d_pixel_size' includes 'U.pixelsize', remove it. */ float matrix_world[4][4]; @@ -519,53 +519,53 @@ void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C) mpr->scale_final = mpr->scale_basis * scale; } -static void manipulator_update_prop_data(wmManipulator *mpr) +static void gizmo_update_prop_data(wmGizmo *mpr) { - /* manipulator property might have been changed, so update manipulator */ + /* gizmo property might have been changed, so update gizmo */ if (mpr->type->property_update) { - wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr); + wmGizmoProperty *mpr_prop_array = WM_gizmo_target_property_array(mpr); for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; - if (WM_manipulator_target_property_is_valid(mpr_prop)) { + wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; + if (WM_gizmo_target_property_is_valid(mpr_prop)) { mpr->type->property_update(mpr, mpr_prop); } } } } -void wm_manipulator_update(wmManipulator *mpr, const bContext *C, const bool refresh_map) +void wm_gizmo_update(wmGizmo *mpr, const bContext *C, const bool refresh_map) { if (refresh_map) { - manipulator_update_prop_data(mpr); + gizmo_update_prop_data(mpr); } - wm_manipulator_calculate_scale(mpr, C); + wm_gizmo_calculate_scale(mpr, C); } -int wm_manipulator_is_visible(wmManipulator *mpr) +int wm_gizmo_is_visible(wmGizmo *mpr) { - if (mpr->flag & WM_MANIPULATOR_HIDDEN) { + if (mpr->flag & WM_GIZMO_HIDDEN) { return 0; } - if ((mpr->state & WM_MANIPULATOR_STATE_MODAL) && - !(mpr->flag & (WM_MANIPULATOR_DRAW_MODAL | WM_MANIPULATOR_DRAW_VALUE))) + if ((mpr->state & WM_GIZMO_STATE_MODAL) && + !(mpr->flag & (WM_GIZMO_DRAW_MODAL | WM_GIZMO_DRAW_VALUE))) { /* don't draw while modal (dragging) */ return 0; } - if ((mpr->flag & WM_MANIPULATOR_DRAW_HOVER) && - !(mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) && - !(mpr->state & WM_MANIPULATOR_STATE_SELECT)) /* still draw selected manipulators */ + if ((mpr->flag & WM_GIZMO_DRAW_HOVER) && + !(mpr->state & WM_GIZMO_STATE_HIGHLIGHT) && + !(mpr->state & WM_GIZMO_STATE_SELECT)) /* still draw selected gizmos */ { /* update but don't draw */ - return WM_MANIPULATOR_IS_VISIBLE_UPDATE; + return WM_GIZMO_IS_VISIBLE_UPDATE; } - return WM_MANIPULATOR_IS_VISIBLE_UPDATE | WM_MANIPULATOR_IS_VISIBLE_DRAW; + return WM_GIZMO_IS_VISIBLE_UPDATE | WM_GIZMO_IS_VISIBLE_DRAW; } -void WM_manipulator_calc_matrix_final_params( - const wmManipulator *mpr, - const struct WM_ManipulatorMatrixParams *params, +void WM_gizmo_calc_matrix_final_params( + const wmGizmo *mpr, + const struct WM_GizmoMatrixParams *params, float r_mat[4][4]) { const float (* const matrix_space)[4] = params->matrix_space ? params->matrix_space : mpr->matrix_space; @@ -581,11 +581,11 @@ void WM_manipulator_calc_matrix_final_params( copy_m4_m4(final_matrix, matrix_basis); } - if (mpr->flag & WM_MANIPULATOR_DRAW_NO_SCALE) { + if (mpr->flag & WM_GIZMO_DRAW_NO_SCALE) { mul_m4_m4m4(final_matrix, final_matrix, matrix_offset); } else { - if (mpr->flag & WM_MANIPULATOR_DRAW_OFFSET_SCALE) { + if (mpr->flag & WM_GIZMO_DRAW_OFFSET_SCALE) { mul_mat3_m4_fl(final_matrix, *scale_final); mul_m4_m4m4(final_matrix, final_matrix, matrix_offset); } @@ -598,14 +598,14 @@ void WM_manipulator_calc_matrix_final_params( mul_m4_m4m4(r_mat, matrix_space, final_matrix); } -void WM_manipulator_calc_matrix_final_no_offset(const wmManipulator *mpr, float r_mat[4][4]) +void WM_gizmo_calc_matrix_final_no_offset(const wmGizmo *mpr, float r_mat[4][4]) { float mat_identity[4][4]; unit_m4(mat_identity); - WM_manipulator_calc_matrix_final_params( + WM_gizmo_calc_matrix_final_params( mpr, - &((struct WM_ManipulatorMatrixParams) { + &((struct WM_GizmoMatrixParams) { .matrix_space = NULL, .matrix_basis = NULL, .matrix_offset = mat_identity, @@ -614,11 +614,11 @@ void WM_manipulator_calc_matrix_final_no_offset(const wmManipulator *mpr, float ); } -void WM_manipulator_calc_matrix_final(const wmManipulator *mpr, float r_mat[4][4]) +void WM_gizmo_calc_matrix_final(const wmGizmo *mpr, float r_mat[4][4]) { - WM_manipulator_calc_matrix_final_params( + WM_gizmo_calc_matrix_final_params( mpr, - &((struct WM_ManipulatorMatrixParams) { + &((struct WM_GizmoMatrixParams) { .matrix_space = NULL, .matrix_basis = NULL, .matrix_offset = NULL, @@ -627,31 +627,31 @@ void WM_manipulator_calc_matrix_final(const wmManipulator *mpr, float r_mat[4][4 ); } -/** \name Manipulator Propery Access +/** \name Gizmo Propery Access * * Matches `WM_operator_properties` conventions. * * \{ */ -void WM_manipulator_properties_create_ptr(PointerRNA *ptr, wmManipulatorType *wt) +void WM_gizmo_properties_create_ptr(PointerRNA *ptr, wmGizmoType *wt) { RNA_pointer_create(NULL, wt->srna, NULL, ptr); } -void WM_manipulator_properties_create(PointerRNA *ptr, const char *wtstring) +void WM_gizmo_properties_create(PointerRNA *ptr, const char *wtstring) { - const wmManipulatorType *wt = WM_manipulatortype_find(wtstring, false); + const wmGizmoType *wt = WM_gizmotype_find(wtstring, false); if (wt) - WM_manipulator_properties_create_ptr(ptr, (wmManipulatorType *)wt); + WM_gizmo_properties_create_ptr(ptr, (wmGizmoType *)wt); else - RNA_pointer_create(NULL, &RNA_ManipulatorProperties, NULL, ptr); + RNA_pointer_create(NULL, &RNA_GizmoProperties, NULL, ptr); } /* similar to the function above except its uses ID properties * used for keymaps and macros */ -void WM_manipulator_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *wtstring) +void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *wtstring) { if (*properties == NULL) { IDPropertyTemplate val = {0}; @@ -660,14 +660,14 @@ void WM_manipulator_properties_alloc(PointerRNA **ptr, IDProperty **properties, if (*ptr == NULL) { *ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr"); - WM_manipulator_properties_create(*ptr, wtstring); + WM_gizmo_properties_create(*ptr, wtstring); } (*ptr)->data = *properties; } -void WM_manipulator_properties_sanitize(PointerRNA *ptr, const bool no_context) +void WM_gizmo_properties_sanitize(PointerRNA *ptr, const bool no_context) { RNA_STRUCT_BEGIN (ptr, prop) { @@ -682,10 +682,10 @@ void WM_manipulator_properties_sanitize(PointerRNA *ptr, const bool no_context) { StructRNA *ptype = RNA_property_pointer_type(ptr, prop); - /* recurse into manipulator properties */ - if (RNA_struct_is_a(ptype, &RNA_ManipulatorProperties)) { + /* recurse into gizmo properties */ + if (RNA_struct_is_a(ptype, &RNA_GizmoProperties)) { PointerRNA opptr = RNA_property_pointer_get(ptr, prop); - WM_manipulator_properties_sanitize(&opptr, no_context); + WM_gizmo_properties_sanitize(&opptr, no_context); } break; } @@ -700,10 +700,10 @@ void WM_manipulator_properties_sanitize(PointerRNA *ptr, const bool no_context) /** set all props to their default, * \param do_update Only update un-initialized props. * - * \note, theres nothing specific to manipulators here. + * \note, theres nothing specific to gizmos here. * this could be made a general function. */ -bool WM_manipulator_properties_default(PointerRNA *ptr, const bool do_update) +bool WM_gizmo_properties_default(PointerRNA *ptr, const bool do_update) { bool changed = false; RNA_STRUCT_BEGIN (ptr, prop) @@ -714,7 +714,7 @@ bool WM_manipulator_properties_default(PointerRNA *ptr, const bool do_update) StructRNA *ptype = RNA_property_pointer_type(ptr, prop); if (ptype != &RNA_Struct) { PointerRNA opptr = RNA_property_pointer_get(ptr, prop); - changed |= WM_manipulator_properties_default(&opptr, do_update); + changed |= WM_gizmo_properties_default(&opptr, do_update); } break; } @@ -733,7 +733,7 @@ bool WM_manipulator_properties_default(PointerRNA *ptr, const bool do_update) } /* remove all props without PROP_SKIP_SAVE */ -void WM_manipulator_properties_reset(wmManipulator *mpr) +void WM_gizmo_properties_reset(wmGizmo *mpr) { if (mpr->ptr->data) { PropertyRNA *iterprop; @@ -752,7 +752,7 @@ void WM_manipulator_properties_reset(wmManipulator *mpr) } } -void WM_manipulator_properties_clear(PointerRNA *ptr) +void WM_gizmo_properties_clear(PointerRNA *ptr) { IDProperty *properties = ptr->data; @@ -761,7 +761,7 @@ void WM_manipulator_properties_clear(PointerRNA *ptr) } } -void WM_manipulator_properties_free(PointerRNA *ptr) +void WM_gizmo_properties_free(PointerRNA *ptr) { IDProperty *properties = ptr->data; @@ -778,14 +778,14 @@ void WM_manipulator_properties_free(PointerRNA *ptr) * * \{ */ -bool WM_manipulator_context_check_drawstep(const struct bContext *C, eWM_ManipulatorMapDrawStep step) +bool WM_gizmo_context_check_drawstep(const struct bContext *C, eWM_GizmoFlagMapDrawStep step) { switch (step) { - case WM_MANIPULATORMAP_DRAWSTEP_2D: + case WM_GIZMOMAP_DRAWSTEP_2D: { break; } - case WM_MANIPULATORMAP_DRAWSTEP_3D: + case WM_GIZMOMAP_DRAWSTEP_3D: { wmWindowManager *wm = CTX_wm_manager(C); if (ED_screen_animation_playing(wm)) { diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index 83af1a71163..f30744859aa 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -26,9 +26,9 @@ /** \file blender/windowmanager/gizmo/intern/wm_gizmo_group.c * \ingroup wm * - * \name Manipulator-Group + * \name Gizmo-Group * - * Manipulator-groups store and manage groups of manipulators. They can be + * Gizmo-groups store and manage groups of gizmos. They can be * attached to modal handlers and have own keymaps. */ @@ -64,22 +64,22 @@ # include "BPY_extern.h" #endif -/* Allow manipulator part's to be single click only, +/* Allow gizmo part's to be single click only, * dragging falls back to activating their 'drag_part' action. */ #define USE_DRAG_DETECT /* -------------------------------------------------------------------- */ -/** \name wmManipulatorGroup +/** \name wmGizmoGroup * * \{ */ /** - * Create a new manipulator-group from \a wgt. + * Create a new gizmo-group from \a wgt. */ -wmManipulatorGroup *wm_manipulatorgroup_new_from_type( - wmManipulatorMap *mmap, wmManipulatorGroupType *wgt) +wmGizmoGroup *wm_gizmogroup_new_from_type( + wmGizmoMap *mmap, wmGizmoGroupType *wgt) { - wmManipulatorGroup *mgroup = MEM_callocN(sizeof(*mgroup), "manipulator-group"); + wmGizmoGroup *mgroup = MEM_callocN(sizeof(*mgroup), "gizmo-group"); mgroup->type = wgt; /* keep back-link */ @@ -90,27 +90,27 @@ wmManipulatorGroup *wm_manipulatorgroup_new_from_type( return mgroup; } -void wm_manipulatorgroup_free(bContext *C, wmManipulatorGroup *mgroup) +void wm_gizmogroup_free(bContext *C, wmGizmoGroup *mgroup) { - wmManipulatorMap *mmap = mgroup->parent_mmap; + wmGizmoMap *mmap = mgroup->parent_mmap; - /* Similar to WM_manipulator_unlink, but only to keep mmap state correct, + /* Similar to WM_gizmo_unlink, but only to keep mmap state correct, * we don't want to run callbacks. */ if (mmap->mmap_context.highlight && mmap->mmap_context.highlight->parent_mgroup == mgroup) { - wm_manipulatormap_highlight_set(mmap, C, NULL, 0); + wm_gizmomap_highlight_set(mmap, C, NULL, 0); } if (mmap->mmap_context.modal && mmap->mmap_context.modal->parent_mgroup == mgroup) { - wm_manipulatormap_modal_set(mmap, C, mmap->mmap_context.modal, NULL, false); + wm_gizmomap_modal_set(mmap, C, mmap->mmap_context.modal, NULL, false); } - for (wmManipulator *mpr = mgroup->manipulators.first, *mpr_next; mpr; mpr = mpr_next) { + for (wmGizmo *mpr = mgroup->gizmos.first, *mpr_next; mpr; mpr = mpr_next) { mpr_next = mpr->next; if (mmap->mmap_context.select.len) { - WM_manipulator_select_unlink(mmap, mpr); + WM_gizmo_select_unlink(mmap, mpr); } - WM_manipulator_free(mpr); + WM_gizmo_free(mpr); } - BLI_listbase_clear(&mgroup->manipulators); + BLI_listbase_clear(&mgroup->gizmos); #ifdef WITH_PYTHON if (mgroup->py_instance) { @@ -138,21 +138,21 @@ void wm_manipulatorgroup_free(bContext *C, wmManipulatorGroup *mgroup) } /** - * Add \a manipulator to \a mgroup and make sure its name is unique within the group. + * Add \a gizmo to \a mgroup and make sure its name is unique within the group. */ -void wm_manipulatorgroup_manipulator_register(wmManipulatorGroup *mgroup, wmManipulator *mpr) +void wm_gizmogroup_gizmo_register(wmGizmoGroup *mgroup, wmGizmo *mpr) { - BLI_assert(BLI_findindex(&mgroup->manipulators, mpr) == -1); - BLI_addtail(&mgroup->manipulators, mpr); + BLI_assert(BLI_findindex(&mgroup->gizmos, mpr) == -1); + BLI_addtail(&mgroup->gizmos, mpr); mpr->parent_mgroup = mgroup; } -wmManipulator *wm_manipulatorgroup_find_intersected_manipulator( - const wmManipulatorGroup *mgroup, bContext *C, const wmEvent *event, +wmGizmo *wm_gizmogroup_find_intersected_gizmo( + const wmGizmoGroup *mgroup, bContext *C, const wmEvent *event, int *r_part) { - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if (mpr->type->test_select && (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) { + for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { + if (mpr->type->test_select && (mpr->flag & WM_GIZMO_HIDDEN) == 0) { if ((*r_part = mpr->type->test_select(C, mpr, event)) != -1) { return mpr; } @@ -163,14 +163,14 @@ wmManipulator *wm_manipulatorgroup_find_intersected_manipulator( } /** - * Adds all manipulators of \a mgroup that can be selected to the head of \a listbase. Added items need freeing! + * Adds all gizmos of \a mgroup that can be selected to the head of \a listbase. Added items need freeing! */ -void wm_manipulatorgroup_intersectable_manipulators_to_list(const wmManipulatorGroup *mgroup, ListBase *listbase) +void wm_gizmogroup_intersectable_gizmos_to_list(const wmGizmoGroup *mgroup, ListBase *listbase) { - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if ((mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) { - if (((mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) && mpr->type->draw_select) || - ((mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0 && mpr->type->test_select)) + for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { + if ((mpr->flag & WM_GIZMO_HIDDEN) == 0) { + if (((mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) && mpr->type->draw_select) || + ((mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0 && mpr->type->test_select)) { BLI_addhead(listbase, BLI_genericNodeN(mpr)); } @@ -178,32 +178,32 @@ void wm_manipulatorgroup_intersectable_manipulators_to_list(const wmManipulatorG } } -void wm_manipulatorgroup_ensure_initialized(wmManipulatorGroup *mgroup, const bContext *C) +void wm_gizmogroup_ensure_initialized(wmGizmoGroup *mgroup, const bContext *C) { /* prepare for first draw */ - if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0)) { + if (UNLIKELY((mgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0)) { mgroup->type->setup(C, mgroup); - /* Not ideal, initialize keymap here, needed for RNA runtime generated manipulators. */ - wmManipulatorGroupType *wgt = mgroup->type; + /* Not ideal, initialize keymap here, needed for RNA runtime generated gizmos. */ + wmGizmoGroupType *wgt = mgroup->type; if (wgt->keymap == NULL) { wmWindowManager *wm = CTX_wm_manager(C); - wm_manipulatorgrouptype_setup_keymap(wgt, wm->defaultconf); + wm_gizmogrouptype_setup_keymap(wgt, wm->defaultconf); BLI_assert(wgt->keymap != NULL); } - mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_SETUP; + mgroup->init_flag |= WM_GIZMOGROUP_INIT_SETUP; } /* refresh may be called multiple times, this just ensures its called at least once before we draw. */ - if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_REFRESH) == 0)) { + if (UNLIKELY((mgroup->init_flag & WM_GIZMOGROUP_INIT_REFRESH) == 0)) { if (mgroup->type->refresh) { mgroup->type->refresh(C, mgroup); } - mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_REFRESH; + mgroup->init_flag |= WM_GIZMOGROUP_INIT_REFRESH; } } -bool WM_manipulator_group_type_poll(const bContext *C, const struct wmManipulatorGroupType *wgt) +bool WM_gizmo_group_type_poll(const bContext *C, const struct wmGizmoGroupType *wgt) { /* If we're tagged, only use compatible. */ if (wgt->owner_id[0] != '\0') { @@ -212,29 +212,29 @@ bool WM_manipulator_group_type_poll(const bContext *C, const struct wmManipulato return false; } } - /* Check for poll function, if manipulator-group belongs to an operator, also check if the operator is running. */ - return (!wgt->poll || wgt->poll(C, (wmManipulatorGroupType *)wgt)); + /* Check for poll function, if gizmo-group belongs to an operator, also check if the operator is running. */ + return (!wgt->poll || wgt->poll(C, (wmGizmoGroupType *)wgt)); } -bool wm_manipulatorgroup_is_visible_in_drawstep( - const wmManipulatorGroup *mgroup, const eWM_ManipulatorMapDrawStep drawstep) +bool wm_gizmogroup_is_visible_in_drawstep( + const wmGizmoGroup *mgroup, const eWM_GizmoFlagMapDrawStep drawstep) { switch (drawstep) { - case WM_MANIPULATORMAP_DRAWSTEP_2D: - return (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) == 0; - case WM_MANIPULATORMAP_DRAWSTEP_3D: - return (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D); + case WM_GIZMOMAP_DRAWSTEP_2D: + return (mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; + case WM_GIZMOMAP_DRAWSTEP_3D: + return (mgroup->type->flag & WM_GIZMOGROUPTYPE_3D); default: BLI_assert(0); return false; } } -bool wm_manipulatorgroup_is_any_selected(const wmManipulatorGroup *mgroup) +bool wm_gizmogroup_is_any_selected(const wmGizmoGroup *mgroup) { - if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SELECT) { - for (const wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if (mpr->state & WM_MANIPULATOR_STATE_SELECT) { + if (mgroup->type->flag & WM_GIZMOGROUPTYPE_SELECT) { + for (const wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { + if (mpr->state & WM_GIZMO_STATE_SELECT) { return true; } } @@ -244,18 +244,18 @@ bool wm_manipulatorgroup_is_any_selected(const wmManipulatorGroup *mgroup) /** \} */ -/** \name Manipulator operators +/** \name Gizmo operators * - * Basic operators for manipulator interaction with user configurable keymaps. + * Basic operators for gizmo interaction with user configurable keymaps. * * \{ */ -static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int gizmo_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { ARegion *ar = CTX_wm_region(C); - wmManipulatorMap *mmap = ar->manipulator_map; - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - wmManipulator *highlight = mmap->mmap_context.highlight; + wmGizmoMap *mmap = ar->gizmo_map; + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; + wmGizmo *highlight = mmap->mmap_context.highlight; bool extend = RNA_boolean_get(op->ptr, "extend"); bool deselect = RNA_boolean_get(op->ptr, "deselect"); @@ -263,13 +263,13 @@ static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent /* deselect all first */ if (extend == false && deselect == false && toggle == false) { - wm_manipulatormap_deselect_all(mmap); + wm_gizmomap_deselect_all(mmap); BLI_assert(msel->items == NULL && msel->len == 0); UNUSED_VARS_NDEBUG(msel); } if (highlight) { - const bool is_selected = (highlight->state & WM_MANIPULATOR_STATE_SELECT); + const bool is_selected = (highlight->state & WM_GIZMO_STATE_SELECT); bool redraw = false; if (toggle) { @@ -278,11 +278,11 @@ static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent } if (deselect) { - if (is_selected && WM_manipulator_select_set(mmap, highlight, false)) { + if (is_selected && WM_gizmo_select_set(mmap, highlight, false)) { redraw = true; } } - else if (wm_manipulator_select_and_highlight(C, mmap, highlight)) { + else if (wm_gizmo_select_and_highlight(C, mmap, highlight)) { redraw = true; } @@ -300,32 +300,32 @@ static int manipulator_select_invoke(bContext *C, wmOperator *op, const wmEvent return OPERATOR_PASS_THROUGH; } -void MANIPULATORGROUP_OT_manipulator_select(wmOperatorType *ot) +void GIZMOGROUP_OT_gizmo_select(wmOperatorType *ot) { /* identifiers */ ot->name = "Gizmo Select"; - ot->description = "Select the currently highlighted manipulator"; - ot->idname = "MANIPULATORGROUP_OT_manipulator_select"; + ot->description = "Select the currently highlighted gizmo"; + ot->idname = "GIZMOGROUP_OT_gizmo_select"; /* api callbacks */ - ot->invoke = manipulator_select_invoke; + ot->invoke = gizmo_select_invoke; ot->flag = OPTYPE_UNDO; WM_operator_properties_mouse_select(ot); } -typedef struct ManipulatorTweakData { - wmManipulatorMap *mmap; - wmManipulatorGroup *mgroup; - wmManipulator *mpr_modal; +typedef struct GizmoTweakData { + wmGizmoMap *mmap; + wmGizmoGroup *mgroup; + wmGizmo *mpr_modal; int init_event; /* initial event type */ int flag; /* tweak flags */ #ifdef USE_DRAG_DETECT /* True until the mouse is moved (only use when the operator has no modal). - * this allows some manipulators to be click-only. */ + * this allows some gizmos to be click-only. */ enum { /* Don't detect dragging. */ DRAG_NOP = 0, @@ -333,27 +333,27 @@ typedef struct ManipulatorTweakData { DRAG_DETECT, /* Drag has started, idle until there is no active modal operator. * This is needed because finishing the modal operator also exits - * the modal manipulator state (un-grabbs the cursor). + * the modal gizmo state (un-grabbs the cursor). * Ideally this workaround could be removed later. */ DRAG_IDLE, } drag_state; #endif -} ManipulatorTweakData; +} GizmoTweakData; -static bool manipulator_tweak_start( - bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr, const wmEvent *event) +static bool gizmo_tweak_start( + bContext *C, wmGizmoMap *mmap, wmGizmo *mpr, const wmEvent *event) { - /* activate highlighted manipulator */ - wm_manipulatormap_modal_set(mmap, C, mpr, event, true); + /* activate highlighted gizmo */ + wm_gizmomap_modal_set(mmap, C, mpr, event, true); - return (mpr->state & WM_MANIPULATOR_STATE_MODAL); + return (mpr->state & WM_GIZMO_STATE_MODAL); } -static bool manipulator_tweak_start_and_finish( - bContext *C, wmManipulatorMap *mmap, wmManipulator *mpr, const wmEvent *event, bool *r_is_modal) +static bool gizmo_tweak_start_and_finish( + bContext *C, wmGizmoMap *mmap, wmGizmo *mpr, const wmEvent *event, bool *r_is_modal) { - wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part); + wmGizmoOpElem *mpop = WM_gizmo_operator_get(mpr, mpr->highlight_part); if (r_is_modal) { *r_is_modal = false; } @@ -364,7 +364,7 @@ static bool manipulator_tweak_start_and_finish( wmWindowManager *wm = CTX_wm_manager(C); wmOperator *op = WM_operator_last_redo(C); - /* We may want to enable this, for now the manipulator can manage it's own properties. */ + /* We may want to enable this, for now the gizmo can manage it's own properties. */ #if 0 IDP_MergeGroup(mpop->ptr.data, op->properties, false); #endif @@ -373,17 +373,17 @@ static bool manipulator_tweak_start_and_finish( ED_undo_pop_op(C, op); } - /* XXX temporary workaround for modal manipulator operator - * conflicting with modal operator attached to manipulator */ + /* XXX temporary workaround for modal gizmo operator + * conflicting with modal operator attached to gizmo */ if (mpop->type->modal) { - /* activate highlighted manipulator */ - wm_manipulatormap_modal_set(mmap, C, mpr, event, true); + /* activate highlighted gizmo */ + wm_gizmomap_modal_set(mmap, C, mpr, event, true); if (r_is_modal) { *r_is_modal = true; } } else { - /* Allow for 'button' manipulators, single click to run an action. */ + /* Allow for 'button' gizmos, single click to run an action. */ WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr); } return true; @@ -393,27 +393,27 @@ static bool manipulator_tweak_start_and_finish( } } -static void manipulator_tweak_finish(bContext *C, wmOperator *op, const bool cancel, bool clear_modal) +static void gizmo_tweak_finish(bContext *C, wmOperator *op, const bool cancel, bool clear_modal) { - ManipulatorTweakData *mtweak = op->customdata; + GizmoTweakData *mtweak = op->customdata; if (mtweak->mpr_modal->type->exit) { mtweak->mpr_modal->type->exit(C, mtweak->mpr_modal, cancel); } if (clear_modal) { - /* The manipulator may have been removed. */ + /* The gizmo may have been removed. */ if ((BLI_findindex(&mtweak->mmap->groups, mtweak->mgroup) != -1) && - (BLI_findindex(&mtweak->mgroup->manipulators, mtweak->mpr_modal) != -1)) + (BLI_findindex(&mtweak->mgroup->gizmos, mtweak->mpr_modal) != -1)) { - wm_manipulatormap_modal_set(mtweak->mmap, C, mtweak->mpr_modal, NULL, false); + wm_gizmomap_modal_set(mtweak->mmap, C, mtweak->mpr_modal, NULL, false); } } MEM_freeN(mtweak); } -static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event) +static int gizmo_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event) { - ManipulatorTweakData *mtweak = op->customdata; - wmManipulator *mpr = mtweak->mpr_modal; + GizmoTweakData *mtweak = op->customdata; + wmGizmo *mpr = mtweak->mpr_modal; int retval = OPERATOR_PASS_THROUGH; bool clear_modal = true; @@ -423,7 +423,7 @@ static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *e } #ifdef USE_DRAG_DETECT - wmManipulatorMap *mmap = mtweak->mmap; + wmGizmoMap *mmap = mtweak->mmap; if (mtweak->drag_state == DRAG_DETECT) { if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { if (len_manhattan_v2v2_int(&event->x, mmap->mmap_context.event_xy) > 2) { @@ -437,15 +437,15 @@ static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *e } if (mtweak->drag_state != DRAG_DETECT) { - /* Follow logic in 'manipulator_tweak_invoke' */ + /* Follow logic in 'gizmo_tweak_invoke' */ bool is_modal = false; - if (manipulator_tweak_start_and_finish(C, mmap, mpr, event, &is_modal)) { + if (gizmo_tweak_start_and_finish(C, mmap, mpr, event, &is_modal)) { if (is_modal) { clear_modal = false; } } else { - if (!manipulator_tweak_start(C, mmap, mpr, event)) { + if (!gizmo_tweak_start(C, mmap, mpr, event)) { retval = OPERATOR_FINISHED; } } @@ -456,7 +456,7 @@ static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *e return OPERATOR_PASS_THROUGH; } else { - manipulator_tweak_finish(C, op, false, false); + gizmo_tweak_finish(C, op, false, false); return OPERATOR_FINISHED; } } @@ -477,51 +477,51 @@ static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *e retval = OPERATOR_FINISHED; break; case TWEAK_MODAL_PRECISION_ON: - mtweak->flag |= WM_MANIPULATOR_TWEAK_PRECISE; + mtweak->flag |= WM_GIZMO_TWEAK_PRECISE; break; case TWEAK_MODAL_PRECISION_OFF: - mtweak->flag &= ~WM_MANIPULATOR_TWEAK_PRECISE; + mtweak->flag &= ~WM_GIZMO_TWEAK_PRECISE; break; case TWEAK_MODAL_SNAP_ON: - mtweak->flag |= WM_MANIPULATOR_TWEAK_SNAP; + mtweak->flag |= WM_GIZMO_TWEAK_SNAP; break; case TWEAK_MODAL_SNAP_OFF: - mtweak->flag &= ~WM_MANIPULATOR_TWEAK_SNAP; + mtweak->flag &= ~WM_GIZMO_TWEAK_SNAP; break; } } if (retval != OPERATOR_PASS_THROUGH) { - manipulator_tweak_finish(C, op, retval != OPERATOR_FINISHED, clear_modal); + gizmo_tweak_finish(C, op, retval != OPERATOR_FINISHED, clear_modal); return retval; } - /* handle manipulator */ - wmManipulatorFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; + /* handle gizmo */ + wmGizmoFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; if (modal_fn) { int modal_retval = modal_fn(C, mpr, event, mtweak->flag); if ((modal_retval & OPERATOR_RUNNING_MODAL) == 0) { - manipulator_tweak_finish(C, op, (modal_retval & OPERATOR_CANCELLED) != 0, true); + gizmo_tweak_finish(C, op, (modal_retval & OPERATOR_CANCELLED) != 0, true); return OPERATOR_FINISHED; } - /* Ugly hack to send manipulator events */ - ((wmEvent *)event)->type = EVT_MANIPULATOR_UPDATE; + /* Ugly hack to send gizmo events */ + ((wmEvent *)event)->type = EVT_GIZMO_UPDATE; } /* always return PASS_THROUGH so modal handlers - * with manipulators attached can update */ + * with gizmos attached can update */ BLI_assert(retval == OPERATOR_PASS_THROUGH); return OPERATOR_PASS_THROUGH; } -static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event) +static int gizmo_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); - wmManipulatorMap *mmap = ar->manipulator_map; - wmManipulator *mpr = mmap->mmap_context.highlight; + wmGizmoMap *mmap = ar->gizmo_map; + wmGizmo *mpr = mmap->mmap_context.highlight; /* Needed for single click actions which don't enter modal state. */ WM_tooltip_clear(C, CTX_wm_window(C)); @@ -539,7 +539,7 @@ static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent * #endif if (use_drag_fallback == false) { - if (manipulator_tweak_start_and_finish(C, mmap, mpr, event, NULL)) { + if (gizmo_tweak_start_and_finish(C, mmap, mpr, event, NULL)) { return OPERATOR_FINISHED; } } @@ -547,7 +547,7 @@ static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent * bool use_drag_detect = false; #ifdef USE_DRAG_DETECT if (use_drag_fallback) { - wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part); + wmGizmoOpElem *mpop = WM_gizmo_operator_get(mpr, mpr->highlight_part); if (mpop && mpop->type) { if (mpop->type->modal == NULL) { use_drag_detect = true; @@ -557,13 +557,13 @@ static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent * #endif if (use_drag_detect == false) { - if (!manipulator_tweak_start(C, mmap, mpr, event)) { + if (!gizmo_tweak_start(C, mmap, mpr, event)) { /* failed to start */ return OPERATOR_PASS_THROUGH; } } - ManipulatorTweakData *mtweak = MEM_mallocN(sizeof(ManipulatorTweakData), __func__); + GizmoTweakData *mtweak = MEM_mallocN(sizeof(GizmoTweakData), __func__); mtweak->init_event = WM_userdef_event_type_from_keymap_type(event->type); mtweak->mpr_modal = mmap->mmap_context.highlight; @@ -582,16 +582,16 @@ static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent * return OPERATOR_RUNNING_MODAL; } -void MANIPULATORGROUP_OT_manipulator_tweak(wmOperatorType *ot) +void GIZMOGROUP_OT_gizmo_tweak(wmOperatorType *ot) { /* identifiers */ ot->name = "Gizmo Tweak"; ot->description = "Tweak the active gizmo"; - ot->idname = "MANIPULATORGROUP_OT_manipulator_tweak"; + ot->idname = "GIZMOGROUP_OT_gizmo_tweak"; /* api callbacks */ - ot->invoke = manipulator_tweak_invoke; - ot->modal = manipulator_tweak_modal; + ot->invoke = gizmo_tweak_invoke; + ot->modal = gizmo_tweak_modal; /* TODO(campbell) This causes problems tweaking settings for operators, * need to find a way to support this. */ @@ -603,7 +603,7 @@ void MANIPULATORGROUP_OT_manipulator_tweak(wmOperatorType *ot) /** \} */ -static wmKeyMap *manipulatorgroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char *mgroupname) +static wmKeyMap *gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char *mgroupname) { wmKeyMap *keymap; char name[KMAP_MAX_NAME]; @@ -646,44 +646,44 @@ static wmKeyMap *manipulatorgroup_tweak_modal_keymap(wmKeyConfig *keyconf, const WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, TWEAK_MODAL_SNAP_ON); WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, TWEAK_MODAL_SNAP_OFF); - WM_modalkeymap_assign(keymap, "MANIPULATORGROUP_OT_manipulator_tweak"); + WM_modalkeymap_assign(keymap, "GIZMOGROUP_OT_gizmo_tweak"); return keymap; } /** - * Common default keymap for manipulator groups + * Common default keymap for gizmo groups */ -wmKeyMap *WM_manipulatorgroup_keymap_common( - const wmManipulatorGroupType *wgt, wmKeyConfig *config) +wmKeyMap *WM_gizmogroup_keymap_common( + const wmGizmoGroupType *wgt, wmKeyConfig *config) { - /* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */ + /* Use area and region id since we might have multiple gizmos with the same name in different areas/regions */ 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", LEFTMOUSE, KM_PRESS, KM_ANY, 0); - manipulatorgroup_tweak_modal_keymap(config, wgt->name); + WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", LEFTMOUSE, KM_PRESS, KM_ANY, 0); + gizmogroup_tweak_modal_keymap(config, wgt->name); return km; } /** - * Variation of #WM_manipulatorgroup_keymap_common but with keymap items for selection + * Variation of #WM_gizmogroup_keymap_common but with keymap items for selection */ -wmKeyMap *WM_manipulatorgroup_keymap_common_select( - const wmManipulatorGroupType *wgt, wmKeyConfig *config) +wmKeyMap *WM_gizmogroup_keymap_common_select( + const wmGizmoGroupType *wgt, wmKeyConfig *config) { - /* Use area and region id since we might have multiple manipulators with the same name in different areas/regions */ + /* Use area and region id since we might have multiple gizmos with the same name in different areas/regions */ 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); - WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_tweak", EVT_TWEAK_S, KM_ANY, 0, 0); - manipulatorgroup_tweak_modal_keymap(config, wgt->name); + WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0); + WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", EVT_TWEAK_S, KM_ANY, 0, 0); + gizmogroup_tweak_modal_keymap(config, wgt->name); - wmKeyMapItem *kmi = WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_select", SELECTMOUSE, KM_PRESS, 0, 0); + wmKeyMapItem *kmi = WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_select", SELECTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", false); RNA_boolean_set(kmi->ptr, "deselect", false); RNA_boolean_set(kmi->ptr, "toggle", false); - kmi = WM_keymap_add_item(km, "MANIPULATORGROUP_OT_manipulator_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); + kmi = WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", false); RNA_boolean_set(kmi->ptr, "deselect", false); RNA_boolean_set(kmi->ptr, "toggle", true); @@ -691,19 +691,19 @@ wmKeyMap *WM_manipulatorgroup_keymap_common_select( return km; } -/** \} */ /* wmManipulatorGroup */ +/** \} */ /* wmGizmoGroup */ /* -------------------------------------------------------------------- */ -/** \name wmManipulatorGroupType +/** \name wmGizmoGroupType * * \{ */ -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr( - struct wmManipulatorMapType *mmap_type, - const wmManipulatorGroupType *wgt) +struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find_ptr( + struct wmGizmoMapType *mmap_type, + const wmGizmoGroupType *wgt) { /* could use hash lookups as operator types do, for now simple search. */ - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { @@ -714,12 +714,12 @@ struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find_ptr( return NULL; } -struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find( - struct wmManipulatorMapType *mmap_type, +struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find( + struct wmGizmoMapType *mmap_type, const char *idname) { /* could use hash lookups as operator types do, for now simple search. */ - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { @@ -731,49 +731,49 @@ struct wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_find( } /** - * Use this for registering manipulators on startup. For runtime, use #WM_manipulatormaptype_group_link_runtime. + * Use this for registering gizmos on startup. For runtime, use #WM_gizmomaptype_group_link_runtime. */ -wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link( - wmManipulatorMapType *mmap_type, const char *idname) +wmGizmoGroupTypeRef *WM_gizmomaptype_group_link( + wmGizmoMapType *mmap_type, const char *idname) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); BLI_assert(wgt != NULL); - return WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); + return WM_gizmomaptype_group_link_ptr(mmap_type, wgt); } -wmManipulatorGroupTypeRef *WM_manipulatormaptype_group_link_ptr( - wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) +wmGizmoGroupTypeRef *WM_gizmomaptype_group_link_ptr( + wmGizmoMapType *mmap_type, wmGizmoGroupType *wgt) { - wmManipulatorGroupTypeRef *wgt_ref = MEM_callocN(sizeof(wmManipulatorGroupTypeRef), "manipulator-group-ref"); + wmGizmoGroupTypeRef *wgt_ref = MEM_callocN(sizeof(wmGizmoGroupTypeRef), "gizmo-group-ref"); wgt_ref->type = wgt; BLI_addtail(&mmap_type->grouptype_refs, wgt_ref); return wgt_ref; } -void WM_manipulatormaptype_group_init_runtime_keymap( +void WM_gizmomaptype_group_init_runtime_keymap( const Main *bmain, - wmManipulatorGroupType *wgt) + wmGizmoGroupType *wgt) { - /* init keymap - on startup there's an extra call to init keymaps for 'permanent' manipulator-groups */ - wm_manipulatorgrouptype_setup_keymap(wgt, ((wmWindowManager *)bmain->wm.first)->defaultconf); + /* init keymap - on startup there's an extra call to init keymaps for 'permanent' gizmo-groups */ + wm_gizmogrouptype_setup_keymap(wgt, ((wmWindowManager *)bmain->wm.first)->defaultconf); } -void WM_manipulatormaptype_group_init_runtime( - const Main *bmain, wmManipulatorMapType *mmap_type, - wmManipulatorGroupType *wgt) +void WM_gizmomaptype_group_init_runtime( + const Main *bmain, wmGizmoMapType *mmap_type, + wmGizmoGroupType *wgt) { - /* now create a manipulator for all existing areas */ + /* now create a gizmo for all existing areas */ 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; + wmGizmoMap *mmap = ar->gizmo_map; if (mmap && mmap->type == mmap_type) { - wm_manipulatorgroup_new_from_type(mmap, wgt); + wm_gizmogroup_new_from_type(mmap, wgt); /* just add here, drawing will occur on next update */ - wm_manipulatormap_highlight_set(mmap, NULL, NULL, 0); + wm_gizmomap_highlight_set(mmap, NULL, NULL, 0); ED_region_tag_redraw(ar); } } @@ -784,16 +784,16 @@ void WM_manipulatormaptype_group_init_runtime( /** - * Unlike #WM_manipulatormaptype_group_unlink this doesn't maintain correct state, simply free. + * Unlike #WM_gizmomaptype_group_unlink this doesn't maintain correct state, simply free. */ -void WM_manipulatormaptype_group_free(wmManipulatorGroupTypeRef *wgt_ref) +void WM_gizmomaptype_group_free(wmGizmoGroupTypeRef *wgt_ref) { MEM_freeN(wgt_ref); } -void WM_manipulatormaptype_group_unlink( - bContext *C, Main *bmain, wmManipulatorMapType *mmap_type, - const wmManipulatorGroupType *wgt) +void WM_gizmomaptype_group_unlink( + bContext *C, Main *bmain, wmGizmoMapType *mmap_type, + const wmGizmoGroupType *wgt) { /* Free instances. */ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { @@ -801,14 +801,14 @@ void WM_manipulatormaptype_group_unlink( 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; + wmGizmoMap *mmap = ar->gizmo_map; if (mmap && mmap->type == mmap_type) { - wmManipulatorGroup *mgroup, *mgroup_next; + wmGizmoGroup *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); - wm_manipulatorgroup_free(C, mgroup); + wm_gizmogroup_free(C, mgroup); ED_region_tag_redraw(ar); } } @@ -819,131 +819,131 @@ void WM_manipulatormaptype_group_unlink( } /* Free types. */ - wmManipulatorGroupTypeRef *wgt_ref = WM_manipulatormaptype_group_find_ptr(mmap_type, wgt); + wmGizmoGroupTypeRef *wgt_ref = WM_gizmomaptype_group_find_ptr(mmap_type, wgt); if (wgt_ref) { BLI_remlink(&mmap_type->grouptype_refs, wgt_ref); - WM_manipulatormaptype_group_free(wgt_ref); + WM_gizmomaptype_group_free(wgt_ref); } /* Note, we may want to keep this keymap for editing */ WM_keymap_remove(wgt->keyconf, wgt->keymap); - BLI_assert(WM_manipulatormaptype_group_find_ptr(mmap_type, wgt) == NULL); + BLI_assert(WM_gizmomaptype_group_find_ptr(mmap_type, wgt) == NULL); } -void wm_manipulatorgrouptype_setup_keymap( - wmManipulatorGroupType *wgt, wmKeyConfig *keyconf) +void wm_gizmogrouptype_setup_keymap( + wmGizmoGroupType *wgt, wmKeyConfig *keyconf) { /* Use flag since setup_keymap may return NULL, * in that case we better not keep calling it. */ - if (wgt->type_update_flag & WM_MANIPULATORMAPTYPE_KEYMAP_INIT) { + if (wgt->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) { wgt->keymap = wgt->setup_keymap(wgt, keyconf); wgt->keyconf = keyconf; - wgt->type_update_flag &= ~WM_MANIPULATORMAPTYPE_KEYMAP_INIT; + wgt->type_update_flag &= ~WM_GIZMOMAPTYPE_KEYMAP_INIT; } } -/** \} */ /* wmManipulatorGroupType */ +/** \} */ /* wmGizmoGroupType */ /* -------------------------------------------------------------------- */ /** \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, + * \note In context of gizmo API these names are a bit misleading, * but for general use terms its OK. - * `WM_manipulator_group_type_add` would be more correctly called: - * `WM_manipulatormaptype_grouptype_reference_link` + * `WM_gizmo_group_type_add` would be more correctly called: + * `WM_gizmomaptype_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_type_add_ptr_ex( - wmManipulatorGroupType *wgt, - wmManipulatorMapType *mmap_type) +void WM_gizmo_group_type_add_ptr_ex( + wmGizmoGroupType *wgt, + wmGizmoMapType *mmap_type) { - WM_manipulatormaptype_group_link_ptr(mmap_type, wgt); + WM_gizmomaptype_group_link_ptr(mmap_type, wgt); - WM_manipulatorconfig_update_tag_init(mmap_type, wgt); + WM_gizmoconfig_update_tag_init(mmap_type, wgt); } -void WM_manipulator_group_type_add_ptr( - wmManipulatorGroupType *wgt) +void WM_gizmo_group_type_add_ptr( + wmGizmoGroupType *wgt) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); + WM_gizmo_group_type_add_ptr_ex(wgt, mmap_type); } -void WM_manipulator_group_type_add(const char *idname) +void WM_gizmo_group_type_add(const char *idname) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); BLI_assert(wgt != NULL); - WM_manipulator_group_type_add_ptr(wgt); + WM_gizmo_group_type_add_ptr(wgt); } -void WM_manipulator_group_type_ensure_ptr_ex( - wmManipulatorGroupType *wgt, - wmManipulatorMapType *mmap_type) +void WM_gizmo_group_type_ensure_ptr_ex( + wmGizmoGroupType *wgt, + wmGizmoMapType *mmap_type) { - wmManipulatorGroupTypeRef *wgt_ref = WM_manipulatormaptype_group_find_ptr(mmap_type, wgt); + wmGizmoGroupTypeRef *wgt_ref = WM_gizmomaptype_group_find_ptr(mmap_type, wgt); if (wgt_ref == NULL) { - WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type); + WM_gizmo_group_type_add_ptr_ex(wgt, mmap_type); } } -void WM_manipulator_group_type_ensure_ptr( - wmManipulatorGroupType *wgt) +void WM_gizmo_group_type_ensure_ptr( + wmGizmoGroupType *wgt) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulator_group_type_ensure_ptr_ex(wgt, mmap_type); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); + WM_gizmo_group_type_ensure_ptr_ex(wgt, mmap_type); } -void WM_manipulator_group_type_ensure(const char *idname) +void WM_gizmo_group_type_ensure(const char *idname) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); BLI_assert(wgt != NULL); - WM_manipulator_group_type_ensure_ptr(wgt); + WM_gizmo_group_type_ensure_ptr(wgt); } -void WM_manipulator_group_type_remove_ptr_ex( - struct Main *bmain, wmManipulatorGroupType *wgt, - wmManipulatorMapType *mmap_type) +void WM_gizmo_group_type_remove_ptr_ex( + struct Main *bmain, wmGizmoGroupType *wgt, + wmGizmoMapType *mmap_type) { - WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt); - WM_manipulatorgrouptype_free_ptr(wgt); + WM_gizmomaptype_group_unlink(NULL, bmain, mmap_type, wgt); + WM_gizmogrouptype_free_ptr(wgt); } -void WM_manipulator_group_type_remove_ptr( - struct Main *bmain, wmManipulatorGroupType *wgt) +void WM_gizmo_group_type_remove_ptr( + struct Main *bmain, wmGizmoGroupType *wgt) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulator_group_type_remove_ptr_ex(bmain, wgt, mmap_type); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); + WM_gizmo_group_type_remove_ptr_ex(bmain, wgt, mmap_type); } -void WM_manipulator_group_type_remove(struct Main *bmain, const char *idname) +void WM_gizmo_group_type_remove(struct Main *bmain, const char *idname) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); BLI_assert(wgt != NULL); - WM_manipulator_group_type_remove_ptr(bmain, wgt); + WM_gizmo_group_type_remove_ptr(bmain, wgt); } /* delayed versions */ -void WM_manipulator_group_type_unlink_delayed_ptr_ex( - wmManipulatorGroupType *wgt, - wmManipulatorMapType *mmap_type) +void WM_gizmo_group_type_unlink_delayed_ptr_ex( + wmGizmoGroupType *wgt, + wmGizmoMapType *mmap_type) { - WM_manipulatorconfig_update_tag_remove(mmap_type, wgt); + WM_gizmoconfig_update_tag_remove(mmap_type, wgt); } -void WM_manipulator_group_type_unlink_delayed_ptr( - wmManipulatorGroupType *wgt) +void WM_gizmo_group_type_unlink_delayed_ptr( + wmGizmoGroupType *wgt) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulator_group_type_unlink_delayed_ptr_ex(wgt, mmap_type); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); + WM_gizmo_group_type_unlink_delayed_ptr_ex(wgt, mmap_type); } -void WM_manipulator_group_type_unlink_delayed(const char *idname) +void WM_gizmo_group_type_unlink_delayed(const char *idname) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); BLI_assert(wgt != NULL); - WM_manipulator_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(wgt); } /** \} */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c index f93beb0ac9f..44f5fac4cd4 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c @@ -36,7 +36,7 @@ #include "WM_api.h" #include "WM_types.h" -/* only for own init/exit calls (wm_manipulatorgrouptype_init/wm_manipulatorgrouptype_free) */ +/* only for own init/exit calls (wm_gizmogrouptype_init/wm_gizmogrouptype_free) */ #include "wm.h" /* own includes */ @@ -44,30 +44,30 @@ #include "wm_gizmo_intern.h" -/** \name ManipulatorGroup Type Append +/** \name GizmoGroup Type Append * * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends. * \{ */ -static GHash *global_manipulatorgrouptype_hash = NULL; +static GHash *global_gizmogrouptype_hash = NULL; -wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool quiet) +wmGizmoGroupType *WM_gizmogrouptype_find(const char *idname, bool quiet) { if (idname[0]) { - wmManipulatorGroupType *wgt; + wmGizmoGroupType *wgt; - wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname); + wgt = BLI_ghash_lookup(global_gizmogrouptype_hash, idname); if (wgt) { return wgt; } if (!quiet) { - printf("search for unknown manipulator group '%s'\n", idname); + printf("search for unknown gizmo group '%s'\n", idname); } } else { if (!quiet) { - printf("search for empty manipulator group\n"); + printf("search for empty gizmo group\n"); } } @@ -75,123 +75,123 @@ wmManipulatorGroupType *WM_manipulatorgrouptype_find(const char *idname, bool qu } /* caller must free */ -void WM_manipulatorgrouptype_iter(GHashIterator *ghi) +void WM_gizmogrouptype_iter(GHashIterator *ghi) { - BLI_ghashIterator_init(ghi, global_manipulatorgrouptype_hash); + BLI_ghashIterator_init(ghi, global_gizmogrouptype_hash); } -static wmManipulatorGroupType *wm_manipulatorgrouptype_append__begin(void) +static wmGizmoGroupType *wm_gizmogrouptype_append__begin(void) { - wmManipulatorGroupType *wgt = MEM_callocN(sizeof(wmManipulatorGroupType), "manipulatorgrouptype"); + wmGizmoGroupType *wgt = MEM_callocN(sizeof(wmGizmoGroupType), "gizmogrouptype"); return wgt; } -static void wm_manipulatorgrouptype_append__end(wmManipulatorGroupType *wgt) +static void wm_gizmogrouptype_append__end(wmGizmoGroupType *wgt) { BLI_assert(wgt->name != NULL); BLI_assert(wgt->idname != NULL); - wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_KEYMAP_INIT; + wgt->type_update_flag |= WM_GIZMOMAPTYPE_KEYMAP_INIT; /* if not set, use default */ if (wgt->setup_keymap == NULL) { - if (wgt->flag & WM_MANIPULATORGROUPTYPE_SELECT) { - wgt->setup_keymap = WM_manipulatorgroup_keymap_common_select; + if (wgt->flag & WM_GIZMOGROUPTYPE_SELECT) { + wgt->setup_keymap = WM_gizmogroup_keymap_common_select; } else { - wgt->setup_keymap = WM_manipulatorgroup_keymap_common; + wgt->setup_keymap = WM_gizmogroup_keymap_common; } } - BLI_ghash_insert(global_manipulatorgrouptype_hash, (void *)wgt->idname, wgt); + BLI_ghash_insert(global_gizmogrouptype_hash, (void *)wgt->idname, wgt); } -wmManipulatorGroupType *WM_manipulatorgrouptype_append( - void (*wtfunc)(struct wmManipulatorGroupType *)) +wmGizmoGroupType *WM_gizmogrouptype_append( + void (*wtfunc)(struct wmGizmoGroupType *)) { - wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin(); + wmGizmoGroupType *wgt = wm_gizmogrouptype_append__begin(); wtfunc(wgt); - wm_manipulatorgrouptype_append__end(wgt); + wm_gizmogrouptype_append__end(wgt); return wgt; } -wmManipulatorGroupType *WM_manipulatorgrouptype_append_ptr( - void (*wtfunc)(struct wmManipulatorGroupType *, void *), void *userdata) +wmGizmoGroupType *WM_gizmogrouptype_append_ptr( + void (*wtfunc)(struct wmGizmoGroupType *, void *), void *userdata) { - wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_append__begin(); + wmGizmoGroupType *wgt = wm_gizmogrouptype_append__begin(); wtfunc(wgt, userdata); - wm_manipulatorgrouptype_append__end(wgt); + wm_gizmogrouptype_append__end(wgt); return wgt; } /** - * Append and insert into a manipulator typemap. - * This is most common for C manipulators which are enabled by default. + * Append and insert into a gizmo typemap. + * This is most common for C gizmos which are enabled by default. */ -wmManipulatorGroupTypeRef *WM_manipulatorgrouptype_append_and_link( - wmManipulatorMapType *mmap_type, - void (*wtfunc)(struct wmManipulatorGroupType *)) +wmGizmoGroupTypeRef *WM_gizmogrouptype_append_and_link( + wmGizmoMapType *mmap_type, + void (*wtfunc)(struct wmGizmoGroupType *)) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append(wtfunc); + wmGizmoGroupType *wgt = WM_gizmogrouptype_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); + return WM_gizmomaptype_group_link_ptr(mmap_type, wgt); } /** * Free but don't remove from ghash. */ -static void manipulatorgrouptype_free(wmManipulatorGroupType *wgt) +static void gizmogrouptype_free(wmGizmoGroupType *wgt) { - if (wgt->ext.srna) { /* python manipulator group, allocs own string */ + if (wgt->ext.srna) { /* python gizmo group, allocs own string */ MEM_freeN((void *)wgt->idname); } MEM_freeN(wgt); } -void WM_manipulatorgrouptype_free_ptr(wmManipulatorGroupType *wgt) +void WM_gizmogrouptype_free_ptr(wmGizmoGroupType *wgt) { - BLI_assert(wgt == WM_manipulatorgrouptype_find(wgt->idname, false)); + BLI_assert(wgt == WM_gizmogrouptype_find(wgt->idname, false)); - BLI_ghash_remove(global_manipulatorgrouptype_hash, wgt->idname, NULL, NULL); + BLI_ghash_remove(global_gizmogrouptype_hash, wgt->idname, NULL, NULL); - manipulatorgrouptype_free(wgt); + gizmogrouptype_free(wgt); /* XXX, TODO, update the world! */ } -bool WM_manipulatorgrouptype_free(const char *idname) +bool WM_gizmogrouptype_free(const char *idname) { - wmManipulatorGroupType *wgt = BLI_ghash_lookup(global_manipulatorgrouptype_hash, idname); + wmGizmoGroupType *wgt = BLI_ghash_lookup(global_gizmogrouptype_hash, idname); if (wgt == NULL) { return false; } - WM_manipulatorgrouptype_free_ptr(wgt); + WM_gizmogrouptype_free_ptr(wgt); return true; } -static void wm_manipulatorgrouptype_ghash_free_cb(wmManipulatorGroupType *wgt) +static void wm_gizmogrouptype_ghash_free_cb(wmGizmoGroupType *wgt) { - manipulatorgrouptype_free(wgt); + gizmogrouptype_free(wgt); } -void wm_manipulatorgrouptype_free(void) +void wm_gizmogrouptype_free(void) { - BLI_ghash_free(global_manipulatorgrouptype_hash, NULL, (GHashValFreeFP)wm_manipulatorgrouptype_ghash_free_cb); - global_manipulatorgrouptype_hash = NULL; + BLI_ghash_free(global_gizmogrouptype_hash, NULL, (GHashValFreeFP)wm_gizmogrouptype_ghash_free_cb); + global_gizmogrouptype_hash = NULL; } /* called on initialize WM_init() */ -void wm_manipulatorgrouptype_init(void) +void wm_gizmogrouptype_init(void) { /* reserve size is set based on blender default setup */ - global_manipulatorgrouptype_hash = BLI_ghash_str_new_ex("wm_manipulatorgrouptype_init gh", 128); + global_gizmogrouptype_hash = BLI_ghash_str_new_ex("wm_gizmogrouptype_init gh", 128); } /** \} */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h index 7a007a8a909..5eed4f2bda2 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_intern.h @@ -29,32 +29,32 @@ #define __WM_GIZMO_INTERN_H__ struct wmKeyConfig; -struct wmManipulatorMap; -struct ManipulatorGeomInfo; +struct wmGizmoMap; +struct GizmoGeomInfo; struct GHashIterator; #include "wm_gizmo_fn.h" /* -------------------------------------------------------------------- */ -/* wmManipulator */ +/* wmGizmo */ -bool wm_manipulator_select_set_ex( - struct wmManipulatorMap *mmap, struct wmManipulator *mpr, bool select, +bool wm_gizmo_select_set_ex( + struct wmGizmoMap *mmap, struct wmGizmo *mpr, bool select, bool use_array, bool use_callback); -bool wm_manipulator_select_and_highlight(bContext *C, struct wmManipulatorMap *mmap, struct wmManipulator *mpr); +bool wm_gizmo_select_and_highlight(bContext *C, struct wmGizmoMap *mmap, struct wmGizmo *mpr); -void wm_manipulator_calculate_scale(struct wmManipulator *mpr, const bContext *C); -void wm_manipulator_update(struct wmManipulator *mpr, const bContext *C, const bool refresh_map); +void wm_gizmo_calculate_scale(struct wmGizmo *mpr, const bContext *C); +void wm_gizmo_update(struct wmGizmo *mpr, const bContext *C, const bool refresh_map); -int wm_manipulator_is_visible(struct wmManipulator *mpr); +int wm_gizmo_is_visible(struct wmGizmo *mpr); enum { - WM_MANIPULATOR_IS_VISIBLE_UPDATE = (1 << 0), - WM_MANIPULATOR_IS_VISIBLE_DRAW = (1 << 1), + WM_GIZMO_IS_VISIBLE_UPDATE = (1 << 0), + WM_GIZMO_IS_VISIBLE_DRAW = (1 << 1), }; /* -------------------------------------------------------------------- */ -/* wmManipulatorGroup */ +/* wmGizmoGroup */ enum { TWEAK_MODAL_CANCEL = 1, @@ -65,53 +65,53 @@ enum { TWEAK_MODAL_SNAP_OFF, }; -struct wmManipulatorGroup *wm_manipulatorgroup_new_from_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_manipulator( - const struct wmManipulatorGroup *mgroup, struct bContext *C, const struct wmEvent *event, +struct wmGizmoGroup *wm_gizmogroup_new_from_type( + struct wmGizmoMap *mmap, struct wmGizmoGroupType *wgt); +void wm_gizmogroup_free(bContext *C, struct wmGizmoGroup *mgroup); +void wm_gizmogroup_gizmo_register(struct wmGizmoGroup *mgroup, struct wmGizmo *mpr); +struct wmGizmo *wm_gizmogroup_find_intersected_gizmo( + const struct wmGizmoGroup *mgroup, struct bContext *C, const struct wmEvent *event, int *r_part); -void wm_manipulatorgroup_intersectable_manipulators_to_list( - const struct wmManipulatorGroup *mgroup, struct ListBase *listbase); -void wm_manipulatorgroup_ensure_initialized(struct wmManipulatorGroup *mgroup, const struct bContext *C); -bool wm_manipulatorgroup_is_visible_in_drawstep( - const struct wmManipulatorGroup *mgroup, const eWM_ManipulatorMapDrawStep drawstep); +void wm_gizmogroup_intersectable_gizmos_to_list( + const struct wmGizmoGroup *mgroup, struct ListBase *listbase); +void wm_gizmogroup_ensure_initialized(struct wmGizmoGroup *mgroup, const struct bContext *C); +bool wm_gizmogroup_is_visible_in_drawstep( + const struct wmGizmoGroup *mgroup, const eWM_GizmoFlagMapDrawStep drawstep); -void wm_manipulatorgrouptype_setup_keymap( - struct wmManipulatorGroupType *wgt, struct wmKeyConfig *keyconf); +void wm_gizmogrouptype_setup_keymap( + struct wmGizmoGroupType *wgt, struct wmKeyConfig *keyconf); /* -------------------------------------------------------------------- */ -/* wmManipulatorMap */ +/* wmGizmoMap */ -typedef struct wmManipulatorMapSelectState { - struct wmManipulator **items; +typedef struct wmGizmoMapSelectState { + struct wmGizmo **items; int len, len_alloc; -} wmManipulatorMapSelectState; +} wmGizmoMapSelectState; -struct wmManipulatorMap { +struct wmGizmoMap { - struct wmManipulatorMapType *type; - ListBase groups; /* wmManipulatorGroup */ + struct wmGizmoMapType *type; + ListBase groups; /* wmGizmoGroup */ /* private, update tagging (enum defined in C source). */ - char update_flag[WM_MANIPULATORMAP_DRAWSTEP_MAX]; + char update_flag[WM_GIZMOMAP_DRAWSTEP_MAX]; /** - * \brief Manipulator map runtime context + * \brief Gizmo map runtime context * - * Contains information about this manipulator-map. Currently - * highlighted manipulator, currently selected manipulators, ... + * Contains information about this gizmo-map. Currently + * highlighted gizmo, currently selected gizmos, ... */ struct { - /* we redraw the manipulator-map when this changes */ - struct wmManipulator *highlight; - /* User has clicked this manipulator and it gets all input. */ - struct wmManipulator *modal; - /* array for all selected manipulators */ - struct wmManipulatorMapSelectState select; - /* cursor location at point of entering modal (see: WM_MANIPULATOR_GRAB_CURSOR) */ + /* we redraw the gizmo-map when this changes */ + struct wmGizmo *highlight; + /* User has clicked this gizmo and it gets all input. */ + struct wmGizmo *modal; + /* array for all selected gizmos */ + struct wmGizmoMapSelectState select; + /* cursor location at point of entering modal (see: WM_GIZMO_GRAB_CURSOR) */ int event_xy[2]; short event_grabcursor; /* until we have nice cursor push/pop API. */ @@ -120,25 +120,25 @@ struct wmManipulatorMap { }; /** - * This is a container for all manipulator types that can be instantiated in a region. + * This is a container for all gizmo types that can be instantiated in a region. * (similar to dropboxes). * * \note There is only ever one of these for every (area, region) combination. */ -struct wmManipulatorMapType { - struct wmManipulatorMapType *next, *prev; +struct wmGizmoMapType { + struct wmGizmoMapType *next, *prev; short spaceid, regionid; - /* types of manipulator-groups for this manipulator-map type */ + /* types of gizmo-groups for this gizmo-map type */ ListBase grouptype_refs; - /* eManipulatorMapTypeUpdateFlags */ - eWM_ManipulatorMapTypeUpdateFlag type_update_flag; + /* eGizmoMapTypeUpdateFlags */ + eWM_GizmoFlagMapTypeUpdateFlag type_update_flag; }; -void wm_manipulatormap_select_array_clear(struct wmManipulatorMap *mmap); -bool wm_manipulatormap_deselect_all(struct wmManipulatorMap *mmap); -void wm_manipulatormap_select_array_shrink(struct wmManipulatorMap *mmap, int len_subtract); -void wm_manipulatormap_select_array_push_back(struct wmManipulatorMap *mmap, wmManipulator *mpr); -void wm_manipulatormap_select_array_remove(struct wmManipulatorMap *mmap, wmManipulator *mpr); +void wm_gizmomap_select_array_clear(struct wmGizmoMap *mmap); +bool wm_gizmomap_deselect_all(struct wmGizmoMap *mmap); +void wm_gizmomap_select_array_shrink(struct wmGizmoMap *mmap, int len_subtract); +void wm_gizmomap_select_array_push_back(struct wmGizmoMap *mmap, wmGizmo *mpr); +void wm_gizmomap_select_array_remove(struct wmGizmoMap *mmap, wmGizmo *mpr); #endif diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index 94db6b45887..9da1591d535 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -61,42 +61,42 @@ #include "wm_gizmo_intern.h" /** - * Store all manipulator-maps here. Anyone who wants to register a manipulator for a certain - * area type can query the manipulator-map to do so. + * Store all gizmo-maps here. Anyone who wants to register a gizmo for a certain + * area type can query the gizmo-map to do so. */ -static ListBase manipulatormaptypes = {NULL, NULL}; +static ListBase gizmomaptypes = {NULL, NULL}; /** - * Update when manipulator-map types change. + * Update when gizmo-map types change. */ /* so operator removal can trigger update */ -typedef enum eWM_ManipulatorGroupTypeGlobalFlag { - WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0), - WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE = (1 << 1), -} eWM_ManipulatorGroupTypeGlobalFlag; +typedef enum eWM_GizmoFlagGroupTypeGlobalFlag { + WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0), + WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE = (1 << 1), +} eWM_GizmoFlagGroupTypeGlobalFlag; -static eWM_ManipulatorGroupTypeGlobalFlag wm_mmap_type_update_flag = 0; +static eWM_GizmoFlagGroupTypeGlobalFlag wm_mmap_type_update_flag = 0; /** - * Manipulator-map update tagging. + * Gizmo-map update tagging. */ enum { - /** #manipulatormap_prepare_drawing has run */ - MANIPULATORMAP_IS_PREPARE_DRAW = (1 << 0), - MANIPULATORMAP_IS_REFRESH_CALLBACK = (1 << 1), + /** #gizmomap_prepare_drawing has run */ + GIZMOMAP_IS_PREPARE_DRAW = (1 << 0), + GIZMOMAP_IS_REFRESH_CALLBACK = (1 << 1), }; /* -------------------------------------------------------------------- */ -/** \name wmManipulatorMap Selection Array API +/** \name wmGizmoMap Selection Array API * - * Just handle ``wm_manipulatormap_select_array_*``, not flags or callbacks. + * Just handle ``wm_gizmomap_select_array_*``, not flags or callbacks. * * \{ */ -static void wm_manipulatormap_select_array_ensure_len_alloc(wmManipulatorMap *mmap, int len) +static void wm_gizmomap_select_array_ensure_len_alloc(wmGizmoMap *mmap, int len) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; if (len <= msel->len_alloc) { return; } @@ -104,20 +104,20 @@ static void wm_manipulatormap_select_array_ensure_len_alloc(wmManipulatorMap *mm msel->len_alloc = len; } -void wm_manipulatormap_select_array_clear(wmManipulatorMap *mmap) +void wm_gizmomap_select_array_clear(wmGizmoMap *mmap) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; MEM_SAFE_FREE(msel->items); msel->len = 0; msel->len_alloc = 0; } -void wm_manipulatormap_select_array_shrink(wmManipulatorMap *mmap, int len_subtract) +void wm_gizmomap_select_array_shrink(wmGizmoMap *mmap, int len_subtract) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; msel->len -= len_subtract; if (msel->len <= 0) { - wm_manipulatormap_select_array_clear(mmap); + wm_gizmomap_select_array_clear(mmap); } else { if (msel->len < msel->len_alloc / 2) { @@ -127,9 +127,9 @@ void wm_manipulatormap_select_array_shrink(wmManipulatorMap *mmap, int len_subtr } } -void wm_manipulatormap_select_array_push_back(wmManipulatorMap *mmap, wmManipulator *mpr) +void wm_gizmomap_select_array_push_back(wmGizmoMap *mmap, wmGizmo *mpr) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; BLI_assert(msel->len <= msel->len_alloc); if (msel->len == msel->len_alloc) { msel->len_alloc = (msel->len + 1) * 2; @@ -138,16 +138,16 @@ void wm_manipulatormap_select_array_push_back(wmManipulatorMap *mmap, wmManipula msel->items[msel->len++] = mpr; } -void wm_manipulatormap_select_array_remove(wmManipulatorMap *mmap, wmManipulator *mpr) +void wm_gizmomap_select_array_remove(wmGizmoMap *mmap, wmGizmo *mpr) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - /* remove manipulator from selected_manipulators array */ + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; + /* remove gizmo from selected_gizmos array */ for (int i = 0; i < msel->len; i++) { if (msel->items[i] == mpr) { for (int j = i; j < (msel->len - 1); j++) { msel->items[j] = msel->items[j + 1]; } - wm_manipulatormap_select_array_shrink(mmap, 1); + wm_gizmomap_select_array_shrink(mmap, 1); break; } } @@ -158,41 +158,41 @@ void wm_manipulatormap_select_array_remove(wmManipulatorMap *mmap, wmManipulator /* -------------------------------------------------------------------- */ -/** \name wmManipulatorMap +/** \name wmGizmoMap * * \{ */ /** - * Creates a manipulator-map with all registered manipulators for that type + * Creates a gizmo-map with all registered gizmos for that type */ -wmManipulatorMap *WM_manipulatormap_new_from_type( - const struct wmManipulatorMapType_Params *mmap_params) +wmGizmoMap *WM_gizmomap_new_from_type( + const struct wmGizmoMapType_Params *mmap_params) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(mmap_params); - wmManipulatorMap *mmap; + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(mmap_params); + wmGizmoMap *mmap; - mmap = MEM_callocN(sizeof(wmManipulatorMap), "ManipulatorMap"); + mmap = MEM_callocN(sizeof(wmGizmoMap), "GizmoMap"); mmap->type = mmap_type; - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); - /* create all manipulator-groups for this manipulator-map. We may create an empty one - * too in anticipation of manipulators from operators etc */ - 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); + /* create all gizmo-groups for this gizmo-map. We may create an empty one + * too in anticipation of gizmos from operators etc */ + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { + wm_gizmogroup_new_from_type(mmap, wgt_ref->type); } return mmap; } -void wm_manipulatormap_remove(wmManipulatorMap *mmap) +void wm_gizmomap_remove(wmGizmoMap *mmap) { /* Clear first so further calls don't waste time trying to maintain correct array state. */ - wm_manipulatormap_select_array_clear(mmap); + wm_gizmomap_select_array_clear(mmap); - for (wmManipulatorGroup *mgroup = mmap->groups.first, *mgroup_next; mgroup; mgroup = mgroup_next) { + for (wmGizmoGroup *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); + wm_gizmogroup_free(NULL, mgroup); } BLI_assert(BLI_listbase_is_empty(&mmap->groups)); @@ -200,22 +200,22 @@ void wm_manipulatormap_remove(wmManipulatorMap *mmap) } -wmManipulatorGroup *WM_manipulatormap_group_find( - struct wmManipulatorMap *mmap, +wmGizmoGroup *WM_gizmomap_group_find( + struct wmGizmoMap *mmap, const char *idname) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); if (wgt) { - return WM_manipulatormap_group_find_ptr(mmap, wgt); + return WM_gizmomap_group_find_ptr(mmap, wgt); } return NULL; } -wmManipulatorGroup *WM_manipulatormap_group_find_ptr( - struct wmManipulatorMap *mmap, - const struct wmManipulatorGroupType *wgt) +wmGizmoGroup *WM_gizmomap_group_find_ptr( + struct wmGizmoMap *mmap, + const struct wmGizmoGroupType *wgt) { - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { if (mgroup->type == wgt) { return mgroup; } @@ -223,12 +223,12 @@ wmManipulatorGroup *WM_manipulatormap_group_find_ptr( return NULL; } -const ListBase *WM_manipulatormap_group_list(wmManipulatorMap *mmap) +const ListBase *WM_gizmomap_group_list(wmGizmoMap *mmap) { return &mmap->groups; } -bool WM_manipulatormap_is_any_selected(const wmManipulatorMap *mmap) +bool WM_gizmomap_is_any_selected(const wmGizmoMap *mmap) { return mmap->mmap_context.select.len != 0; } @@ -236,8 +236,8 @@ bool WM_manipulatormap_is_any_selected(const wmManipulatorMap *mmap) /** * \note We could use a callback to define bounds, for now just use matrix location. */ -bool WM_manipulatormap_minmax( - const wmManipulatorMap *mmap, bool UNUSED(use_hidden), bool use_select, +bool WM_gizmomap_minmax( + const wmGizmoMap *mmap, bool UNUSED(use_hidden), bool use_select, float r_min[3], float r_max[3]) { if (use_select) { @@ -255,26 +255,26 @@ bool WM_manipulatormap_minmax( } /** - * Creates and returns idname hash table for (visible) manipulators in \a mmap + * Creates and returns idname hash table for (visible) gizmos in \a mmap * - * \param poll Polling function for excluding manipulators. + * \param poll Polling function for excluding gizmos. * \param data Custom data passed to \a poll * * TODO(campbell): this uses unreliable order, * best we use an iterator function instead of a hash. */ -static GHash *WM_manipulatormap_manipulator_hash_new( - const bContext *C, wmManipulatorMap *mmap, - bool (*poll)(const wmManipulator *, void *), +static GHash *WM_gizmomap_gizmo_hash_new( + const bContext *C, wmGizmoMap *mmap, + bool (*poll)(const wmGizmo *, void *), void *data, const bool include_hidden) { GHash *hash = BLI_ghash_ptr_new(__func__); - /* collect manipulators */ - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - if (WM_manipulator_group_type_poll(C, mgroup->type)) { - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if ((include_hidden || (mpr->flag & WM_MANIPULATOR_HIDDEN) == 0) && + /* collect gizmos */ + for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + if (WM_gizmo_group_type_poll(C, mgroup->type)) { + for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { + if ((include_hidden || (mpr->flag & WM_GIZMO_HIDDEN) == 0) && (!poll || poll(mpr, data))) { BLI_ghash_insert(hash, mpr, mpr); @@ -286,35 +286,35 @@ static GHash *WM_manipulatormap_manipulator_hash_new( return hash; } -void WM_manipulatormap_tag_refresh(wmManipulatorMap *mmap) +void WM_gizmomap_tag_refresh(wmGizmoMap *mmap) { if (mmap) { /* We might want only to refresh some, for tag all steps. */ - for (int i = 0; i < WM_MANIPULATORMAP_DRAWSTEP_MAX; i++) { + for (int i = 0; i < WM_GIZMOMAP_DRAWSTEP_MAX; i++) { mmap->update_flag[i] |= ( - MANIPULATORMAP_IS_PREPARE_DRAW | - MANIPULATORMAP_IS_REFRESH_CALLBACK); + GIZMOMAP_IS_PREPARE_DRAW | + GIZMOMAP_IS_REFRESH_CALLBACK); } } } -static bool manipulator_prepare_drawing( - wmManipulatorMap *mmap, wmManipulator *mpr, - const bContext *C, ListBase *draw_manipulators, - const eWM_ManipulatorMapDrawStep drawstep) +static bool gizmo_prepare_drawing( + wmGizmoMap *mmap, wmGizmo *mpr, + const bContext *C, ListBase *draw_gizmos, + const eWM_GizmoFlagMapDrawStep drawstep) { - int do_draw = wm_manipulator_is_visible(mpr); + int do_draw = wm_gizmo_is_visible(mpr); if (do_draw == 0) { /* skip */ } else { /* Ensure we get RNA updates */ - if (do_draw & WM_MANIPULATOR_IS_VISIBLE_UPDATE) { - /* hover manipulators need updating, even if we don't draw them */ - wm_manipulator_update(mpr, C, (mmap->update_flag[drawstep] & MANIPULATORMAP_IS_PREPARE_DRAW) != 0); + if (do_draw & WM_GIZMO_IS_VISIBLE_UPDATE) { + /* hover gizmos need updating, even if we don't draw them */ + wm_gizmo_update(mpr, C, (mmap->update_flag[drawstep] & GIZMOMAP_IS_PREPARE_DRAW) != 0); } - if (do_draw & WM_MANIPULATOR_IS_VISIBLE_DRAW) { - BLI_addhead(draw_manipulators, BLI_genericNodeN(mpr)); + if (do_draw & WM_GIZMO_IS_VISIBLE_DRAW) { + BLI_addhead(draw_gizmos, BLI_genericNodeN(mpr)); } return true; } @@ -323,67 +323,67 @@ static bool manipulator_prepare_drawing( } /** - * Update manipulators of \a mmap to prepare for drawing. Adds all manipulators that - * should be drawn to list \a draw_manipulators, note that added items need freeing. + * Update gizmos of \a mmap to prepare for drawing. Adds all gizmos that + * should be drawn to list \a draw_gizmos, note that added items need freeing. */ -static void manipulatormap_prepare_drawing( - wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators, - const eWM_ManipulatorMapDrawStep drawstep) +static void gizmomap_prepare_drawing( + wmGizmoMap *mmap, const bContext *C, ListBase *draw_gizmos, + const eWM_GizmoFlagMapDrawStep drawstep) { if (!mmap || BLI_listbase_is_empty(&mmap->groups)) return; - wmManipulator *mpr_modal = mmap->mmap_context.modal; + wmGizmo *mpr_modal = mmap->mmap_context.modal; - /* only active manipulator needs updating */ + /* only active gizmo needs updating */ if (mpr_modal) { - if ((mpr_modal->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL) == 0) { - if (wm_manipulatorgroup_is_visible_in_drawstep(mpr_modal->parent_mgroup, drawstep)) { - if (manipulator_prepare_drawing(mmap, mpr_modal, C, draw_manipulators, drawstep)) { - mmap->update_flag[drawstep] &= ~MANIPULATORMAP_IS_PREPARE_DRAW; + if ((mpr_modal->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL) == 0) { + if (wm_gizmogroup_is_visible_in_drawstep(mpr_modal->parent_mgroup, drawstep)) { + if (gizmo_prepare_drawing(mmap, mpr_modal, C, draw_gizmos, drawstep)) { + mmap->update_flag[drawstep] &= ~GIZMOMAP_IS_PREPARE_DRAW; } } - /* don't draw any other manipulators */ + /* don't draw any other gizmos */ return; } } - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + for (wmGizmoGroup *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_manipulator_group_type_poll(C, mgroup->type)) + if (!wm_gizmogroup_is_visible_in_drawstep(mgroup, drawstep) || + !WM_gizmo_group_type_poll(C, mgroup->type)) { continue; } /* needs to be initialized on first draw */ - /* XXX weak: Manipulator-group may skip refreshing if it's invisible (map gets untagged nevertheless) */ - if (mmap->update_flag[drawstep] & MANIPULATORMAP_IS_REFRESH_CALLBACK) { + /* XXX weak: Gizmo-group may skip refreshing if it's invisible (map gets untagged nevertheless) */ + if (mmap->update_flag[drawstep] & GIZMOMAP_IS_REFRESH_CALLBACK) { /* force refresh again. */ - mgroup->init_flag &= ~WM_MANIPULATORGROUP_INIT_REFRESH; + mgroup->init_flag &= ~WM_GIZMOGROUP_INIT_REFRESH; } /* Calls `setup`, `setup_keymap` and `refresh` if they're defined. */ - wm_manipulatorgroup_ensure_initialized(mgroup, C); + wm_gizmogroup_ensure_initialized(mgroup, C); /* prepare drawing */ if (mgroup->type->draw_prepare) { mgroup->type->draw_prepare(C, mgroup); } - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - manipulator_prepare_drawing(mmap, mpr, C, draw_manipulators, drawstep); + for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { + gizmo_prepare_drawing(mmap, mpr, C, draw_gizmos, drawstep); } } mmap->update_flag[drawstep] &= - ~(MANIPULATORMAP_IS_REFRESH_CALLBACK | - MANIPULATORMAP_IS_PREPARE_DRAW); + ~(GIZMOMAP_IS_REFRESH_CALLBACK | + GIZMOMAP_IS_PREPARE_DRAW); } /** - * Draw all visible manipulators in \a mmap. - * Uses global draw_manipulators listbase. + * Draw all visible gizmos in \a mmap. + * Uses global draw_gizmos listbase. */ -static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext *C, ListBase *draw_manipulators) +static void gizmos_draw_list(const wmGizmoMap *mmap, const bContext *C, ListBase *draw_gizmos) { /* Can be empty if we're dynamically added and removed. */ if ((mmap == NULL) || BLI_listbase_is_empty(&mmap->groups)) { @@ -391,19 +391,19 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext } /* TODO this will need it own shader probably? don't think it can be handled from that point though. */ -/* const bool use_lighting = (U.manipulator_flag & V3D_MANIPULATOR_SHADED) != 0; */ +/* const bool use_lighting = (U.gizmo_flag & V3D_GIZMO_SHADED) != 0; */ bool is_depth_prev = false; - /* draw_manipulators contains all visible manipulators - draw them */ - for (LinkData *link = draw_manipulators->first, *link_next; link; link = link_next) { - wmManipulator *mpr = link->data; + /* draw_gizmos contains all visible gizmos - draw them */ + for (LinkData *link = draw_gizmos->first, *link_next; link; link = link_next) { + wmGizmo *mpr = link->data; link_next = link->next; - bool is_depth = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DEPTH_3D) != 0; + bool is_depth = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_DEPTH_3D) != 0; /* Weak! since we don't 100% support depth yet (select ignores depth) always show highlighted */ - if (is_depth && (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT)) { + if (is_depth && (mpr->state & WM_GIZMO_STATE_HIGHLIGHT)) { is_depth = false; } @@ -420,7 +420,7 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext is_depth_prev = is_depth; } - /* XXX force AntiAlias Manipulators. */ + /* XXX force AntiAlias Gizmos. */ glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); @@ -429,8 +429,8 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext glDisable(GL_LINE_SMOOTH); glDisable(GL_POLYGON_SMOOTH); - /* free/remove manipulator link after drawing */ - BLI_freelinkN(draw_manipulators, link); + /* free/remove gizmo link after drawing */ + BLI_freelinkN(draw_gizmos, link); } if (is_depth_prev) { @@ -438,34 +438,34 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext } } -void WM_manipulatormap_draw( - wmManipulatorMap *mmap, const bContext *C, - const eWM_ManipulatorMapDrawStep drawstep) +void WM_gizmomap_draw( + wmGizmoMap *mmap, const bContext *C, + const eWM_GizmoFlagMapDrawStep drawstep) { - if (!WM_manipulator_context_check_drawstep(C, drawstep)) { + if (!WM_gizmo_context_check_drawstep(C, drawstep)) { return; } - ListBase draw_manipulators = {NULL}; + ListBase draw_gizmos = {NULL}; - manipulatormap_prepare_drawing(mmap, C, &draw_manipulators, drawstep); - manipulators_draw_list(mmap, C, &draw_manipulators); - BLI_assert(BLI_listbase_is_empty(&draw_manipulators)); + gizmomap_prepare_drawing(mmap, C, &draw_gizmos, drawstep); + gizmos_draw_list(mmap, C, &draw_gizmos); + BLI_assert(BLI_listbase_is_empty(&draw_gizmos)); } -static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible_manipulators) +static void gizmo_draw_select_3D_loop(const bContext *C, ListBase *visible_gizmos) { int select_id = 0; - wmManipulator *mpr; + wmGizmo *mpr; /* TODO(campbell): this depends on depth buffer being written to, currently broken for the 3D view. */ bool is_depth_prev = false; bool is_depth_skip_prev = false; - for (LinkData *link = visible_manipulators->first; link; link = link->next) { + for (LinkData *link = visible_gizmos->first; link; link = link->next) { mpr = link->data; - bool is_depth = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DEPTH_3D) != 0; + bool is_depth = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_DEPTH_3D) != 0; if (is_depth == is_depth_prev) { /* pass */ } @@ -478,7 +478,7 @@ static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible } is_depth_prev = is_depth; } - bool is_depth_skip = (mpr->flag & WM_MANIPULATOR_SELECT_BACKGROUND) != 0; + bool is_depth_skip = (mpr->flag & WM_GIZMO_SELECT_BACKGROUND) != 0; if (is_depth_skip == is_depth_skip_prev) { /* pass */ } @@ -487,7 +487,7 @@ static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible is_depth_skip_prev = is_depth_skip; } - /* pass the selection id shifted by 8 bits. Last 8 bits are used for selected manipulator part id */ + /* pass the selection id shifted by 8 bits. Last 8 bits are used for selected gizmo part id */ mpr->type->draw_select(C, mpr, select_id << 8); @@ -503,15 +503,15 @@ static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible } } -static int manipulator_find_intersected_3d_intern( - ListBase *visible_manipulators, const bContext *C, const int co[2], +static int gizmo_find_intersected_3d_intern( + ListBase *visible_gizmos, const bContext *C, const int co[2], const int hotspot) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); View3D *v3d = sa->spacedata.first; rcti rect; - /* Almost certainly overkill, but allow for many custom manipulators. */ + /* Almost certainly overkill, but allow for many custom gizmos. */ GLuint buffer[MAXPICKBUF]; short hits; const bool do_passes = GPU_select_query_check_active(); @@ -525,13 +525,13 @@ static int manipulator_find_intersected_3d_intern( else GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_ALL, 0); /* do the drawing */ - manipulator_draw_select_3D_loop(C, visible_manipulators); + gizmo_draw_select_3D_loop(C, visible_gizmos); hits = GPU_select_end(); if (do_passes && (hits > 0)) { GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); - manipulator_draw_select_3D_loop(C, visible_manipulators); + gizmo_draw_select_3D_loop(C, visible_gizmos); GPU_select_end(); } @@ -543,13 +543,13 @@ static int manipulator_find_intersected_3d_intern( } /** - * Try to find a 3D manipulator at screen-space coordinate \a co. Uses OpenGL picking. + * Try to find a 3D gizmo at screen-space coordinate \a co. Uses OpenGL picking. */ -static wmManipulator *manipulator_find_intersected_3d( - bContext *C, const int co[2], ListBase *visible_manipulators, +static wmGizmo *gizmo_find_intersected_3d( + bContext *C, const int co[2], ListBase *visible_gizmos, int *r_part) { - wmManipulator *result = NULL; + wmGizmo *result = NULL; int hit = -1; int hotspot_radii[] = { @@ -566,20 +566,20 @@ static wmManipulator *manipulator_find_intersected_3d( hit = -1; for (int i = 0; i < ARRAY_SIZE(hotspot_radii); i++) { - hit = manipulator_find_intersected_3d_intern(visible_manipulators, C, co, hotspot_radii[i]); + hit = gizmo_find_intersected_3d_intern(visible_gizmos, C, co, hotspot_radii[i]); if (hit != -1) { break; } } if (hit != -1) { - LinkData *link = BLI_findlink(visible_manipulators, hit >> 8); + LinkData *link = BLI_findlink(visible_gizmos, hit >> 8); if (link != NULL) { *r_part = hit & 255; result = link->data; } else { - /* All manipulators should use selection ID they're given as part of the callback, + /* All gizmos should use selection ID they're given as part of the callback, * if they don't it will attempt tp lookup non-existing index. */ BLI_assert(0); } @@ -589,51 +589,51 @@ static wmManipulator *manipulator_find_intersected_3d( } /** - * Try to find a manipulator under the mouse position. 2D intersections have priority over + * Try to find a gizmo under the mouse position. 2D intersections have priority over * 3D ones (could check for smallest screen-space distance but not needed right now). */ -wmManipulator *wm_manipulatormap_highlight_find( - wmManipulatorMap *mmap, bContext *C, const wmEvent *event, +wmGizmo *wm_gizmomap_highlight_find( + wmGizmoMap *mmap, bContext *C, const wmEvent *event, int *r_part) { - wmManipulator *mpr = NULL; - ListBase visible_3d_manipulators = {NULL}; - bool do_step[WM_MANIPULATORMAP_DRAWSTEP_MAX]; + wmGizmo *mpr = NULL; + ListBase visible_3d_gizmos = {NULL}; + bool do_step[WM_GIZMOMAP_DRAWSTEP_MAX]; for (int i = 0; i < ARRAY_SIZE(do_step); i++) { - do_step[i] = WM_manipulator_context_check_drawstep(C, i); + do_step[i] = WM_gizmo_context_check_drawstep(C, i); } - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { /* If it were important we could initialize here, * but this only happens when events are handled before drawing, - * just skip to keep code-path for initializing manipulators simple. */ - if ((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0) { + * just skip to keep code-path for initializing gizmos simple. */ + if ((mgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0) { continue; } - if (WM_manipulator_group_type_poll(C, mgroup->type)) { - eWM_ManipulatorMapDrawStep step; - if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) { - step = WM_MANIPULATORMAP_DRAWSTEP_3D; + if (WM_gizmo_group_type_poll(C, mgroup->type)) { + eWM_GizmoFlagMapDrawStep step; + if (mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + step = WM_GIZMOMAP_DRAWSTEP_3D; } else { - step = WM_MANIPULATORMAP_DRAWSTEP_2D; + step = WM_GIZMOMAP_DRAWSTEP_2D; } if (do_step[step]) { - if ((mmap->update_flag[step] & MANIPULATORMAP_IS_REFRESH_CALLBACK) && + if ((mmap->update_flag[step] & GIZMOMAP_IS_REFRESH_CALLBACK) && (mgroup->type->refresh != NULL)) { mgroup->type->refresh(C, mgroup); /* cleared below */ } - if (step == WM_MANIPULATORMAP_DRAWSTEP_3D) { - wm_manipulatorgroup_intersectable_manipulators_to_list(mgroup, &visible_3d_manipulators); + if (step == WM_GIZMOMAP_DRAWSTEP_3D) { + wm_gizmogroup_intersectable_gizmos_to_list(mgroup, &visible_3d_gizmos); } - else if (step == WM_MANIPULATORMAP_DRAWSTEP_2D) { - if ((mpr = wm_manipulatorgroup_find_intersected_manipulator(mgroup, C, event, r_part))) { + else if (step == WM_GIZMOMAP_DRAWSTEP_2D) { + if ((mpr = wm_gizmogroup_find_intersected_gizmo(mgroup, C, event, r_part))) { break; } } @@ -641,62 +641,62 @@ wmManipulator *wm_manipulatormap_highlight_find( } } - if (!BLI_listbase_is_empty(&visible_3d_manipulators)) { - /* 2D manipulators get priority. */ + if (!BLI_listbase_is_empty(&visible_3d_gizmos)) { + /* 2D gizmos get priority. */ if (mpr == NULL) { - mpr = manipulator_find_intersected_3d(C, event->mval, &visible_3d_manipulators, r_part); + mpr = gizmo_find_intersected_3d(C, event->mval, &visible_3d_gizmos, r_part); } - BLI_freelistN(&visible_3d_manipulators); + BLI_freelistN(&visible_3d_gizmos); } - mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_3D] &= ~MANIPULATORMAP_IS_REFRESH_CALLBACK; - mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_2D] &= ~MANIPULATORMAP_IS_REFRESH_CALLBACK; + mmap->update_flag[WM_GIZMOMAP_DRAWSTEP_3D] &= ~GIZMOMAP_IS_REFRESH_CALLBACK; + mmap->update_flag[WM_GIZMOMAP_DRAWSTEP_2D] &= ~GIZMOMAP_IS_REFRESH_CALLBACK; return mpr; } -void WM_manipulatormap_add_handlers(ARegion *ar, wmManipulatorMap *mmap) +void WM_gizmomap_add_handlers(ARegion *ar, wmGizmoMap *mmap) { wmEventHandler *handler; for (handler = ar->handlers.first; handler; handler = handler->next) { - if (handler->manipulator_map == mmap) { + if (handler->gizmo_map == mmap) { return; } } - handler = MEM_callocN(sizeof(wmEventHandler), "manipulator handler"); + handler = MEM_callocN(sizeof(wmEventHandler), "gizmo handler"); - BLI_assert(mmap == ar->manipulator_map); - handler->manipulator_map = mmap; + BLI_assert(mmap == ar->gizmo_map); + handler->gizmo_map = mmap; BLI_addtail(&ar->handlers, handler); } -void wm_manipulatormaps_handled_modal_update( +void wm_gizmomaps_handled_modal_update( bContext *C, wmEvent *event, wmEventHandler *handler) { const bool modal_running = (handler->op != NULL); /* happens on render or when joining areas */ - if (!handler->op_region || !handler->op_region->manipulator_map) { + if (!handler->op_region || !handler->op_region->gizmo_map) { return; } - wmManipulatorMap *mmap = handler->op_region->manipulator_map; - wmManipulator *mpr = wm_manipulatormap_modal_get(mmap); + wmGizmoMap *mmap = handler->op_region->gizmo_map; + wmGizmo *mpr = wm_gizmomap_modal_get(mmap); ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - wm_manipulatormap_handler_context(C, handler); + wm_gizmomap_handler_context(C, handler); /* regular update for running operator */ if (modal_running) { - wmManipulatorOpElem *mpop = mpr ? WM_manipulator_operator_get(mpr, mpr->highlight_part) : NULL; + wmGizmoOpElem *mpop = mpr ? WM_gizmo_operator_get(mpr, mpr->highlight_part) : NULL; if (mpr && mpop && (mpop->type != NULL) && (mpop->type == handler->op->type)) { - wmManipulatorFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; + wmGizmoFnModal modal_fn = mpr->custom_modal ? mpr->custom_modal : mpr->type->modal; if (modal_fn != NULL) { int retval = modal_fn(C, mpr, event, 0); - /* The manipulator is tried to the operator, we can't choose when to exit. */ + /* The gizmo is tried to the operator, we can't choose when to exit. */ BLI_assert(retval & OPERATOR_RUNNING_MODAL); UNUSED_VARS_NDEBUG(retval); } @@ -704,14 +704,14 @@ void wm_manipulatormaps_handled_modal_update( } /* operator not running anymore */ else { - wm_manipulatormap_highlight_set(mmap, C, NULL, 0); + wm_gizmomap_highlight_set(mmap, C, NULL, 0); if (mpr) { /* This isn't defined if it ends because of success of cancel, we may want to change. */ bool cancel = true; if (mpr->type->exit) { mpr->type->exit(C, mpr, cancel); } - wm_manipulatormap_modal_set(mmap, C, mpr, NULL, false); + wm_gizmomap_modal_set(mmap, C, mpr, NULL, false); } } @@ -721,58 +721,58 @@ void wm_manipulatormaps_handled_modal_update( } /** - * Deselect all selected manipulators in \a mmap. + * Deselect all selected gizmos in \a mmap. * \return if selection has changed. */ -bool wm_manipulatormap_deselect_all(wmManipulatorMap *mmap) +bool wm_gizmomap_deselect_all(wmGizmoMap *mmap) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; if (msel->items == NULL || msel->len == 0) { return false; } for (int i = 0; i < msel->len; i++) { - wm_manipulator_select_set_ex(mmap, msel->items[i], false, false, true); + wm_gizmo_select_set_ex(mmap, msel->items[i], false, false, true); } - wm_manipulatormap_select_array_clear(mmap); + wm_gizmomap_select_array_clear(mmap); /* always return true, we already checked * if there's anything to deselect */ return true; } -BLI_INLINE bool manipulator_selectable_poll(const wmManipulator *mpr, void *UNUSED(data)) +BLI_INLINE bool gizmo_selectable_poll(const wmGizmo *mpr, void *UNUSED(data)) { - return (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SELECT); + return (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_SELECT); } /** - * Select all selectable manipulators in \a mmap. + * Select all selectable gizmos in \a mmap. * \return if selection has changed. */ -static bool wm_manipulatormap_select_all_intern( - bContext *C, wmManipulatorMap *mmap) +static bool wm_gizmomap_select_all_intern( + bContext *C, wmGizmoMap *mmap) { - wmManipulatorMapSelectState *msel = &mmap->mmap_context.select; - /* GHash is used here to avoid having to loop over all manipulators twice (once to + wmGizmoMapSelectState *msel = &mmap->mmap_context.select; + /* GHash is used here to avoid having to loop over all gizmos twice (once to * get tot_sel for allocating, once for actually selecting). Instead we collect - * selectable manipulators in hash table and use this to get tot_sel and do selection */ + * selectable gizmos in hash table and use this to get tot_sel and do selection */ - GHash *hash = WM_manipulatormap_manipulator_hash_new(C, mmap, manipulator_selectable_poll, NULL, true); + GHash *hash = WM_gizmomap_gizmo_hash_new(C, mmap, gizmo_selectable_poll, NULL, true); GHashIterator gh_iter; int i; bool changed = false; - wm_manipulatormap_select_array_ensure_len_alloc(mmap, BLI_ghash_len(hash)); + wm_gizmomap_select_array_ensure_len_alloc(mmap, BLI_ghash_len(hash)); GHASH_ITER_INDEX (gh_iter, hash, i) { - wmManipulator *mpr_iter = BLI_ghashIterator_getValue(&gh_iter); - WM_manipulator_select_set(mmap, mpr_iter, true); + wmGizmo *mpr_iter = BLI_ghashIterator_getValue(&gh_iter); + WM_gizmo_select_set(mmap, mpr_iter, true); } - /* highlight first manipulator */ - wm_manipulatormap_highlight_set(mmap, C, msel->items[0], msel->items[0]->highlight_part); + /* highlight first gizmo */ + wm_gizmomap_highlight_set(mmap, C, msel->items[0], msel->items[0]->highlight_part); BLI_assert(BLI_ghash_len(hash) == msel->len); @@ -781,21 +781,21 @@ static bool wm_manipulatormap_select_all_intern( } /** - * Select/Deselect all selectable manipulators in \a mmap. + * Select/Deselect all selectable gizmos in \a mmap. * \return if selection has changed. * * TODO select all by type */ -bool WM_manipulatormap_select_all(bContext *C, wmManipulatorMap *mmap, const int action) +bool WM_gizmomap_select_all(bContext *C, wmGizmoMap *mmap, const int action) { bool changed = false; switch (action) { case SEL_SELECT: - changed = wm_manipulatormap_select_all_intern(C, mmap); + changed = wm_gizmomap_select_all_intern(C, mmap); break; case SEL_DESELECT: - changed = wm_manipulatormap_deselect_all(mmap); + changed = wm_gizmomap_deselect_all(mmap); break; default: BLI_assert(0); @@ -809,10 +809,10 @@ bool WM_manipulatormap_select_all(bContext *C, wmManipulatorMap *mmap, const int } /** - * Prepare context for manipulator handling (but only if area/region is - * part of screen). Version of #wm_handler_op_context for manipulators. + * Prepare context for gizmo handling (but only if area/region is + * part of screen). Version of #wm_handler_op_context for gizmos. */ -void wm_manipulatormap_handler_context(bContext *C, wmEventHandler *handler) +void wm_gizmomap_handler_context(bContext *C, wmEventHandler *handler) { bScreen *screen = CTX_wm_screen(C); @@ -829,8 +829,8 @@ void wm_manipulatormap_handler_context(bContext *C, wmEventHandler *handler) if (sa == NULL) { /* when changing screen layouts with running modal handlers (like render display), this * is not an error to print */ - if (handler->manipulator_map == NULL) - printf("internal error: modal manipulator-map handler has invalid area\n"); + if (handler->gizmo_map == NULL) + printf("internal error: modal gizmo-map handler has invalid area\n"); } else { ARegion *ar; @@ -846,9 +846,9 @@ void wm_manipulatormap_handler_context(bContext *C, wmEventHandler *handler) } } -bool WM_manipulatormap_cursor_set(const wmManipulatorMap *mmap, wmWindow *win) +bool WM_gizmomap_cursor_set(const wmGizmoMap *mmap, wmWindow *win) { - wmManipulator *mpr = mmap->mmap_context.highlight; + wmGizmo *mpr = mmap->mmap_context.highlight; if (mpr && mpr->type->cursor_get) { WM_cursor_set(win, mpr->type->cursor_get(mpr)); return true; @@ -857,21 +857,21 @@ bool WM_manipulatormap_cursor_set(const wmManipulatorMap *mmap, wmWindow *win) return false; } -bool wm_manipulatormap_highlight_set( - wmManipulatorMap *mmap, const bContext *C, wmManipulator *mpr, int part) +bool wm_gizmomap_highlight_set( + wmGizmoMap *mmap, const bContext *C, wmGizmo *mpr, int part) { if ((mpr != mmap->mmap_context.highlight) || (mpr && part != mpr->highlight_part)) { if (mmap->mmap_context.highlight) { - mmap->mmap_context.highlight->state &= ~WM_MANIPULATOR_STATE_HIGHLIGHT; + mmap->mmap_context.highlight->state &= ~WM_GIZMO_STATE_HIGHLIGHT; mmap->mmap_context.highlight->highlight_part = -1; } mmap->mmap_context.highlight = mpr; if (mpr) { - mpr->state |= WM_MANIPULATOR_STATE_HIGHLIGHT; + mpr->state |= WM_GIZMO_STATE_HIGHLIGHT; mpr->highlight_part = part; mmap->mmap_context.last_cursor = -1; @@ -900,7 +900,7 @@ bool wm_manipulatormap_highlight_set( return false; } -wmManipulator *wm_manipulatormap_highlight_get(wmManipulatorMap *mmap) +wmGizmo *wm_gizmomap_highlight_get(wmGizmoMap *mmap) { return mmap->mmap_context.highlight; } @@ -908,8 +908,8 @@ wmManipulator *wm_manipulatormap_highlight_get(wmManipulatorMap *mmap) /** * Caller should call exit when (enable == False). */ -void wm_manipulatormap_modal_set( - wmManipulatorMap *mmap, bContext *C, wmManipulator *mpr, const wmEvent *event, bool enable) +void wm_gizmomap_modal_set( + wmGizmoMap *mmap, bContext *C, wmGizmo *mpr, const wmEvent *event, bool enable) { if (enable) { BLI_assert(mmap->mmap_context.modal == NULL); @@ -926,10 +926,10 @@ void wm_manipulatormap_modal_set( } } - mpr->state |= WM_MANIPULATOR_STATE_MODAL; + mpr->state |= WM_GIZMO_STATE_MODAL; mmap->mmap_context.modal = mpr; - if ((mpr->flag & WM_MANIPULATOR_GRAB_CURSOR) && + if ((mpr->flag & WM_GIZMO_GRAB_CURSOR) && (event->is_motion_absolute == false)) { WM_cursor_grab_enable(win, true, true, NULL); @@ -940,16 +940,16 @@ void wm_manipulatormap_modal_set( mmap->mmap_context.event_xy[0] = INT_MAX; } - struct wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, mpr->highlight_part); + struct wmGizmoOpElem *mpop = WM_gizmo_operator_get(mpr, mpr->highlight_part); if (mpop && mpop->type) { const int retval = WM_operator_name_call_ptr(C, mpop->type, WM_OP_INVOKE_DEFAULT, &mpop->ptr); if ((retval & OPERATOR_RUNNING_MODAL) == 0) { - wm_manipulatormap_modal_set(mmap, C, mpr, event, false); + wm_gizmomap_modal_set(mmap, C, mpr, event, false); } - /* we failed to hook the manipulator to the operator handler or operator was cancelled, return */ + /* we failed to hook the gizmo to the operator handler or operator was cancelled, return */ if (!mmap->mmap_context.modal) { - mpr->state &= ~WM_MANIPULATOR_STATE_MODAL; + mpr->state &= ~WM_GIZMO_STATE_MODAL; MEM_SAFE_FREE(mpr->interaction_data); } return; @@ -958,9 +958,9 @@ void wm_manipulatormap_modal_set( else { BLI_assert(ELEM(mmap->mmap_context.modal, NULL, mpr)); - /* deactivate, manipulator but first take care of some stuff */ + /* deactivate, gizmo but first take care of some stuff */ if (mpr) { - mpr->state &= ~WM_MANIPULATOR_STATE_MODAL; + mpr->state &= ~WM_GIZMO_STATE_MODAL; MEM_SAFE_FREE(mpr->interaction_data); } mmap->mmap_context.modal = NULL; @@ -986,34 +986,34 @@ void wm_manipulatormap_modal_set( } } -wmManipulator *wm_manipulatormap_modal_get(wmManipulatorMap *mmap) +wmGizmo *wm_gizmomap_modal_get(wmGizmoMap *mmap) { return mmap->mmap_context.modal; } -wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len) +wmGizmo **wm_gizmomap_selected_get(wmGizmoMap *mmap, int *r_selected_len) { *r_selected_len = mmap->mmap_context.select.len; return mmap->mmap_context.select.items; } -ListBase *wm_manipulatormap_groups_get(wmManipulatorMap *mmap) +ListBase *wm_gizmomap_groups_get(wmGizmoMap *mmap) { return &mmap->groups; } -void WM_manipulatormap_message_subscribe( - bContext *C, wmManipulatorMap *mmap, ARegion *ar, struct wmMsgBus *mbus) +void WM_gizmomap_message_subscribe( + bContext *C, wmGizmoMap *mmap, ARegion *ar, struct wmMsgBus *mbus) { - for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - if (!WM_manipulator_group_type_poll(C, mgroup->type)) { + for (wmGizmoGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { + if (!WM_gizmo_group_type_poll(C, mgroup->type)) { continue; } - for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { - if (mpr->flag & WM_MANIPULATOR_HIDDEN) { + for (wmGizmo *mpr = mgroup->gizmos.first; mpr; mpr = mpr->next) { + if (mpr->flag & WM_GIZMO_HIDDEN) { continue; } - WM_manipulator_target_property_subscribe_all(mpr, mbus, ar); + WM_gizmo_target_property_subscribe_all(mpr, mbus, ar); } if (mgroup->type->message_subscribe != NULL) { mgroup->type->message_subscribe(C, mgroup, mbus); @@ -1021,7 +1021,7 @@ void WM_manipulatormap_message_subscribe( } } -/** \} */ /* wmManipulatorMap */ +/** \} */ /* wmGizmoMap */ /* -------------------------------------------------------------------- */ @@ -1029,31 +1029,31 @@ void WM_manipulatormap_message_subscribe( * * \{ */ -struct ARegion *WM_manipulatormap_tooltip_init( +struct ARegion *WM_gizmomap_tooltip_init( struct bContext *C, struct ARegion *ar, bool *r_exit_on_event) { - wmManipulatorMap *mmap = ar->manipulator_map; + wmGizmoMap *mmap = ar->gizmo_map; *r_exit_on_event = true; if (mmap) { - wmManipulator *mpr = mmap->mmap_context.highlight; + wmGizmo *mpr = mmap->mmap_context.highlight; if (mpr) { - return UI_tooltip_create_from_manipulator(C, mpr); + return UI_tooltip_create_from_gizmo(C, mpr); } } return NULL; } -/** \} */ /* wmManipulatorMapType */ +/** \} */ /* wmGizmoMapType */ /* -------------------------------------------------------------------- */ -/** \name wmManipulatorMapType +/** \name wmGizmoMapType * * \{ */ -wmManipulatorMapType *WM_manipulatormaptype_find( - const struct wmManipulatorMapType_Params *mmap_params) +wmGizmoMapType *WM_gizmomaptype_find( + const struct wmGizmoMapType_Params *mmap_params) { - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; mmap_type; mmap_type = mmap_type->next) { + for (wmGizmoMapType *mmap_type = gizmomaptypes.first; mmap_type; mmap_type = mmap_type->next) { if (mmap_type->spaceid == mmap_params->spaceid && mmap_type->regionid == mmap_params->regionid) { @@ -1064,57 +1064,57 @@ wmManipulatorMapType *WM_manipulatormaptype_find( return NULL; } -wmManipulatorMapType *WM_manipulatormaptype_ensure( - const struct wmManipulatorMapType_Params *mmap_params) +wmGizmoMapType *WM_gizmomaptype_ensure( + const struct wmGizmoMapType_Params *mmap_params) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_find(mmap_params); + wmGizmoMapType *mmap_type = WM_gizmomaptype_find(mmap_params); if (mmap_type) { return mmap_type; } - mmap_type = MEM_callocN(sizeof(wmManipulatorMapType), "manipulatortype list"); + mmap_type = MEM_callocN(sizeof(wmGizmoMapType), "gizmotype list"); mmap_type->spaceid = mmap_params->spaceid; mmap_type->regionid = mmap_params->regionid; - BLI_addhead(&manipulatormaptypes, mmap_type); + BLI_addhead(&gizmomaptypes, mmap_type); return mmap_type; } -void wm_manipulatormaptypes_free(void) +void wm_gizmomaptypes_free(void) { - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first, *mmap_type_next; + for (wmGizmoMapType *mmap_type = gizmomaptypes.first, *mmap_type_next; mmap_type; mmap_type = mmap_type_next) { mmap_type_next = mmap_type->next; - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_next; + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_next; wgt_ref; wgt_ref = wgt_next) { wgt_next = wgt_ref->next; - WM_manipulatormaptype_group_free(wgt_ref); + WM_gizmomaptype_group_free(wgt_ref); } MEM_freeN(mmap_type); } } /** - * Initialize keymaps for all existing manipulator-groups + * Initialize keymaps for all existing gizmo-groups */ -void wm_manipulators_keymap(wmKeyConfig *keyconf) +void wm_gizmos_keymap(wmKeyConfig *keyconf) { - /* we add this item-less keymap once and use it to group manipulator-group keymaps into it */ - WM_keymap_find(keyconf, "Manipulators", 0, 0); + /* we add this item-less keymap once and use it to group gizmo-group keymaps into it */ + WM_keymap_find(keyconf, "Gizmos", 0, 0); - 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); + for (wmGizmoMapType *mmap_type = gizmomaptypes.first; mmap_type; mmap_type = mmap_type->next) { + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { + wm_gizmogrouptype_setup_keymap(wgt_ref->type, keyconf); } } } -/** \} */ /* wmManipulatorMapType */ +/** \} */ /* wmGizmoMapType */ /* -------------------------------------------------------------------- */ /** \name Updates for Dynamic Type Registraion @@ -1122,31 +1122,31 @@ void wm_manipulators_keymap(wmKeyConfig *keyconf) * \{ */ -void WM_manipulatorconfig_update_tag_init( - wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) +void WM_gizmoconfig_update_tag_init( + wmGizmoMapType *mmap_type, wmGizmoGroupType *wgt) { /* tag for update on next use */ - mmap_type->type_update_flag |= (WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT); - wgt->type_update_flag |= (WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT); + mmap_type->type_update_flag |= (WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT); + wgt->type_update_flag |= (WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT); - wm_mmap_type_update_flag |= WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT; + wm_mmap_type_update_flag |= WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT; } -void WM_manipulatorconfig_update_tag_remove( - wmManipulatorMapType *mmap_type, wmManipulatorGroupType *wgt) +void WM_gizmoconfig_update_tag_remove( + wmGizmoMapType *mmap_type, wmGizmoGroupType *wgt) { /* tag for update on next use */ - mmap_type->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; - wgt->type_update_flag |= WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; + mmap_type->type_update_flag |= WM_GIZMOMAPTYPE_UPDATE_REMOVE; + wgt->type_update_flag |= WM_GIZMOMAPTYPE_UPDATE_REMOVE; - wm_mmap_type_update_flag |= WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE; + wm_mmap_type_update_flag |= WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE; } /** * Run incase new types have been added (runs often, early exit where possible). * Follows #WM_keyconfig_update concentions. */ -void WM_manipulatorconfig_update(struct Main *bmain) +void WM_gizmoconfig_update(struct Main *bmain) { if (G.background) return; @@ -1154,55 +1154,55 @@ void WM_manipulatorconfig_update(struct Main *bmain) if (wm_mmap_type_update_flag == 0) return; - if (wm_mmap_type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE) { - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; + if (wm_mmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) { + for (wmGizmoMapType *mmap_type = gizmomaptypes.first; mmap_type; mmap_type = mmap_type->next) { - if (mmap_type->type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE) { - mmap_type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_ref_next; + if (mmap_type->type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) { + mmap_type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE; + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first, *wgt_ref_next; wgt_ref; wgt_ref = wgt_ref_next) { wgt_ref_next = wgt_ref->next; - if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_REMOVE) { - wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_REMOVE; - WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt_ref->type); + if (wgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_UPDATE_REMOVE) { + wgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE; + WM_gizmomaptype_group_unlink(NULL, bmain, mmap_type, wgt_ref->type); } } } } - wm_mmap_type_update_flag &= ~WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_REMOVE; + wm_mmap_type_update_flag &= ~WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE; } - if (wm_mmap_type_update_flag & WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT) { - for (wmManipulatorMapType *mmap_type = manipulatormaptypes.first; + if (wm_mmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT) { + for (wmGizmoMapType *mmap_type = gizmomaptypes.first; mmap_type; mmap_type = mmap_type->next) { - const uchar type_update_all = WM_MANIPULATORMAPTYPE_UPDATE_INIT | WM_MANIPULATORMAPTYPE_KEYMAP_INIT; + const uchar type_update_all = WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT; if (mmap_type->type_update_flag & type_update_all) { mmap_type->type_update_flag &= ~type_update_all; - for (wmManipulatorGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; + for (wmGizmoGroupTypeRef *wgt_ref = mmap_type->grouptype_refs.first; wgt_ref; wgt_ref = wgt_ref->next) { - if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_KEYMAP_INIT) { - WM_manipulatormaptype_group_init_runtime_keymap(bmain, wgt_ref->type); - wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_KEYMAP_INIT; + if (wgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) { + WM_gizmomaptype_group_init_runtime_keymap(bmain, wgt_ref->type); + wgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_KEYMAP_INIT; } - if (wgt_ref->type->type_update_flag & WM_MANIPULATORMAPTYPE_UPDATE_INIT) { - WM_manipulatormaptype_group_init_runtime(bmain, mmap_type, wgt_ref->type); - wgt_ref->type->type_update_flag &= ~WM_MANIPULATORMAPTYPE_UPDATE_INIT; + if (wgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_UPDATE_INIT) { + WM_gizmomaptype_group_init_runtime(bmain, mmap_type, wgt_ref->type); + wgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_INIT; } } } } - wm_mmap_type_update_flag &= ~WM_MANIPULATORMAPTYPE_GLOBAL_UPDATE_INIT; + wm_mmap_type_update_flag &= ~WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT; } } diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c index 78d12e4e4ba..f3df001af55 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c @@ -51,43 +51,43 @@ /** \name Property Definition * \{ */ -BLI_INLINE wmManipulatorProperty *wm_manipulator_target_property_array(wmManipulator *mpr) +BLI_INLINE wmGizmoProperty *wm_gizmo_target_property_array(wmGizmo *mpr) { - return (wmManipulatorProperty *)(POINTER_OFFSET(mpr, mpr->type->struct_size)); + return (wmGizmoProperty *)(POINTER_OFFSET(mpr, mpr->type->struct_size)); } -wmManipulatorProperty *WM_manipulator_target_property_array(wmManipulator *mpr) +wmGizmoProperty *WM_gizmo_target_property_array(wmGizmo *mpr) { - return wm_manipulator_target_property_array(mpr); + return wm_gizmo_target_property_array(mpr); } -wmManipulatorProperty *WM_manipulator_target_property_at_index(wmManipulator *mpr, int index) +wmGizmoProperty *WM_gizmo_target_property_at_index(wmGizmo *mpr, int index) { BLI_assert(index < mpr->type->target_property_defs_len); BLI_assert(index != -1); - wmManipulatorProperty *mpr_prop_array = wm_manipulator_target_property_array(mpr); + wmGizmoProperty *mpr_prop_array = wm_gizmo_target_property_array(mpr); return &mpr_prop_array[index]; } -wmManipulatorProperty *WM_manipulator_target_property_find(wmManipulator *mpr, const char *idname) +wmGizmoProperty *WM_gizmo_target_property_find(wmGizmo *mpr, const char *idname) { int index = BLI_findstringindex( - &mpr->type->target_property_defs, idname, offsetof(wmManipulatorPropertyType, idname)); + &mpr->type->target_property_defs, idname, offsetof(wmGizmoPropertyType, idname)); if (index != -1) { - return WM_manipulator_target_property_at_index(mpr, index); + return WM_gizmo_target_property_at_index(mpr, index); } else { return NULL; } } -void WM_manipulator_target_property_def_rna_ptr( - wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type, +void WM_gizmo_target_property_def_rna_ptr( + wmGizmo *mpr, const wmGizmoPropertyType *mpr_prop_type, PointerRNA *ptr, PropertyRNA *prop, int index) { - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type); + wmGizmoProperty *mpr_prop = WM_gizmo_target_property_at_index(mpr, mpr_prop_type->index_in_type); - /* if manipulator evokes an operator we cannot use it for property manipulation */ + /* if gizmo evokes an operator we cannot use it for property manipulation */ BLI_assert(mpr->op_data == NULL); mpr_prop->type = mpr_prop_type; @@ -101,22 +101,22 @@ void WM_manipulator_target_property_def_rna_ptr( } } -void WM_manipulator_target_property_def_rna( - wmManipulator *mpr, const char *idname, +void WM_gizmo_target_property_def_rna( + wmGizmo *mpr, const char *idname, PointerRNA *ptr, const char *propname, int index) { - const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname); + const wmGizmoPropertyType *mpr_prop_type = WM_gizmotype_target_property_find(mpr->type, idname); PropertyRNA *prop = RNA_struct_find_property(ptr, propname); - WM_manipulator_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index); + WM_gizmo_target_property_def_rna_ptr(mpr, mpr_prop_type, ptr, prop, index); } -void WM_manipulator_target_property_def_func_ptr( - wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type, - const wmManipulatorPropertyFnParams *params) +void WM_gizmo_target_property_def_func_ptr( + wmGizmo *mpr, const wmGizmoPropertyType *mpr_prop_type, + const wmGizmoPropertyFnParams *params) { - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type); + wmGizmoProperty *mpr_prop = WM_gizmo_target_property_at_index(mpr, mpr_prop_type->index_in_type); - /* if manipulator evokes an operator we cannot use it for property manipulation */ + /* if gizmo evokes an operator we cannot use it for property manipulation */ BLI_assert(mpr->op_data == NULL); mpr_prop->type = mpr_prop_type; @@ -132,20 +132,20 @@ void WM_manipulator_target_property_def_func_ptr( } } -void WM_manipulator_target_property_def_func( - wmManipulator *mpr, const char *idname, - const wmManipulatorPropertyFnParams *params) +void WM_gizmo_target_property_def_func( + wmGizmo *mpr, const char *idname, + const wmGizmoPropertyFnParams *params) { - const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname); - WM_manipulator_target_property_def_func_ptr(mpr, mpr_prop_type, params); + const wmGizmoPropertyType *mpr_prop_type = WM_gizmotype_target_property_find(mpr->type, idname); + WM_gizmo_target_property_def_func_ptr(mpr, mpr_prop_type, params); } -void WM_manipulator_target_property_clear_rna_ptr( - wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type) +void WM_gizmo_target_property_clear_rna_ptr( + wmGizmo *mpr, const wmGizmoPropertyType *mpr_prop_type) { - wmManipulatorProperty *mpr_prop = WM_manipulator_target_property_at_index(mpr, mpr_prop_type->index_in_type); + wmGizmoProperty *mpr_prop = WM_gizmo_target_property_at_index(mpr, mpr_prop_type->index_in_type); - /* if manipulator evokes an operator we cannot use it for property manipulation */ + /* if gizmo evokes an operator we cannot use it for property manipulation */ BLI_assert(mpr->op_data == NULL); mpr_prop->type = NULL; @@ -155,11 +155,11 @@ void WM_manipulator_target_property_clear_rna_ptr( mpr_prop->index = -1; } -void WM_manipulator_target_property_clear_rna( - wmManipulator *mpr, const char *idname) +void WM_gizmo_target_property_clear_rna( + wmGizmo *mpr, const char *idname) { - const wmManipulatorPropertyType *mpr_prop_type = WM_manipulatortype_target_property_find(mpr->type, idname); - WM_manipulator_target_property_clear_rna_ptr(mpr, mpr_prop_type); + const wmGizmoPropertyType *mpr_prop_type = WM_gizmotype_target_property_find(mpr->type, idname); + WM_gizmo_target_property_clear_rna_ptr(mpr, mpr_prop_type); } @@ -171,26 +171,26 @@ void WM_manipulator_target_property_clear_rna( /** \name Property Access * \{ */ -bool WM_manipulator_target_property_is_valid_any(wmManipulator *mpr) +bool WM_gizmo_target_property_is_valid_any(wmGizmo *mpr) { - wmManipulatorProperty *mpr_prop_array = wm_manipulator_target_property_array(mpr); + wmGizmoProperty *mpr_prop_array = wm_gizmo_target_property_array(mpr); for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; - if (WM_manipulator_target_property_is_valid(mpr_prop)) { + wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; + if (WM_gizmo_target_property_is_valid(mpr_prop)) { return true; } } return false; } -bool WM_manipulator_target_property_is_valid(const wmManipulatorProperty *mpr_prop) +bool WM_gizmo_target_property_is_valid(const wmGizmoProperty *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) +float WM_gizmo_target_property_value_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop) { if (mpr_prop->custom_func.value_get_fn) { float value = 0.0f; @@ -207,9 +207,9 @@ float WM_manipulator_target_property_value_get( } } -void WM_manipulator_target_property_value_set( - bContext *C, const wmManipulator *mpr, - wmManipulatorProperty *mpr_prop, const float value) +void WM_gizmo_target_property_value_set( + bContext *C, const wmGizmo *mpr, + wmGizmoProperty *mpr_prop, const float value) { if (mpr_prop->custom_func.value_set_fn) { BLI_assert(mpr_prop->type->array_length == 1); @@ -227,8 +227,8 @@ void WM_manipulator_target_property_value_set( RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); } -void WM_manipulator_target_property_value_get_array( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +void WM_gizmo_target_property_value_get_array( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, float *value) { if (mpr_prop->custom_func.value_get_fn) { @@ -238,8 +238,8 @@ void WM_manipulator_target_property_value_get_array( 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, +void WM_gizmo_target_property_value_set_array( + bContext *C, const wmGizmo *mpr, wmGizmoProperty *mpr_prop, const float *value) { if (mpr_prop->custom_func.value_set_fn) { @@ -251,8 +251,8 @@ void WM_manipulator_target_property_value_set_array( RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop); } -bool WM_manipulator_target_property_range_get( - const wmManipulator *mpr, wmManipulatorProperty *mpr_prop, +bool WM_gizmo_target_property_range_get( + const wmGizmo *mpr, wmGizmoProperty *mpr_prop, float range[2]) { if (mpr_prop->custom_func.value_get_fn) { @@ -271,8 +271,8 @@ bool WM_manipulator_target_property_range_get( return true; } -int WM_manipulator_target_property_array_length( - const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop) +int WM_gizmo_target_property_array_length( + const wmGizmo *UNUSED(mpr), wmGizmoProperty *mpr_prop) { if (mpr_prop->custom_func.value_get_fn) { return mpr_prop->type->array_length; @@ -288,21 +288,21 @@ int WM_manipulator_target_property_array_length( /** \name Property Define * \{ */ -const wmManipulatorPropertyType *WM_manipulatortype_target_property_find( - const wmManipulatorType *wt, const char *idname) +const wmGizmoPropertyType *WM_gizmotype_target_property_find( + const wmGizmoType *wt, const char *idname) { - return BLI_findstring(&wt->target_property_defs, idname, offsetof(wmManipulatorPropertyType, idname)); + return BLI_findstring(&wt->target_property_defs, idname, offsetof(wmGizmoPropertyType, idname)); } -void WM_manipulatortype_target_property_def( - wmManipulatorType *wt, const char *idname, int data_type, int array_length) +void WM_gizmotype_target_property_def( + wmGizmoType *wt, const char *idname, int data_type, int array_length) { - wmManipulatorPropertyType *mpt; + wmGizmoPropertyType *mpt; - BLI_assert(WM_manipulatortype_target_property_find(wt, idname) == NULL); + BLI_assert(WM_gizmotype_target_property_find(wt, idname) == NULL); const uint idname_size = strlen(idname) + 1; - mpt = MEM_callocN(sizeof(wmManipulatorPropertyType) + idname_size, __func__); + mpt = MEM_callocN(sizeof(wmGizmoPropertyType) + idname_size, __func__); memcpy(mpt->idname, idname, idname_size); mpt->data_type = data_type; mpt->array_length = array_length; @@ -318,28 +318,28 @@ void WM_manipulatortype_target_property_def( /** \name Property Utilities * \{ */ -void WM_manipulator_do_msg_notify_tag_refresh( +void WM_gizmo_do_msg_notify_tag_refresh( bContext *UNUSED(C), wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val) { ARegion *ar = msg_val->owner; - wmManipulatorMap *mmap = msg_val->user_data; + wmGizmoMap *mmap = msg_val->user_data; ED_region_tag_redraw(ar); - WM_manipulatormap_tag_refresh(mmap); + WM_gizmomap_tag_refresh(mmap); } /** * Runs on the "prepare draw" pass, * drawing the region clears. */ -void WM_manipulator_target_property_subscribe_all( - wmManipulator *mpr, struct wmMsgBus *mbus, ARegion *ar) +void WM_gizmo_target_property_subscribe_all( + wmGizmo *mpr, struct wmMsgBus *mbus, ARegion *ar) { if (mpr->type->target_property_defs_len) { - wmManipulatorProperty *mpr_prop_array = WM_manipulator_target_property_array(mpr); + wmGizmoProperty *mpr_prop_array = WM_gizmo_target_property_array(mpr); for (int i = 0; i < mpr->type->target_property_defs_len; i++) { - wmManipulatorProperty *mpr_prop = &mpr_prop_array[i]; - if (WM_manipulator_target_property_is_valid(mpr_prop)) { + wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; + if (WM_gizmo_target_property_is_valid(mpr_prop)) { if (mpr_prop->prop) { WM_msg_subscribe_rna( mbus, &mpr_prop->ptr, mpr_prop->prop, @@ -353,7 +353,7 @@ void WM_manipulator_target_property_subscribe_all( &(const wmMsgSubscribeValue){ .owner = ar, .user_data = mpr->parent_mgroup->parent_mmap, - .notify = WM_manipulator_do_msg_notify_tag_refresh, + .notify = WM_gizmo_do_msg_notify_tag_refresh, }, __func__); } } diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c index 4f31afb5b56..ba145af9582 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c @@ -44,7 +44,7 @@ #include "ED_screen.h" -/* only for own init/exit calls (wm_manipulatortype_init/wm_manipulatortype_free) */ +/* only for own init/exit calls (wm_gizmotype_init/wm_gizmotype_free) */ #include "wm.h" /* own includes */ @@ -52,30 +52,30 @@ #include "wm_gizmo_intern.h" -/** \name Manipulator Type Append +/** \name Gizmo Type Append * * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends. * \{ */ -static GHash *global_manipulatortype_hash = NULL; +static GHash *global_gizmotype_hash = NULL; -const wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet) +const wmGizmoType *WM_gizmotype_find(const char *idname, bool quiet) { if (idname[0]) { - wmManipulatorType *wt; + wmGizmoType *wt; - wt = BLI_ghash_lookup(global_manipulatortype_hash, idname); + wt = BLI_ghash_lookup(global_gizmotype_hash, idname); if (wt) { return wt; } if (!quiet) { - printf("search for unknown manipulator '%s'\n", idname); + printf("search for unknown gizmo '%s'\n", idname); } } else { if (!quiet) { - printf("search for empty manipulator\n"); + printf("search for empty gizmo\n"); } } @@ -83,15 +83,15 @@ const wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet) } /* caller must free */ -void WM_manipulatortype_iter(GHashIterator *ghi) +void WM_gizmotype_iter(GHashIterator *ghi) { - BLI_ghashIterator_init(ghi, global_manipulatortype_hash); + BLI_ghashIterator_init(ghi, global_gizmotype_hash); } -static wmManipulatorType *wm_manipulatortype_append__begin(void) +static wmGizmoType *wm_gizmotype_append__begin(void) { - wmManipulatorType *wt = MEM_callocN(sizeof(wmManipulatorType), "manipulatortype"); - wt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_ManipulatorProperties); + wmGizmoType *wt = MEM_callocN(sizeof(wmGizmoType), "gizmotype"); + wt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_GizmoProperties); #if 0 /* Set the default i18n context now, so that opfunc can redefine it if needed! */ RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); @@ -99,35 +99,35 @@ static wmManipulatorType *wm_manipulatortype_append__begin(void) #endif return wt; } -static void wm_manipulatortype_append__end(wmManipulatorType *wt) +static void wm_gizmotype_append__end(wmGizmoType *wt) { - BLI_assert(wt->struct_size >= sizeof(wmManipulator)); + BLI_assert(wt->struct_size >= sizeof(wmGizmo)); RNA_def_struct_identifier(&BLENDER_RNA, wt->srna, wt->idname); - BLI_ghash_insert(global_manipulatortype_hash, (void *)wt->idname, wt); + BLI_ghash_insert(global_gizmotype_hash, (void *)wt->idname, wt); } -void WM_manipulatortype_append(void (*wtfunc)(struct wmManipulatorType *)) +void WM_gizmotype_append(void (*wtfunc)(struct wmGizmoType *)) { - wmManipulatorType *wt = wm_manipulatortype_append__begin(); + wmGizmoType *wt = wm_gizmotype_append__begin(); wtfunc(wt); - wm_manipulatortype_append__end(wt); + wm_gizmotype_append__end(wt); } -void WM_manipulatortype_append_ptr(void (*wtfunc)(struct wmManipulatorType *, void *), void *userdata) +void WM_gizmotype_append_ptr(void (*wtfunc)(struct wmGizmoType *, void *), void *userdata) { - wmManipulatorType *mt = wm_manipulatortype_append__begin(); + wmGizmoType *mt = wm_gizmotype_append__begin(); wtfunc(mt, userdata); - wm_manipulatortype_append__end(mt); + wm_gizmotype_append__end(mt); } /** * Free but don't remove from ghash. */ -static void manipulatortype_free(wmManipulatorType *wt) +static void gizmotype_free(wmGizmoType *wt) { - if (wt->ext.srna) { /* python manipulator, allocs own string */ + if (wt->ext.srna) { /* python gizmo, allocs own string */ MEM_freeN((void *)wt->idname); } @@ -138,8 +138,8 @@ static void manipulatortype_free(wmManipulatorType *wt) /** * \param C: May be NULL. */ -static void manipulatortype_unlink( - bContext *C, Main *bmain, wmManipulatorType *wt) +static void gizmotype_unlink( + bContext *C, Main *bmain, wmGizmoType *wt) { /* Free instances. */ for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) { @@ -147,15 +147,15 @@ static void manipulatortype_unlink( 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; + wmGizmoMap *mmap = ar->gizmo_map; if (mmap) { - wmManipulatorGroup *mgroup; + wmGizmoGroup *mgroup; for (mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) { - for (wmManipulator *mpr = mgroup->manipulators.first, *mpr_next; mpr; mpr = mpr_next) { + for (wmGizmo *mpr = mgroup->gizmos.first, *mpr_next; mpr; mpr = mpr_next) { mpr_next = mpr->next; BLI_assert(mgroup->parent_mmap == mmap); if (mpr->type == wt) { - WM_manipulator_unlink(&mgroup->manipulators, mgroup->parent_mmap, mpr, C); + WM_gizmo_unlink(&mgroup->gizmos, mgroup->parent_mmap, mpr, C); ED_region_tag_redraw(ar); } } @@ -167,46 +167,46 @@ static void manipulatortype_unlink( } } -void WM_manipulatortype_remove_ptr(bContext *C, Main *bmain, wmManipulatorType *wt) +void WM_gizmotype_remove_ptr(bContext *C, Main *bmain, wmGizmoType *wt) { - BLI_assert(wt == WM_manipulatortype_find(wt->idname, false)); + BLI_assert(wt == WM_gizmotype_find(wt->idname, false)); - BLI_ghash_remove(global_manipulatortype_hash, wt->idname, NULL, NULL); + BLI_ghash_remove(global_gizmotype_hash, wt->idname, NULL, NULL); - manipulatortype_unlink(C, bmain, wt); + gizmotype_unlink(C, bmain, wt); - manipulatortype_free(wt); + gizmotype_free(wt); } -bool WM_manipulatortype_remove(bContext *C, Main *bmain, const char *idname) +bool WM_gizmotype_remove(bContext *C, Main *bmain, const char *idname) { - wmManipulatorType *wt = BLI_ghash_lookup(global_manipulatortype_hash, idname); + wmGizmoType *wt = BLI_ghash_lookup(global_gizmotype_hash, idname); if (wt == NULL) { return false; } - WM_manipulatortype_remove_ptr(C, bmain, wt); + WM_gizmotype_remove_ptr(C, bmain, wt); return true; } -static void wm_manipulatortype_ghash_free_cb(wmManipulatorType *mt) +static void wm_gizmotype_ghash_free_cb(wmGizmoType *mt) { - manipulatortype_free(mt); + gizmotype_free(mt); } -void wm_manipulatortype_free(void) +void wm_gizmotype_free(void) { - BLI_ghash_free(global_manipulatortype_hash, NULL, (GHashValFreeFP)wm_manipulatortype_ghash_free_cb); - global_manipulatortype_hash = NULL; + BLI_ghash_free(global_gizmotype_hash, NULL, (GHashValFreeFP)wm_gizmotype_ghash_free_cb); + global_gizmotype_hash = NULL; } /* called on initialize WM_init() */ -void wm_manipulatortype_init(void) +void wm_gizmotype_init(void) { /* reserve size is set based on blender default setup */ - global_manipulatortype_hash = BLI_ghash_str_new_ex("wm_manipulatortype_init gh", 128); + global_gizmotype_hash = BLI_ghash_str_new_ex("wm_gizmotype_init gh", 128); } /** \} */ diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_fn.h b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h index 8d28febbd5d..a94f1e994e9 100644 --- a/source/blender/windowmanager/gizmo/wm_gizmo_fn.h +++ b/source/blender/windowmanager/gizmo/wm_gizmo_fn.h @@ -29,60 +29,60 @@ #include "BLI_compiler_attrs.h" -/* wmManipulatorGroup */ -typedef bool (*wmManipulatorGroupFnPoll)( - const struct bContext *, struct wmManipulatorGroupType *) +/* wmGizmoGroup */ +typedef bool (*wmGizmoGroupFnPoll)( + const struct bContext *, struct wmGizmoGroupType *) 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 *) +typedef void (*wmGizmoGroupFnInit)( + const struct bContext *, struct wmGizmoGroup *); +typedef void (*wmGizmoGroupFnRefresh)( + const struct bContext *, struct wmGizmoGroup *); +typedef void (*wmGizmoGroupFnDrawPrepare)( + const struct bContext *, struct wmGizmoGroup *); +typedef struct wmKeyMap *(*wmGizmoGroupFnSetupKeymap)( + const struct wmGizmoGroupType *, struct wmKeyConfig *) ATTR_WARN_UNUSED_RESULT; -typedef void (*wmManipulatorGroupFnMsgBusSubscribe)( - const struct bContext *, struct wmManipulatorGroup *, struct wmMsgBus *); +typedef void (*wmGizmoGroupFnMsgBusSubscribe)( + const struct bContext *, struct wmGizmoGroup *, struct wmMsgBus *); -/* wmManipulator */ -/* See: wmManipulatorType for docs on each type. */ +/* wmGizmo */ +/* See: wmGizmoType for docs on each type. */ -typedef void (*wmManipulatorFnSetup)(struct wmManipulator *); -typedef void (*wmManipulatorFnDraw)(const struct bContext *, struct wmManipulator *); -typedef void (*wmManipulatorFnDrawSelect)(const struct bContext *, struct wmManipulator *, int); -typedef int (*wmManipulatorFnTestSelect)(struct bContext *, struct wmManipulator *, const struct wmEvent *); -typedef int (*wmManipulatorFnModal)(struct bContext *, struct wmManipulator *, const struct wmEvent *, eWM_ManipulatorTweak); -typedef void (*wmManipulatorFnPropertyUpdate)(struct wmManipulator *, struct wmManipulatorProperty *); -typedef void (*wmManipulatorFnMatrixBasisGet)(const struct wmManipulator *, float[4][4]); -typedef int (*wmManipulatorFnInvoke)(struct bContext *, struct wmManipulator *, const struct wmEvent *); -typedef void (*wmManipulatorFnExit)(struct bContext *, struct wmManipulator *, const bool); -typedef int (*wmManipulatorFnCursorGet)(struct wmManipulator *); -typedef void (*wmManipulatorFnSelectRefresh)(struct wmManipulator *); -typedef void (*wmManipulatorFnFree)(struct wmManipulator *); +typedef void (*wmGizmoFnSetup)(struct wmGizmo *); +typedef void (*wmGizmoFnDraw)(const struct bContext *, struct wmGizmo *); +typedef void (*wmGizmoFnDrawSelect)(const struct bContext *, struct wmGizmo *, int); +typedef int (*wmGizmoFnTestSelect)(struct bContext *, struct wmGizmo *, const struct wmEvent *); +typedef int (*wmGizmoFnModal)(struct bContext *, struct wmGizmo *, const struct wmEvent *, eWM_GizmoFlagTweak); +typedef void (*wmGizmoFnPropertyUpdate)(struct wmGizmo *, struct wmGizmoProperty *); +typedef void (*wmGizmoFnMatrixBasisGet)(const struct wmGizmo *, float[4][4]); +typedef int (*wmGizmoFnInvoke)(struct bContext *, struct wmGizmo *, const struct wmEvent *); +typedef void (*wmGizmoFnExit)(struct bContext *, struct wmGizmo *, const bool); +typedef int (*wmGizmoFnCursorGet)(struct wmGizmo *); +typedef void (*wmGizmoFnSelectRefresh)(struct wmGizmo *); +typedef void (*wmGizmoFnFree)(struct wmGizmo *); -/* wmManipulatorProperty ('value' type defined by 'wmManipulatorProperty.data_type') */ -typedef void (*wmManipulatorPropertyFnGet)( - const struct wmManipulator *, struct wmManipulatorProperty *, +/* wmGizmoProperty ('value' type defined by 'wmGizmoProperty.data_type') */ +typedef void (*wmGizmoPropertyFnGet)( + const struct wmGizmo *, struct wmGizmoProperty *, /* typically 'float *' */ void *value); -typedef void (*wmManipulatorPropertyFnSet)( - const struct wmManipulator *, struct wmManipulatorProperty *, +typedef void (*wmGizmoPropertyFnSet)( + const struct wmGizmo *, struct wmGizmoProperty *, /* typically 'const float *' */ const void *value); -typedef void (*wmManipulatorPropertyFnRangeGet)( - const struct wmManipulator *, struct wmManipulatorProperty *, +typedef void (*wmGizmoPropertyFnRangeGet)( + const struct wmGizmo *, struct wmGizmoProperty *, /* typically 'float[2]' */ void *range); -typedef void (*wmManipulatorPropertyFnFree)( - const struct wmManipulator *, struct wmManipulatorProperty *); +typedef void (*wmGizmoPropertyFnFree)( + const struct wmGizmo *, struct wmGizmoProperty *); -typedef struct wmManipulatorPropertyFnParams { - wmManipulatorPropertyFnGet value_get_fn; - wmManipulatorPropertyFnSet value_set_fn; - wmManipulatorPropertyFnRangeGet range_get_fn; - wmManipulatorPropertyFnFree free_fn; +typedef struct wmGizmoPropertyFnParams { + wmGizmoPropertyFnGet value_get_fn; + wmGizmoPropertyFnSet value_set_fn; + wmGizmoPropertyFnRangeGet range_get_fn; + wmGizmoPropertyFnFree free_fn; void *user_data; -} wmManipulatorPropertyFnParams; +} wmGizmoPropertyFnParams; #endif /* __WM_GIZMO_FN_H__ */ diff --git a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h index 80418cbfeb3..5b1085db4a1 100644 --- a/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h +++ b/source/blender/windowmanager/gizmo/wm_gizmo_wmapi.h @@ -26,10 +26,10 @@ /** \file blender/windowmanager/gizmo/wm_gizmo_wmapi.h * \ingroup wm * - * \name Manipulators Window Manager API + * \name Gizmos Window Manager API * API for usage in window manager code only. It should contain all functionality - * needed to hook up the manipulator system with Blender's window manager. It's - * mostly the event system that needs to communicate with manipulator code. + * needed to hook up the gizmo system with Blender's window manager. It's + * mostly the event system that needs to communicate with gizmo code. * * Only included in wm.h and lower level files. */ @@ -39,59 +39,59 @@ #define __WM_GIZMO_WMAPI_H__ struct wmEventHandler; -struct wmManipulatorMap; +struct wmGizmoMap; struct wmOperatorType; struct wmOperator; /* -------------------------------------------------------------------- */ -/* wmManipulator */ +/* wmGizmo */ -/* wm_manipulator_type.c, for init/exit */ -void wm_manipulatortype_free(void); -void wm_manipulatortype_init(void); +/* wm_gizmo_type.c, for init/exit */ +void wm_gizmotype_free(void); +void wm_gizmotype_init(void); -/* wm_manipulatorgroup_type.c, for init/exit */ -void wm_manipulatorgrouptype_free(void); -void wm_manipulatorgrouptype_init(void); +/* wm_gizmogroup_type.c, for init/exit */ +void wm_gizmogrouptype_free(void); +void wm_gizmogrouptype_init(void); /* -------------------------------------------------------------------- */ -/* wmManipulatorGroup */ +/* wmGizmoGroup */ -void MANIPULATORGROUP_OT_manipulator_select(struct wmOperatorType *ot); -void MANIPULATORGROUP_OT_manipulator_tweak(struct wmOperatorType *ot); +void GIZMOGROUP_OT_gizmo_select(struct wmOperatorType *ot); +void GIZMOGROUP_OT_gizmo_tweak(struct wmOperatorType *ot); -bool wm_manipulatorgroup_is_any_selected(const struct wmManipulatorGroup *mgroup); +bool wm_gizmogroup_is_any_selected(const struct wmGizmoGroup *mgroup); /* -------------------------------------------------------------------- */ -/* wmManipulatorMap */ +/* wmGizmoMap */ -void wm_manipulatormap_remove(struct wmManipulatorMap *mmap); +void wm_gizmomap_remove(struct wmGizmoMap *mmap); -void wm_manipulators_keymap(struct wmKeyConfig *keyconf); +void wm_gizmos_keymap(struct wmKeyConfig *keyconf); -void wm_manipulatormaps_handled_modal_update( +void wm_gizmomaps_handled_modal_update( bContext *C, struct wmEvent *event, struct wmEventHandler *handler); -void wm_manipulatormap_handler_context(bContext *C, struct wmEventHandler *handler); +void wm_gizmomap_handler_context(bContext *C, struct wmEventHandler *handler); -struct wmManipulator *wm_manipulatormap_highlight_find( - struct wmManipulatorMap *mmap, bContext *C, const struct wmEvent *event, +struct wmGizmo *wm_gizmomap_highlight_find( + struct wmGizmoMap *mmap, bContext *C, const struct wmEvent *event, int *r_part); -bool wm_manipulatormap_highlight_set( - struct wmManipulatorMap *mmap, const bContext *C, - struct wmManipulator *mpr, int part); -struct wmManipulator *wm_manipulatormap_highlight_get(struct wmManipulatorMap *mmap); -void wm_manipulatormap_modal_set( - struct wmManipulatorMap *mmap, bContext *C, struct wmManipulator *mpr, +bool wm_gizmomap_highlight_set( + struct wmGizmoMap *mmap, const bContext *C, + struct wmGizmo *mpr, int part); +struct wmGizmo *wm_gizmomap_highlight_get(struct wmGizmoMap *mmap); +void wm_gizmomap_modal_set( + struct wmGizmoMap *mmap, bContext *C, struct wmGizmo *mpr, const struct wmEvent *event, bool enable); -struct wmManipulator *wm_manipulatormap_modal_get(struct wmManipulatorMap *mmap); -struct wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len); -struct ListBase *wm_manipulatormap_groups_get(wmManipulatorMap *mmap); +struct wmGizmo *wm_gizmomap_modal_get(struct wmGizmoMap *mmap); +struct wmGizmo **wm_gizmomap_selected_get(wmGizmoMap *mmap, int *r_selected_len); +struct ListBase *wm_gizmomap_groups_get(wmGizmoMap *mmap); /* -------------------------------------------------------------------- */ -/* wmManipulatorMapType */ +/* wmGizmoMapType */ -void wm_manipulatormaptypes_free(void); +void wm_gizmomaptypes_free(void); #endif /* __WM_GIZMO_WMAPI_H__ */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 8469dc9da0e..bc24b7698e2 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2004,8 +2004,8 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand CTX_wm_region_set(C, NULL); } - /* update manipulators during modal handlers */ - wm_manipulatormaps_handled_modal_update(C, event, handler); + /* update gizmos during modal handlers */ + wm_gizmomaps_handled_modal_update(C, event, handler); /* remove modal handler, operator itself should have been canceled and freed */ if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) { @@ -2392,32 +2392,32 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers } } } - else if (handler->manipulator_map) { + else if (handler->gizmo_map) { ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - wmManipulatorMap *mmap = handler->manipulator_map; - wmManipulator *mpr = wm_manipulatormap_highlight_get(mmap); + wmGizmoMap *mmap = handler->gizmo_map; + wmGizmo *mpr = wm_gizmomap_highlight_get(mmap); - if (region->manipulator_map != handler->manipulator_map) { - WM_manipulatormap_tag_refresh(handler->manipulator_map); + if (region->gizmo_map != handler->gizmo_map) { + WM_gizmomap_tag_refresh(handler->gizmo_map); } - wm_manipulatormap_handler_context(C, handler); + wm_gizmomap_handler_context(C, handler); wm_region_mouse_co(C, event); - /* handle manipulator highlighting */ - if (event->type == MOUSEMOVE && !wm_manipulatormap_modal_get(mmap)) { + /* handle gizmo highlighting */ + if (event->type == MOUSEMOVE && !wm_gizmomap_modal_get(mmap)) { int part; - mpr = wm_manipulatormap_highlight_find(mmap, C, event, &part); - if (wm_manipulatormap_highlight_set(mmap, C, mpr, part) && mpr != NULL) { - WM_tooltip_timer_init(C, CTX_wm_window(C), region, WM_manipulatormap_tooltip_init); + mpr = wm_gizmomap_highlight_find(mmap, C, event, &part); + if (wm_gizmomap_highlight_set(mmap, C, mpr, part) && mpr != NULL) { + WM_tooltip_timer_init(C, CTX_wm_window(C), region, WM_gizmomap_tooltip_init); } } else { /* Either we operate on a single highlighted item - * or groups attached to the selected manipulators. + * or groups attached to the selected gizmos. * To simplify things both cases loop over an array of items. */ - wmManipulatorGroup *mgroup_first; + wmGizmoGroup *mgroup_first; bool is_mgroup_single; if (ISMOUSE(event->type)) { @@ -2431,8 +2431,8 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers is_mgroup_single = true; } else { - if (WM_manipulatormap_is_any_selected(mmap)) { - const ListBase *groups = WM_manipulatormap_group_list(mmap); + if (WM_gizmomap_is_any_selected(mmap)) { + const ListBase *groups = WM_gizmomap_group_list(mmap); mgroup_first = groups->first; } else { @@ -2444,13 +2444,13 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers /* Don't use from now on. */ mpr = NULL; - for (wmManipulatorGroup *mgroup = mgroup_first; mgroup; mgroup = mgroup->next) { + for (wmGizmoGroup *mgroup = mgroup_first; mgroup; mgroup = mgroup->next) { /* get user customized keymap from default one */ if ((is_mgroup_single == false) && - /* We might want to change the logic here and use some kind of manipulator edit-mode. + /* We might want to change the logic here and use some kind of gizmo edit-mode. * For now just use keymap when a selection exists. */ - wm_manipulatorgroup_is_any_selected(mgroup) == false) + wm_gizmogroup_is_any_selected(mgroup) == false) { continue; } @@ -2472,14 +2472,14 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers /* weak, but allows interactive callback to not use rawkey */ event->keymap_idname = kmi->idname; - CTX_wm_manipulator_group_set(C, mgroup); + CTX_wm_gizmo_group_set(C, mgroup); /* handler->op is called later, we want keymap op to be triggered here */ handler->op = NULL; action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr); handler->op = op; - CTX_wm_manipulator_group_set(C, NULL); + CTX_wm_gizmo_group_set(C, NULL); if (action & WM_HANDLER_BREAK) { if (keymap_callback.handle_post_fn != NULL) { @@ -2804,7 +2804,7 @@ static bool wm_event_pie_filter(wmWindow *win, const wmEvent *event) } #ifdef USE_WORKSPACE_TOOL -static void wm_event_manipulator_temp_handler_apply( +static void wm_event_gizmo_temp_handler_apply( bContext *C, ScrArea *sa, ARegion *ar, wmEventHandler *sneaky_handler) { if (ar->regiontype == RGN_TYPE_WINDOW) { @@ -2818,17 +2818,17 @@ static void wm_event_manipulator_temp_handler_apply( /* Handle widgets first. */ wmEventHandler *handler_last = ar->handlers.last; - while (handler_last && handler_last->manipulator_map == NULL) { + while (handler_last && handler_last->gizmo_map == NULL) { handler_last = handler_last->prev; } - /* Head of list or after last manipulator. */ + /* Head of list or after last gizmo. */ BLI_insertlinkafter(&ar->handlers, handler_last, sneaky_handler); } } } } -static void wm_event_manipulator_temp_handler_clear( +static void wm_event_gizmo_temp_handler_clear( bContext *UNUSED(C), ScrArea *UNUSED(sa), ARegion *ar, wmEventHandler *sneaky_handler) { if (sneaky_handler->keymap) { @@ -2846,7 +2846,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)); + WM_gizmoconfig_update(CTX_data_main(C)); for (win = wm->windows.first; win; win = win->next) { bScreen *screen = WM_window_get_active_screen(win); @@ -3021,13 +3021,13 @@ void wm_event_do_handlers(bContext *C) * to fetch its current keymap. */ wmEventHandler sneaky_handler = {NULL}; - wm_event_manipulator_temp_handler_apply(C, sa, ar, &sneaky_handler); + wm_event_gizmo_temp_handler_apply(C, sa, ar, &sneaky_handler); #endif /* USE_WORKSPACE_TOOL */ action |= wm_handlers_do(C, event, &ar->handlers); #ifdef USE_WORKSPACE_TOOL - wm_event_manipulator_temp_handler_clear(C, sa, ar, &sneaky_handler); + wm_event_gizmo_temp_handler_clear(C, sa, ar, &sneaky_handler); #endif /* USE_WORKSPACE_TOOL */ /* fileread case (python), [#29489] */ @@ -3094,7 +3094,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)); + WM_gizmoconfig_update(CTX_data_main(C)); } /* ********** filesector handling ************ */ @@ -4470,7 +4470,7 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) #ifdef USE_WORKSPACE_TOOL wmEventHandler sneaky_handler = {NULL}; - wm_event_manipulator_temp_handler_apply(C, sa, ar, &sneaky_handler); + wm_event_gizmo_temp_handler_apply(C, sa, ar, &sneaky_handler); #endif ListBase *handlers[] = { @@ -4503,7 +4503,7 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) } #ifdef USE_WORKSPACE_TOOL - wm_event_manipulator_temp_handler_clear(C, sa, ar, &sneaky_handler); + wm_event_gizmo_temp_handler_clear(C, sa, ar, &sneaky_handler); #endif if (memcmp(&cd_prev.text, &cd->text, sizeof(cd_prev.text)) != 0) { diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 463508674d5..0c7c85e0d94 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -212,15 +212,15 @@ void WM_init(bContext *C, int argc, const char **argv) WM_paneltype_init(); /* Lookup table only. */ WM_menutype_init(); WM_uilisttype_init(); - wm_manipulatortype_init(); - wm_manipulatorgrouptype_init(); + wm_gizmotype_init(); + wm_gizmogrouptype_init(); ED_undosys_type_init(); BKE_library_callback_free_window_manager_set(wm_close_and_free); /* library.c */ BKE_library_callback_free_notifier_reference_set(WM_main_remove_notifier_reference); /* library.c */ - BKE_region_callback_free_manipulatormap_set(wm_manipulatormap_remove); /* screen.c */ - BKE_region_callback_refresh_tag_manipulatormap_set(WM_manipulatormap_tag_refresh); + BKE_region_callback_free_gizmomap_set(wm_gizmomap_remove); /* screen.c */ + BKE_region_callback_refresh_tag_gizmomap_set(WM_gizmomap_tag_refresh); BKE_library_callback_remap_editor_id_reference_set(WM_main_remap_editor_id_reference); /* library.c */ BKE_blender_callback_test_break_set(wm_window_testbreak); /* blender.c */ BKE_spacedata_callback_id_remap_set(ED_spacedata_id_remap); /* screen.c */ @@ -507,10 +507,10 @@ void WM_exit_ext(bContext *C, const bool do_python) ED_gpencil_strokes_copybuf_free(); BKE_node_clipboard_clear(); - /* free manipulator-maps after freeing blender, so no deleted data get accessed during cleaning up of areas */ - wm_manipulatormaptypes_free(); - wm_manipulatorgrouptype_free(); - wm_manipulatortype_free(); + /* free gizmo-maps after freeing blender, so no deleted data get accessed during cleaning up of areas */ + wm_gizmomaptypes_free(); + wm_gizmogrouptype_free(); + wm_gizmotype_free(); BLF_exit(); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index dd9b8324b11..5cf9ac625c3 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3248,9 +3248,9 @@ void wm_operatortypes_register(void) WM_operatortype_append(WM_OT_previews_clear); WM_operatortype_append(WM_OT_doc_view_manual_ui_context); - /* manipulators */ - WM_operatortype_append(MANIPULATORGROUP_OT_manipulator_select); - WM_operatortype_append(MANIPULATORGROUP_OT_manipulator_tweak); + /* gizmos */ + WM_operatortype_append(GIZMOGROUP_OT_gizmo_select); + WM_operatortype_append(GIZMOGROUP_OT_gizmo_tweak); } /* circleselect-like modal operators */ @@ -3580,7 +3580,7 @@ void wm_window_keymap(wmKeyConfig *keyconf) RNA_float_set(kmi->ptr, "value", 1.0f / 1.5f); #endif /* WITH_INPUT_NDOF */ - wm_manipulators_keymap(keyconf); + wm_gizmos_keymap(keyconf); gesture_circle_modal_keymap(keyconf); gesture_border_modal_keymap(keyconf); gesture_zoom_border_modal_keymap(keyconf); diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index d06cc21ec21..350327e8590 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -131,8 +131,8 @@ static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *t { bToolRef_Runtime *tref_rt = tref->runtime; - if (tref_rt->manipulator_group[0]) { - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(tref_rt->manipulator_group, false); + if (tref_rt->gizmo_group[0]) { + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(tref_rt->gizmo_group, false); if (wgt != NULL) { bool found = false; @@ -144,7 +144,7 @@ static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *t for (wmWindow *win = wm->windows.first; win; win = win->next) { const WorkSpace *workspace_iter = WM_window_get_active_workspace(win); if (workspace != workspace_iter) { - if (STREQ(workspace->tool.manipulator_group, workspace_iter->tool.manipulator_group)) { + if (STREQ(workspace->tool.gizmo_group, workspace_iter->tool.gizmo_group)) { found = true; break; } @@ -154,8 +154,8 @@ static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *t UNUSED_VARS(workspace); #endif if (!found) { - wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params); - WM_manipulatormaptype_group_unlink(C, bmain, mmap_type, wgt); + wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); + WM_gizmomaptype_group_unlink(C, bmain, mmap_type, wgt); } } } @@ -171,11 +171,11 @@ void WM_toolsystem_unlink(bContext *C, WorkSpace *workspace, const bToolKey *tke static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tref) { bToolRef_Runtime *tref_rt = tref->runtime; - if (tref_rt->manipulator_group[0]) { - const char *idname = tref_rt->manipulator_group; - wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false); + if (tref_rt->gizmo_group[0]) { + const char *idname = tref_rt->gizmo_group; + wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); if (wgt != NULL) { - WM_manipulator_group_type_ensure_ptr(wgt); + WM_gizmo_group_type_ensure_ptr(wgt); } else { CLOG_WARN(WM_LOG_TOOLS, "'%s' widget not found", idname); diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h index d191fe4a9c2..1dcd0cb62d0 100644 --- a/source/blender/windowmanager/wm_event_system.h +++ b/source/blender/windowmanager/wm_event_system.h @@ -77,8 +77,8 @@ typedef struct wmEventHandler { /* drop box handler */ ListBase *dropboxes; - /* manipulator handler */ - struct wmManipulatorMap *manipulator_map; + /* gizmo handler */ + struct wmGizmoMap *gizmo_map; } wmEventHandler; /* custom types for handlers, for signaling, freeing */ diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 3f98b6ef512..6a0e4882830 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -339,8 +339,8 @@ enum { EVT_DROP = 0x5023, EVT_BUT_CANCEL = 0x5024, - /* could become manipulator callback */ - EVT_MANIPULATOR_UPDATE = 0x5025, + /* could become gizmo callback */ + EVT_GIZMO_UPDATE = 0x5025, /* ********** End of Blender internal events. ********** */ }; |