2024-03-19 07:52:57 +00:00
|
|
|
class_name DesktopWindow
|
|
|
|
extends Control
|
|
|
|
|
|
|
|
@export var desktop: Desktop # desktop
|
|
|
|
@export var maximized_windows: Control # maximized windows
|
|
|
|
@export var taskbar: Control # taskbar
|
|
|
|
|
|
|
|
var windowed_rect: Rect2
|
|
|
|
|
|
|
|
func _input(event: InputEvent):
|
|
|
|
if event is InputEventMouseButton:
|
|
|
|
if event.pressed:
|
|
|
|
if get_global_rect().has_point(get_global_mouse_position()):
|
|
|
|
desktop.current_window = self
|
2024-03-20 20:29:18 +00:00
|
|
|
get_parent().move_child(self, get_parent().get_child_count())
|
2024-03-19 07:52:57 +00:00
|
|
|
elif event is InputEventKey:
|
|
|
|
if event.keycode == KEY_F11:
|
|
|
|
if event.pressed:
|
|
|
|
if desktop.current_window == self:
|
|
|
|
toggle_maximized()
|
|
|
|
|
|
|
|
# toggle maximized
|
|
|
|
func toggle_maximized():
|
|
|
|
if get_parent() == maximized_windows:
|
|
|
|
position = windowed_rect.position
|
|
|
|
size = windowed_rect.size
|
|
|
|
reparent(desktop)
|
|
|
|
else:
|
|
|
|
windowed_rect = get_global_rect()
|
|
|
|
reparent(maximized_windows)
|
|
|
|
|
|
|
|
func close():
|
|
|
|
visible = false
|
|
|
|
|
|
|
|
func minimize():
|
|
|
|
visible = false
|