2023-03-04 05:37:11 +01:00
|
|
|
use crate::core::alignment;
|
2023-04-19 02:00:45 +02:00
|
|
|
use crate::core::text;
|
2023-08-30 04:31:21 +02:00
|
|
|
use crate::core::{Color, Font, Pixels, Point, Rectangle};
|
2023-09-12 14:51:00 +02:00
|
|
|
use crate::graphics::text::editor;
|
2023-08-30 04:31:21 +02:00
|
|
|
use crate::graphics::text::paragraph;
|
2022-10-05 10:49:58 -07:00
|
|
|
|
2023-10-27 05:04:14 +02:00
|
|
|
/// A text primitive.
|
2023-08-30 04:31:21 +02:00
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
|
pub enum Text<'a> {
|
2023-10-27 05:04:14 +02:00
|
|
|
/// A paragraph.
|
|
|
|
|
#[allow(missing_docs)]
|
2023-09-12 14:51:00 +02:00
|
|
|
Paragraph {
|
2023-08-30 04:31:21 +02:00
|
|
|
paragraph: paragraph::Weak,
|
|
|
|
|
position: Point,
|
|
|
|
|
color: Color,
|
2023-12-01 16:04:27 +01:00
|
|
|
viewport: Rectangle,
|
2023-08-30 04:31:21 +02:00
|
|
|
},
|
2023-10-27 05:04:14 +02:00
|
|
|
/// An editor.
|
|
|
|
|
#[allow(missing_docs)]
|
2023-09-12 14:51:00 +02:00
|
|
|
Editor {
|
|
|
|
|
editor: editor::Weak,
|
|
|
|
|
position: Point,
|
|
|
|
|
color: Color,
|
2023-12-01 16:04:27 +01:00
|
|
|
viewport: Rectangle,
|
2023-09-12 14:51:00 +02:00
|
|
|
},
|
2023-10-27 05:04:14 +02:00
|
|
|
/// A cached text.
|
2023-08-30 04:31:21 +02:00
|
|
|
Cached(Cached<'a>),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
|
pub struct Cached<'a> {
|
2022-10-05 10:49:58 -07:00
|
|
|
/// The content of the [`Text`].
|
|
|
|
|
pub content: &'a str,
|
|
|
|
|
|
|
|
|
|
/// The layout bounds of the [`Text`].
|
|
|
|
|
pub bounds: Rectangle,
|
|
|
|
|
|
|
|
|
|
/// The color of the [`Text`], in __linear RGB_.
|
2023-01-31 06:29:21 +01:00
|
|
|
pub color: Color,
|
2022-10-05 10:49:58 -07:00
|
|
|
|
2023-05-04 13:00:16 +02:00
|
|
|
/// The size of the [`Text`] in logical pixels.
|
2023-08-30 04:31:21 +02:00
|
|
|
pub size: Pixels,
|
2022-10-05 10:49:58 -07:00
|
|
|
|
2023-05-04 13:00:16 +02:00
|
|
|
/// The line height of the [`Text`].
|
|
|
|
|
pub line_height: text::LineHeight,
|
|
|
|
|
|
2022-10-05 10:49:58 -07:00
|
|
|
/// The font of the [`Text`].
|
|
|
|
|
pub font: Font,
|
|
|
|
|
|
|
|
|
|
/// The horizontal alignment of the [`Text`].
|
|
|
|
|
pub horizontal_alignment: alignment::Horizontal,
|
|
|
|
|
|
|
|
|
|
/// The vertical alignment of the [`Text`].
|
|
|
|
|
pub vertical_alignment: alignment::Vertical,
|
2023-04-19 01:19:56 +02:00
|
|
|
|
2023-04-19 02:00:45 +02:00
|
|
|
/// The shaping strategy of the text.
|
|
|
|
|
pub shaping: text::Shaping,
|
2023-12-01 16:04:27 +01:00
|
|
|
|
|
|
|
|
/// The viewport of the text.
|
|
|
|
|
pub viewport: Rectangle,
|
2022-10-06 07:28:05 -07:00
|
|
|
}
|