Skip to content

Commit

Permalink
editor: numinput: avoid drag math when drag is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
q009 committed Jun 29, 2024
1 parent 06787fa commit 8a91b12
Showing 1 changed file with 47 additions and 39 deletions.
86 changes: 47 additions & 39 deletions config/ui/tool/toolview/widgets/toolnuminput.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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:<pivot val> 2:<min> 3:<max> 4:<step>
Expand All @@ -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:<var> 2:<min> 3:<max> 4:<step> 5:<dir>
Expand Down

0 comments on commit 8a91b12

Please sign in to comment.