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