Fix T62939: Incorrect cursor position when exiting UI slider
Differential Revision: https://developer.blender.org/D4629
This commit is contained in:
parent
822c67364e
commit
2f8b7030d4
Notes:
blender-bot
2023-02-14 11:18:07 +01:00
Referenced by issue #62939, UI Value Slider, incorrect cursor position
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue