More text improvements, performance enhancements, input handling, text selection, wl cursors

This commit is contained in:
2026-03-20 22:24:29 -04:00
parent d79a3bb728
commit 423df4ae1f
15 changed files with 2458 additions and 265 deletions

View File

@@ -1427,7 +1427,9 @@ fn text_texture_key(text: &PreparedText) -> TextTextureKey {
#[cfg(test)]
mod tests {
use super::{blend_rgba, build_vertices, text_texture_key};
use ruin_ui::{Color, GlyphInstance, Point, PreparedText, Rect, SceneSnapshot, UiSize};
use ruin_ui::{
Color, GlyphInstance, Point, PreparedText, Rect, SceneSnapshot, TextSelectionStyle, UiSize,
};
#[test]
fn quad_scenes_expand_to_six_vertices_per_quad() {
@@ -1441,12 +1443,16 @@ mod tests {
Color::rgb(0x44, 0x55, 0x66),
);
scene.push_text(PreparedText {
element_id: None,
text: "ignored".into(),
origin: Point::new(4.0, 8.0),
bounds: None,
font_size: 16.0,
line_height: 18.0,
color: Color::rgb(0xFF, 0xFF, 0xFF),
selectable: true,
selection_style: TextSelectionStyle::DEFAULT,
lines: Vec::new(),
glyphs: Vec::new(),
});
@@ -1466,18 +1472,23 @@ mod tests {
#[test]
fn text_texture_key_ignores_absolute_origin() {
let first = PreparedText {
element_id: None,
text: "cache me".into(),
origin: Point::new(20.0, 30.0),
bounds: Some(UiSize::new(120.0, 48.0)),
font_size: 16.0,
line_height: 20.0,
color: Color::rgb(0xEE, 0xEE, 0xEE),
selectable: true,
selection_style: TextSelectionStyle::DEFAULT,
lines: Vec::new(),
glyphs: vec![GlyphInstance {
glyph: "c".into(),
position: Point::new(24.0, 44.0),
advance: 8.0,
color: Color::rgb(0xEE, 0xEE, 0xEE),
cache_key: None,
text_start: 0,
text_end: 1,
}],
};
let second = PreparedText {