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>2015-09-17 14:50:40 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-09-17 15:09:18 +0300
commitc4bcb6a479c0a416fc66204b95017436bc0e2975 (patch)
treedc3cf94d2d9c59f70fd0650a0711f302b0a638f7 /source/blender/editors/interface/interface.c
parent209ca1e746b246a2bccd240eb9126a927bcd81f1 (diff)
Fix T46134: units degrees increment are too small
The user interface was ignoring the precision step size for degrees, making all rotation inputs drag by a 100th of a degree. Now use a 10th of a degree instead.
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r--source/blender/editors/interface/interface.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index e40e4f1a1dd..5a70dc85530 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2087,14 +2087,32 @@ static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double va
static float ui_get_but_step_unit(uiBut *but, float step_default)
{
int unit_type = RNA_SUBTYPE_UNIT_VALUE(UI_but_unit_type_get(but));
- double step;
-
- step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, step_default), but->block->unit->system, unit_type);
+ const double step_orig = step_default * UI_PRECISION_FLOAT_SCALE;
+ /* Scaling up 'step_origg ' here is a bit arbitrary, its just giving better scales from user POV */
+ const double scale_step = ui_get_but_scale_unit(but, step_orig * 10);
+ const double step = bUnit_ClosestScalar(scale_step, but->block->unit->system, unit_type);
/* -1 is an error value */
if (step != -1.0) {
+ const double scale_unit = ui_get_but_scale_unit(but, 1.0);
+ const double step_unit = bUnit_ClosestScalar(scale_unit, but->block->unit->system, unit_type);
+ double step_final;
+
BLI_assert(step > 0.0);
- return (float)(step / ui_get_but_scale_unit(but, 1.0));
+
+ step_final = (step / scale_unit) / UI_PRECISION_FLOAT_SCALE;
+
+ if (step == step_unit) {
+ /* Logic here is to scale by the original 'step_orig'
+ * only when the unit step matches the scaled step.
+ *
+ * This is needed for units that don't have a wide range of scales (degrees for eg.).
+ * Without this we can't select between a single degree, or a 10th of a degree.
+ */
+ step_final *= step_orig;
+ }
+
+ return (float)step_final;
}
else {
return step_default;