Skip to content

Commit fc523e5

Browse files
committed
Script Window: Improve layout
Remove black ColorRect node. Also remove the Scroll node because the TextEdit containing the script can scroll automatically. Add a PanelContainer and Panel node. And remove unneeded MarginContainer nodes. This makes the layout work as expected when resizing the window. Previously the controls didn't shrink correctly (overflowing below the window).
1 parent 8288b9b commit fc523e5

File tree

2 files changed

+18
-27
lines changed

2 files changed

+18
-27
lines changed

addons/block_code/ui/script_window/script_window.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extends Window
33

44
var script_content: String = ""
55

6-
@onready var script_label: TextEdit = $Margin/VBox/ColorRect/Scroll/Margin/Code
6+
@onready var script_label: TextEdit = %Code
77

88

99
func _ready():

addons/block_code/ui/script_window/script_window.tscn

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,49 +36,40 @@ size = Vector2i(750, 750)
3636
transient = true
3737
script = ExtResource("1_jja22")
3838

39-
[node name="Margin" type="MarginContainer" parent="."]
39+
[node name="PanelContainer" type="PanelContainer" parent="."]
4040
anchors_preset = 15
4141
anchor_right = 1.0
4242
anchor_bottom = 1.0
4343
grow_horizontal = 2
4444
grow_vertical = 2
45-
theme_override_constants/margin_left = 25
46-
theme_override_constants/margin_top = 25
47-
theme_override_constants/margin_right = 25
48-
theme_override_constants/margin_bottom = 25
4945

50-
[node name="VBox" type="VBoxContainer" parent="Margin"]
46+
[node name="Panel" type="Panel" parent="PanelContainer"]
5147
layout_mode = 2
5248

53-
[node name="CopyCode" type="Button" parent="Margin/VBox"]
49+
[node name="VBox" type="VBoxContainer" parent="PanelContainer"]
5450
layout_mode = 2
55-
text = "Copy"
5651

57-
[node name="ColorRect" type="ColorRect" parent="Margin/VBox"]
52+
[node name="Code" type="TextEdit" parent="PanelContainer/VBox"]
53+
unique_name_in_owner = true
5854
layout_mode = 2
59-
size_flags_horizontal = 3
6055
size_flags_vertical = 3
61-
color = Color(0.172833, 0.172833, 0.172833, 1)
56+
theme_override_fonts/font = SubResource("SystemFont_r6ct2")
57+
editable = false
58+
syntax_highlighter = SubResource("CodeHighlighter_yvmnf")
6259

63-
[node name="Scroll" type="ScrollContainer" parent="Margin/VBox/ColorRect"]
60+
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/VBox"]
6461
layout_mode = 2
65-
offset_top = -27.0
66-
offset_right = 700.0
67-
offset_bottom = 673.0
6862

69-
[node name="Margin" type="MarginContainer" parent="Margin/VBox/ColorRect/Scroll"]
63+
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBox/HBoxContainer"]
7064
layout_mode = 2
7165
size_flags_horizontal = 3
72-
size_flags_vertical = 3
73-
theme_override_constants/margin_left = 35
74-
theme_override_constants/margin_top = 55
75-
theme_override_constants/margin_right = 35
76-
theme_override_constants/margin_bottom = 35
66+
theme_override_constants/margin_left = 3
67+
theme_override_constants/margin_right = 3
68+
theme_override_constants/margin_bottom = 3
7769

78-
[node name="Code" type="TextEdit" parent="Margin/VBox/ColorRect/Scroll/Margin"]
70+
[node name="CopyCode" type="Button" parent="PanelContainer/VBox/HBoxContainer/MarginContainer"]
7971
layout_mode = 2
80-
theme_override_fonts/font = SubResource("SystemFont_r6ct2")
81-
editable = false
82-
syntax_highlighter = SubResource("CodeHighlighter_yvmnf")
72+
size_flags_horizontal = 4
73+
text = "Copy"
8374

84-
[connection signal="pressed" from="Margin/VBox/CopyCode" to="." method="_on_copy_code_pressed"]
75+
[connection signal="pressed" from="PanelContainer/VBox/HBoxContainer/MarginContainer/CopyCode" to="." method="_on_copy_code_pressed"]

0 commit comments

Comments
 (0)