[Bf-blender-cvs] [338d9e1] wiggly-widgets: Don't offset arrow widget range by property min value

Julian Eisel noreply at git.blender.org
Thu Sep 10 02:15:00 CEST 2015


Commit: 338d9e128f013d07ff978cc0b1fbf9070c998fdd
Author: Julian Eisel
Date:   Thu Sep 10 01:59:33 2015 +0200
Branches: wiggly-widgets
https://developer.blender.org/rB338d9e128f013d07ff978cc0b1fbf9070c998fdd

Don't offset arrow widget range by property min value

Previously, the min value of the arrow range was set to be at the origin, but figured out in most cases this is actually not wanted (e.g: force field strength widget min value is -200, meaning at strength=0, the widget would be offset 200 pixels; camera focal length widget min value is 1, meaning widget was constantly offset by -1). Instead, the origin should be where the value of the property is 0.

This might still be wanted for some future cases, so leaving old behavior #ifdef'ed out.

===================================================================

M	source/blender/windowmanager/intern/wm_generic_widgets.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_generic_widgets.c b/source/blender/windowmanager/intern/wm_generic_widgets.c
index fc2bdb6..c7ffc27 100644
--- a/source/blender/windowmanager/intern/wm_generic_widgets.c
+++ b/source/blender/windowmanager/intern/wm_generic_widgets.c
@@ -378,6 +378,10 @@ static void widget_arrow_draw(const bContext *UNUSED(C), wmWidget *widget)
 	arrow_draw_intern((ArrowWidget *)widget, false, (widget->flag & WM_WIDGET_HIGHLIGHT) != 0);
 }
 
+/* calculate arrow offset independent from prop min value,
+ * meaning the range will not be offset by min value first */
+#define USE_ABS_HANDLE_RANGE
+
 static int widget_arrow_handler(bContext *C, const wmEvent *event, wmWidget *widget)
 {
 	ArrowWidget *arrow = (ArrowWidget *)widget;
@@ -475,7 +479,11 @@ static int widget_arrow_handler(bContext *C, const wmEvent *event, wmWidget *wid
 			if (arrow->style & WIDGET_ARROW_STYLE_INVERTED)
 				value = max - (value * arrow->range / arrow->range_fac);
 			else
+#ifdef USE_ABS_HANDLE_RANGE
+				value = value * arrow->range / arrow->range_fac;
+#else
 				value = arrow->min + (value * arrow->range / arrow->range_fac);
+#endif
 		}
 
 		/* clamp to custom range */
@@ -493,7 +501,11 @@ static int widget_arrow_handler(bContext *C, const wmEvent *event, wmWidget *wid
 			if (arrow->style & WIDGET_ARROW_STYLE_INVERTED)
 				arrow->offset = arrow->range_fac * (max - value) / arrow->range;
 			else
+#ifdef USE_ABS_HANDLE_RANGE
+				arrow->offset = arrow->range_fac * (value / arrow->range);
+#else
 				arrow->offset = arrow->range_fac * ((value - arrow->min) / arrow->range);
+#endif
 		}
 		else
 			arrow->offset = value;
@@ -559,7 +571,11 @@ static void widget_arrow_bind_to_prop(wmWidget *widget, const int UNUSED(slot))
 				arrow->offset = arrow->range_fac * (max - float_prop) / arrow->range;
 			}
 			else {
+#ifdef USE_ABS_HANDLE_RANGE
+				arrow->offset = arrow->range_fac * (float_prop / arrow->range);
+#else
 				arrow->offset = arrow->range_fac * ((float_prop - arrow->min) / arrow->range);
+#endif
 			}
 		}
 		else {




More information about the Bf-blender-cvs mailing list