Skip to content

Commit dde8496

Browse files
Add Multiple Windows Demo
Co-Authored-By: A Thousand Ships <[email protected]>
1 parent 6d5ded3 commit dde8496

28 files changed

+1074
-0
lines changed

misc/multiple_windows/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Window Management
2+
3+
A demo showing all [`Window`](https://docs.godotengine.org/en/stable/classes/class_window.html) classes and their use within the main window.
4+
5+
It includes:
6+
- Embedding/Unembedding subwindows.
7+
- Using a transparent window.
8+
- Adding physical objects to new windows.
9+
- Showcase of all Dialog Windows.
10+
- Showcase of all Popup Windows.
11+
- Adding elements to Popup Menu.
12+
- Adding an icon to system tray.
13+
14+
Language: GDScript
15+
16+
Renderer: Compatbility
17+
18+
## Screenshots
19+
20+
![Screenshot](screenshots/screenshot.webp)

misc/multiple_windows/icon.webp

414 Bytes
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://cehd300ehf1vw"
6+
path="res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://icon.webp"
14+
dest_files=["res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
; Engine configuration file.
2+
; It's best edited using the editor UI and not directly,
3+
; since the parameters that go here are not all obvious.
4+
;
5+
; Format:
6+
; [section] ; section goes between []
7+
; param=value ; assign values to parameters
8+
9+
config_version=5
10+
11+
[application]
12+
13+
config/name="Multiple Windows Demo"
14+
config/description="A demo showing all Window classes and their use within the main window."
15+
run/main_scene="res://scenes/main_scene.tscn"
16+
config/features=PackedStringArray("4.3", "GL Compatibility")
17+
run/low_processor_mode=true
18+
config/icon="res://icon.webp"
19+
20+
[display]
21+
22+
window/size/viewport_width=650
23+
window/size/viewport_height=650
24+
window/stretch/mode="canvas_items"
25+
window/stretch/aspect="expand"
26+
window/per_pixel_transparency/allowed=true
27+
28+
[rendering]
29+
30+
renderer/rendering_method="gl_compatibility"
31+
renderer/rendering_method.mobile="gl_compatibility"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[gd_scene format=3 uid="uid://cudrukovmha7p"]
2+
3+
[node name="AcceptDialog" type="AcceptDialog"]
4+
initial_position = 2
5+
size = Vector2i(277, 100)
6+
visible = true
7+
dialog_text = "This is an AcceptDialog window"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[gd_scene format=3 uid="uid://1nswovajdv3n"]
2+
3+
[node name="ConfirmationDialog" type="ConfirmationDialog"]
4+
initial_position = 2
5+
size = Vector2i(310, 100)
6+
visible = true
7+
dialog_text = "This is a ConfimationDialog window"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
extends BaseButton
2+
3+
@export var others: Array[BaseButton] = []
4+
5+
enum Behavior {
6+
ENABLE_OTHERS_WHEN_ENABLED,
7+
ENABLE_OTHERS_WHEN_DISABLED
8+
}
9+
10+
@export var behavior: Behavior = Behavior.ENABLE_OTHERS_WHEN_ENABLED
11+
12+
func _ready() -> void:
13+
var others_disabled: bool
14+
if behavior == Behavior.ENABLE_OTHERS_WHEN_ENABLED:
15+
others_disabled = not button_pressed
16+
else:
17+
others_disabled = button_pressed
18+
for other in others:
19+
other.disabled = others_disabled
20+
21+
22+
func _toggled(toggled_on: bool) -> void:
23+
if behavior == Behavior.ENABLE_OTHERS_WHEN_ENABLED:
24+
for other in others:
25+
other.disabled = not toggled_on
26+
else:
27+
for other in others:
28+
other.disabled = toggled_on
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
extends Area2D
2+
3+
var window_delta: Vector2i
4+
5+
var held_down: bool = false
6+
7+
func _input_event(_viewport, event, _shape_idx):
8+
if event is InputEventMouseButton:
9+
held_down = event.pressed
10+
if event.pressed:
11+
window_delta = get_window().position - DisplayServer.mouse_get_position()
12+
13+
14+
func _process(_delta):
15+
if held_down:
16+
get_window().position = DisplayServer.mouse_get_position() + window_delta
17+
var mouse_state = DisplayServer.mouse_get_button_state()
18+
if mouse_state & MOUSE_BUTTON_MASK_LEFT == 0:
19+
held_down = false
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[gd_scene load_steps=6 format=3 uid="uid://ek1fmwy87san"]
2+
3+
[ext_resource type="Texture2D" uid="uid://pgdemhy0xqog" path="res://scenes/draggable_window/hand.svg" id="1_y4nm8"]
4+
[ext_resource type="Script" path="res://scenes/draggable_window/draggable_region.gd" id="2_pflw3"]
5+
[ext_resource type="Script" path="res://scenes/draggable_window/sprite_polygon_passthrough.gd" id="3_20753"]
6+
7+
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_ghj85"]
8+
size = Vector2(256, 256)
9+
10+
[sub_resource type="RectangleShape2D" id="RectangleShape2D_cvhp1"]
11+
size = Vector2(128, 128)
12+
13+
[node name="DraggableWindow" type="Window"]
14+
transparent_bg = true
15+
physics_object_picking = true
16+
size = Vector2i(128, 128)
17+
unresizable = true
18+
borderless = true
19+
always_on_top = true
20+
transparent = true
21+
22+
[node name="BG" type="Sprite2D" parent="."]
23+
visible = false
24+
texture = SubResource("PlaceholderTexture2D_ghj85")
25+
centered = false
26+
27+
[node name="Icon" type="Sprite2D" parent="."]
28+
position = Vector2(64, 64)
29+
texture = ExtResource("1_y4nm8")
30+
31+
[node name="Area2D" type="Area2D" parent="Icon"]
32+
script = ExtResource("2_pflw3")
33+
34+
[node name="CollisionShape2D" type="CollisionShape2D" parent="Icon/Area2D"]
35+
shape = SubResource("RectangleShape2D_cvhp1")
36+
37+
[node name="PassthroughGenerator" type="Node" parent="." node_paths=PackedStringArray("sprite")]
38+
script = ExtResource("3_20753")
39+
sprite = NodePath("../Icon")
Lines changed: 66 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)