From b9b0d3e1b3c632415504da53e608b7ed60bc2d6a Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Sun, 8 Mar 2020 21:57:22 +0200 Subject: [PATCH] Small UI improvement - The visibility icon will remain in a fixed place no matter how long the layer name is. --- Prefabs/LayerContainer.tscn | 54 ++++++++++++++++++++++++------------- Scripts/Global.gd | 4 +-- Scripts/LayerContainer.gd | 11 +++++--- 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/Prefabs/LayerContainer.tscn b/Prefabs/LayerContainer.tscn index b9a5d530b..439554a80 100644 --- a/Prefabs/LayerContainer.tscn +++ b/Prefabs/LayerContainer.tscn @@ -8,27 +8,32 @@ margin_right = 210.0 margin_bottom = 36.0 rect_min_size = Vector2( 212, 36 ) +size_flags_horizontal = 0 toggle_mode = true script = ExtResource( 1 ) __meta__ = { -"_edit_horizontal_guides_": [ ] +"_edit_horizontal_guides_": [ ], +"_edit_use_anchors_": false } [node name="HBoxContainer" type="HBoxContainer" parent="."] -anchor_top = 0.5 anchor_right = 1.0 -anchor_bottom = 0.5 -margin_top = -16.0 -margin_bottom = 16.0 -mouse_default_cursor_shape = 2 -alignment = 1 +anchor_bottom = 1.0 +size_flags_horizontal = 0 +__meta__ = { +"_edit_use_anchors_": false +} -[node name="VisibilityButton" type="TextureButton" parent="HBoxContainer" groups=[ +[node name="LayerButtons" type="HBoxContainer" parent="HBoxContainer"] +margin_right = 32.0 +margin_bottom = 36.0 + +[node name="VisibilityButton" type="TextureButton" parent="HBoxContainer/LayerButtons" groups=[ "UIButtons", ]] -margin_left = 65.0 -margin_right = 97.0 -margin_bottom = 32.0 +margin_top = 2.0 +margin_right = 32.0 +margin_bottom = 34.0 hint_tooltip = "LAYERVISIBILITY_HT" mouse_default_cursor_shape = 2 size_flags_horizontal = 0 @@ -36,15 +41,28 @@ size_flags_vertical = 4 texture_normal = ExtResource( 2 ) texture_hover = ExtResource( 3 ) -[node name="Label" type="Label" parent="HBoxContainer"] -margin_left = 101.0 -margin_top = 9.0 -margin_right = 147.0 -margin_bottom = 23.0 +[node name="LayerName" type="HBoxContainer" parent="HBoxContainer"] +margin_left = 36.0 +margin_right = 212.0 +margin_bottom = 36.0 +rect_min_size = Vector2( 176, 0 ) +mouse_default_cursor_shape = 2 +size_flags_horizontal = 0 +alignment = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label" type="Label" parent="HBoxContainer/LayerName"] +margin_top = 11.0 +margin_right = 176.0 +margin_bottom = 25.0 +size_flags_horizontal = 3 text = "Layer 0" align = 1 +clip_text = true -[node name="LineEdit" type="LineEdit" parent="HBoxContainer"] +[node name="LineEdit" type="LineEdit" parent="HBoxContainer/LayerName"] visible = false margin_left = 86.0 margin_top = 5.0 @@ -57,4 +75,4 @@ editable = false caret_blink = true caret_blink_speed = 0.5 [connection signal="pressed" from="." to="." method="_on_LayerContainer_pressed"] -[connection signal="pressed" from="HBoxContainer/VisibilityButton" to="." method="_on_VisibilityButton_pressed"] +[connection signal="pressed" from="HBoxContainer/LayerButtons/VisibilityButton" to="." method="_on_VisibilityButton_pressed"] diff --git a/Scripts/Global.gd b/Scripts/Global.gd index 7e629517a..41f1edf06 100644 --- a/Scripts/Global.gd +++ b/Scripts/Global.gd @@ -516,9 +516,9 @@ func layers_changed(value : Array) -> void: if !layers[i][0]: layers[i][0] = tr("Layer") + " %s" % i - layer_container.get_child(0).get_child(1).text = layers[i][0] - layer_container.get_child(0).get_child(2).text = layers[i][0] layers_container.add_child(layer_container) + layer_container.label.text = layers[i][0] + layer_container.line_edit.text = layers[i][0] frames_container.add_child(layers[i][2]) for j in range(canvases.size()): diff --git a/Scripts/LayerContainer.gd b/Scripts/LayerContainer.gd index e518f7f96..9d9bef92a 100644 --- a/Scripts/LayerContainer.gd +++ b/Scripts/LayerContainer.gd @@ -4,12 +4,15 @@ extends Button var i := 0 # warning-ignore:unused_class_variable var currently_selected := false - -onready var visibility_button := $HBoxContainer/VisibilityButton -onready var label := $HBoxContainer/Label -onready var line_edit := $HBoxContainer/LineEdit +var visibility_button : BaseButton +var label : Label +var line_edit : LineEdit func _ready() -> void: + visibility_button = Global.find_node_by_name(self, "VisibilityButton") + label = Global.find_node_by_name(self, "Label") + line_edit = Global.find_node_by_name(self, "LineEdit") + if Global.layers[i][1]: visibility_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Layer_Visible.png" % Global.theme_type) visibility_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Layer_Visible_Hover.png" % Global.theme_type)