-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWindow.tscn
234 lines (186 loc) · 5.67 KB
/
Window.tscn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
[gd_scene load_steps=5 format=3 uid="uid://c4kpdo3fvc34i"]
[ext_resource type="Texture2D" uid="uid://cprnohng2r1nh" path="res://png/max.png" id="1"]
[ext_resource type="Texture2D" uid="uid://ddrssqwoedrv7" path="res://png/cross.png" id="2"]
[sub_resource type="GDScript" id="2"]
script/source = "extends Control
var held = {\"l\":false, \"r\":false, \"m\":false}
var grid = Vector2(100,100)
signal req_show_on_top (window)
var dock_icon
var title = \"App\" : set = set_title
func set_title(arg):
title = arg
find_child(\"title\").text = arg
func toggle_visible():
visible = !visible
func _ready():
custom_minimum_size = grid
position = get_parent_control().size*0.5# - size*0.5
# $V/header.custom_minimum_size = grid
find_child(\"close\").connect(\"pressed\",Callable(self,\"close\"))
find_child(\"size\").connect(\"pressed\",Callable(self,\"maximize\"))
var is_corner = false
func corner(event):
if event is InputEventMouseButton:
match event.button_index:
MOUSE_BUTTON_LEFT: is_corner = event.pressed
if event is InputEventMouseMotion:
if is_corner: size += event.relative
func close():
#play animation?
dock_icon.queue_free()
queue_free()
var floating_pos:Vector2
var floating_size:Vector2
func maximize():
var max_pos = Vector2(0,38)
var max_size = get_parent_control().size - Vector2(0,38+38)
if position == max_pos and size == max_size:
position = floating_pos; size = floating_size
else:
floating_pos = position; floating_size = size
position = max_pos; size = max_size
func _gui_input(event):
#pressed
if event is InputEventMouseButton and event.pressed:
match event.button_index:
MOUSE_BUTTON_LEFT: emit_signal(\"req_show_on_top\", self)
MOUSE_BUTTON_MIDDLE: pass
MOUSE_BUTTON_RIGHT: pass
#held
if event is InputEventMouseButton:
match event.button_index:
MOUSE_BUTTON_LEFT: held.l = event.pressed
MOUSE_BUTTON_MIDDLE: held.m = event.pressed
MOUSE_BUTTON_RIGHT: held.r = event.pressed
#drag
if event is InputEventMouseMotion:
if held.l: position += event.relative
if held.m: pass
if held.r: size += event.relative
#release
if event is InputEventMouseButton and not event.pressed:
match event.button_index:
MOUSE_BUTTON_LEFT: if Input.is_key_pressed(KEY_CTRL): position = position.snapped(grid)
MOUSE_BUTTON_MIDDLE: pass
MOUSE_BUTTON_RIGHT: if Input.is_key_pressed(KEY_CTRL): size = size.snapped(grid)
func _on_header_gui_input(event):
if event is InputEventMouseButton\\
and event.double_click:
maximize()
"
[sub_resource type="GDScript" id="3"]
script/source = "extends Control
func _gui_input(event):
# emit_signal(\"_gui_input\", event)
get_parent().corner(event)
# print(event)
# #pressed
# if event is InputEventMouseButton:
# match event.button_index:
# MOUSE_BUTTON_LEFT: get_parent().held.l = true
"
[node name="Window" type="Panel"]
custom_minimum_size = Vector2(50, 50)
offset_right = 403.0
offset_bottom = 266.0
script = SubResource("2")
[node name="Corner" type="Control" parent="."]
anchors_preset = 0
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -15.0
offset_top = -15.0
offset_right = 15.0
offset_bottom = 14.0
mouse_default_cursor_shape = 12
script = SubResource("3")
[node name="ColorRect" type="ColorRect" parent="Corner"]
visible = false
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
color = Color(0.0862745, 0.894118, 1, 1)
[node name="V" type="VBoxContainer" parent="."]
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
[node name="header" type="Control" parent="V"]
clip_contents = true
custom_minimum_size = Vector2(40, 40)
layout_mode = 2
size_flags_horizontal = 3
mouse_filter = 1
[node name="center" type="HBoxContainer" parent="V/header"]
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
mouse_filter = 2
alignment = 1
[node name="title" type="Button" parent="V/header/center"]
custom_minimum_size = Vector2(24, 24)
layout_mode = 2
mouse_filter = 1
disabled = true
text = "App"
flat = true
[node name="right" type="HBoxContainer" parent="V/header"]
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
mouse_filter = 2
alignment = 2
[node name="size" type="TextureButton" parent="V/header/right"]
custom_minimum_size = Vector2(40, 40)
layout_mode = 2
texture_normal = ExtResource("1")
stretch_mode = 3
[node name="ColorRect2" type="ColorRect" parent="V/header/right/size"]
visible = false
show_behind_parent = true
custom_minimum_size = Vector2(40, 40)
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
color = Color(0.690196, 0.788235, 0.894118, 1)
[node name="left" type="HBoxContainer" parent="V/header"]
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -1.43195
offset_bottom = -1.43195
size_flags_horizontal = 3
size_flags_vertical = 3
mouse_filter = 2
[node name="close" type="TextureButton" parent="V/header/left"]
custom_minimum_size = Vector2(40, 40)
layout_mode = 2
texture_normal = ExtResource("2")
stretch_mode = 3
[node name="ColorRect" type="ColorRect" parent="V/header/left/close"]
visible = false
show_behind_parent = true
custom_minimum_size = Vector2(40, 40)
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
color = Color(0.894118, 0.690196, 0.690196, 1)
[node name="header_shadow" type="ColorRect" parent="V"]
custom_minimum_size = Vector2(1, 1)
layout_mode = 2
size_flags_horizontal = 3
color = Color(0.843137, 0.843137, 0.843137, 1)
[node name="app_container" type="Container" parent="V"]
clip_contents = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
mouse_filter = 2
[connection signal="gui_input" from="V/header" to="." method="_on_header_gui_input"]