fix: font polish and layouts

This commit is contained in:
tiger tiger tiger 2026-03-20 22:06:48 +01:00
parent 9c3984aee0
commit 9d0272f68c
7 changed files with 160 additions and 247 deletions

View File

@ -18,7 +18,7 @@ generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=true
msdf_pixel_range=8
msdf_size=48
msdf_size=64
allow_system_fallback=true
force_autohinter=false
modulate_color_glyphs=false
@ -34,7 +34,8 @@ preload=[{
"chars": [],
"glyphs": [],
"name": "New Configuration",
"size": Vector2i(16, 0)
"size": Vector2i(16, 0),
&"variation_embolden": 0.0
}]
language_support={}
script_support={}

View File

@ -2,16 +2,16 @@ class_name ChatView extends ScrollContainer
@export var messages: Array[ChatMessage]
var prefab_other: PackedScene = preload("res://logic-scenes/chat_view/message_other.tscn")
var prefab_self: PackedScene = preload("res://logic-scenes/chat_view/message_self.tscn")
var v_box: VBoxContainer
func _ready() -> void:
v_box = VBoxContainer.new()
add_child(v_box, false, Node.INTERNAL_MODE_BACK)
rebuild()
rebuild.call_deferred()
func rebuild():
#var text_server: = TextServerManager.get_primary_interface()
for message in messages:
pass
var bubble : ChatBubble = prefab_self.instantiate() if message.is_own_message else prefab_other.instantiate()
$VBoxContainer.add_child(bubble)
bubble.set_text.call_deferred(message.text, message.time_string)

View File

