diff options
author | Martin Poirier <theeth@yahoo.com> | 2005-03-14 00:42:22 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2005-03-14 00:42:22 +0300 |
commit | fd4ad35d4ca04fe35c4a6cdf9cd7385fd56a6106 (patch) | |
tree | 0fe2123d62931d372b9983b159fcd207e94ed422 /source/blender/src/transform_numinput.c | |
parent | 60b0e67e328e23d64713887d60bf4714c42ed820 (diff) |
New AFFECTALL flag for numinput
When that flag is set, numbers typed when the cursor is on the first position will affect all positions who do not currently have something typed for them.
Enabled Skey, 2, Enter to quickly double the size of something.
All modesty asside, it's coded rather smartly so it shows the cursor in every position that it will affect and lets you tab in undefined position to type in values there.
Thanks to Samadam for reminding me that the old code permitted that.
Diffstat (limited to 'source/blender/src/transform_numinput.c')
-rwxr-xr-x | source/blender/src/transform_numinput.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/source/blender/src/transform_numinput.c b/source/blender/src/transform_numinput.c index b94dcff3e05..c83955f46f7 100755 --- a/source/blender/src/transform_numinput.c +++ b/source/blender/src/transform_numinput.c @@ -63,9 +63,14 @@ void outputNumInput(NumInput *n, char *str) { char cur; - short i; + short i, j; - for (i=0; i<=n->idx_max; i++) { + for (j=0; j<=n->idx_max; j++) { + /* if AFFECTALL and no number typed and cursor not on number, use first number */ + if (n->flags & AFFECTALL && n->idx != j && n->ctrl[j] == 0) + i = 0; + else + i = j; if (n->idx != i) cur = ' '; @@ -74,60 +79,65 @@ void outputNumInput(NumInput *n, char *str) switch (n->ctrl[i]) { case 0: - sprintf(&str[i*20], "NONE%c", cur); + sprintf(&str[j*20], "NONE%c", cur); break; case 1: case -1: - sprintf(&str[i*20], "%.0f%c", n->val[i], cur); + sprintf(&str[j*20], "%.0f%c", n->val[i], cur); break; case 10: case -10: - sprintf(&str[i*20], "%.f.%c", n->val[i], cur); + sprintf(&str[j*20], "%.f.%c", n->val[i], cur); break; case 100: case -100: - sprintf(&str[i*20], "%.1f%c", n->val[i], cur); + sprintf(&str[j*20], "%.1f%c", n->val[i], cur); break; case 1000: case -1000: - sprintf(&str[i*20], "%.2f%c", n->val[i], cur); + sprintf(&str[j*20], "%.2f%c", n->val[i], cur); case 10000: case -10000: - sprintf(&str[i*20], "%.3f%c", n->val[i], cur); + sprintf(&str[j*20], "%.3f%c", n->val[i], cur); break; default: - sprintf(&str[i*20], "%.4f%c", n->val[i], cur); + sprintf(&str[j*20], "%.4f%c", n->val[i], cur); } } } short hasNumInput(NumInput *n) { - short doit = 0; short i; for (i=0; i<=n->idx_max; i++) { if (n->ctrl[i]) - doit = 1; + return 1; } - return doit; + return 0; } void applyNumInput(NumInput *n, float *vec) { - short i; + short i, j; if (hasNumInput(n)) { - for (i=0; i<=n->idx_max; i++) { + for (j=0; j<=n->idx_max; j++) { + /* if AFFECTALL and no number typed and cursor not on number, use first number */ + if (n->flags & AFFECTALL && n->idx != j && n->ctrl[j] == 0) + i = 0; + else + i = j; + if (n->ctrl[i] == 0 && n->flags & NULLONE) { - vec[i] = 1.0f; + vec[j] = 1.0f; } else if (n->val[i] == 0.0f && n->flags & NOZERO) { - vec[i] = 0.0001f; + vec[j] = 0.0001f; } else { - vec[i] = n->val[i]; + vec[j] = n->val[i]; } } } |