immersive-home/app/content/ui/components/tabs/tabs.gd

38 lines
625 B
GDScript3
Raw Normal View History

2024-04-23 23:11:18 +03:00
@tool
extends FlexContainer3D
2024-01-23 18:48:13 +02:00
class_name Tabs3D
signal on_select(selected: int)
2024-04-09 18:11:24 +03:00
var selected = R.state(null)
2024-03-21 14:29:10 +02:00
2024-01-23 18:48:13 +02:00
@export var initial_selected: Node3D
func _ready():
2024-04-23 23:11:18 +03:00
_update()
if Engine.is_editor_hint():
return
2024-04-09 18:11:24 +03:00
if initial_selected:
selected.value = initial_selected
R.effect(func(_arg):
on_select.emit(selected.value)
)
2024-01-23 18:48:13 +02:00
for option in get_children():
if option is Button3D == false:
continue
2024-03-21 14:29:10 +02:00
option.on_button_down.connect(func():
2024-04-09 18:11:24 +03:00
selected.value=option
)
R.effect(func(_arg):
option.active=option == selected.value
option.disabled=option == selected.value
2024-01-23 18:48:13 +02:00
)
2024-03-21 14:29:10 +02:00
2024-01-23 19:02:41 +02:00
option.toggleable = true