Fix: Inconsistent input drag editing for factor properties #112004

Open
Guillermo Venegas wants to merge 5 commits from guishe/blender:fix-mouse-drag-edit-factor into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 20 additions and 19 deletions

View File

@ -5583,12 +5583,13 @@ static bool ui_numedit_but_SLI(uiBut *but,
const bool is_horizontal,
const bool is_motion,
const bool snap,
const bool shift)
const bool shift,
const bool use_continuous_grab)
{
float cursor_x_range, f, tempf, softmin, softmax, softrange;
int temp, lvalue;
bool changed = false;
float mx_fl, my_fl;
float mx_fl = float(mx);
/* prevent unwanted drag adjustments, test motion so modifier keys refresh. */
if ((but->type != UI_BTYPE_SCROLL) && (is_motion || data->draglock) &&
@ -5606,25 +5607,27 @@ static bool ui_numedit_but_SLI(uiBut *but,
softmax = but->softmax;
softrange = softmax - softmin;
/* yes, 'mx' as both x/y is intentional */
ui_mouse_scale_warp(data, mx, mx, &mx_fl, &my_fl, shift);
if (but->type == UI_BTYPE_NUM_SLIDER) {
cursor_x_range = BLI_rctf_size_x(&but->rect);
if (use_continuous_grab) {
const float fac = ui_mouse_scale_warp_factor(shift);
f = ((mx_fl - data->draglastx) / cursor_x_range) * fac + data->dragf;
}
else {
mx_fl = clamp_f(mx_fl, but->rect.xmin, but->rect.xmax);
f = (mx_fl - but->rect.xmin) / cursor_x_range;
}
}
else if (but->type == UI_BTYPE_SCROLL) {
const float size = (is_horizontal) ? BLI_rctf_size_x(&but->rect) :
-BLI_rctf_size_y(&but->rect);
cursor_x_range = size * (but->softmax - but->softmin) /
(but->softmax - but->softmin + but->a1);
}
else {
const float ofs = (BLI_rctf_size_y(&but->rect) / 2.0f);
cursor_x_range = (BLI_rctf_size_x(&but->rect) - ofs);
f = (mx_fl - data->dragstartx) / cursor_x_range + data->dragfstart;
}
f = (mx_fl - data->dragstartx) / cursor_x_range + data->dragfstart;
CLAMP(f, 0.0f, 1.0f);
data->dragf = f;
/* deal with mouse correction */
#ifdef USE_CONT_MOUSE_CORRECT
@ -5828,14 +5831,11 @@ static int ui_do_but_SLI(
data->multi_data.drag_dir[0] += abs(data->draglastx - mx);
data->multi_data.drag_dir[1] += abs(data->draglasty - my);
#endif
if (ui_numedit_but_SLI(but,
data,
mx,
true,
is_motion,
event->modifier & KM_CTRL,
event->modifier & KM_SHIFT))
{
const bool ctrl = event->modifier & KM_CTRL;
const bool shift = event->modifier & KM_SHIFT;
const bool use_continuous_grab = ui_but_is_cursor_warp(but) &&
event->tablet.active == EVT_TABLET_NONE;
if (ui_numedit_but_SLI(but, data, mx, true, is_motion, ctrl, shift, use_continuous_grab)) {
ui_numedit_apply(C, block, but, data);
}
@ -5990,7 +5990,8 @@ static int ui_do_but_SCROLL(
else if (event->type == MOUSEMOVE) {
const bool is_motion = (event->type == MOUSEMOVE);
if (ui_numedit_but_SLI(
but, data, (horizontal) ? mx : my, horizontal, is_motion, false, false)) {
but, data, (horizontal) ? mx : my, horizontal, is_motion, false, false, false))
{
ui_numedit_apply(C, block, but, data);
}
}