FloatingWindows.gd 680 B

1234567891011121314151617181920212223242526272829
  1. extends Control
  2. @onready var prevSize = size
  3. #
  4. func MoveWindow(window : WindowPanel):
  5. move_child(window, get_child_count() - 1)
  6. func ClearWindowsModifier():
  7. for window in get_children():
  8. window.ResetWindowModifier()
  9. #
  10. func _ready():
  11. prevSize = size
  12. for window in get_children():
  13. window.MoveFloatingWindowToTop.connect(self.MoveWindow)
  14. func _on_window_resized():
  15. var overallRatio = Vector2.ONE
  16. if prevSize != null and prevSize.x != 0 and prevSize.y != 0:
  17. overallRatio = size / prevSize
  18. prevSize = size
  19. for child in get_children():
  20. if overallRatio != Vector2.ONE:
  21. child.set_position(child.get_position() * overallRatio)
  22. child.ClampToMargin(get_size())