From 8a91b120d326c2cef2a2e3e0ca5ae0b96868dca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20=27Q009=27=20B=C5=82auciak?= Date: Sat, 29 Jun 2024 11:33:22 +0200 Subject: [PATCH] editor: numinput: avoid drag math when drag is 0 --- .../ui/tool/toolview/widgets/toolnuminput.cfg | 86 ++++++++++--------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/config/ui/tool/toolview/widgets/toolnuminput.cfg b/config/ui/tool/toolview/widgets/toolnuminput.cfg index 964cd8434..a8da75d92 100644 --- a/config/ui/tool/toolview/widgets/toolnuminput.cfg +++ b/config/ui/tool/toolview/widgets/toolnuminput.cfg @@ -31,31 +31,35 @@ tool_numinput_drag_f = [ _drag = (tool_numinput_get_drag) _key_mods = (getkeymodifiers) - if (>f $arg4 0) [ - caseif (& $_key_mods $KMOD_SHIFT) [ - arg4 = (*f $arg4 10) - ] (& $_key_mods @KMOD_ALT) [ - arg4 = (*f $arg4 0.1) - ] + if (!= $_drag 0) [ + if (>f $arg4 0) [ + caseif (& $_key_mods $KMOD_SHIFT) [ + arg4 = (*f $arg4 10) + ] (& $_key_mods @KMOD_ALT) [ + arg4 = (*f $arg4 0.1) + ] - _new_val = (+f $tool_numinput_drag_val (*f $arg4 $_drag)) - ] [ - _new_val = (*f $tool_numinput_drag_val (divf 1 (pow 2 (*f -1 $_drag)))) - ] + _new_val = (+f $tool_numinput_drag_val (*f $arg4 $_drag)) + ] [ + _new_val = (*f $tool_numinput_drag_val (divf 1 (pow 2 (*f -1 $_drag)))) + ] - _new_val = (round $_new_val 1e-05) + _new_val = (round $_new_val 1e-05) - if (= $arg2 $arg3) [ - case (getvartype $tool_numinput_drag_var) $ididxvar [ - arg2 = (p_get (getvarmin $tool_numinput_drag_var)) - arg3 = (p_get (getvarmax $tool_numinput_drag_var)) - ] $ididxfvar [ - arg2 = (p_get (getfvarmin $tool_numinput_drag_var)) - arg3 = (p_get (getfvarmax $tool_numinput_drag_var)) + if (= $arg2 $arg3) [ + case (getvartype $tool_numinput_drag_var) $ididxvar [ + arg2 = (p_get (getvarmin $tool_numinput_drag_var)) + arg3 = (p_get (getvarmax $tool_numinput_drag_var)) + ] $ididxfvar [ + arg2 = (p_get (getfvarmin $tool_numinput_drag_var)) + arg3 = (p_get (getfvarmax $tool_numinput_drag_var)) + ] ] - ] - $_clamp_func $_new_val $arg2 $arg3 + $_clamp_func $_new_val $arg2 $arg3 + ] [ + result $tool_numinput_drag_old_val + ] ] // 1: 2: 3: 4: @@ -68,29 +72,33 @@ tool_numinput_drag_i = [ _drag = (tool_numinput_get_drag) _key_mods = (getkeymodifiers) - if (> $arg4 0) [ - caseif (& $_key_mods $KMOD_SHIFT) [ - arg4 = (*f $arg4 10) - ] (& $_key_mods @KMOD_ALT) [ - arg4 = (max (*f $arg4 0.1) 1) - ] + if (!= $_drag 0) [ + if (> $arg4 0) [ + caseif (& $_key_mods $KMOD_SHIFT) [ + arg4 = (*f $arg4 10) + ] (& $_key_mods @KMOD_ALT) [ + arg4 = (max (*f $arg4 0.1) 1) + ] - _new_val = (+ $tool_numinput_drag_val (* $arg4 $_drag)) - ] [ - _new_val = (toint (*f $tool_numinput_drag_val (divf 1 (pow 2 (*f -1 $_drag))))) - ] + _new_val = (+ $tool_numinput_drag_val (* $arg4 $_drag)) + ] [ + _new_val = (toint (*f $tool_numinput_drag_val (divf 1 (pow 2 (*f -1 $_drag))))) + ] - if (= $arg2 $arg3) [ - case (getvartype $tool_numinput_drag_var) $ididxvar [ - arg2 = (p_get (getvarmin $tool_numinput_drag_var)) - arg3 = (p_get (getvarmax $tool_numinput_drag_var)) - ] $ididxfvar [ - arg2 = (p_get (getfvarmin $tool_numinput_drag_var)) - arg3 = (p_get (getfvarmax $tool_numinput_drag_var)) + if (= $arg2 $arg3) [ + case (getvartype $tool_numinput_drag_var) $ididxvar [ + arg2 = (p_get (getvarmin $tool_numinput_drag_var)) + arg3 = (p_get (getvarmax $tool_numinput_drag_var)) + ] $ididxfvar [ + arg2 = (p_get (getfvarmin $tool_numinput_drag_var)) + arg3 = (p_get (getfvarmax $tool_numinput_drag_var)) + ] ] - ] - toint ($_clamp_func $_new_val $arg2 $arg3) + toint ($_clamp_func $_new_val $arg2 $arg3) + ] [ + result $tool_numinput_drag_old_val + ] ] // 1: 2: 3: 4: 5: