Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform.c
| Show First 20 Lines • Show All 535 Lines • ▼ Show 20 Lines | static void viewRedrawPost(bContext *C, TransInfo *t) | ||||
| } | } | ||||
| } | } | ||||
| /* ************************************************* */ | /* ************************************************* */ | ||||
| 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_SNAP_SOURCE) { | |||||
| if (value == TFM_MODAL_EDIT_SNAP_SOURCE) { | |||||
| return true; | |||||
| } | |||||
| else if (!ELEM(value, | |||||
| TFM_MODAL_CANCEL, | |||||
| TFM_MODAL_CONFIRM, | |||||
| TFM_MODAL_ADD_SNAP, | |||||
| TFM_MODAL_REMOVE_SNAP)) { | |||||
| 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 65 Lines • ▼ Show 20 Lines | switch (value) { | ||||
| case TFM_MODAL_TRANSLATE: | case TFM_MODAL_TRANSLATE: | ||||
| case TFM_MODAL_ROTATE: | case TFM_MODAL_ROTATE: | ||||
| case TFM_MODAL_RESIZE: { | case TFM_MODAL_RESIZE: { | ||||
| if (!transform_mode_is_changeable(t->mode)) { | if (!transform_mode_is_changeable(t->mode)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case TFM_MODAL_EDIT_SNAP_SOURCE: { | |||||
| if (t->spacetype != SPACE_VIEW3D) { | |||||
| return false; | |||||
| } | |||||
| if (!ELEM(t->mode, TFM_TRANSLATION, TFM_ROTATION, TFM_RESIZE)) { | |||||
| /* More modes can be added over time if this feature proves useful for them. */ | |||||
| return false; | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) | wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) | ||||
| { | { | ||||
| static const EnumPropertyItem modal_items[] = { | static const EnumPropertyItem modal_items[] = { | ||||
| {TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, | {TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, | ||||
| {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, | {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, | ||||
| {TFM_MODAL_AXIS_X, "AXIS_X", 0, "X Axis", ""}, | {TFM_MODAL_AXIS_X, "AXIS_X", 0, "X Axis", ""}, | ||||
| {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Y Axis", ""}, | {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Y Axis", ""}, | ||||
| {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Z Axis", ""}, | {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Z Axis", ""}, | ||||
| {TFM_MODAL_PLANE_X, "PLANE_X", 0, "X Plane", ""}, | {TFM_MODAL_PLANE_X, "PLANE_X", 0, "X Plane", ""}, | ||||
| {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Y Plane", ""}, | {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Y Plane", ""}, | ||||
| {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Z Plane", ""}, | {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Z Plane", ""}, | ||||
| {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Clear Constraints", ""}, | {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Clear Constraints", ""}, | ||||
| {TFM_MODAL_EDIT_SNAP_SOURCE, "EDIT_SNAP_SOURCE", 0, "Set Snap Base", ""}, | |||||
| {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Snap Invert", ""}, | {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Snap Invert", ""}, | ||||
| {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Snap Invert (Off)", ""}, | {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Snap Invert (Off)", ""}, | ||||
| {TFM_MODAL_SNAP_TOGGLE, "SNAP_TOGGLE", 0, "Snap Toggle", ""}, | {TFM_MODAL_SNAP_TOGGLE, "SNAP_TOGGLE", 0, "Snap Toggle", ""}, | ||||
| {TFM_MODAL_ADD_SNAP, "ADD_SNAP", 0, "Add Snap Point", ""}, | {TFM_MODAL_ADD_SNAP, "ADD_SNAP", 0, "Add Snap Point", ""}, | ||||
| {TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""}, | {TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""}, | ||||
| {NUM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""}, | {NUM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""}, | ||||
| {NUM_MODAL_INCREMENT_DOWN, "INCREMENT_DOWN", 0, "Numinput Increment Down", ""}, | {NUM_MODAL_INCREMENT_DOWN, "INCREMENT_DOWN", 0, "Numinput Increment Down", ""}, | ||||
| {TFM_MODAL_PROPSIZE_UP, "PROPORTIONAL_SIZE_UP", 0, "Increase Proportional Influence", ""}, | {TFM_MODAL_PROPSIZE_UP, "PROPORTIONAL_SIZE_UP", 0, "Increase Proportional Influence", ""}, | ||||
| ▲ Show 20 Lines • Show All 247 Lines • ▼ Show 20 Lines | else if (event->type == MOUSEMOVE) { | ||||
| 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: | ||||
| if (!(t->modifiers & MOD_EDIT_SNAP_SOURCE)) { | |||||
| 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_SNAP_SOURCE)) { | |||||
| 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); | ||||
| resetTransRestrictions(t); | resetTransRestrictions(t); | ||||
| ▲ Show 20 Lines • Show All 268 Lines • ▼ Show 20 Lines | switch (event->val) { | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| } | } | ||||
| else if (event->prev_val == KM_RELEASE) { | else if (event->prev_val == KM_RELEASE) { | ||||
| t->modifiers &= ~MOD_PRECISION; | t->modifiers &= ~MOD_PRECISION; | ||||
| t->mouse.precision = 0; | t->mouse.precision = 0; | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| } | } | ||||
| break; | break; | ||||
| case TFM_MODAL_EDIT_SNAP_SOURCE: | |||||
| if (event->prev_val == KM_PRESS) { | |||||
| transform_mode_snap_source_init(t); | |||||
| } | |||||
| break; | |||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| /* Else do non-mapped events. */ | /* Else do non-mapped events. */ | ||||
| else if (event->val == KM_PRESS) { | else if (event->val == KM_PRESS) { | ||||
| switch (event->type) { | switch (event->type) { | ||||
| case EVT_CKEY: | case EVT_CKEY: | ||||
| ▲ Show 20 Lines • Show All 379 Lines • ▼ Show 20 Lines | if ((prop = RNA_struct_find_property(op->ptr, "snap_elements"))) { | ||||
| RNA_boolean_set(op->ptr, "use_snap_nonedit", (target & SCE_SNAP_TARGET_NOT_NONEDITED) == 0); | RNA_boolean_set(op->ptr, "use_snap_nonedit", (target & SCE_SNAP_TARGET_NOT_NONEDITED) == 0); | ||||
| RNA_boolean_set( | RNA_boolean_set( | ||||
| op->ptr, "use_snap_selectable", (target & SCE_SNAP_TARGET_ONLY_SELECTABLE) != 0); | op->ptr, "use_snap_selectable", (target & SCE_SNAP_TARGET_ONLY_SELECTABLE) != 0); | ||||
| } | } | ||||
| /* Update `ToolSettings` for properties that change during modal. */ | /* Update `ToolSettings` for properties that change during modal. */ | ||||
| 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->tsnap.status & SNAP_FORCED)) { | ||||
| if (!(t->modifiers & MOD_SNAP) != !(t->tsnap.flag & SCE_SNAP)) { | if (!(t->modifiers & MOD_SNAP) != !(t->tsnap.flag & SCE_SNAP)) { | ||||
| /* Type is #eSnapFlag, but type must match various snap attributes in #ToolSettings. */ | /* Type is #eSnapFlag, but type must match various snap attributes in #ToolSettings. */ | ||||
| short *snap_flag_ptr; | short *snap_flag_ptr; | ||||
| wmMsgParams_RNA msg_key_params = {{0}}; | wmMsgParams_RNA msg_key_params = {{0}}; | ||||
| RNA_pointer_create(&t->scene->id, &RNA_ToolSettings, ts, &msg_key_params.ptr); | RNA_pointer_create(&t->scene->id, &RNA_ToolSettings, ts, &msg_key_params.ptr); | ||||
| if (t->spacetype == SPACE_NODE) { | if (t->spacetype == SPACE_NODE) { | ||||
| ▲ Show 20 Lines • Show All 496 Lines • Show Last 20 Lines | |||||