2
* $Id: transform_numinput.c,v 1.8 2005/06/05 14:26:45 theeth Exp $
4
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version. The Blender
10
* Foundation also sells licenses for use in proprietary software under
11
* the Blender License. See http://www.blender.org/BL/ for information
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software Foundation,
21
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24
* All rights reserved.
26
* The Original Code is: all of this file.
28
* Contributor(s): none yet.
30
* ***** END GPL/BL DUAL LICENSE BLOCK *****
47
#include "MEM_guardedalloc.h"
49
#include "BKE_global.h" /* for G */
55
#include "BLI_arithb.h"
57
#include "transform.h"
59
/* ************************** Functions *************************** */
61
/* ************************** NUMINPUT **************************** */
63
void outputNumInput(NumInput *n, char *str)
68
for (j=0; j<=n->idx_max; j++) {
69
/* if AFFECTALL and no number typed and cursor not on number, use first number */
70
if (n->flag & NUM_AFFECT_ALL && n->idx != j && n->ctrl[j] == 0)
82
sprintf(&str[j*20], "NONE%c", cur);
86
sprintf(&str[j*20], "%.0f%c", n->val[i], cur);
90
sprintf(&str[j*20], "%.f.%c", n->val[i], cur);
94
sprintf(&str[j*20], "%.1f%c", n->val[i], cur);
98
sprintf(&str[j*20], "%.2f%c", n->val[i], cur);
101
sprintf(&str[j*20], "%.3f%c", n->val[i], cur);
104
sprintf(&str[j*20], "%.4f%c", n->val[i], cur);
109
short hasNumInput(NumInput *n)
113
for (i=0; i<=n->idx_max; i++) {
121
void applyNumInput(NumInput *n, float *vec)
125
if (hasNumInput(n)) {
126
for (j=0; j<=n->idx_max; j++) {
127
/* if AFFECTALL and no number typed and cursor not on number, use first number */
128
if (n->flag & NUM_AFFECT_ALL && n->idx != j && n->ctrl[j] == 0)
133
if (n->ctrl[i] == 0 && n->flag & NUM_NULL_ONE) {
136
else if (n->val[i] == 0.0f && n->flag & NUM_NO_ZERO) {
146
char handleNumInput(NumInput *n, unsigned short event)
149
short idx = n->idx, idx_max = n->idx_max;
153
if (n->ctrl[idx] == 0) {
168
if (n->flag & NUM_NO_FRACTION)
171
switch (n->ctrl[idx])
182
if(G.qual & LR_ALTKEY)
185
if (n->flag & NUM_NO_NEGATIVE)
233
if (n->ctrl[idx] == 1) {
237
else if (n->ctrl[idx] == -1) {
242
n->val[idx] += Val / (float)n->ctrl[idx];
249
/* REDRAW SINCE NUMBERS HAVE CHANGED */