From 9083809865719e443b8c85af0f4a517e7b2742e1 Mon Sep 17 00:00:00 2001 From: dam Date: Mon, 28 Mar 2022 16:26:50 +0000 Subject: Add title on popup control and use it to display the option sets placeholder texts. --- logic/popup.gd | 7 +++++-- main.tscn | 22 ++++++++++++++++++++-- option_set/option_set.gd | 6 ++++-- option_set/option_set_list.gd | 1 + 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/logic/popup.gd b/logic/popup.gd index 1b1813a..7526678 100644 --- a/logic/popup.gd +++ b/logic/popup.gd @@ -3,15 +3,18 @@ class_name ModalPopup var control : Control +onready var title := get_node("title") as Label +onready var background := get_node("background") as Panel + func _init(): anchor_right = 1.0 anchor_bottom = 1.0 -func popup_control(item: Control): +func popup_control(title: String, item: Control): + self.title.text = title control = item control.connect("visibility_changed", self, "closed") - var background = $background control.anchor_left = background.anchor_left control.anchor_top = background.anchor_top control.anchor_right = background.anchor_right diff --git a/main.tscn b/main.tscn index 0b3d4a0..a52ec08 100644 --- a/main.tscn +++ b/main.tscn @@ -125,6 +125,7 @@ margin_top = 336.0 margin_right = 1080.0 margin_bottom = 398.0 rect_min_size = Vector2( 0, 62 ) +placeholder = "Local" [node name="anesthesia" parent="stage/controls" index="4" instance=ExtResource( 7 )] anchor_right = 0.0 @@ -133,6 +134,7 @@ margin_top = 402.0 margin_right = 1080.0 margin_bottom = 464.0 rect_min_size = Vector2( 0, 62 ) +placeholder = "Anestesia" [node name="first_assistant" parent="stage/controls" index="5" instance=ExtResource( 7 )] anchor_right = 0.0 @@ -141,6 +143,7 @@ margin_top = 468.0 margin_right = 1080.0 margin_bottom = 530.0 rect_min_size = Vector2( 0, 62 ) +placeholder = "1º Ajudante" [node name="type" parent="stage/controls" index="6" instance=ExtResource( 7 )] anchor_right = 0.0 @@ -149,6 +152,7 @@ margin_top = 534.0 margin_right = 1080.0 margin_bottom = 596.0 rect_min_size = Vector2( 0, 62 ) +placeholder = "Tipo" [node name="sub_type" parent="stage/controls" index="7" instance=ExtResource( 7 )] anchor_right = 0.0 @@ -157,6 +161,7 @@ margin_top = 600.0 margin_right = 1080.0 margin_bottom = 662.0 rect_min_size = Vector2( 0, 62 ) +placeholder = "Sub-tipo" [node name="sub_sub_type" parent="stage/controls" index="8" instance=ExtResource( 7 )] anchor_right = 0.0 @@ -165,6 +170,7 @@ margin_top = 666.0 margin_right = 1080.0 margin_bottom = 728.0 rect_min_size = Vector2( 0, 62 ) +placeholder = "Sub-sub-tipo" [node name="pathology" parent="stage/controls" index="9" instance=ExtResource( 7 )] anchor_right = 0.0 @@ -173,6 +179,7 @@ margin_top = 732.0 margin_right = 1080.0 margin_bottom = 794.0 rect_min_size = Vector2( 0, 62 ) +placeholder = "Patologia" [node name="intervention" parent="stage/controls" index="10" instance=ExtResource( 7 )] anchor_right = 0.0 @@ -181,6 +188,7 @@ margin_top = 798.0 margin_right = 1080.0 margin_bottom = 860.0 rect_min_size = Vector2( 0, 62 ) +placeholder = "Intervenção" [node name="is_urgency" type="CheckBox" parent="stage/controls" index="11"] margin_top = 864.0 @@ -250,15 +258,25 @@ dialog_autowrap = true visible = false anchor_right = 1.0 anchor_bottom = 1.0 -color = Color( 0, 0, 0, 0.501961 ) +color = Color( 0, 0, 0, 0.870588 ) script = ExtResource( 10 ) [node name="background" type="Panel" parent="popup"] anchor_left = 0.05 -anchor_top = 0.025 +anchor_top = 0.1 anchor_right = 0.95 anchor_bottom = 0.975 +[node name="title" type="Label" parent="popup"] +anchor_left = 0.05 +anchor_top = 0.025 +anchor_right = 0.95 +anchor_bottom = 0.1 +align = 1 +valign = 1 +autowrap = true +uppercase = true + [node name="option_set_list" type="Control" parent="."] visible = false rect_clip_content = true diff --git a/option_set/option_set.gd b/option_set/option_set.gd index 040566a..2ac1475 100644 --- a/option_set/option_set.gd +++ b/option_set/option_set.gd @@ -1,6 +1,8 @@ extends Control class_name OptionSet +export var placeholder: String + var text: String setget set_text, get_text func set_text(var value: String): @@ -19,7 +21,7 @@ onready var options := get_node("/root/main/option_set_list") as OptionSetList func _ready(): assert(popup != null, "OptionSet failed to get 'popup' node.") - + input.placeholder_text = placeholder input.connect("focus_entered", input, "set", ["caret_position", input.max_length]) input.connect("focus_exited", input, "deselect") @@ -34,7 +36,7 @@ func show_options(options_array: Array): else: options.unselect() options.connect("item_selected", self, "option_selected", [], CONNECT_ONESHOT) - popup.popup_control(options) + popup.popup_control(input.placeholder_text, options) # popup.connect("item_selected", self, "option_selected", [], CONNECT_ONESHOT) # popup.clear_items() # popup_opt.visible = true diff --git a/option_set/option_set_list.gd b/option_set/option_set_list.gd index 6efd068..5ebe5bf 100644 --- a/option_set/option_set_list.gd +++ b/option_set/option_set_list.gd @@ -116,6 +116,7 @@ func remove_items(indices: Array): func clear_items(): items.clear() + v_scroll_bar.value = 0.0 is_dirty = true -- cgit v1.2.3