mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-24 02:17:27 -04:00
prompt focus
This commit is contained in:
parent
bffe8a330f
commit
3985aece50
7 changed files with 84 additions and 22 deletions
|
@ -41,6 +41,7 @@ grow_vertical = 2
|
||||||
theme_override_styles/normal = SubResource("StyleBoxFlat_wbjg7")
|
theme_override_styles/normal = SubResource("StyleBoxFlat_wbjg7")
|
||||||
theme_override_styles/hover = SubResource("StyleBoxFlat_srt8r")
|
theme_override_styles/hover = SubResource("StyleBoxFlat_srt8r")
|
||||||
theme_override_styles/pressed = SubResource("StyleBoxFlat_awixv")
|
theme_override_styles/pressed = SubResource("StyleBoxFlat_awixv")
|
||||||
|
theme_override_styles/focus = SubResource("StyleBoxFlat_srt8r")
|
||||||
script = ExtResource("1_7xv44")
|
script = ExtResource("1_7xv44")
|
||||||
gate_events = ExtResource("2_33m26")
|
gate_events = ExtResource("2_33m26")
|
||||||
prompt_text = NodePath("Label")
|
prompt_text = NodePath("Label")
|
||||||
|
@ -56,6 +57,7 @@ theme_override_font_sizes/font_size = 20
|
||||||
theme_override_styles/normal = SubResource("StyleBoxEmpty_6fg0o")
|
theme_override_styles/normal = SubResource("StyleBoxEmpty_6fg0o")
|
||||||
text = "prompt"
|
text = "prompt"
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
text_overrun_behavior = 3
|
||||||
|
|
||||||
[node name="SearchStatus" type="Control" parent="."]
|
[node name="SearchStatus" type="Control" parent="."]
|
||||||
self_modulate = Color(1, 1, 1, 0.8)
|
self_modulate = Color(1, 1, 1, 0.8)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=20 format=3 uid="uid://ctam0fxigbefk"]
|
[gd_scene load_steps=21 format=3 uid="uid://ctam0fxigbefk"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/ui/search.gd" id="1_7ivk2"]
|
[ext_resource type="Script" path="res://scripts/ui/search.gd" id="1_7ivk2"]
|
||||||
[ext_resource type="Resource" uid="uid://b1xvdym0qh6td" path="res://resources/gate_events.res" id="2_13io8"]
|
[ext_resource type="Resource" uid="uid://b1xvdym0qh6td" path="res://resources/gate_events.res" id="2_13io8"]
|
||||||
|
@ -15,6 +15,7 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://lxx36xkotvh1" path="res://textures/star_filled.svg" id="9_2en0l"]
|
[ext_resource type="Texture2D" uid="uid://lxx36xkotvh1" path="res://textures/star_filled.svg" id="9_2en0l"]
|
||||||
[ext_resource type="Script" path="res://scripts/ui/search/prompt_results.gd" id="14_0lofv"]
|
[ext_resource type="Script" path="res://scripts/ui/search/prompt_results.gd" id="14_0lofv"]
|
||||||
[ext_resource type="Script" path="res://scripts/ui/top_level.gd" id="14_5k27g"]
|
[ext_resource type="Script" path="res://scripts/ui/top_level.gd" id="14_5k27g"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/ui/search/prompt_navigation.gd" id="14_h86vl"]
|
||||||
[ext_resource type="Resource" uid="uid://cjcdum6fm4ta0" path="res://resources/api_settings.tres" id="15_uafyh"]
|
[ext_resource type="Resource" uid="uid://cjcdum6fm4ta0" path="res://resources/api_settings.tres" id="15_uafyh"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b57n6cvtqn5b7" path="res://scenes/components/prompt.tscn" id="16_lbcsd"]
|
[ext_resource type="PackedScene" uid="uid://b57n6cvtqn5b7" path="res://scenes/components/prompt.tscn" id="16_lbcsd"]
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ corner_radius_bottom_right = 6
|
||||||
corner_radius_bottom_left = 6
|
corner_radius_bottom_left = 6
|
||||||
corner_detail = 10
|
corner_detail = 10
|
||||||
|
|
||||||
[node name="Search" type="LineEdit"]
|
[node name="Search" type="LineEdit" node_paths=PackedStringArray("prompt_panel")]
|
||||||
custom_minimum_size = Vector2(1000, 40)
|
custom_minimum_size = Vector2(1000, 40)
|
||||||
anchors_preset = 8
|
anchors_preset = 8
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
|
@ -73,6 +74,7 @@ theme_override_styles/focus = SubResource("StyleBoxFlat_hyysn")
|
||||||
placeholder_text = "Search or enter address"
|
placeholder_text = "Search or enter address"
|
||||||
script = ExtResource("1_7ivk2")
|
script = ExtResource("1_7ivk2")
|
||||||
gate_events = ExtResource("2_13io8")
|
gate_events = ExtResource("2_13io8")
|
||||||
|
prompt_panel = NodePath("Prompt/Panel")
|
||||||
|
|
||||||
[node name="SearchStatus" type="Control" parent="." node_paths=PackedStringArray("search_line_edit", "search", "downloading", "success", "error")]
|
[node name="SearchStatus" type="Control" parent="." node_paths=PackedStringArray("search_line_edit", "search", "downloading", "success", "error")]
|
||||||
self_modulate = Color(1, 1, 1, 0.8)
|
self_modulate = Color(1, 1, 1, 0.8)
|
||||||
|
@ -409,14 +411,18 @@ grow_vertical = 2
|
||||||
texture = ExtResource("9_2en0l")
|
texture = ExtResource("9_2en0l")
|
||||||
expand_mode = 1
|
expand_mode = 1
|
||||||
|
|
||||||
[node name="Prompt" type="Control" parent="."]
|
[node name="Prompt" type="Control" parent="." node_paths=PackedStringArray("search", "prompt_results")]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 2
|
anchors_preset = 2
|
||||||
anchor_top = 1.0
|
anchor_top = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_vertical = 0
|
grow_vertical = 0
|
||||||
|
script = ExtResource("14_h86vl")
|
||||||
|
search = NodePath("..")
|
||||||
|
prompt_results = NodePath("Panel/VBoxContainer")
|
||||||
|
|
||||||
[node name="Panel" type="Panel" parent="Prompt"]
|
[node name="Panel" type="Panel" parent="Prompt"]
|
||||||
|
visible = false
|
||||||
top_level = true
|
top_level = true
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 5
|
anchors_preset = 5
|
||||||
|
@ -425,22 +431,24 @@ anchor_right = 0.5
|
||||||
offset_left = -500.0
|
offset_left = -500.0
|
||||||
offset_top = 560.0
|
offset_top = 560.0
|
||||||
offset_right = 500.0
|
offset_right = 500.0
|
||||||
offset_bottom = 1060.0
|
offset_bottom = 860.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
theme_override_styles/panel = SubResource("StyleBoxFlat_mh73y")
|
theme_override_styles/panel = SubResource("StyleBoxFlat_mh73y")
|
||||||
script = ExtResource("14_5k27g")
|
script = ExtResource("14_5k27g")
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="Prompt/Panel"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="Prompt/Panel" node_paths=PackedStringArray("panel")]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
theme_override_constants/separation = 0
|
||||||
script = ExtResource("14_0lofv")
|
script = ExtResource("14_0lofv")
|
||||||
gate_events = ExtResource("2_13io8")
|
gate_events = ExtResource("2_13io8")
|
||||||
api = ExtResource("15_uafyh")
|
api = ExtResource("15_uafyh")
|
||||||
result_scene = ExtResource("16_lbcsd")
|
result_scene = ExtResource("16_lbcsd")
|
||||||
|
panel = NodePath("..")
|
||||||
|
|
||||||
[connection signal="text_changed" from="." to="." method="_on_text_changed"]
|
[connection signal="text_changed" from="." to="." method="_on_text_changed"]
|
||||||
[connection signal="text_changed" from="." to="Go" method="_on_search_text_changed"]
|
[connection signal="text_changed" from="." to="Go" method="_on_search_text_changed"]
|
||||||
|
|
|
@ -209,6 +209,8 @@ _import_path = NodePath("")
|
||||||
unique_name_in_owner = false
|
unique_name_in_owner = false
|
||||||
process_mode = 0
|
process_mode = 0
|
||||||
process_priority = 0
|
process_priority = 0
|
||||||
|
process_physics_priority = 0
|
||||||
|
process_thread_group = 0
|
||||||
editor_description = ""
|
editor_description = ""
|
||||||
visible = true
|
visible = true
|
||||||
modulate = Color(1, 1, 1, 1)
|
modulate = Color(1, 1, 1, 1)
|
||||||
|
@ -278,6 +280,8 @@ _import_path = NodePath("")
|
||||||
unique_name_in_owner = false
|
unique_name_in_owner = false
|
||||||
process_mode = 0
|
process_mode = 0
|
||||||
process_priority = 0
|
process_priority = 0
|
||||||
|
process_physics_priority = 0
|
||||||
|
process_thread_group = 0
|
||||||
editor_description = ""
|
editor_description = ""
|
||||||
visible = true
|
visible = true
|
||||||
modulate = Color(1, 1, 1, 1)
|
modulate = Color(1, 1, 1, 1)
|
||||||
|
@ -345,6 +349,8 @@ _import_path = NodePath("")
|
||||||
unique_name_in_owner = false
|
unique_name_in_owner = false
|
||||||
process_mode = 0
|
process_mode = 0
|
||||||
process_priority = 0
|
process_priority = 0
|
||||||
|
process_physics_priority = 0
|
||||||
|
process_thread_group = 0
|
||||||
editor_description = ""
|
editor_description = ""
|
||||||
visible = true
|
visible = true
|
||||||
modulate = Color(1, 1, 1, 1)
|
modulate = Color(1, 1, 1, 1)
|
||||||
|
@ -417,6 +423,8 @@ _import_path = NodePath("")
|
||||||
unique_name_in_owner = false
|
unique_name_in_owner = false
|
||||||
process_mode = 0
|
process_mode = 0
|
||||||
process_priority = 0
|
process_priority = 0
|
||||||
|
process_physics_priority = 0
|
||||||
|
process_thread_group = 0
|
||||||
editor_description = ""
|
editor_description = ""
|
||||||
visible = true
|
visible = true
|
||||||
modulate = Color(1, 1, 1, 1)
|
modulate = Color(1, 1, 1, 1)
|
||||||
|
@ -484,6 +492,8 @@ _import_path = NodePath("")
|
||||||
unique_name_in_owner = false
|
unique_name_in_owner = false
|
||||||
process_mode = 0
|
process_mode = 0
|
||||||
process_priority = 0
|
process_priority = 0
|
||||||
|
process_physics_priority = 0
|
||||||
|
process_thread_group = 0
|
||||||
editor_description = ""
|
editor_description = ""
|
||||||
visible = true
|
visible = true
|
||||||
modulate = Color(1, 1, 1, 1)
|
modulate = Color(1, 1, 1, 1)
|
||||||
|
|
|
@ -3,15 +3,15 @@ class_name StringTools
|
||||||
|
|
||||||
|
|
||||||
static func to_alpha(text: String) -> String:
|
static func to_alpha(text: String) -> String:
|
||||||
var clean_text = ""
|
var last_is_alpha = false
|
||||||
var last_is_char = false
|
var result = ""
|
||||||
|
|
||||||
for char in text:
|
for symbol in text:
|
||||||
if (char >= 'a' and char <= 'z') or (char >= 'A' and char <= 'Z'):
|
if (symbol >= 'a' and symbol <= 'z') or (symbol >= 'A' and symbol <= 'Z'):
|
||||||
clean_text += char
|
result += symbol
|
||||||
last_is_char = true
|
last_is_alpha = true
|
||||||
elif last_is_char:
|
elif last_is_alpha:
|
||||||
clean_text += " "
|
result += " "
|
||||||
last_is_char = false
|
last_is_alpha = false
|
||||||
|
|
||||||
return clean_text
|
return result
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
extends LineEdit
|
extends LineEdit
|
||||||
|
class_name Search
|
||||||
|
|
||||||
|
signal on_release_focus
|
||||||
|
|
||||||
@export var gate_events: GateEvents
|
@export var gate_events: GateEvents
|
||||||
|
@export var prompt_panel: Control
|
||||||
|
|
||||||
var url: String
|
var url: String
|
||||||
|
|
||||||
|
@ -15,12 +19,15 @@ func set_current_url(_url: String) -> void:
|
||||||
url = _url
|
url = _url
|
||||||
text = url
|
text = url
|
||||||
|
|
||||||
|
on_release_focus.emit()
|
||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if (has_focus()
|
if (has_focus() and event is InputEventMouseButton
|
||||||
and event is InputEventMouseButton
|
and not get_global_rect().has_point(event.position)
|
||||||
and not get_global_rect().has_point(event.position)):
|
and not prompt_panel.get_global_rect().has_point(event.position)):
|
||||||
release_focus()
|
release_focus()
|
||||||
|
on_release_focus.emit()
|
||||||
|
|
||||||
|
|
||||||
func _on_text_changed(_url: String) -> void:
|
func _on_text_changed(_url: String) -> void:
|
||||||
|
@ -42,4 +49,6 @@ func open_gate() -> void:
|
||||||
gate_events.open_gate_emit(url)
|
gate_events.open_gate_emit(url)
|
||||||
else:
|
else:
|
||||||
gate_events.search_emit(url)
|
gate_events.search_emit(url)
|
||||||
|
|
||||||
release_focus()
|
release_focus()
|
||||||
|
on_release_focus.emit()
|
||||||
|
|
17
project/scripts/ui/search/prompt_navigation.gd
Normal file
17
project/scripts/ui/search/prompt_navigation.gd
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
@export var search: Search
|
||||||
|
@export var prompt_results: PromptResults
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
search.focus_entered.connect(_on_focus_entered)
|
||||||
|
search.on_release_focus.connect(_on_release_focus)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_focus_entered() -> void:
|
||||||
|
prompt_results._on_search_text_changed(search.text)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_release_focus() -> void:
|
||||||
|
prompt_results.clear()
|
|
@ -1,23 +1,32 @@
|
||||||
extends VBoxContainer
|
extends VBoxContainer
|
||||||
|
class_name PromptResults
|
||||||
|
|
||||||
@export var gate_events: GateEvents
|
@export var gate_events: GateEvents
|
||||||
@export var api: ApiSettings
|
@export var api: ApiSettings
|
||||||
@export var result_scene: PackedScene
|
@export var result_scene: PackedScene
|
||||||
|
|
||||||
|
@export var panel: Control
|
||||||
|
|
||||||
|
var prompt_size: float
|
||||||
var result_str: String
|
var result_str: String
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
pass
|
var prompt: Control = result_scene.instantiate()
|
||||||
|
prompt_size = prompt.size.y
|
||||||
|
prompt.queue_free()
|
||||||
|
|
||||||
|
panel.visible = true
|
||||||
|
clear()
|
||||||
|
|
||||||
|
|
||||||
func _on_search_text_changed(query: String) -> void:
|
func _on_search_text_changed(query: String) -> void:
|
||||||
clear()
|
if query.is_empty(): clear(); return
|
||||||
if query.is_empty(): return
|
|
||||||
|
|
||||||
await prompt_request(query)
|
await prompt_request(query)
|
||||||
|
clear()
|
||||||
|
|
||||||
var prompts = JSON.parse_string(result_str)
|
var prompts: Array = JSON.parse_string(result_str)
|
||||||
if prompts == null or prompts.is_empty():
|
if prompts == null or prompts.is_empty():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -26,6 +35,8 @@ func _on_search_text_changed(query: String) -> void:
|
||||||
result.fill(prompt)
|
result.fill(prompt)
|
||||||
add_child(result)
|
add_child(result)
|
||||||
|
|
||||||
|
change_size(prompts.size())
|
||||||
|
|
||||||
|
|
||||||
func prompt_request(query: String) -> void:
|
func prompt_request(query: String) -> void:
|
||||||
var url = api.prompt + query.uri_encode()
|
var url = api.prompt + query.uri_encode()
|
||||||
|
@ -42,3 +53,8 @@ func clear() -> void:
|
||||||
for child in get_children():
|
for child in get_children():
|
||||||
child.queue_free()
|
child.queue_free()
|
||||||
remove_child(child)
|
remove_child(child)
|
||||||
|
change_size(0)
|
||||||
|
|
||||||
|
|
||||||
|
func change_size(promt_count: int) -> void:
|
||||||
|
panel.size = Vector2(panel.size.x, promt_count * prompt_size)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue