-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added collapse/expand blocks to hide advanced settings.
This commit modifies the display_template parsing of .tres block definitions, adding a separator using the | character. All labels and parameters after this separator are added to a new CollapsableSettings container that has collapse/expand buttons, with the goal of hiding advanced settings from users. To do this, a new hidden key with a boolean value is added to the results of the parse_display_template method. Additionally, CollapsableSettings is implemented using an HBoxContainer and changing the visibility of child nodes when changing collapse/expand states. Fixes #288.
- Loading branch information
Showing
9 changed files
with
177 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
addons/block_code/ui/blocks/utilities/template_editor/collapsable_settings.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@tool | ||
class_name CollapsableSettings | ||
extends HBoxContainer | ||
|
||
@onready var _expand_button: Button = %ExpandSettingsButton | ||
@onready var _collapse_button: Button = %CollapseSettingsButton | ||
var _collapsed := false | ||
|
||
|
||
func _ready() -> void: | ||
_collapse() | ||
move_child(_expand_button, 0) | ||
move_child(_collapse_button, -1) | ||
_expand_button.connect("button_up", _expand) | ||
_collapse_button.connect("button_up", _collapse) | ||
|
||
|
||
func _expand() -> void: | ||
if not _collapsed: | ||
return | ||
for child in get_children(true): | ||
child.visible = true | ||
_expand_button.visible = false | ||
_collapse_button.visible = true | ||
_collapsed = false | ||
|
||
|
||
func _collapse() -> void: | ||
if _collapsed: | ||
return | ||
for child in get_children(true): | ||
child.visible = false | ||
_expand_button.visible = true | ||
_collapsed = true |
25 changes: 25 additions & 0 deletions
25
addons/block_code/ui/blocks/utilities/template_editor/collapsable_settings.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[gd_scene load_steps=4 format=3 uid="uid://1xfpd777g8pf"] | ||
|
||
[ext_resource type="Script" path="res://addons/block_code/ui/blocks/utilities/template_editor/collapsable_settings.gd" id="1_f0ssn"] | ||
[ext_resource type="Texture2D" uid="uid://br7yvjjtbuups" path="res://addons/block_code/ui/blocks/utilities/template_editor/plus.png" id="2_8s057"] | ||
[ext_resource type="Texture2D" uid="uid://di3ona3fudjkx" path="res://addons/block_code/ui/blocks/utilities/template_editor/minus.png" id="3_6qcv3"] | ||
|
||
[node name="CollapsableSettings" type="HBoxContainer"] | ||
offset_right = 36.0 | ||
offset_bottom = 31.0 | ||
script = ExtResource("1_f0ssn") | ||
|
||
[node name="ExpandSettingsButton" type="Button" parent="."] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
icon = ExtResource("2_8s057") | ||
flat = true | ||
icon_alignment = 1 | ||
|
||
[node name="CollapseSettingsButton" type="Button" parent="."] | ||
unique_name_in_owner = true | ||
custom_minimum_size = Vector2(20, 20) | ||
layout_mode = 2 | ||
icon = ExtResource("3_6qcv3") | ||
flat = true | ||
icon_alignment = 1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
addons/block_code/ui/blocks/utilities/template_editor/minus.png.import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://di3ona3fudjkx" | ||
path="res://.godot/imported/minus.png-7cbe293178ea19d9e5fbc8ba50c3a01b.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://addons/block_code/ui/blocks/utilities/template_editor/minus.png" | ||
dest_files=["res://.godot/imported/minus.png-7cbe293178ea19d9e5fbc8ba50c3a01b.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
addons/block_code/ui/blocks/utilities/template_editor/plus.png.import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://br7yvjjtbuups" | ||
path="res://.godot/imported/plus.png-415014510d01c9db50069dbfc9e6ab6f.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://addons/block_code/ui/blocks/utilities/template_editor/plus.png" | ||
dest_files=["res://.godot/imported/plus.png-415014510d01c9db50069dbfc9e6ab6f.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters