can resize tool
This commit is contained in:
parent
85740ade1d
commit
4edf4f5024
3 changed files with 42 additions and 3 deletions
25
TitleBar.gd
25
TitleBar.gd
|
|
@ -2,6 +2,7 @@ extends Control
|
||||||
|
|
||||||
var following = false
|
var following = false
|
||||||
var dragging_start_position : Vector2i = Vector2i()
|
var dragging_start_position : Vector2i = Vector2i()
|
||||||
|
@export var options_menu : PopupMenu
|
||||||
|
|
||||||
func _on_TitleBar_gui_input(event):
|
func _on_TitleBar_gui_input(event):
|
||||||
if event is InputEventMouseButton:
|
if event is InputEventMouseButton:
|
||||||
|
|
@ -9,12 +10,18 @@ func _on_TitleBar_gui_input(event):
|
||||||
if event.get_button_index() == 1:
|
if event.get_button_index() == 1:
|
||||||
following = !following
|
following = !following
|
||||||
dragging_start_position = get_local_mouse_position()
|
dragging_start_position = get_local_mouse_position()
|
||||||
|
if event.get_button_index() == 2:
|
||||||
|
open_menu()
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if following:
|
if following:
|
||||||
get_window().position = get_window().position + Vector2i(get_global_mouse_position()) - dragging_start_position
|
get_window().position = get_window().position + Vector2i(get_global_mouse_position()) - dragging_start_position
|
||||||
#OS.set_window_position(OS.window_position + get_global_mouse_position() - dragging_start_position)
|
#OS.set_window_position(OS.window_position + get_global_mouse_position() - dragging_start_position)
|
||||||
|
#if (Input.is_action_just_pressed("ui_up")):
|
||||||
|
#get_window().size += Vector2i(100,90)
|
||||||
|
|
||||||
|
func open_menu():
|
||||||
|
options_menu.show()
|
||||||
|
|
||||||
#
|
#
|
||||||
#func _on_CloseButton_pressed():
|
#func _on_CloseButton_pressed():
|
||||||
|
|
@ -24,3 +31,21 @@ func _process(_delta):
|
||||||
#func _on_MinimizeButton_pressed():
|
#func _on_MinimizeButton_pressed():
|
||||||
#OS.set_window_minimized(true)
|
#OS.set_window_minimized(true)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_popup_menu_id_pressed(id: int) -> void:
|
||||||
|
if id == 2:
|
||||||
|
get_window().size = Vector2i(200,180)
|
||||||
|
options_menu.set_item_checked(2, true)
|
||||||
|
options_menu.set_item_checked(3, false)
|
||||||
|
options_menu.set_item_checked(4, false)
|
||||||
|
elif id == 3:
|
||||||
|
get_window().size = Vector2i(300,270)
|
||||||
|
options_menu.set_item_checked(2, false)
|
||||||
|
options_menu.set_item_checked(3, true)
|
||||||
|
options_menu.set_item_checked(4, false)
|
||||||
|
elif id == 4:
|
||||||
|
get_window().size = Vector2i(400,360)
|
||||||
|
options_menu.set_item_checked(2, false)
|
||||||
|
options_menu.set_item_checked(3, false)
|
||||||
|
options_menu.set_item_checked(4, true)
|
||||||
|
|
|
||||||
18
main.tscn
18
main.tscn
|
|
@ -46,9 +46,10 @@ anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
|
||||||
[node name="TitleBar" type="PanelContainer" parent="VBoxContainer"]
|
[node name="TitleBar" type="PanelContainer" parent="VBoxContainer" node_paths=PackedStringArray("options_menu")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
script = ExtResource("1_ig7tw")
|
script = ExtResource("1_ig7tw")
|
||||||
|
options_menu = NodePath("../../StatusIndicator/PopupMenu")
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/TitleBar"]
|
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/TitleBar"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
@ -163,11 +164,24 @@ icon = ExtResource("3_h2yge")
|
||||||
menu = NodePath("PopupMenu")
|
menu = NodePath("PopupMenu")
|
||||||
|
|
||||||
[node name="PopupMenu" type="PopupMenu" parent="StatusIndicator"]
|
[node name="PopupMenu" type="PopupMenu" parent="StatusIndicator"]
|
||||||
item_count = 1
|
item_count = 5
|
||||||
item_0/text = "Exit"
|
item_0/text = "Exit"
|
||||||
item_0/id = 0
|
item_0/id = 0
|
||||||
|
item_1/id = 1
|
||||||
|
item_1/separator = true
|
||||||
|
item_2/text = "Small"
|
||||||
|
item_2/checkable = 2
|
||||||
|
item_2/checked = true
|
||||||
|
item_2/id = 2
|
||||||
|
item_3/text = "Medium"
|
||||||
|
item_3/checkable = 2
|
||||||
|
item_3/id = 3
|
||||||
|
item_4/text = "Large"
|
||||||
|
item_4/checkable = 2
|
||||||
|
item_4/id = 4
|
||||||
|
|
||||||
[connection signal="gui_input" from="VBoxContainer/TitleBar" to="VBoxContainer/TitleBar" method="_on_TitleBar_gui_input"]
|
[connection signal="gui_input" from="VBoxContainer/TitleBar" to="VBoxContainer/TitleBar" method="_on_TitleBar_gui_input"]
|
||||||
[connection signal="pressed" from="VBoxContainer/Buttons/OffTaskButton" to="." method="_on_off_task_button_pressed"]
|
[connection signal="pressed" from="VBoxContainer/Buttons/OffTaskButton" to="." method="_on_off_task_button_pressed"]
|
||||||
[connection signal="pressed" from="VBoxContainer/Buttons/PauseButton" to="." method="_on_pause_button_pressed"]
|
[connection signal="pressed" from="VBoxContainer/Buttons/PauseButton" to="." method="_on_pause_button_pressed"]
|
||||||
[connection signal="id_pressed" from="StatusIndicator/PopupMenu" to="." method="_on_popup_menu_id_pressed"]
|
[connection signal="id_pressed" from="StatusIndicator/PopupMenu" to="." method="_on_popup_menu_id_pressed"]
|
||||||
|
[connection signal="id_pressed" from="StatusIndicator/PopupMenu" to="VBoxContainer/TitleBar" method="_on_popup_menu_id_pressed"]
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ config/icon="res://icon.svg"
|
||||||
|
|
||||||
window/size/viewport_width=200
|
window/size/viewport_width=200
|
||||||
window/size/viewport_height=180
|
window/size/viewport_height=180
|
||||||
window/size/resizable=false
|
|
||||||
window/size/borderless=true
|
window/size/borderless=true
|
||||||
window/size/always_on_top=true
|
window/size/always_on_top=true
|
||||||
|
window/stretch/mode="canvas_items"
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue