Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/transform/transform.c')
-rw-r--r--source/blender/editors/transform/transform.c59
1 files changed, 53 insertions, 6 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index ae4c3f02c46..c376c718245 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -578,6 +578,21 @@ static void viewRedrawPost(bContext *C, TransInfo *t)
static bool transform_modal_item_poll(const wmOperator *op, int value)
{
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_SNAP_INV_ON,
+ TFM_MODAL_SNAP_INV_OFF,
+ TFM_MODAL_ADD_SNAP,
+ TFM_MODAL_REMOVE_SNAP)) {
+ return false;
+ }
+ }
+
switch (value) {
case TFM_MODAL_CANCEL: {
/* TODO: Canceling with LMB is not possible when the operator is activated
@@ -593,6 +608,13 @@ static bool transform_modal_item_poll(const wmOperator *op, int value)
}
break;
}
+ case TFM_MODAL_SNAP_INV_ON:
+ case TFM_MODAL_SNAP_INV_OFF: {
+ if (t->modifiers & MOD_SNAP_TEMP) {
+ return false;
+ }
+ break;
+ }
case TFM_MODAL_ADD_SNAP:
case TFM_MODAL_REMOVE_SNAP: {
if (t->spacetype != SPACE_VIEW3D) {
@@ -664,6 +686,19 @@ static bool transform_modal_item_poll(const wmOperator *op, int value)
}
break;
}
+ case TFM_MODAL_EDIT_SNAP_SOURCE: {
+ if (t->spacetype != SPACE_VIEW3D) {
+ return false;
+ }
+ if (t->flag & T_RELEASE_CONFIRM) {
+ 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;
}
@@ -714,6 +749,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
{TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""},
{TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint Plane", ""},
{TFM_MODAL_PRECISION, "PRECISION", 0, "Precision Mode", ""},
+ {TFM_MODAL_EDIT_SNAP_SOURCE, "EDIT_SNAP_SOURCE", 0, "Snap Source Toggle", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -891,7 +927,12 @@ int transformEvent(TransInfo *t, const wmEvent *event)
handled = true;
break;
case TFM_MODAL_CONFIRM:
- t->state = TRANS_CONFIRM;
+ if (t->modifiers & MOD_EDIT_SNAP_SOURCE) {
+ tranform_snap_source_mod_confirm(t);
+ }
+ else {
+ t->state = TRANS_CONFIRM;
+ }
handled = true;
break;
case TFM_MODAL_TRANSLATE:
@@ -1156,6 +1197,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
t->redraw |= TREDRAW_HARD;
}
break;
+ case TFM_MODAL_EDIT_SNAP_SOURCE:
+ tranform_snap_source_mod_toggle(t);
+ break;
/* Those two are only handled in transform's own handler, see T44634! */
case TFM_MODAL_EDGESLIDE_UP:
case TFM_MODAL_EDGESLIDE_DOWN:
@@ -1532,7 +1576,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
if (t->flag & T_MODAL) {
/* 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;
@@ -1920,14 +1964,17 @@ void transformApply(bContext *C, TransInfo *t)
if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) {
selectConstraint(t);
- if (t->transform) {
+ if (t->modifiers & MOD_EDIT_SNAP_SOURCE) {
+ tranform_snap_source_mod_update(t);
+ }
+ else if (t->transform) {
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);
+ t->redraw = TREDRAW_NOTHING;
}
/* If auto confirm is on, break after one pass */