mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
54 lines
1,016 B
GDScript
54 lines
1,016 B
GDScript
extends HBoxContainer
|
|
|
|
@onready var left_slot: ColorRect = $LeftSlot
|
|
@onready var right_slot: ColorRect = $RightSlot
|
|
|
|
var text: String
|
|
|
|
signal button_pressed
|
|
|
|
|
|
func set_input_enabled(enabled: bool) -> void:
|
|
left_slot.visible = enabled
|
|
|
|
|
|
func set_output_enabled(enabled: bool) -> void:
|
|
right_slot.visible = enabled
|
|
|
|
|
|
func add_label(text: String) -> void:
|
|
var l := Label.new()
|
|
add_child(l)
|
|
l.text = text
|
|
move_child(l, 1)
|
|
l.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
|
|
|
|
func add_field(placeholder: String = "") -> void:
|
|
var le := LineEdit.new()
|
|
add_child(le)
|
|
move_child(le, 1)
|
|
le.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
le.placeholder_text = placeholder
|
|
|
|
le.text_changed.connect(
|
|
func(new_text: String):
|
|
text = new_text
|
|
)
|
|
|
|
|
|
func get_text() -> String:
|
|
return text
|
|
|
|
|
|
func add_button(text: String) -> void:
|
|
var b := Button.new()
|
|
b.text = text
|
|
add_child(b)
|
|
move_child(b, 1)
|
|
b.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
|
|
b.pressed.connect(
|
|
func():
|
|
button_pressed.emit()
|
|
)
|