FAbrowser/scripts/AdaptiveGrid.gd
2024-07-22 11:06:25 -04:00

24 lines
504 B
GDScript

extends GridContainer
class_name AdaptiveGrid
export var content_width:int = 256
export var margin:int = 8
export var padding:int = 4
func _ready():
get_parent().connect("resized",self,"resized")
resized()
func resized():
columns = floor((get_parent().rect_size.x - margin) / (content_width + padding))
func _on_sizeSlider_value_changed(value):
Global.sub_size = value
content_width = value
resized()
for i in get_children():
if i is Control:
i.rect_min_size = Vector2(value,value+64)