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>2013-12-21 20:11:43 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2013-12-21 20:44:48 +0400
commit87cc890aef53c4660448b1125dc0c40a187ae1f2 (patch)
tree5742d07986fa362b4f17590129dd8c5692cd51b7 /source/blender/editors/include/ED_numinput.h
parentf72b86da8cab4bff482fc58095d14c97823fa39f (diff)
Support units in modal numinput
Summary: This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value. We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so). Features: - units (cm, ", deg, etc.). - basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.). - you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything. - you can go to next/previous value with (ctrl-)TAB key. - As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse. Notes: - Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent. - Added back radian support in BKE_unit. - Added arcminute/arcsecond to BKE_unit. (those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units). Related to T37600. Reviewers: brecht, campbellbarton, carter2422 Reviewed By: brecht, campbellbarton, carter2422 Thanks everybody! Differential Revision: http://developer.blender.org/D61
Diffstat (limited to 'source/blender/editors/include/ED_numinput.h')
-rw-r--r--source/blender/editors/include/ED_numinput.h55
1 files changed, 32 insertions, 23 deletions
diff --git a/source/blender/editors/include/ED_numinput.h b/source/blender/editors/include/ED_numinput.h
index f46332c9a82..e44dab7bff0 100644
--- a/source/blender/editors/include/ED_numinput.h
+++ b/source/blender/editors/include/ED_numinput.h
@@ -27,40 +27,49 @@
#ifndef __ED_NUMINPUT_H__
#define __ED_NUMINPUT_H__
-/*
- * The ctrl value has different meaning:
- * 0 : No value has been typed
- *
- * otherwise, |value| - 1 is where the cursor is located after the period
- * Positive : number is positive
- * Negative : number is negative
- */
+#define NUM_STR_REP_LEN 64
+#define NUM_MAX_ELEMENTS 3
typedef struct NumInput {
- short idx;
- short idx_max;
- short flag; /* Different flags to indicate different behaviors */
- char inv[3]; /* If the value is inverted or not */
- float val[3]; /* Direct value of the input */
- int ctrl[3]; /* Control to indicate what to do with the numbers that are typed */
- float increment;
+ short idx_max; /* idx_max < NUM_MAX_ELEMENTS */
+ int unit_sys;
+ int unit_type[NUM_MAX_ELEMENTS]; /* Each value can have a different type */
+ bool unit_use_radians;
+
+ short flag; /* Flags affecting all values' behavior */
+ short val_flag[NUM_MAX_ELEMENTS]; /* Per-value flags */
+ float val[NUM_MAX_ELEMENTS]; /* Direct value of the input */
+ float val_org[NUM_MAX_ELEMENTS]; /* Original value of the input, for reset */
+ float val_inc[NUM_MAX_ELEMENTS]; /* Increment steps */
+
+ short idx; /* Active element/value */
+ char str[NUM_STR_REP_LEN]; /* String as typed by user for edited value (we assume ASCII world!) */
+ /* Current position of cursor in edited value str (first byte of "current" letter, so 0 for an empty str) */
+ int str_cur;
} NumInput;
-/* NUMINPUT FLAGS */
-#define NUM_NULL_ONE 2
-#define NUM_NO_NEGATIVE 4
-#define NUM_NO_ZERO 8
-#define NUM_NO_FRACTION 16
-#define NUM_AFFECT_ALL 32
+/* NumInput.flag */
+enum {
+ NUM_AFFECT_ALL = (1 << 0),
+};
+
+/* NumInput.val_flag[] */
+enum {
+ /* Public! */
+ NUM_NULL_ONE = (1 << 0),
+ NUM_NO_NEGATIVE = (1 << 1),
+ NUM_NO_ZERO = (1 << 2),
+ NUM_NO_FRACTION = (1 << 3),
+ /* (1 << 9) and above are reserved for internal flags! */
+};
/*********************** NumInput ********************************/
void initNumInput(NumInput *n);
-#define NUM_STR_REP_LEN 20 /* str must be NUM_STR_LEN * (idx_max + 1) length. */
void outputNumInput(NumInput *n, char *str);
bool hasNumInput(const NumInput *n);
void applyNumInput(NumInput *n, float *vec);
-bool handleNumInput(NumInput *n, const struct wmEvent *event);
+bool handleNumInput(struct bContext *C, NumInput *n, const struct wmEvent *event);
#define NUM_MODAL_INCREMENT_UP 18
#define NUM_MODAL_INCREMENT_DOWN 19