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:
authorAntony Riakiotakis <kalast@gmail.com>2014-09-08 20:15:42 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-09-08 20:15:42 +0400
commitd9ffc99e66d659ac887d801b9cc071b4c3f9b8ab (patch)
treed88e83b5a9edab115081641d26c811b6aa22296a /source/blender/editors/util/numinput.c
parent551ebaa3dd758bc1975548c28766bfa3159d3846 (diff)
parentb1490e39dd1017e51984d8a34d226e869bbb25df (diff)
Merge branch 'master' into soc-2014-viewport_fxsoc-2014-viewport_fx
I have resolved some differences, for instance selection code which was more or less a stub, to be the same as master. This will have to be fixed later. Conflicts: CMakeLists.txt intern/ghost/CMakeLists.txt intern/ghost/intern/GHOST_SystemWin32.cpp intern/ghost/intern/GHOST_Window.cpp intern/ghost/intern/GHOST_WindowWin32.cpp intern/ghost/intern/GHOST_WindowX11.cpp source/blender/blenlib/BLI_math_matrix.h source/blender/blenlib/intern/math_matrix.c source/blender/gpu/CMakeLists.txt source/blender/gpu/GPU_select.h source/blender/gpu/intern/gpu_buffers.c source/blender/gpu/intern/gpu_draw.c source/blender/gpu/intern/gpu_extensions.c source/blender/gpu/intern/gpu_select.c source/blender/gpu/shaders/gpu_shader_simple_vert.glsl source/blender/nodes/CMakeLists.txt
Diffstat (limited to 'source/blender/editors/util/numinput.c')
-rw-r--r--source/blender/editors/util/numinput.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index a618ab8419b..a154f12a786 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -33,6 +33,7 @@
#include "BLI_string_cursor_utf8.h"
#include "BKE_context.h"
+#include "BKE_scene.h"
#include "BKE_unit.h"
#include "DNA_scene_types.h"
@@ -87,7 +88,7 @@ void initNumInput(NumInput *n)
}
/* str must be NUM_STR_REP_LEN * (idx_max + 1) length. */
-void outputNumInput(NumInput *n, char *str, const float scale_length)
+void outputNumInput(NumInput *n, char *str, UnitSettings *unit_settings)
{
short j;
const int ln = NUM_STR_REP_LEN;
@@ -98,7 +99,7 @@ void outputNumInput(NumInput *n, char *str, const float scale_length)
const short i = (n->flag & NUM_AFFECT_ALL && n->idx != j && !(n->val_flag[j] & NUM_EDITED)) ? 0 : j;
/* Use scale_length if needed! */
- const float fac = ELEM3(n->unit_type[j], B_UNIT_LENGTH, B_UNIT_AREA, B_UNIT_VOLUME) ? scale_length : 1.0f;
+ const float fac = (float)BKE_scene_unit_scale(unit_settings, n->unit_type[j], 1.0);
if (n->val_flag[i] & NUM_EDITED) {
/* Get the best precision, allows us to draw '10.0001' as '10' instead! */
@@ -189,15 +190,15 @@ bool applyNumInput(NumInput *n, float *vec)
if (n->val_flag[i] & NUM_NO_NEGATIVE && val < 0.0f) {
val = 0.0f;
}
- if (n->val_flag[i] & NUM_NO_ZERO && val == 0.0f) {
- val = 0.0001f;
- }
if (n->val_flag[i] & NUM_NO_FRACTION && val != floorf(val)) {
val = floorf(val + 0.5f);
if (n->val_flag[i] & NUM_NO_ZERO && val == 0.0f) {
val = 1.0f;
}
}
+ else if (n->val_flag[i] & NUM_NO_ZERO && val == 0.0f) {
+ val = 0.0001f;
+ }
}
vec[j] = val;
}
@@ -442,6 +443,13 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
}
}
+ /* Up to this point, if we have a ctrl modifier, skip.
+ * This allows to still access most of modals' shortcuts even in numinput mode.
+ */
+ if (!updated && event->ctrl) {
+ return false;
+ }
+
if ((!utf8_buf || !utf8_buf[0]) && ascii[0]) {
/* Fallback to ascii. */
utf8_buf = ascii;
@@ -471,26 +479,24 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
#ifdef WITH_PYTHON
Scene *sce = CTX_data_scene(C);
double val;
- float fac = 1.0f;
char str_unit_convert[NUM_STR_REP_LEN * 6]; /* Should be more than enough! */
const char *default_unit = NULL;
+ /* Use scale_length if needed! */
+ const float fac = (float)BKE_scene_unit_scale(&sce->unit, n->unit_type[idx], 1.0);
+
/* Make radian default unit when needed. */
if (n->unit_use_radians && n->unit_type[idx] == B_UNIT_ROTATION)
default_unit = "r";
- /* Use scale_length if needed! */
- if (ELEM3(n->unit_type[idx], B_UNIT_LENGTH, B_UNIT_AREA, B_UNIT_VOLUME))
- fac /= sce->unit.scale_length;
-
BLI_strncpy(str_unit_convert, n->str, sizeof(str_unit_convert));
- bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), default_unit, 1.0,
+ bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), default_unit, fac,
n->unit_sys, n->unit_type[idx]);
/* Note: with angles, we always get values as radians here... */
if (BPY_button_exec(C, str_unit_convert, &val, false) != -1) {
- n->val[idx] = (float)val * fac;
+ n->val[idx] = (float)val;
n->val_flag[idx] &= ~NUM_INVALID;
}
else {