Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform.c
| Show First 20 Lines • Show All 560 Lines • ▼ Show 20 Lines | |||||
| #endif | #endif | ||||
| } | } | ||||
| /* ************************************************* */ | /* ************************************************* */ | ||||
| static bool transform_modal_item_poll(const wmOperator *op, int value) | static bool transform_modal_item_poll(const wmOperator *op, int value) | ||||
| { | { | ||||
| const TransInfo *t = op->customdata; | const TransInfo *t = op->customdata; | ||||
| if (t->modifiers & MOD_EDIT_BASEPOINT) { | |||||
| if (ELEM(value, | |||||
| TFM_MODAL_CANCEL, | |||||
| TFM_MODAL_CONFIRM, | |||||
| TFM_MODAL_SNAP_INV_ON, | |||||
| TFM_MODAL_SNAP_INV_OFF, | |||||
| TFM_MODAL_ADD_SNAP, | |||||
| TFM_MODAL_REMOVE_SNAP, | |||||
| TFM_MODAL_EDIT_SNAPWITH)) { | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| switch (value) { | switch (value) { | ||||
| case TFM_MODAL_CANCEL: { | case TFM_MODAL_CANCEL: { | ||||
| /* TODO: Canceling with LMB is not possible when the operator is activated | /* TODO: Canceling with LMB is not possible when the operator is activated | ||||
| * through tweak and the LMB is pressed. | * through tweak and the LMB is pressed. | ||||
| * Therefore, this item should not appear in the status bar. */ | * Therefore, this item should not appear in the status bar. */ | ||||
| break; | break; | ||||
| } | } | ||||
| case TFM_MODAL_PROPSIZE: | case TFM_MODAL_PROPSIZE: | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | switch (value) { | ||||
| } | } | ||||
| case TFM_MODAL_AUTOIK_LEN_INC: | case TFM_MODAL_AUTOIK_LEN_INC: | ||||
| case TFM_MODAL_AUTOIK_LEN_DEC: { | case TFM_MODAL_AUTOIK_LEN_DEC: { | ||||
| if ((t->flag & T_AUTOIK) == 0) { | if ((t->flag & T_AUTOIK) == 0) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case TFM_MODAL_EDIT_SNAPWITH: { | |||||
| if (t->spacetype != SPACE_VIEW3D) { | |||||
| return false; | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* called in transform_ops.c, on each regeneration of keymaps */ | /* called in transform_ops.c, on each regeneration of keymaps */ | ||||
| wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) | wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) | ||||
| { | { | ||||
| static const EnumPropertyItem modal_items[] = { | static const EnumPropertyItem modal_items[] = { | ||||
| Show All 33 Lines | static const EnumPropertyItem modal_items[] = { | ||||
| 0, | 0, | ||||
| "Toggle Direction for Node Auto-Offset", | "Toggle Direction for Node Auto-Offset", | ||||
| ""}, | ""}, | ||||
| {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Move", ""}, | {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Move", ""}, | ||||
| {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""}, | {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""}, | ||||
| {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""}, | {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""}, | ||||
| {TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""}, | {TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""}, | ||||
| {TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint Plane", ""}, | {TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint Plane", ""}, | ||||
| {TFM_MODAL_EDIT_SNAPWITH, "EDIT_SNAPWITH", 0, "Edit snap with", ""}, | |||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Transform Modal Map"); | wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Transform Modal Map"); | ||||
| keymap = WM_modalkeymap_ensure(keyconf, "Transform Modal Map", modal_items); | keymap = WM_modalkeymap_ensure(keyconf, "Transform Modal Map", modal_items); | ||||
| keymap->poll_modal_item = transform_modal_item_poll; | keymap->poll_modal_item = transform_modal_item_poll; | ||||
| ▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | int transformEvent(TransInfo *t, const wmEvent *event) | ||||
| /* Handle modal numinput events first, if already activated. */ | /* Handle modal numinput events first, if already activated. */ | ||||
| if (((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) && hasNumInput(&t->num) && | if (((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) && hasNumInput(&t->num) && | ||||
| handleNumInput(t->context, &(t->num), event)) { | handleNumInput(t->context, &(t->num), event)) { | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| else if (event->type == MOUSEMOVE) { | else if (event->type == MOUSEMOVE) { | ||||
| if (t->mval[0] != event->mval[0] || t->mval[1] != event->mval[1]) { | |||||
| if (t->modifiers & (MOD_CONSTRAINT_SELECT | MOD_CONSTRAINT_PLANE)) { | if (t->modifiers & (MOD_CONSTRAINT_SELECT | MOD_CONSTRAINT_PLANE)) { | ||||
| t->con.mode |= CON_SELECT; | t->con.mode |= CON_SELECT; | ||||
| } | } | ||||
| copy_v2_v2_int(t->mval, event->mval); | copy_v2_v2_int(t->mval, event->mval); | ||||
| /* Use this for soft redraw. Might cause flicker in object mode */ | /* Use this for soft redraw. Might cause flicker in object mode */ | ||||
| // t->redraw |= TREDRAW_SOFT; | // t->redraw |= TREDRAW_SOFT; | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| if (t->state == TRANS_STARTING) { | if (t->state == TRANS_STARTING) { | ||||
| t->state = TRANS_RUNNING; | t->state = TRANS_RUNNING; | ||||
| } | } | ||||
| applyMouseInput(t, &t->mouse, t->mval, t->values); | applyMouseInput(t, &t->mouse, t->mval, t->values); | ||||
| /* Snapping mouse move events. */ | /* Snapping mouse move events. */ | ||||
| t->redraw |= handleSnapping(t, event); | t->redraw |= handleSnapping(t, event); | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| } | |||||
| /* handle modal keymap first */ | /* handle modal keymap first */ | ||||
| /* enforce redraw of transform when modifiers are used */ | /* enforce redraw of transform when modifiers are used */ | ||||
| else if (event->type == EVT_MODAL_MAP) { | else if (event->type == EVT_MODAL_MAP) { | ||||
| switch (event->val) { | switch (event->val) { | ||||
| case TFM_MODAL_CANCEL: | case TFM_MODAL_CANCEL: | ||||
| t->state = TRANS_CANCEL; | t->state = TRANS_CANCEL; | ||||
| handled = true; | handled = true; | ||||
| break; | break; | ||||
| case TFM_MODAL_CONFIRM: | case TFM_MODAL_CONFIRM: | ||||
| if (t->modifiers & MOD_EDIT_BASEPOINT) { | |||||
| tranform_snap_editbasepoint_confirm(t); | |||||
| } | |||||
| else { | |||||
| t->state = TRANS_CONFIRM; | t->state = TRANS_CONFIRM; | ||||
| } | |||||
| handled = true; | handled = true; | ||||
| break; | break; | ||||
| case TFM_MODAL_TRANSLATE: | case TFM_MODAL_TRANSLATE: | ||||
| /* only switch when... */ | /* only switch when... */ | ||||
| if (t->mode == TFM_TRANSLATION) { | if (t->mode == TFM_TRANSLATION) { | ||||
| if ((t->obedit_type == OB_MESH) && (t->spacetype == SPACE_VIEW3D)) { | if ((t->obedit_type == OB_MESH) && (t->spacetype == SPACE_VIEW3D)) { | ||||
| restoreTransObjects(t); | restoreTransObjects(t); | ||||
| resetTransModal(t); | resetTransModal(t); | ||||
| ▲ Show 20 Lines • Show All 264 Lines • ▼ Show 20 Lines | switch (event->val) { | ||||
| initSelectConstraint(t); | initSelectConstraint(t); | ||||
| postSelectConstraint(t); | postSelectConstraint(t); | ||||
| } | } | ||||
| } | } | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case TFM_MODAL_EDIT_SNAPWITH: | |||||
| tranform_snap_editbasepoint_toggle(t); | |||||
| break; | |||||
| /* Those two are only handled in transform's own handler, see T44634! */ | /* Those two are only handled in transform's own handler, see T44634! */ | ||||
| case TFM_MODAL_EDGESLIDE_UP: | case TFM_MODAL_EDGESLIDE_UP: | ||||
| case TFM_MODAL_EDGESLIDE_DOWN: | case TFM_MODAL_EDGESLIDE_DOWN: | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| /* Else do non-mapped events. */ | /* Else do non-mapped events. */ | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | switch (event->type) { | ||||
| t->flag &= ~T_ALT_TRANSFORM; | t->flag &= ~T_ALT_TRANSFORM; | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| break; | break; | ||||
| default: { | default: { | ||||
| /* Disable modifiers. */ | /* Disable modifiers. */ | ||||
| int modifiers = t->modifiers; | int modifiers = t->modifiers; | ||||
| modifiers &= ~MOD_CONSTRAINT_SELECT; | modifiers &= ~(MOD_CONSTRAINT_SELECT | MOD_CONSTRAINT_PLANE); | ||||
| modifiers &= ~MOD_CONSTRAINT_PLANE; | |||||
| if (modifiers != t->modifiers) { | if (modifiers != t->modifiers) { | ||||
| if (t->modifiers & (MOD_CONSTRAINT_SELECT | MOD_CONSTRAINT_PLANE)) { | |||||
| postSelectConstraint(t); | postSelectConstraint(t); | ||||
| } | |||||
| t->modifiers = modifiers; | t->modifiers = modifiers; | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | if (!(t->options & CTX_NO_PET)) { | ||||
| !RNA_property_is_set(op->ptr, prop)) { | !RNA_property_is_set(op->ptr, prop)) { | ||||
| ts->prop_mode = t->prop_mode; | ts->prop_mode = t->prop_mode; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (t->flag & T_MODAL) { | if (t->flag & T_MODAL) { | ||||
| /* do we check for parameter? */ | /* do we check for parameter? */ | ||||
| if (transformModeUseSnap(t)) { | if (transformModeUseSnap(t) & !(t->modifiers & MOD_SNAP_TEMP)) { | ||||
| if (!(t->modifiers & MOD_SNAP) != !(ts->snap_flag & SCE_SNAP)) { | if (!(t->modifiers & MOD_SNAP) != !(ts->snap_flag & SCE_SNAP)) { | ||||
| if (t->modifiers & MOD_SNAP) { | if (t->modifiers & MOD_SNAP) { | ||||
| ts->snap_flag |= SCE_SNAP; | ts->snap_flag |= SCE_SNAP; | ||||
| } | } | ||||
| else { | else { | ||||
| ts->snap_flag &= ~SCE_SNAP; | ts->snap_flag &= ~SCE_SNAP; | ||||
| } | } | ||||
| WM_msg_publish_rna_prop(t->mbus, &t->scene->id, ts, ToolSettings, use_snap); | WM_msg_publish_rna_prop(t->mbus, &t->scene->id, ts, ToolSettings, use_snap); | ||||
| ▲ Show 20 Lines • Show All 374 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| void transformApply(bContext *C, TransInfo *t) | void transformApply(bContext *C, TransInfo *t) | ||||
| { | { | ||||
| t->context = C; | t->context = C; | ||||
| if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) { | if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) { | ||||
| selectConstraint(t); | selectConstraint(t); | ||||
| if (t->transform) { | if (t->modifiers & MOD_EDIT_BASEPOINT) { | ||||
| tranform_snap_editbasepoint_update(t); | |||||
| } | |||||
| else if (t->transform) { | |||||
| t->transform(t, t->mval); /* calls recalcData() */ | t->transform(t, t->mval); /* calls recalcData() */ | ||||
| viewRedrawForce(C, t); | |||||
| } | } | ||||
| t->redraw = TREDRAW_NOTHING; | |||||
| } | } | ||||
| else if (t->redraw & TREDRAW_SOFT) { | |||||
| if (t->redraw & (TREDRAW_HARD | TREDRAW_SOFT)) { | |||||
| viewRedrawForce(C, t); | viewRedrawForce(C, t); | ||||
| t->redraw = TREDRAW_NOTHING; | |||||
| } | } | ||||
| /* If auto confirm is on, break after one pass */ | /* If auto confirm is on, break after one pass */ | ||||
| if (t->options & CTX_AUTOCONFIRM) { | if (t->options & CTX_AUTOCONFIRM) { | ||||
| t->state = TRANS_CONFIRM; | t->state = TRANS_CONFIRM; | ||||
| } | } | ||||
| t->context = NULL; | t->context = NULL; | ||||
| ▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines | |||||