change edit button in GroupMenu to be a signal
change rename to be handled by double click on label
This commit is contained in:
parent
7d83a15625
commit
1ecf9dba09
@ -1,4 +1,5 @@
|
||||
extends VBoxContainer
|
||||
class_name GroupMenu
|
||||
|
||||
@onready var collapse_button: Button = %CollapseButton
|
||||
@onready var header_icon: TextureRect = %HeaderIcon
|
||||
@ -7,14 +8,16 @@ extends VBoxContainer
|
||||
@onready var child_container: VBoxContainer = %ChildContainer
|
||||
@onready var add_install_button_container: CenterContainer = %AddInstallButtonContainer
|
||||
@onready var add_install_button: Button = %AddInstallButton
|
||||
@onready var description_label: Label = %DescriptionLabel
|
||||
|
||||
@onready var edit_text_button: Button = %EditTextButton
|
||||
@onready var edit_group_button: Button = %EditGroupButton
|
||||
@onready var delete_group_button: Button = %DeleteGroupButton
|
||||
|
||||
@onready var header_container: HBoxContainer = %HeaderContainer
|
||||
|
||||
signal add_install_button_pressed
|
||||
|
||||
signal edit_group_button_pressed
|
||||
signal delete_button_pressed
|
||||
signal header_text_changed(new_text: String)
|
||||
|
||||
@ -28,11 +31,14 @@ func _ready() -> void:
|
||||
|
||||
add_install_button.pressed.connect(func(): add_install_button_pressed.emit())
|
||||
|
||||
edit_text_button.pressed.connect(setup_rename)
|
||||
# edit_group_button.pressed.connect(setup_rename)
|
||||
edit_group_button.pressed.connect(func(): edit_group_button_pressed.emit())
|
||||
delete_group_button.pressed.connect(func(): delete_button_pressed.emit())
|
||||
|
||||
header_text_label.gui_input.connect(_on_header_text_label_gui_input)
|
||||
|
||||
func add(item) -> void:
|
||||
|
||||
func add(item: InstallItem) -> void:
|
||||
pass
|
||||
|
||||
|
||||
@ -51,6 +57,15 @@ func set_text(text: String) -> void:
|
||||
header_text_label.text = text
|
||||
|
||||
|
||||
func set_description(text: String) -> void:
|
||||
if text == "":
|
||||
description_label.visible = false
|
||||
return
|
||||
|
||||
description_label.visible = true
|
||||
description_label.text = text
|
||||
|
||||
|
||||
func set_icon(icon: Texture2D) -> void:
|
||||
header_icon.texture = icon
|
||||
|
||||
@ -74,14 +89,14 @@ func setup_rename() -> void:
|
||||
var l := RenameLineEdit.new(header_text_label.text)
|
||||
l.size_flags_horizontal = header_text_label.size_flags_horizontal
|
||||
|
||||
edit_text_button.disabled = true
|
||||
# edit_group_button.disabled = true
|
||||
|
||||
header_container.add_child(l)
|
||||
header_container.move_child(l, 2)
|
||||
|
||||
var reenable = func():
|
||||
header_text_label.visible = true
|
||||
edit_text_button.disabled = false
|
||||
# edit_group_button.disabled = false
|
||||
|
||||
l.canceled.connect(reenable)
|
||||
|
||||
@ -94,3 +109,12 @@ func setup_rename() -> void:
|
||||
)
|
||||
|
||||
l.grab_focus()
|
||||
|
||||
|
||||
func _on_header_text_label_gui_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton && \
|
||||
(event as InputEventMouseButton).double_click && \
|
||||
(event as InputEventMouseButton).button_index == MOUSE_BUTTON_LEFT:
|
||||
get_viewport().set_input_as_handled()
|
||||
setup_rename()
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
[ext_resource type="Texture2D" uid="uid://de57eeeobflp4" path="res://icon.svg" id="2_crg6a"]
|
||||
|
||||
[node name="GroupMenu" type="VBoxContainer"]
|
||||
offset_right = 169.0
|
||||
offset_bottom = 71.0
|
||||
offset_right = 299.0
|
||||
offset_bottom = 87.0
|
||||
script = ExtResource("1_h3o1w")
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="."]
|
||||
@ -36,14 +36,14 @@ unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
text = "header text"
|
||||
mouse_filter = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="HeaderCustomControlContainer" type="HBoxContainer" parent="HeaderContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="EditTextButton" type="Button" parent="HeaderContainer/HeaderCustomControlContainer"]
|
||||
[node name="EditGroupButton" type="Button" parent="HeaderContainer/HeaderCustomControlContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "E"
|
||||
@ -53,6 +53,11 @@ unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "X"
|
||||
|
||||
[node name="DescriptionLabel" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ChildContainer" type="VBoxContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
Loading…
Reference in New Issue
Block a user