Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/data_classes/Element.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ signal descendant_attribute_changed(name: String)
var _child_elements: Array[XNode]
var _attributes: Dictionary[String, Attribute]

var meta_collapsed: bool

func _init() -> void:
attribute_changed.connect(_on_attribute_changed)
ancestor_attribute_changed.connect(_on_ancestor_attribute_changed)
Expand Down
22 changes: 21 additions & 1 deletion src/ui_widgets/element_frame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ func _ready() -> void:
main_container.add_child(child_xnodes_container)
for xnode_editor in XNodeChildrenBuilder.create(element):
child_xnodes_container.add_child(xnode_editor)

for child in main_container.get_children():
child.visible = not element.meta_collapsed

func _exit_tree() -> void:
RenderingServer.free_rid(surface)
Expand Down Expand Up @@ -108,6 +111,13 @@ func _on_title_button_pressed() -> void:
Utils.LayoutPart.INSPECTOR), rect, viewport)


func _on_collapse_button_pressed() -> void:
State.normal_select(element.xid)
element.meta_collapsed = not element.meta_collapsed
for child: Control in main_container.get_children():
child.visible = not element.meta_collapsed


func _gui_input(event: InputEvent) -> void:
if event is InputEventMouseMotion and event.button_mask == 0:
if State.semi_hovered_xid != element.xid and\
Expand Down Expand Up @@ -142,7 +152,17 @@ func _on_mouse_entered() -> void:
var half_bar_width := title_bar.size.x / 2
var title_width := ThemeUtils.mono_font.get_string_size(element.name,
HORIZONTAL_ALIGNMENT_LEFT, 180, 12).x
# Add button.
# Add collapse button
var collapse_button := Button.new()
collapse_button.focus_mode = Control.FOCUS_NONE
collapse_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
collapse_button.mouse_filter = Control.MOUSE_FILTER_PASS
collapse_button.theme_type_variation = "FlatButton"
collapse_button.size = Vector2(title_bar.size.x, title_bar.size.y)
title_bar.add_child(collapse_button)
collapse_button.pressed.connect(_on_collapse_button_pressed)
mouse_exited.connect(collapse_button.queue_free)
# Add title button.
var title_button := Button.new()
title_button.focus_mode = Control.FOCUS_NONE
title_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
Expand Down
Loading