extends PanelContainer signal element_requested(element_type: String) const CATALOG = preload("res://scripts/layout_catalog.gd") var _types: Array = [] func _ready() -> void: _types = CATALOG.ENTRIES.keys() for element_type in _types: $Margin/Body/List.add_item(CATALOG.ENTRIES[element_type].title) $Margin/Body/List.item_selected.connect(_select) $Margin/Body/List.item_activated.connect(func(_index: int) -> void: _request()) $Margin/Body/Add.pressed.connect(_request) $Margin/Body/Header/Close.pressed.connect(hide) $Margin/Body/List.select(0) _select(0) func _select(index: int) -> void: var entry: Dictionary = CATALOG.ENTRIES[_types[index]] $Margin/Body/Description.text = entry.description $Margin/Body/Size.text = "%d × %d cells · minimum %d × %d" % [entry.size.x, entry.size.y, entry.minimum.x, entry.minimum.y] $Margin/Body/Status.text = "" func _request() -> void: var indices: PackedInt32Array = $Margin/Body/List.get_selected_items() if not indices.is_empty(): element_requested.emit(_types[indices[0]]) func show_no_space() -> void: $Margin/Body/Status.text = "No space available. Move, resize or remove a panel first."