Implement explicit text caching in the widget state tree

This commit is contained in:
Héctor Ramón Jiménez 2023-08-30 04:31:21 +02:00
parent c9bd48704d
commit ed3454301e
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
79 changed files with 1910 additions and 1705 deletions

View file

@ -1,10 +1,21 @@
use crate::core::alignment;
use crate::core::text;
use crate::core::{Color, Font, Rectangle};
use crate::core::{Color, Font, Pixels, Point, Rectangle};
use crate::graphics::text::paragraph;
/// A paragraph of text.
#[derive(Debug, Clone, Copy)]
pub struct Text<'a> {
#[derive(Debug, Clone)]
pub enum Text<'a> {
Managed {
paragraph: paragraph::Weak,
position: Point,
color: Color,
},
Cached(Cached<'a>),
}
#[derive(Debug, Clone)]
pub struct Cached<'a> {
/// The content of the [`Text`].
pub content: &'a str,
@ -15,7 +26,7 @@ pub struct Text<'a> {
pub color: Color,
/// The size of the [`Text`] in logical pixels.
pub size: f32,
pub size: Pixels,
/// The line height of the [`Text`].
pub line_height: text::LineHeight,