@ -7,11 +7,8 @@
[ext_resource type="Texture2D" uid="uid://cv58eu35ra1ku" path="res://logic-scenes/chat_view/phone-dot.png" id="4_vvup7"]
[ext_resource type="Texture2D" uid="uid://bng2qbusdg7dj" path="res://logic-scenes/chat_view/phone-signal.png" id="4_xckgu"]
[ext_resource type="Script" uid="uid://be16bo6mf4kqu" path="res://logic-scenes/chat_view/chat-message.gd" id="5_xckgu"]
[ext_resource type="Texture2D" uid="uid://dekaqj10p8rqk" path="res://logic-scenes/chat_view/avatar-self.png" id="6_bvmqu"]
[ext_resource type="StyleBox" uid="uid://dj1fuvcy0sw7k" path="res://logic-scenes/chat_view/style-chat-bubble.tres" id="9_vvup7"]
[ext_resource type="LabelSettings" uid="uid://mh8uu4rlqmv5" path="res://logic-scenes/chat_view/label-timestamp.tres" id="9_xckgu"]
[ext_resource type="StyleBox" uid="uid://dd4xc216ul21m" path="res://logic-scenes/chat_view/style-chat-bubble-self.tres" id="11_qbcw0"]
[ext_resource type="Script" uid="uid://dlbwvie007wfx" path="res://logic-scenes/chat_view/auto_size_richt_text_container.gd" id="12_qgt32"]
[ext_resource type="PackedScene" uid="uid://dc58hnxdn0l2o" path="res://logic-scenes/chat_view/message_other.tscn" id="8_wih1b"]
[ext_resource type="PackedScene" uid="uid://cjodbrwc01gwi" path="res://logic-scenes/chat_view/message_self.tscn" id="13_qw8qg"]
[sub_resource type="Resource" id="Resource_iwd5k"]
script = ExtResource("5_xckgu")
@ -21,12 +18,14 @@ metadata/_custom_type_script = "uid://be16bo6mf4kqu"
[sub_resource type="Resource" id="Resource_1hd2w"]
script = ExtResource("5_xckgu")
text = "I never knew what to say. Can I write instead?"
text = "I never knew what to say. Can I write instead? "
time_string = "8:12 PM"
metadata/_custom_type_script = "uid://be16bo6mf4kqu"
[sub_resource type="Resource" id="Resource_w8y7q"]
script = ExtResource("5_xckgu")
text = "🙄"
time_string = "7:59 PM"
is_own_message = true
metadata/_custom_type_script = "uid://be16bo6mf4kqu"
@ -113,240 +112,19 @@ size_flags_vertical = 3
horizontal_scroll_mode = 0
vertical_scroll_mode = 2
script = ExtResource("4_myhe7")
messages = Array[ExtResource("5_xckgu")]([SubResource("Resource_iwd5k"), SubResource("Resource_1hd2w"), SubResource("Resource_w8y7q")])
messages = Array[ExtResource("5_xckgu")]([SubResource("Resource_iwd5k"), SubResource("Resource_1hd2w"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q"), SubResource("Resource_w8y7q")])
[node name="VBoxContainer" type="VBoxContainer" parent="AppLayout/ChatContainer" unique_id=1303301180]
layout_mode = 2
size_flags_horizontal = 3
[node name="Message-Other" type="HBoxContainer" parent="AppLayout/ChatContainer/VBoxContainer" unique_id=1768184408]
[node name="Message-Other" parent="AppLayout/ChatContainer/VBoxContainer" unique_id=102479796 instance=ExtResource("8_wih1b")]
layout_mode = 2
size_flags_horizontal = 3
alignment = 2
script = null
[node name="Avatar" type="TextureRect" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other" unique_id=692150965]
[node name="Message-Self" parent="AppLayout/ChatContainer/VBoxContainer" unique_id=806983375 instance=ExtResource("13_qw8qg")]
layout_mode = 2
size_flags_vertical = 8
texture = ExtResource("6_bvmqu")
stretch_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other" unique_id=1815081203]
layout_mode = 2
size_flags_horizontal = 2
size_flags_vertical = 9
[node name="Bubble" type="PanelContainer" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other/VBoxContainer" unique_id=5067436]
custom_minimum_size = Vector2(0, 52)
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 3
theme_override_styles/panel = ExtResource("9_vvup7")
[node name="MarginContainer" type="MarginContainer" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other/VBoxContainer/Bubble" unique_id=866335976]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 4
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
script = ExtResource("12_qgt32")
[node name="RichTextLabel" type="RichTextLabel" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other/VBoxContainer/Bubble/MarginContainer" unique_id=1973907637]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
size_flags_horizontal = 3
theme_type_variation = &"message-other"
bbcode_enabled = true
text = "Dies ist eine T-legram-Message.
"
fit_content = true
scroll_active = false
autowrap_mode = 0
vertical_alignment = 1
justification_flags = 99
metadata/_custom_type_script = "uid://dlbwvie007wfx"
[node name="TimeStamp" type="Label" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other/VBoxContainer" unique_id=801686504]
layout_mode = 2
text = "8:12 PM"
label_settings = ExtResource("9_xckgu")
horizontal_alignment = 2
[node name="Spacer" type="Control" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other" unique_id=1232564412]
custom_minimum_size = Vector2(160, 0)
layout_mode = 2
[node name="Message-Other2" type="HBoxContainer" parent="AppLayout/ChatContainer/VBoxContainer" unique_id=230318593]
layout_mode = 2
size_flags_horizontal = 3
alignment = 2
[node name="Avatar" type="TextureRect" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other2" unique_id=1854076166]
layout_mode = 2
size_flags_vertical = 8
texture = ExtResource("6_bvmqu")
stretch_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other2" unique_id=216841372]
layout_mode = 2
size_flags_horizontal = 2
size_flags_vertical = 9
[node name="Bubble" type="PanelContainer" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other2/VBoxContainer" unique_id=1704898778]
custom_minimum_size = Vector2(0, 52)
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 3
theme_override_styles/panel = ExtResource("9_vvup7")
[node name="MarginContainer" type="MarginContainer" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other2/VBoxContainer/Bubble" unique_id=343453369]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 4
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
script = ExtResource("12_qgt32")
[node name="RichTextLabel" type="RichTextLabel" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other2/VBoxContainer/Bubble/MarginContainer" unique_id=598363127]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
size_flags_horizontal = 3
theme_type_variation = &"message-other"
bbcode_enabled = true
text = "😝"
fit_content = true
scroll_active = false
autowrap_mode = 0
vertical_alignment = 1
justification_flags = 99
metadata/_custom_type_script = "uid://dlbwvie007wfx"
[node name="TimeStamp" type="Label" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other2/VBoxContainer" unique_id=257313481]
layout_mode = 2
text = "8:12 PM"
label_settings = ExtResource("9_xckgu")
horizontal_alignment = 2
[node name="Spacer" type="Control" parent="AppLayout/ChatContainer/VBoxContainer/Message-Other2" unique_id=97162962]
custom_minimum_size = Vector2(160, 0)
layout_mode = 2
[node name="Message-Self" type="HBoxContainer" parent="AppLayout/ChatContainer/VBoxContainer" unique_id=2088488179]
layout_mode = 2
size_flags_horizontal = 3
alignment = 2
[node name="Spacer" type="Control" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self" unique_id=492147653]
custom_minimum_size = Vector2(160, 0)
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self" unique_id=157124478]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 9
[node name="Bubble" type="PanelContainer" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self/VBoxContainer" unique_id=842242817]
custom_minimum_size = Vector2(0, 52)
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 3
theme_override_styles/panel = ExtResource("11_qbcw0")
[node name="MarginContainer" type="MarginContainer" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self/VBoxContainer/Bubble" unique_id=766411309]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 4
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
script = ExtResource("12_qgt32")
min_bubble_width = null
[node name="RichTextLabel" type="RichTextLabel" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self/VBoxContainer/Bubble/MarginContainer" unique_id=1320329524]
custom_minimum_size = Vector2(512, 64)
layout_mode = 2
size_flags_horizontal = 3
theme_type_variation = &"message-other"
bbcode_enabled = true
text = "Dies ist auch eine T-legram-Message. Ich schreibe mal etwas länger, ob zu sehen, ob der Text irgendwann umbricht.
"
fit_content = true
scroll_active = false
vertical_alignment = 1
justification_flags = 99
metadata/_custom_type_script = "uid://dlbwvie007wfx"
[node name="TimeStamp" type="Label" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self/VBoxContainer" unique_id=433463928]
layout_mode = 2
text = "8:12 PM"
label_settings = ExtResource("9_xckgu")
horizontal_alignment = 2
[node name="Avatar" type="TextureRect" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self" unique_id=434370099]
layout_mode = 2
size_flags_vertical = 8
texture = ExtResource("6_bvmqu")
stretch_mode = 2
[node name="Message-Self-Short" type="HBoxContainer" parent="AppLayout/ChatContainer/VBoxContainer" unique_id=1126894869]
layout_mode = 2
size_flags_horizontal = 3
alignment = 2
[node name="Spacer" type="Control" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self-Short" unique_id=2062000365]
custom_minimum_size = Vector2(160, 0)
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self-Short" unique_id=1331255119]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 9
[node name="Bubble" type="PanelContainer" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self-Short/VBoxContainer" unique_id=2249691]
custom_minimum_size = Vector2(0, 52)
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 3
theme_override_styles/panel = ExtResource("11_qbcw0")
[node name="MarginContainer" type="MarginContainer" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self-Short/VBoxContainer/Bubble" unique_id=2077306006]
layout_mode = 2
size_flags_horizontal = 0
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
script = ExtResource("12_qgt32")
min_bubble_width = null
[node name="RichTextLabel" type="RichTextLabel" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self-Short/VBoxContainer/Bubble/MarginContainer" unique_id=425927748]
custom_minimum_size = Vector2(0, 64)
layout_mode = 2
size_flags_horizontal = 3
theme_type_variation = &"message-other"
bbcode_enabled = true
text = "Fasse dich kurz!"
fit_content = true
scroll_active = false
autowrap_mode = 0
vertical_alignment = 1
metadata/_custom_type_script = "uid://dlbwvie007wfx"
[node name="TimeStamp" type="Label" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self-Short/VBoxContainer" unique_id=1787589161]
layout_mode = 2
text = "8:12 PM"
label_settings = ExtResource("9_xckgu")
horizontal_alignment = 2
[node name="Avatar" type="TextureRect" parent="AppLayout/ChatContainer/VBoxContainer/Message-Self-Short" unique_id=740045102]
layout_mode = 2
size_flags_vertical = 8
texture = ExtResource("6_bvmqu")
stretch_mode = 2
script = null
[node name="PanelContainer" type="PanelContainer" parent="AppLayout" unique_id=1252298765]
layout_mode = 2

View File

@ -1,13 +1,15 @@
## chat_bubble.gd — attach to your bubble container (e.g. PanelContainer)
@tool
class_name ChatBubble
extends Container
@export var min_bubble_width: float = 64.0
@export var max_bubble_width: float = 512.0
@onready var label: RichTextLabel = $RichTextLabel
@onready var label: RichTextLabel = %RichTextLabel
@onready var timestamp: Label = %TimeStamp
var text := ""
var _text := ""
func _ready():
label.resized.connect(_on_label_resized)
@ -15,14 +17,15 @@ func _ready():
label.fit_content = true
func _process(_delta: float) -> void:
if (label.text != text):
set_text(label.text)
if (label.text != _text):
set_text(label.text, timestamp.text)
func set_text(new_text: String) -> void:
text = new_text
func set_text(new_text: String, new_time: String) -> void:
_text = new_text
label.autowrap_mode = TextServer.AUTOWRAP_OFF
label.custom_minimum_size.x = min_bubble_width
label.text = text # triggers layout → NOTIFICATION_RESIZED
label.text = _text # triggers layout → NOTIFICATION_RESIZED
timestamp.text = new_time
func _on_label_resized() -> void:
if label.get_content_width() > max_bubble_width:

View File

@ -0,0 +1,66 @@
[gd_scene format=3 uid="uid://dc58hnxdn0l2o"]
[ext_resource type="Theme" uid="uid://bhw3jbbrt3m1k" path="res://logic-scenes/chat_view/theme-smartphone.tres" id="1_0pomh"]
[ext_resource type="Texture2D" uid="uid://dekaqj10p8rqk" path="res://logic-scenes/chat_view/avatar-self.png" id="1_r4gcv"]
[ext_resource type="StyleBox" uid="uid://dj1fuvcy0sw7k" path="res://logic-scenes/chat_view/style-chat-bubble.tres" id="2_0pomh"]
[ext_resource type="Script" uid="uid://dlbwvie007wfx" path="res://logic-scenes/chat_view/chat_bubble.gd" id="3_3g7sa"]
[ext_resource type="LabelSettings" uid="uid://mh8uu4rlqmv5" path="res://logic-scenes/chat_view/label-timestamp.tres" id="4_yjo27"]
[node name="Message-Other" type="HBoxContainer" unique_id=102479796]
size_flags_horizontal = 3
theme = ExtResource("1_0pomh")
alignment = 2
script = ExtResource("3_3g7sa")
[node name="Avatar" type="TextureRect" parent="." unique_id=1077043040]
layout_mode = 2
size_flags_vertical = 8
texture = ExtResource("1_r4gcv")
stretch_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1636732531]
layout_mode = 2
size_flags_horizontal = 2
size_flags_vertical = 9
[node name="Bubble" type="PanelContainer" parent="VBoxContainer" unique_id=793380316]
custom_minimum_size = Vector2(0, 52)
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 3
theme_override_styles/panel = ExtResource("2_0pomh")
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/Bubble" unique_id=1163778954]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 4
theme_override_constants/margin_left = 0
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 4
[node name="RichTextLabel" type="RichTextLabel" parent="VBoxContainer/Bubble/MarginContainer" unique_id=418400525]
unique_name_in_owner = true
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
size_flags_horizontal = 3
theme_type_variation = &"message-other"
bbcode_enabled = true
text = "It is a long established fact"
fit_content = true
scroll_active = false
autowrap_mode = 0
vertical_alignment = 1
justification_flags = 99
metadata/_custom_type_script = "uid://dlbwvie007wfx"
[node name="TimeStamp" type="Label" parent="VBoxContainer" unique_id=1723936773]
unique_name_in_owner = true
layout_mode = 2
text = "8:12 PM"
label_settings = ExtResource("4_yjo27")
horizontal_alignment = 2
[node name="Spacer" type="Control" parent="." unique_id=1047768334]
custom_minimum_size = Vector2(160, 0)
layout_mode = 2

View File

@ -0,0 +1,65 @@
[gd_scene format=3 uid="uid://cjodbrwc01gwi"]
[ext_resource type="Theme" uid="uid://bhw3jbbrt3m1k" path="res://logic-scenes/chat_view/theme-smartphone.tres" id="1_aitur"]
[ext_resource type="StyleBox" uid="uid://dd4xc216ul21m" path="res://logic-scenes/chat_view/style-chat-bubble-self.tres" id="1_ufk1a"]
[ext_resource type="Script" uid="uid://dlbwvie007wfx" path="res://logic-scenes/chat_view/chat_bubble.gd" id="2_aitur"]
[ext_resource type="LabelSettings" uid="uid://mh8uu4rlqmv5" path="res://logic-scenes/chat_view/label-timestamp.tres" id="3_hmjif"]
[ext_resource type="Texture2D" uid="uid://dekaqj10p8rqk" path="res://logic-scenes/chat_view/avatar-self.png" id="4_q2b2g"]
[node name="Message-Self" type="HBoxContainer" unique_id=806983375]
size_flags_horizontal = 3
theme = ExtResource("1_aitur")
alignment = 2
script = ExtResource("2_aitur")
[node name="Spacer" type="Control" parent="." unique_id=929861663]
custom_minimum_size = Vector2(160, 0)
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=361845079]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 9
[node name="Bubble" type="PanelContainer" parent="VBoxContainer" unique_id=930440916]
custom_minimum_size = Vector2(0, 52)
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 3
theme_override_styles/panel = ExtResource("1_ufk1a")
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/Bubble" unique_id=2011015357]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 4
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 0
theme_override_constants/margin_bottom = 4
[node name="RichTextLabel" type="RichTextLabel" parent="VBoxContainer/Bubble/MarginContainer" unique_id=342773493]
unique_name_in_owner = true
custom_minimum_size = Vector2(512, 64)
layout_mode = 2
size_flags_horizontal = 3
theme_type_variation = &"message-other"
bbcode_enabled = true
text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s."
fit_content = true
scroll_active = false
vertical_alignment = 1
justification_flags = 99
metadata/_custom_type_script = "uid://dlbwvie007wfx"
[node name="TimeStamp" type="Label" parent="VBoxContainer" unique_id=1916601114]
unique_name_in_owner = true
layout_mode = 2
text = "8:12 PM"
label_settings = ExtResource("3_hmjif")
horizontal_alignment = 2
[node name="Avatar" type="TextureRect" parent="." unique_id=502320005]
layout_mode = 2
size_flags_vertical = 8
texture = ExtResource("4_q2b2g")
stretch_mode = 2