Commit: 2f8b7030d439644bab94fe601066e7a1c848367a
Author: Victor Seiji Hariki
Date:   Wed Apr 3 15:14:57 2019 +0200
Branches: master
https://developer.blender.org/rB2f8b7030d439644bab94fe601066e7a1c848367a

Fix T62939: Incorrect cursor position when exiting UI slider

Differential Revision: https://developer.blender.org/D4629

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

M       source/blender/editors/interface/interface_handlers.c

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

diff --git a/source/blender/editors/interface/interface_handlers.c 
b/source/blender/editors/interface/interface_handlers.c
index 2641b28554c..208c1a90b89 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4786,12 +4786,10 @@ static bool ui_numedit_but_SLI(
         int mx, const bool is_horizontal, const bool is_motion,
         const bool snap, const bool shift)
 {
-       float deler, f, tempf, softmin, softmax, softrange;
+       float cursor_x_range, f, tempf, softmin, softmax, softrange;
        int temp, lvalue;
        bool changed = false;
        float mx_fl, my_fl;
-       /* note, 'offs' is really from the widget drawing rounded corners see 
'widget_numslider' */
-       float offs;
 
        /* prevent unwanted drag adjustments, test motion so modifier keys 
refresh. */
        if ((but->type != UI_BTYPE_SCROLL) &&
@@ -4809,20 +4807,18 @@ static bool ui_numedit_but_SLI(
        ui_mouse_scale_warp(data, mx, mx, &mx_fl, &my_fl, shift);
 
        if (but->type == UI_BTYPE_NUM_SLIDER) {
-               offs = (BLI_rctf_size_y(&but->rect) / 2.0f);
-               deler = BLI_rctf_size_x(&but->rect) - offs;
+               cursor_x_range = BLI_rctf_size_x(&but->rect);
        }
        else if (but->type == UI_BTYPE_SCROLL) {
                const float size = (is_horizontal) ? 
BLI_rctf_size_x(&but->rect) : -BLI_rctf_size_y(&but->rect);
-               deler = size * (but->softmax - but->softmin) / (but->softmax - 
but->softmin + but->a1);
-               offs = 0.0;
+               cursor_x_range = size * (but->softmax - but->softmin) / 
(but->softmax - but->softmin + but->a1);
        }
        else {
-               offs = (BLI_rctf_size_y(&but->rect) / 2.0f);
-               deler = (BLI_rctf_size_x(&but->rect) - offs);
+               float offs = (BLI_rctf_size_y(&but->rect) / 2.0f);
+               cursor_x_range = (BLI_rctf_size_x(&but->rect) - offs);
        }
 
-       f = (mx_fl - data->dragstartx) / deler + data->dragfstart;
+       f = (mx_fl - data->dragstartx) / cursor_x_range + data->dragfstart;
        CLAMP(f, 0.0f, 1.0f);
 
 
@@ -4831,11 +4827,11 @@ static bool ui_numedit_but_SLI(
        if (ui_but_is_cursor_warp(but)) {
                /* OK but can go outside bounds */
                if (is_horizontal) {
-                       data->ungrab_mval[0] = (but->rect.xmin + offs) + (f * 
deler);
+                       data->ungrab_mval[0] = but->rect.xmin + (f * 
cursor_x_range);
                        data->ungrab_mval[1] = BLI_rctf_cent_y(&but->rect);
                }
                else {
-                       data->ungrab_mval[1] = (but->rect.ymin + offs) + (f * 
deler);
+                       data->ungrab_mval[1] = but->rect.ymin + (f * 
cursor_x_range);
                        data->ungrab_mval[0] = BLI_rctf_cent_x(&but->rect);
                }
                BLI_rctf_clamp_pt_v(&but->rect, data->ungrab_mval);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to