simplify button depth logic
This commit is contained in:
parent
3369c37a00
commit
26c2272c1b
|
@ -91,22 +91,24 @@ func set_pressed(value: bool) -> void:
|
|||
# Signals
|
||||
#
|
||||
func _on_Button_button_down():
|
||||
button.rect_position.y += depth - _pressed_depth
|
||||
button.rect_position.y = depth - _pressed_depth
|
||||
emit_signal("button_down")
|
||||
|
||||
func _on_Button_button_up():
|
||||
button.rect_position.y -= depth - _pressed_depth
|
||||
if _toggled:
|
||||
button.rect_position.y = depth - _toggled_depth
|
||||
else:
|
||||
button.rect_position.y = 0
|
||||
emit_signal("button_up")
|
||||
|
||||
func _on_Button_toggled(button_pressed):
|
||||
if _toggled == button_pressed:
|
||||
return
|
||||
|
||||
var delta = depth - _toggled_depth
|
||||
if (not _toggled) and button_pressed: # off -> on
|
||||
button.rect_position.y += depth - _toggled_depth
|
||||
elif _toggled and (not button_pressed): # on -> off
|
||||
button.rect_position.y -= depth - _toggled_depth
|
||||
if button_pressed:
|
||||
button.rect_position.y = depth - _toggled_depth
|
||||
else:
|
||||
button.rect_position.y = 0
|
||||
|
||||
_toggled = button_pressed
|
||||
emit_signal("toggled", _toggled)
|
||||
|
|
Loading…
Reference in a new issue