diff --git a/project.godot b/project.godot index 63d14c5..dd12d0e 100644 --- a/project.godot +++ b/project.godot @@ -80,6 +80,7 @@ config/windows_native_icon="res://build/logo.ico" window/size/width=360 window/size/height=760 +window/size/resizable=false window/size/always_on_top=true window/per_pixel_transparency/allowed=true window/per_pixel_transparency/enabled=true diff --git a/scripts/config_manager.gd b/scripts/config_manager.gd index c4a4af8..e53f5af 100644 --- a/scripts/config_manager.gd +++ b/scripts/config_manager.gd @@ -149,6 +149,19 @@ func get_current_task_name() -> String: return _config.get_value("CACHE", "current_task_name", "") +var last_window_position := Vector2() setget set_last_window_position, get_last_window_position + + +func set_last_window_position(value: Vector2) -> void: + last_window_position = value + _config.set_value("CACHE", "last_window_position", value) + save() + + +func get_last_window_position() -> Vector2: + return _config.get_value("CACHE", "last_window_position", OS.get_screen_size()/2) + + ############################################################################### # # BOOTSTRAP diff --git a/ui/main.gd b/ui/main.gd new file mode 100644 index 0000000..369db2f --- /dev/null +++ b/ui/main.gd @@ -0,0 +1,49 @@ +extends VBoxContainer + +var config: ConfigManager = preload("res://config_manager.tres") + +onready var v_box_container_primary := $"%VBoxContainerPrimary" as VBoxContainer +onready var toggle_tab_container_button := $"%ToggleTabContainerButton" as Button +onready var tab_container := $"%TabContainer" as TabContainer + +func _ready() -> void: + toggle_tab_container_button.toggle_mode = true + # warning-ignore:return_value_discarded + toggle_tab_container_button.connect("toggled", self, "_on_toggle_tab_container_button_toggled") + tab_container.visible = toggle_tab_container_button.pressed + OS.window_position = config.last_window_position + set_window_size() + get_tree().get_root().set_transparent_background(true) + + +func _on_toggle_tab_container_button_toggled(is_toggled: bool) -> void: + tab_container.visible = is_toggled + set_window_size() + + +func set_window_size() -> void: + OS.window_size = v_box_container_primary.rect_size + if tab_container.visible: + OS.window_size.y += tab_container.rect_size.y + + +var mouse_button_is_pressed := false +var dragging_start_position = Vector2() + +func _gui_input(event: InputEvent) -> void: + if event is InputEventMouseButton: + if event.get_button_index() == 1: + mouse_button_is_pressed = !mouse_button_is_pressed + dragging_start_position = get_local_mouse_position() + + +func _process(_delta: float) -> void: + if mouse_button_is_pressed: + OS.set_window_position(OS.window_position + get_global_mouse_position() - dragging_start_position) + + +func _notification(what: int) -> void: + match what: + MainLoop.NOTIFICATION_WM_QUIT_REQUEST: + config.last_window_position = OS.window_position + get_tree().quit() diff --git a/ui/main.tscn b/ui/main.tscn index bf177d4..d15a367 100644 --- a/ui/main.tscn +++ b/ui/main.tscn @@ -1,22 +1,43 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://ui/time_counter.tscn" type="PackedScene" id=1] [ext_resource path="res://ui/tasks_list.tscn" type="PackedScene" id=2] [ext_resource path="res://ui/settings.tscn" type="PackedScene" id=3] +[ext_resource path="res://ui/main.gd" type="Script" id=4] -[node name="VBoxContainer" type="VBoxContainer"] +[node name="Main" type="VBoxContainer"] anchor_right = 1.0 anchor_bottom = 1.0 +script = ExtResource( 4 ) -[node name="TimeCounter" parent="." instance=ExtResource( 1 )] +[node name="VBoxContainerPrimary" type="VBoxContainer" parent="."] +unique_name_in_owner = true +margin_right = 360.0 +margin_bottom = 72.0 + +[node name="TimeCounter" parent="VBoxContainerPrimary" instance=ExtResource( 1 )] anchor_right = 0.0 anchor_bottom = 0.0 margin_right = 360.0 margin_bottom = 48.0 -[node name="TabContainer" type="TabContainer" parent="."] +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainerPrimary"] margin_top = 52.0 margin_right = 360.0 +margin_bottom = 72.0 +alignment = 2 + +[node name="ToggleTabContainerButton" type="Button" parent="VBoxContainerPrimary/HBoxContainer"] +unique_name_in_owner = true +margin_left = 348.0 +margin_right = 360.0 +margin_bottom = 20.0 +toggle_mode = true + +[node name="TabContainer" type="TabContainer" parent="."] +unique_name_in_owner = true +margin_top = 76.0 +margin_right = 360.0 margin_bottom = 760.0 size_flags_vertical = 3 @@ -42,4 +63,4 @@ size_flags_vertical = 3 anchor_right = 0.0 anchor_bottom = 0.0 margin_right = 352.0 -margin_bottom = 672.0 +margin_bottom = 648.0