add group list item component
This commit is contained in:
parent
1ecf9dba09
commit
3e967559e2
@ -39,7 +39,7 @@ func _ready() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func add(item: InstallItem) -> void:
|
func add(item: InstallItem) -> void:
|
||||||
pass
|
child_container.add_child(item)
|
||||||
|
|
||||||
|
|
||||||
func free_item(at_idx: int) -> void:
|
func free_item(at_idx: int) -> void:
|
||||||
@ -90,9 +90,10 @@ func setup_rename() -> void:
|
|||||||
l.size_flags_horizontal = header_text_label.size_flags_horizontal
|
l.size_flags_horizontal = header_text_label.size_flags_horizontal
|
||||||
|
|
||||||
# edit_group_button.disabled = true
|
# edit_group_button.disabled = true
|
||||||
|
var label_index := header_text_label.get_index()
|
||||||
|
|
||||||
header_container.add_child(l)
|
header_container.add_child(l)
|
||||||
header_container.move_child(l, 2)
|
header_container.move_child(l, label_index)
|
||||||
|
|
||||||
var reenable = func():
|
var reenable = func():
|
||||||
header_text_label.visible = true
|
header_text_label.visible = true
|
||||||
|
60
UI/Components/InstallItem.gd
Normal file
60
UI/Components/InstallItem.gd
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
extends HBoxContainer
|
||||||
|
class_name InstallItem
|
||||||
|
|
||||||
|
@onready var item_icon: TextureRect = %ItemIcon
|
||||||
|
@onready var name_label: Label = %NameLabel
|
||||||
|
@onready var edit_item_button: Button = %EditItemButton
|
||||||
|
@onready var delete_item_button: Button = %DeleteItemButton
|
||||||
|
@onready var launch_item_button: Button = %LaunchItemButton
|
||||||
|
|
||||||
|
signal edit_item_button_pressed
|
||||||
|
signal delete_item_button_pressed
|
||||||
|
signal launch_item_button_pressed
|
||||||
|
|
||||||
|
signal name_changed(new_name: String)
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
edit_item_button.pressed.connect(func(): edit_item_button_pressed.emit())
|
||||||
|
delete_item_button.pressed.connect(func(): delete_item_button_pressed.emit())
|
||||||
|
|
||||||
|
name_label.gui_input.connect(_on_name_label_gui_input)
|
||||||
|
|
||||||
|
|
||||||
|
func set_icon(icon: Texture2D) -> void:
|
||||||
|
item_icon.texture = icon
|
||||||
|
|
||||||
|
|
||||||
|
func set_icon_visible(p_visible: bool) -> void:
|
||||||
|
item_icon.visible = p_visible
|
||||||
|
|
||||||
|
|
||||||
|
func setup_rename() -> void:
|
||||||
|
name_label.visible = false
|
||||||
|
var l := RenameLineEdit.new(name_label.text)
|
||||||
|
l.size_flags_horizontal = name_label.size_flags_horizontal
|
||||||
|
|
||||||
|
var label_index := name_label.get_index()
|
||||||
|
|
||||||
|
add_child(l)
|
||||||
|
move_child(l, label_index)
|
||||||
|
|
||||||
|
l.canceled.connect(name_label.set_visible.bind(true))
|
||||||
|
|
||||||
|
l.text_submitted.connect(
|
||||||
|
func(new_text: String):
|
||||||
|
name_label.text = new_text
|
||||||
|
name_changed.emit(new_text)
|
||||||
|
|
||||||
|
name_label.visible = true
|
||||||
|
)
|
||||||
|
|
||||||
|
l.grab_focus()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_name_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()
|
48
UI/Components/InstallItem.tscn
Normal file
48
UI/Components/InstallItem.tscn
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
[gd_scene load_steps=3 format=3 uid="uid://duq208khfvm2t"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://UI/Components/InstallItem.gd" id="1_sh2ev"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://de57eeeobflp4" path="res://icon.svg" id="1_wwvlr"]
|
||||||
|
|
||||||
|
[node name="InstallItem" type="HBoxContainer"]
|
||||||
|
anchors_preset = -1
|
||||||
|
offset_right = 299.0
|
||||||
|
offset_bottom = 32.0
|
||||||
|
script = ExtResource("1_sh2ev")
|
||||||
|
metadata/_edit_use_anchors_ = true
|
||||||
|
|
||||||
|
[node name="Indent" type="MarginContainer" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/margin_left = 6
|
||||||
|
|
||||||
|
[node name="ItemIcon" type="TextureRect" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
texture = ExtResource("1_wwvlr")
|
||||||
|
expand_mode = 2
|
||||||
|
|
||||||
|
[node name="NameLabel" type="Label" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
mouse_filter = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="EditItemButton" type="Button" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
text = "E"
|
||||||
|
|
||||||
|
[node name="DeleteItemButton" type="Button" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
text = "X"
|
||||||
|
|
||||||
|
[node name="LaunchItemButton" type="Button" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
text = ">"
|
||||||
|
|
||||||
|
[node name="Indent2" type="MarginContainer" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/margin_left = 6
|
@ -6,6 +6,7 @@ anchor_right = 1.0
|
|||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
metadata/_edit_use_anchors_ = true
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="."]
|
[node name="Label" type="Label" parent="."]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
Loading…
Reference in New Issue
Block a user