diff options
| author | dam <dam@gudinoff> | 2022-02-17 00:30:16 +0000 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2022-02-17 00:30:16 +0000 |
| commit | 48a26128f175047528fcc1c96590f1a7bbc281eb (patch) | |
| tree | 03cebc078fd30f74da8fdce4469055d9b70b3985 | |
| parent | 00825f2a5664000fa98d36922c0c329b052a724f (diff) | |
| download | surgery-log-48a26128f175047528fcc1c96590f1a7bbc281eb.tar.zst surgery-log-48a26128f175047528fcc1c96590f1a7bbc281eb.zip | |
Prototype with custom option set control.
| -rw-r--r-- | logic/stage.gd | 47 | ||||
| -rw-r--r-- | main.tscn | 151 | ||||
| -rw-r--r-- | option_set/option_set.gd | 15 | ||||
| -rw-r--r-- | option_set/option_set.tscn | 34 | ||||
| -rw-r--r-- | project.godot | 6 | ||||
| -rw-r--r-- | touch_vertical_container/touch_vertical_container.gd | 35 |
6 files changed, 146 insertions, 142 deletions
diff --git a/logic/stage.gd b/logic/stage.gd index 66d6d6d..3cc5943 100644 --- a/logic/stage.gd +++ b/logic/stage.gd @@ -26,14 +26,14 @@ onready var confirm_action := get_node("/root/main/confirm_action") as Confirmat onready var process_id := get_node("controls/process_id") as LineEdit onready var surgery_id := get_node("controls/surgery_id") as LineEdit onready var date := get_node("controls/date_picker") as DatePicker -onready var place := get_node("controls/place") as LineEdit -onready var anesthesia := get_node("controls/anesthesia") as LineEdit -onready var first_assistant := get_node("controls/first_assistant") as LineEdit -onready var type := get_node("controls/type") as LineEdit -onready var sub_type := get_node("controls/sub_type") as LineEdit -onready var sub_sub_type := get_node("controls/sub_sub_type") as LineEdit -onready var pathology := get_node("controls/pathology") as LineEdit -onready var intervention := get_node("controls/intervention") as LineEdit +onready var place := get_node("controls/place") as OptionSet +onready var anesthesia := get_node("controls/anesthesia") as OptionSet +onready var first_assistant := get_node("controls/first_assistant") as OptionSet +onready var type := get_node("controls/type") as OptionSet +onready var sub_type := get_node("controls/sub_type") as OptionSet +onready var sub_sub_type := get_node("controls/sub_sub_type") as OptionSet +onready var pathology := get_node("controls/pathology") as OptionSet +onready var intervention := get_node("controls/intervention") as OptionSet onready var is_urgency := get_node("controls/is_urgency") as Button onready var notes := get_node("controls/notes") as LineEdit onready var save_button := get_node("controls/save") as Button @@ -49,8 +49,9 @@ func _ready(): save_button.connect("pressed", self, "save_action") discard_button.connect("pressed", self, "discard_action") + # @DAM Not working because we changed the stage/controls/.. estructure with the new option_sets. + # @DAM We could try to do a recursive approach or, build a stack of next items to process. for it in get_node("controls").get_children(): - it = it as Control if it is LineEdit: it.connect("focus_entered", it, "set_cursor_position", [99999999]) # @DAM Use MAX_INT it.connect("focus_exited", it, "deselect") @@ -67,7 +68,12 @@ func _ready(): "intervention": intervention } for key in option_sets_map: - var button := option_sets_map[key].get_node("option_set") as Button +# var button := option_sets_map[key].get_node("option_set") as Button +# button.connect("pressed", self, "show_option_sets", [key]) + +# if key != "place": # @DAM DEBUG +# continue + var button := option_sets_map[key].get_node("options") as Button button.connect("pressed", self, "show_option_sets", [key]) @@ -89,6 +95,7 @@ func get_option_sets(field: String): return options +# @DAM WIP I suspect that these should go inside the option_set class... func show_option_sets(field: String): var stage_options = get_node("/root/main/popup_list") as Popup stage_options.connect("item_selected", self, "option_set_selected", [field], CONNECT_ONESHOT) @@ -96,7 +103,7 @@ func show_option_sets(field: String): func option_set_selected(index: int, field: String): - var field_input: LineEdit = self[field] + var field_input: LineEdit = self[field].get_node("input") field_input.text = get_option_sets(field)[index] field_input.caret_position = field_input.text.length() @@ -232,21 +239,3 @@ func clear_option_sets(save_changes: bool = false): store_option_sets() -func pointer_input_on_click_handler(pointer: PointerInputSensor.PointerInputData): - .pointer_input_on_click_handler(pointer) - - var target: Control = pointer.target.get_parent() - var button: Button - if target is Button: - button = target - elif target.get_node("option_set") is Button: - button = target.get_node("option_set") - - if button != null && button.get_global_rect().has_point(pointer.current_position): - if button is CheckBox || button is CheckButton: - button.pressed = !button.pressed - button.emit_signal("button_down") - button.emit_signal("pressed") - button.emit_signal("button_up") - - @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=2] +[gd_scene load_steps=12 format=2] [ext_resource path="res://main.gd" type="Script" id=1] [ext_resource path="res://date_picker/date_picker.tscn" type="PackedScene" id=2] @@ -6,6 +6,7 @@ [ext_resource path="res://menu/menu.gd" type="Script" id=4] [ext_resource path="res://logic/database.gd" type="Script" id=5] [ext_resource path="res://fonts/font_icons.tres" type="DynamicFont" id=6] +[ext_resource path="res://option_set/option_set.tscn" type="PackedScene" id=7] [ext_resource path="res://logic/stage.gd" type="Script" id=9] [ext_resource path="res://logic/popup_list.gd" type="Script" id=10] [ext_resource path="res://touch_item_list/touch_item_list.tscn" type="PackedScene" id=11] @@ -52,6 +53,8 @@ __meta__ = { } [node name="delete" type="Button" parent="database/actions"] +margin_right = 95.0 +margin_bottom = 162.0 focus_mode = 0 custom_fonts/font = ExtResource( 6 ) enabled_focus_mode = 0 @@ -62,8 +65,9 @@ __meta__ = { } [node name="edit" type="Button" parent="database/actions"] -anchor_top = 0.333 -anchor_bottom = 0.333 +margin_top = 166.0 +margin_right = 95.0 +margin_bottom = 328.0 focus_mode = 0 custom_fonts/font = ExtResource( 6 ) enabled_focus_mode = 0 @@ -74,8 +78,9 @@ __meta__ = { } [node name="add" type="Button" parent="database/actions"] -anchor_top = 0.667 -anchor_bottom = 0.667 +margin_top = 332.0 +margin_right = 95.0 +margin_bottom = 494.0 focus_mode = 0 custom_fonts/font = ExtResource( 6 ) enabled_focus_mode = 0 @@ -114,141 +119,69 @@ margin_bottom = 332.0 rect_min_size = Vector2( 400, 200 ) size_flags_horizontal = 4 -[node name="place" type="LineEdit" parent="stage/controls" index="3"] +[node name="place" parent="stage/controls" index="3" instance=ExtResource( 7 )] +anchor_right = 0.0 +anchor_bottom = 0.0 margin_top = 336.0 margin_right = 1080.0 margin_bottom = 398.0 -placeholder_text = "Local" -caret_blink = true -caret_blink_speed = 0.5 - -[node name="option_set" type="Button" parent="stage/controls/place"] -anchor_left = 0.88 -anchor_right = 1.0 -anchor_bottom = 1.0 -text = "▽" -__meta__ = { -"_edit_use_anchors_": false -} +rect_min_size = Vector2( 0, 62 ) -[node name="anesthesia" type="LineEdit" parent="stage/controls" index="4"] +[node name="anesthesia" parent="stage/controls" index="4" instance=ExtResource( 7 )] +anchor_right = 0.0 +anchor_bottom = 0.0 margin_top = 402.0 margin_right = 1080.0 margin_bottom = 464.0 -placeholder_text = "Anestesia" -caret_blink = true -caret_blink_speed = 0.5 - -[node name="option_set" type="Button" parent="stage/controls/anesthesia"] -anchor_left = 0.88 -anchor_right = 1.0 -anchor_bottom = 1.0 -text = "▽" -__meta__ = { -"_edit_use_anchors_": false -} +rect_min_size = Vector2( 0, 62 ) -[node name="first_assistant" type="LineEdit" parent="stage/controls" index="5"] +[node name="first_assistant" parent="stage/controls" index="5" instance=ExtResource( 7 )] +anchor_right = 0.0 +anchor_bottom = 0.0 margin_top = 468.0 margin_right = 1080.0 margin_bottom = 530.0 -placeholder_text = "1º Ajudante" -caret_blink = true -caret_blink_speed = 0.5 - -[node name="option_set" type="Button" parent="stage/controls/first_assistant"] -anchor_left = 0.88 -anchor_right = 1.0 -anchor_bottom = 1.0 -text = "▽" -__meta__ = { -"_edit_use_anchors_": false -} +rect_min_size = Vector2( 0, 62 ) -[node name="type" type="LineEdit" parent="stage/controls" index="6"] +[node name="type" parent="stage/controls" index="6" instance=ExtResource( 7 )] +anchor_right = 0.0 +anchor_bottom = 0.0 margin_top = 534.0 margin_right = 1080.0 margin_bottom = 596.0 -placeholder_text = "Tipo" -caret_blink = true -caret_blink_speed = 0.5 - -[node name="option_set" type="Button" parent="stage/controls/type"] -anchor_left = 0.88 -anchor_right = 1.0 -anchor_bottom = 1.0 -text = "▽" -__meta__ = { -"_edit_use_anchors_": false -} +rect_min_size = Vector2( 0, 62 ) -[node name="sub_type" type="LineEdit" parent="stage/controls" index="7"] +[node name="sub_type" parent="stage/controls" index="7" instance=ExtResource( 7 )] +anchor_right = 0.0 +anchor_bottom = 0.0 margin_top = 600.0 margin_right = 1080.0 margin_bottom = 662.0 -placeholder_text = "Subtipo" -caret_blink = true -caret_blink_speed = 0.5 - -[node name="option_set" type="Button" parent="stage/controls/sub_type"] -anchor_left = 0.88 -anchor_right = 1.0 -anchor_bottom = 1.0 -text = "▽" -__meta__ = { -"_edit_use_anchors_": false -} +rect_min_size = Vector2( 0, 62 ) -[node name="sub_sub_type" type="LineEdit" parent="stage/controls" index="8"] +[node name="sub_sub_type" parent="stage/controls" index="8" instance=ExtResource( 7 )] +anchor_right = 0.0 +anchor_bottom = 0.0 margin_top = 666.0 margin_right = 1080.0 margin_bottom = 728.0 -placeholder_text = "Sub-Subtipo" -caret_blink = true -caret_blink_speed = 0.5 - -[node name="option_set" type="Button" parent="stage/controls/sub_sub_type"] -anchor_left = 0.88 -anchor_right = 1.0 -anchor_bottom = 1.0 -text = "▽" -__meta__ = { -"_edit_use_anchors_": false -} +rect_min_size = Vector2( 0, 62 ) -[node name="pathology" type="LineEdit" parent="stage/controls" index="9"] +[node name="pathology" parent="stage/controls" index="9" instance=ExtResource( 7 )] +anchor_right = 0.0 +anchor_bottom = 0.0 margin_top = 732.0 margin_right = 1080.0 margin_bottom = 794.0 -placeholder_text = "Patologia" -caret_blink = true -caret_blink_speed = 0.5 - -[node name="option_set" type="Button" parent="stage/controls/pathology"] -anchor_left = 0.88 -anchor_right = 1.0 -anchor_bottom = 1.0 -text = "▽" -__meta__ = { -"_edit_use_anchors_": false -} +rect_min_size = Vector2( 0, 62 ) -[node name="intervention" type="LineEdit" parent="stage/controls" index="10"] +[node name="intervention" parent="stage/controls" index="10" instance=ExtResource( 7 )] +anchor_right = 0.0 +anchor_bottom = 0.0 margin_top = 798.0 margin_right = 1080.0 margin_bottom = 860.0 -placeholder_text = "Intervenção" -caret_blink = true -caret_blink_speed = 0.5 - -[node name="option_set" type="Button" parent="stage/controls/intervention"] -anchor_left = 0.88 -anchor_right = 1.0 -anchor_bottom = 1.0 -text = "▽" -__meta__ = { -"_edit_use_anchors_": false -} +rect_min_size = Vector2( 0, 62 ) [node name="is_urgency" type="CheckBox" parent="stage/controls" index="11"] margin_top = 864.0 diff --git a/option_set/option_set.gd b/option_set/option_set.gd new file mode 100644 index 0000000..e9cac3f --- /dev/null +++ b/option_set/option_set.gd @@ -0,0 +1,15 @@ +extends Control +class_name OptionSet + +var text: String setget set_text, get_text + +func set_text(var value: String): + input.text = value + +func get_text() -> String: + return input.text + + +onready var input := get_node("input") as LineEdit + + diff --git a/option_set/option_set.tscn b/option_set/option_set.tscn new file mode 100644 index 0000000..fc2aff5 --- /dev/null +++ b/option_set/option_set.tscn @@ -0,0 +1,34 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://option_set/option_set.gd" type="Script" id=1] + +[node name="option_set" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="input" type="LineEdit" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_right = -100.0 +size_flags_horizontal = 3 +placeholder_text = "option set placeholder" +caret_blink = true +caret_blink_speed = 0.5 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="options" type="Button" parent="."] +anchor_left = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = -100.0 +grow_horizontal = 0 +text = "▽" +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/project.godot b/project.godot index 9067744..aed55ea 100644 --- a/project.godot +++ b/project.godot @@ -25,6 +25,11 @@ _global_script_classes=[ { "path": "res://date_picker/date_picker.gd" }, { "base": "Control", +"class": "OptionSet", +"language": "GDScript", +"path": "res://option_set/option_set.gd" +}, { +"base": "Control", "class": "PointerInputSensor", "language": "GDScript", "path": "res://pointer_input_sensor.gd" @@ -53,6 +58,7 @@ _global_script_class_icons={ "Database": "", "DatabaseEntry": "", "DatePicker": "", +"OptionSet": "", "PointerInputSensor": "", "Stage": "", "TouchItemList": "", diff --git a/touch_vertical_container/touch_vertical_container.gd b/touch_vertical_container/touch_vertical_container.gd index f9c43e9..7c2ba84 100644 --- a/touch_vertical_container/touch_vertical_container.gd +++ b/touch_vertical_container/touch_vertical_container.gd @@ -27,8 +27,8 @@ func _ready(): sensor.connect("on_end_drag", self, "pointer_input_on_end_drag_handler") sensor.connect("on_click", self, "pointer_input_on_click_handler") - it.connect("focus_entered", sensor, "set_visible", [false]) - it.connect("focus_exited", sensor, "set_visible", [true]) +# it.connect("focus_entered", sensor, "set_visible", [false]) +# it.connect("focus_exited", sensor, "set_visible", [true]) func _process(delta: float): @@ -54,6 +54,33 @@ func pointer_input_on_end_drag_handler(pointer: PointerInputSensor.PointerInputD func pointer_input_on_click_handler(pointer: PointerInputSensor.PointerInputData): - pointer.target.get_parent().grab_focus() - + propagate_click(pointer.target.get_parent(), pointer) + + +# @DAM Maybe replace this with a stack of next items to process approach. +func propagate_click(control: Control, pointer: PointerInputSensor.PointerInputData) -> bool: + if control is PointerInputSensor || control.mouse_filter == MOUSE_FILTER_IGNORE || control.visible == false: + return false + var click_processed := false + if control.get_global_rect().has_point(pointer.current_position): + var children = control.get_children() + children.invert() # @DAM Use inverted index for loop to avoid invert() operation. + for child in children: + if child is Control: + click_processed = click_processed || propagate_click(child, pointer) + if click_processed == true: + break + + if click_processed == false: + if control is CheckBox || control is CheckButton: + control.pressed = !control.pressed + control.grab_focus() + control.emit_signal("button_down") + control.emit_signal("pressed") + control.emit_signal("button_up") + click_processed = true + pointer.target.visible = false + control.connect("focus_exited", pointer.target, "set_visible", [true]) + + return click_processed |
