[Bf-blender-cvs] [7148c97] master: Fix T39312 Multipling two values in the Transform Tools Number Input not possible.

Bastien Montagne noreply at git.blender.org
Fri Mar 21 12:36:42 CET 2014


Commit: 7148c97796723d9f074bdf5acd244be02c54b814
Author: Bastien Montagne
Date:   Fri Mar 21 12:05:13 2014 +0100
https://developer.blender.org/rB7148c97796723d9f074bdf5acd244be02c54b814

Fix T39312 Multipling two values in the Transform Tools Number Input not possible.

There was actually a few bugs in new event handling of numinput :/

In case of 2.70 'a' release, this commit should be considered imho.

===================================================================

M	source/blender/editors/util/numinput.c

===================================================================

diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index 1f3725a..980582b 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -321,8 +321,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
 			n->val_org[idx] = n->val[idx];
 			n->val_flag[idx] &= ~(NUM_NEGATE | NUM_INVERSE);
 
-			idx += event->ctrl ? -1 : 1;
-			idx %= idx_max + 1;
+			idx = (idx + idx_max + (event->ctrl ? 0 : 2)) % (idx_max + 1);
 			n->idx = idx;
 			n->val[idx] = n->val_org[idx];
 			if (n->val_flag[idx] & NUM_EDITED) {
@@ -338,38 +337,43 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
 			ascii[0] = '.';
 			utf8_buf = ascii;
 			break;
+#if 0  /* Those keys are not directly accessible in all layouts, preventing to generate matching events.
+        * So we use a hack (ascii value) instead, see below.
+        */
 		case EQUALKEY:
-			/* XXX Advanced mode toggle, hack around keyboards without direct access to '=' nor '*'... */
-			ascii[0] = '=';
-			break;
 		case PADASTERKEY:
-			/* XXX Advanced mode toggle, hack around keyboards without direct access to '=' nor '*'... */
-			ascii[0] = '*';
+			if (!(n->flag & NUM_EDIT_FULL)) {
+				n->flag |= NUM_EDIT_FULL;
+				n->val_flag[idx] |= NUM_EDITED;
+				return true;
+			}
+			else if (event->ctrl) {
+				n->flag &= ~NUM_EDIT_FULL;
+				return true;
+			}
 			break;
+#endif
 		case PADMINUS:
 		case MINUSKEY:
 			if (event->ctrl || !(n->flag & NUM_EDIT_FULL)) {
 				n->val_flag[idx] ^= NUM_NEGATE;
 				updated = true;
-				break;
 			}
-			/* fall-through */
+			break;
 		case PADSLASHKEY:
 		case SLASHKEY:
 			if (event->ctrl || !(n->flag & NUM_EDIT_FULL)) {
 				n->val_flag[idx] ^= NUM_INVERSE;
 				updated = true;
-				break;
 			}
-			/* fall-through */
+			break;
 		case CKEY:
 			if (event->ctrl) {
 				/* Copy current str to the copypaste buffer. */
 				WM_clipboard_text_set(n->str, 0);
 				updated = true;
-				break;
 			}
-			/* fall-through */
+			break;
 		case VKEY:
 			if (event->ctrl) {
 				/* extract the first line from the clipboard */
@@ -377,9 +381,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
 				char *pbuf = WM_clipboard_text_get_firstline(false, &pbuf_len);
 
 				if (pbuf) {
-					bool success;
-
-					success = editstr_insert_at_cursor(n, pbuf, pbuf_len);
+					const bool success = editstr_insert_at_cursor(n, pbuf, pbuf_len);
 
 					MEM_freeN(pbuf);
 					if (!success) {
@@ -389,15 +391,17 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
 					n->val_flag[idx] |= NUM_EDITED;
 				}
 				updated = true;
-				break;
 			}
-			/* fall-through */
+			break;
 		default:
-			utf8_buf = event->utf8_buf;
-			ascii[0] = event->ascii;
 			break;
 	}
 
+	if (!updated && !utf8_buf && (event->utf8_buf[0] || event->ascii)) {
+		utf8_buf = event->utf8_buf;
+		ascii[0] = event->ascii;
+	}
+
 	/* XXX Hack around keyboards without direct access to '=' nor '*'... */
 	if (ELEM(ascii[0], '=', '*')) {
 		if (!(n->flag & NUM_EDIT_FULL)) {
@@ -411,7 +415,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
 		}
 	}
 
-	if (utf8_buf && !utf8_buf[0] && ascii[0]) {
+	if ((!utf8_buf || !utf8_buf[0]) && ascii[0]) {
 		/* Fallback to ascii. */
 		utf8_buf = ascii;
 	}




More information about the Bf-blender-cvs mailing list