diff options
Diffstat (limited to 'source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c')
-rw-r--r-- | source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c | 466 |
1 files changed, 233 insertions, 233 deletions
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); } /** \} */ |