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:
authorBastien Montagne <montagne29@wanadoo.fr>2014-02-20 09:11:36 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-02-20 09:11:36 +0400
commit32d6f853f33c107fd3afbff7845269c41c2686d4 (patch)
tree07cacb4da52fc6972e19d448d9d7794266c7d54a /source/blender/editors/util/numinput.c
parent9a5b61cf581c3aa4e6179c326902ffe071a1fcec (diff)
Transform: revert to 2.69 numeric input behavior by default
This allows to get the same "quickies" as in previous (2.69) code, (XYZ, -/, etc.), yet keeping nice non-conflicting new stuff like cursor navigation or copy/paste. You can switch to full mode hitting '=', and back to simple mode hitting 'ctrl ='.
Diffstat (limited to 'source/blender/editors/util/numinput.c')
-rw-r--r--source/blender/editors/util/numinput.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index 628492d459d..158ff42a57b 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -55,6 +55,7 @@ enum {
NUM_INVALID = (1 << 10), /* Current expression for this value is invalid. */
NUM_NEGATE = (1 << 11), /* Current expression's result has to be negated. */
NUM_INVERSE = (1 << 12), /* Current expression's result has to be inverted. */
+ NUM_EDIT_FULL = (1 << 13), /* Enable full editing, with units and math operators support. */
};
/* ************************** Functions *************************** */
@@ -207,6 +208,19 @@ static bool editstr_insert_at_cursor(NumInput *n, const char *buf, const int buf
return true;
}
+static bool editstr_is_simple_numinput(const char ascii)
+{
+ if (ascii >= '0' && ascii <= '9') {
+ return true;
+ }
+ else if (ascii == '.') {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
{
const char *utf8_buf = NULL;
@@ -319,9 +333,19 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
ascii[0] = '.';
utf8_buf = ascii;
break;
+ case EQUALKEY:
+ if (!(n->flag & NUM_EDIT_FULL)) {
+ n->flag |= NUM_EDIT_FULL;
+ return true;
+ }
+ else if (event->ctrl) {
+ n->flag &= ~NUM_EDIT_FULL;
+ return true;
+ }
+ /* fall-through */
case PADMINUS:
case MINUSKEY:
- if (event->ctrl) {
+ if (event->ctrl || !(n->flag & NUM_EDIT_FULL)) {
n->val_flag[idx] ^= NUM_NEGATE;
updated = true;
break;
@@ -329,7 +353,7 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
/* fall-through */
case PADSLASHKEY:
case SLASHKEY:
- if (event->ctrl) {
+ if (event->ctrl || !(n->flag & NUM_EDIT_FULL)) {
n->val_flag[idx] ^= NUM_INVERSE;
updated = true;
break;
@@ -377,6 +401,14 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
}
if (utf8_buf && utf8_buf[0]) {
+ if (!(n->flag & NUM_EDIT_FULL)) {
+ /* In simple edit mode, we only keep a few chars as valid! */
+ /* no need to decode unicode, ascii is first char only */
+ if (!editstr_is_simple_numinput(utf8_buf[0])) {
+ return false;
+ }
+ }
+
if (!editstr_insert_at_cursor(n, utf8_buf, BLI_str_utf8_size(utf8_buf))) {
return false;
}