~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/editors/util/numinput.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
        char cur;
67
67
        char inv[] = "1/";
68
68
        short i, j;
 
69
        const int ln = NUM_STR_REP_LEN;
69
70
 
70
71
        for (j = 0; j <= n->idx_max; j++) {
71
72
                /* if AFFECTALL and no number typed and cursor not on number, use first number */
85
86
                        inv[0] = 0;
86
87
 
87
88
                if (n->val[i] > 1e10f || n->val[i] < -1e10f)
88
 
                        BLI_snprintf(&str[j * 20], 20, "%s%.4e%c", inv, n->val[i], cur);
 
89
                        BLI_snprintf(&str[j * ln], ln, "%s%.4e%c", inv, n->val[i], cur);
89
90
                else
90
91
                        switch (n->ctrl[i]) {
91
92
                                case 0:
92
 
                                        BLI_snprintf(&str[j * 20], 20, "%sNONE%c", inv, cur);
 
93
                                        BLI_snprintf(&str[j * ln], ln, "%sNONE%c", inv, cur);
93
94
                                        break;
94
95
                                case 1:
95
96
                                case -1:
96
 
                                        BLI_snprintf(&str[j * 20], 20, "%s%.0f%c", inv, n->val[i], cur);
 
97
                                        BLI_snprintf(&str[j * ln], ln, "%s%.0f%c", inv, n->val[i], cur);
97
98
                                        break;
98
99
                                case 10:
99
100
                                case -10:
100
 
                                        BLI_snprintf(&str[j * 20], 20, "%s%.f.%c", inv, n->val[i], cur);
 
101
                                        BLI_snprintf(&str[j * ln], ln, "%s%.f.%c", inv, n->val[i], cur);
101
102
                                        break;
102
103
                                case 100:
103
104
                                case -100:
104
 
                                        BLI_snprintf(&str[j * 20], 20, "%s%.1f%c", inv, n->val[i], cur);
 
105
                                        BLI_snprintf(&str[j * ln], ln, "%s%.1f%c", inv, n->val[i], cur);
105
106
                                        break;
106
107
                                case 1000:
107
108
                                case -1000:
108
 
                                        BLI_snprintf(&str[j * 20], 20, "%s%.2f%c", inv, n->val[i], cur);
 
109
                                        BLI_snprintf(&str[j * ln], ln, "%s%.2f%c", inv, n->val[i], cur);
109
110
                                        break;
110
111
                                case 10000:
111
112
                                case -10000:
112
 
                                        BLI_snprintf(&str[j * 20], 20, "%s%.3f%c", inv, n->val[i], cur);
 
113
                                        BLI_snprintf(&str[j * ln], ln, "%s%.3f%c", inv, n->val[i], cur);
113
114
                                        break;
114
115
                                default:
115
 
                                        BLI_snprintf(&str[j * 20], 20, "%s%.4e%c", inv, n->val[i], cur);
 
116
                                        BLI_snprintf(&str[j * ln], ln, "%s%.4e%c", inv, n->val[i], cur);
116
117
                        }
117
118
        }
118
119
}
129
130
        return 0;
130
131
}
131
132
 
 
133
/**
 
134
 * \warning \a vec must be set beforehand otherwise we risk uninitialized vars.
 
135
 */
132
136
void applyNumInput(NumInput *n, float *vec)
133
137
{
134
138
        short i, j;
207
211
                                if (n->flag & NUM_NO_FRACTION)
208
212
                                        return 0;
209
213
 
210
 
                                switch (n->ctrl[idx])
211
 
                                {
 
214
                                switch (n->ctrl[idx]) {
212
215
                                        case 0:
213
216
                                        case 1:
214
217
                                                n->ctrl[idx] = 10;
222
225
                                        break;
223
226
                        case MINUSKEY:
224
227
                                if (n->flag & NUM_NO_NEGATIVE)
225
 
                                        break;
 
228
                                        return 0;
226
229
 
227
230
                                if (n->ctrl[idx]) {
228
231
                                        n->ctrl[idx] *= -1;
279
282
                                if (!n->ctrl[idx])
280
283
                                        n->ctrl[idx] = 1;
281
284
 
282
 
                                if (fabsf(n->val[idx]) > 9999999.0f) ;
 
285
                                if (fabsf(n->val[idx]) > 9999999.0f) {
 
286
                                        /* pass */
 
287
                                }
283
288
                                else if (n->ctrl[idx] == 1) {
284
289
                                        n->val[idx] *= 10;
285
290
                                        n->val[idx] += Val;