diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-09-17 14:50:40 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-09-17 15:09:18 +0300 |
commit | c4bcb6a479c0a416fc66204b95017436bc0e2975 (patch) | |
tree | dc3cf94d2d9c59f70fd0650a0711f302b0a638f7 /source/blender/editors | |
parent | 209ca1e746b246a2bccd240eb9126a927bcd81f1 (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')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 26 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 4 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 10 |
4 files changed, 28 insertions, 14 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 5550c0651a6..ba3e3a61aee 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1040,6 +1040,8 @@ void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p); /* Float precision helpers */ #define UI_PRECISION_FLOAT_MAX 7 +/* For float buttons the 'step' (or a1), is scaled */ +#define UI_PRECISION_FLOAT_SCALE 0.01f /* Typical UI text */ #define UI_FSTYLE_WIDGET (const uiFontStyle *)&(UI_style_get()->widget) 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; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 995dc198cf3..fe5a5031725 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4291,7 +4291,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (mx < (but->rect.xmin + handlewidth)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - tempf = (float)data->value - 0.01f * but->a1; + tempf = (float)data->value - (UI_PRECISION_FLOAT_SCALE * but->a1); if (tempf < softmin) tempf = softmin; data->value = tempf; @@ -4300,7 +4300,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton else if (mx > but->rect.xmax - handlewidth) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - tempf = (float)data->value + 0.01f * but->a1; + tempf = (float)data->value + (UI_PRECISION_FLOAT_SCALE * but->a1); if (tempf > softmax) tempf = softmax; data->value = tempf; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 4c8eda447d4..c6d0d6cde2e 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -643,8 +643,6 @@ static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot) static void TRANSFORM_OT_trackball(struct wmOperatorType *ot) { - PropertyRNA *prop; - /* identifiers */ ot->name = "Trackball"; ot->description = "Trackball style rotation of selected items"; @@ -659,16 +657,13 @@ static void TRANSFORM_OT_trackball(struct wmOperatorType *ot) ot->poll = ED_operator_screenactive; /* Maybe we could use float_vector_xyz here too? */ - prop = RNA_def_float_vector(ot->srna, "value", 2, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -FLT_MAX, FLT_MAX); - RNA_def_property_subtype(prop, PROP_ANGLE); + RNA_def_float_rotation(ot->srna, "value", 2, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -FLT_MAX, FLT_MAX); Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT); } static void TRANSFORM_OT_rotate(struct wmOperatorType *ot) { - PropertyRNA *prop; - /* identifiers */ ot->name = "Rotate"; ot->description = "Rotate selected items"; @@ -682,8 +677,7 @@ static void TRANSFORM_OT_rotate(struct wmOperatorType *ot) ot->cancel = transform_cancel; ot->poll = ED_operator_screenactive; - prop = RNA_def_float(ot->srna, "value", 0.0f, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2); - RNA_def_property_subtype(prop, PROP_ANGLE); + RNA_def_float_rotation(ot->srna, "value", 0, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2); Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_GPENCIL_EDIT); } |