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:
authorCampbell Barton <ideasman42@gmail.com>2012-03-30 14:00:20 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-30 14:00:20 +0400
commita32cc95fa87e50efbd2ea152ea44766614894a49 (patch)
tree1f61196b883adeb5fd3271b90014366525a7bf1d /source/blender/editors/util/numinput.c
parent28889a3500ee5dcb1a4851f2d6c40ec3800c968f (diff)
style cleanup
Diffstat (limited to 'source/blender/editors/util/numinput.c')
-rw-r--r--source/blender/editors/util/numinput.c320
1 files changed, 160 insertions, 160 deletions
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index 1d9e053376a..c037508687b 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -30,8 +30,8 @@
*/
-#include <math.h> /* fabs */
-#include <stdio.h> /* for size_t */
+#include <math.h> /* fabs */
+#include <stdio.h> /* for size_t */
#include "BLI_utildefines.h"
#include "BLI_string.h"
@@ -46,19 +46,19 @@
void initNumInput(NumInput *n)
{
- n->flag =
- n->idx =
- n->idx_max =
+ n->flag =
+ n->idx =
+ n->idx_max =
n->inv[0] =
n->inv[1] =
n->inv[2] =
- n->ctrl[0] =
- n->ctrl[1] =
- n->ctrl[2] = 0;
+ n->ctrl[0] =
+ n->ctrl[1] =
+ n->ctrl[2] = 0;
- n->val[0] =
- n->val[1] =
- n->val[2] = 0.0f;
+ n->val[0] =
+ n->val[1] =
+ n->val[2] = 0.0f;
}
void outputNumInput(NumInput *n, char *str)
@@ -67,7 +67,7 @@ void outputNumInput(NumInput *n, char *str)
char inv[] = "1/";
short i, j;
- for (j=0; j<=n->idx_max; j++) {
+ for (j = 0; j <= n->idx_max; j++) {
/* if AFFECTALL and no number typed and cursor not on number, use first number */
if (n->flag & NUM_AFFECT_ALL && n->idx != j && n->ctrl[j] == 0)
i = 0;
@@ -84,35 +84,35 @@ void outputNumInput(NumInput *n, char *str)
else
inv[0] = 0;
- if ( n->val[i] > 1e10f || n->val[i] < -1e10f )
- BLI_snprintf(&str[j*20], 20, "%s%.4e%c", inv, n->val[i], cur);
+ if (n->val[i] > 1e10f || n->val[i] < -1e10f)
+ BLI_snprintf(&str[j * 20], 20, "%s%.4e%c", inv, n->val[i], cur);
else
switch (n->ctrl[i]) {
- case 0:
- BLI_snprintf(&str[j*20], 20, "%sNONE%c", inv, cur);
- break;
- case 1:
- case -1:
- BLI_snprintf(&str[j*20], 20, "%s%.0f%c", inv, n->val[i], cur);
- break;
- case 10:
- case -10:
- BLI_snprintf(&str[j*20], 20, "%s%.f.%c", inv, n->val[i], cur);
- break;
- case 100:
- case -100:
- BLI_snprintf(&str[j*20], 20, "%s%.1f%c", inv, n->val[i], cur);
- break;
- case 1000:
- case -1000:
- BLI_snprintf(&str[j*20], 20, "%s%.2f%c", inv, n->val[i], cur);
- break;
- case 10000:
- case -10000:
- BLI_snprintf(&str[j*20], 20, "%s%.3f%c", inv, n->val[i], cur);
- break;
- default:
- BLI_snprintf(&str[j*20], 20, "%s%.4e%c", inv, n->val[i], cur);
+ case 0:
+ BLI_snprintf(&str[j * 20], 20, "%sNONE%c", inv, cur);
+ break;
+ case 1:
+ case -1:
+ BLI_snprintf(&str[j * 20], 20, "%s%.0f%c", inv, n->val[i], cur);
+ break;
+ case 10:
+ case -10:
+ BLI_snprintf(&str[j * 20], 20, "%s%.f.%c", inv, n->val[i], cur);
+ break;
+ case 100:
+ case -100:
+ BLI_snprintf(&str[j * 20], 20, "%s%.1f%c", inv, n->val[i], cur);
+ break;
+ case 1000:
+ case -1000:
+ BLI_snprintf(&str[j * 20], 20, "%s%.2f%c", inv, n->val[i], cur);
+ break;
+ case 10000:
+ case -10000:
+ BLI_snprintf(&str[j * 20], 20, "%s%.3f%c", inv, n->val[i], cur);
+ break;
+ default:
+ BLI_snprintf(&str[j * 20], 20, "%s%.4e%c", inv, n->val[i], cur);
}
}
}
@@ -121,7 +121,7 @@ short hasNumInput(NumInput *n)
{
short i;
- for (i=0; i<=n->idx_max; i++) {
+ for (i = 0; i <= n->idx_max; i++) {
if (n->ctrl[i])
return 1;
}
@@ -134,7 +134,7 @@ void applyNumInput(NumInput *n, float *vec)
short i, j;
if (hasNumInput(n)) {
- for (j=0; j<=n->idx_max; j++) {
+ for (j = 0; j <= n->idx_max; j++) {
/* if AFFECTALL and no number typed and cursor not on number, use first number */
if (n->flag & NUM_AFFECT_ALL && n->idx != j && n->ctrl[j] == 0)
i = 0;
@@ -166,138 +166,138 @@ char handleNumInput(NumInput *n, wmEvent *event)
if (event->type == EVT_MODAL_MAP) {
switch (event->val) {
- case NUM_MODAL_INCREMENT_UP:
- if (!n->ctrl[idx])
- n->ctrl[idx] = 1;
+ case NUM_MODAL_INCREMENT_UP:
+ if (!n->ctrl[idx])
+ n->ctrl[idx] = 1;
- n->val[idx] += n->increment;
- break;
- case NUM_MODAL_INCREMENT_DOWN:
- if (!n->ctrl[idx])
- n->ctrl[idx] = 1;
+ n->val[idx] += n->increment;
+ break;
+ case NUM_MODAL_INCREMENT_DOWN:
+ if (!n->ctrl[idx])
+ n->ctrl[idx] = 1;
- n->val[idx] -= n->increment;
- break;
- default:
- return 0;
+ n->val[idx] -= n->increment;
+ break;
+ default:
+ return 0;
}
}
else {
switch (event->type) {
- case BACKSPACEKEY:
- if (n->ctrl[idx] == 0) {
- n->val[0] =
- n->val[1] =
- n->val[2] = 0.0f;
- n->ctrl[0] =
- n->ctrl[1] =
- n->ctrl[2] = 0;
- n->inv[0] =
- n->inv[1] =
- n->inv[2] = 0;
- }
- else {
- n->val[idx] = 0.0f;
- n->ctrl[idx] = 0;
- n->inv[idx] = 0;
- }
- break;
- case PERIODKEY:
- case PADPERIOD:
- if (n->flag & NUM_NO_FRACTION)
- return 0;
-
- switch (n->ctrl[idx])
- {
- case 0:
- case 1:
- n->ctrl[idx] = 10;
- break;
- case -1:
- n->ctrl[idx] = -10;
- }
- break;
- case PADMINUS:
- if (event->alt)
+ case BACKSPACEKEY:
+ if (n->ctrl[idx] == 0) {
+ n->val[0] =
+ n->val[1] =
+ n->val[2] = 0.0f;
+ n->ctrl[0] =
+ n->ctrl[1] =
+ n->ctrl[2] = 0;
+ n->inv[0] =
+ n->inv[1] =
+ n->inv[2] = 0;
+ }
+ else {
+ n->val[idx] = 0.0f;
+ n->ctrl[idx] = 0;
+ n->inv[idx] = 0;
+ }
break;
- case MINUSKEY:
- if (n->flag & NUM_NO_NEGATIVE)
+ case PERIODKEY:
+ case PADPERIOD:
+ if (n->flag & NUM_NO_FRACTION)
+ return 0;
+
+ switch (n->ctrl[idx])
+ {
+ case 0:
+ case 1:
+ n->ctrl[idx] = 10;
+ break;
+ case -1:
+ n->ctrl[idx] = -10;
+ }
break;
+ case PADMINUS:
+ if (event->alt)
+ break;
+ case MINUSKEY:
+ if (n->flag & NUM_NO_NEGATIVE)
+ break;
- if (n->ctrl[idx]) {
- n->ctrl[idx] *= -1;
- n->val[idx] *= -1;
- }
- else
- n->ctrl[idx] = -1;
- break;
- case PADSLASHKEY:
- case SLASHKEY:
- if (n->flag & NUM_NO_FRACTION)
- return 0;
+ if (n->ctrl[idx]) {
+ n->ctrl[idx] *= -1;
+ n->val[idx] *= -1;
+ }
+ else
+ n->ctrl[idx] = -1;
+ break;
+ case PADSLASHKEY:
+ case SLASHKEY:
+ if (n->flag & NUM_NO_FRACTION)
+ return 0;
- n->inv[idx] = !n->inv[idx];
- break;
- case TABKEY:
- if (idx_max == 0)
- return 0;
+ n->inv[idx] = !n->inv[idx];
+ break;
+ case TABKEY:
+ if (idx_max == 0)
+ return 0;
- idx++;
- if (idx > idx_max)
- idx = 0;
- n->idx = idx;
- break;
- case PAD9:
- case NINEKEY:
- Val += 1.0f;
- case PAD8:
- case EIGHTKEY:
- Val += 1.0f;
- case PAD7:
- case SEVENKEY:
- Val += 1.0f;
- case PAD6:
- case SIXKEY:
- Val += 1.0f;
- case PAD5:
- case FIVEKEY:
- Val += 1.0f;
- case PAD4:
- case FOURKEY:
- Val += 1.0f;
- case PAD3:
- case THREEKEY:
- Val += 1.0f;
- case PAD2:
- case TWOKEY:
- Val += 1.0f;
- case PAD1:
- case ONEKEY:
- Val += 1.0f;
- case PAD0:
- case ZEROKEY:
- if (!n->ctrl[idx])
- n->ctrl[idx] = 1;
+ idx++;
+ if (idx > idx_max)
+ idx = 0;
+ n->idx = idx;
+ break;
+ case PAD9:
+ case NINEKEY:
+ Val += 1.0f;
+ case PAD8:
+ case EIGHTKEY:
+ Val += 1.0f;
+ case PAD7:
+ case SEVENKEY:
+ Val += 1.0f;
+ case PAD6:
+ case SIXKEY:
+ Val += 1.0f;
+ case PAD5:
+ case FIVEKEY:
+ Val += 1.0f;
+ case PAD4:
+ case FOURKEY:
+ Val += 1.0f;
+ case PAD3:
+ case THREEKEY:
+ Val += 1.0f;
+ case PAD2:
+ case TWOKEY:
+ Val += 1.0f;
+ case PAD1:
+ case ONEKEY:
+ Val += 1.0f;
+ case PAD0:
+ case ZEROKEY:
+ if (!n->ctrl[idx])
+ n->ctrl[idx] = 1;
- if (fabsf(n->val[idx]) > 9999999.0f);
- else if (n->ctrl[idx] == 1) {
- n->val[idx] *= 10;
- n->val[idx] += Val;
- }
- else if (n->ctrl[idx] == -1) {
- n->val[idx] *= 10;
- n->val[idx] -= Val;
- }
- else {
- /* float resolution breaks when over six digits after comma */
- if ( ABS(n->ctrl[idx]) < 10000000) {
- n->val[idx] += Val / (float)n->ctrl[idx];
- n->ctrl[idx] *= 10;
+ if (fabsf(n->val[idx]) > 9999999.0f) ;
+ else if (n->ctrl[idx] == 1) {
+ n->val[idx] *= 10;
+ n->val[idx] += Val;
}
- }
- break;
- default:
- return 0;
+ else if (n->ctrl[idx] == -1) {
+ n->val[idx] *= 10;
+ n->val[idx] -= Val;
+ }
+ else {
+ /* float resolution breaks when over six digits after comma */
+ if (ABS(n->ctrl[idx]) < 10000000) {
+ n->val[idx] += Val / (float)n->ctrl[idx];
+ n->ctrl[idx] *= 10;
+ }
+ }
+ break;
+ default:
+ return 0;
}
}