#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct FontFaceId(pub u32);
pub struct RenderFrame {
pub atlas_dirty: bool,
pub atlas_width: u32,
pub atlas_height: u32,
pub atlas_pixels: Vec<u8>,
pub glyphs: Vec<GlyphQuad>,
pub images: Vec<ImageQuad>,
pub decorations: Vec<DecorationRect>,
pub(crate) block_glyphs: Vec<(usize, Vec<GlyphQuad>)>,
pub(crate) block_decorations: Vec<(usize, Vec<DecorationRect>)>,
pub(crate) block_images: Vec<(usize, Vec<ImageQuad>)>,
pub(crate) block_heights: std::collections::HashMap<usize, f32>,
}
#[derive(Clone)]
pub struct GlyphQuad {
pub screen: [f32; 4],
pub atlas: [f32; 4],
pub color: [f32; 4],
}
#[derive(Clone)]
pub struct ImageQuad {
pub screen: [f32; 4],
pub name: String,
}
#[derive(Clone)]
pub struct DecorationRect {
pub rect: [f32; 4],
pub color: [f32; 4],
pub kind: DecorationKind,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DecorationKind {
Selection,
Cursor,
Underline,
Strikeout,
Overline,
Background,
BlockBackground,
TableBorder,
TableCellBackground,
TextBackground,
CellSelection,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum UnderlineStyle {
#[default]
None,
Single,
Dash,
Dot,
DashDot,
DashDotDot,
Wave,
SpellCheck,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum VerticalAlignment {
#[default]
Normal,
SuperScript,
SubScript,
}
pub struct HitTestResult {
pub position: usize,
pub block_id: usize,
pub offset_in_block: usize,
pub region: HitRegion,
pub tooltip: Option<String>,
pub table_id: Option<usize>,
}
#[derive(Debug)]
pub enum HitRegion {
Text,
LeftMargin,
Indent,
TableBorder,
BelowContent,
PastLineEnd,
Image { name: String },
Link { href: String },
}
pub struct CursorDisplay {
pub position: usize,
pub anchor: usize,
pub visible: bool,
pub selected_cells: Vec<(usize, usize, usize)>,
}
pub struct BlockVisualInfo {
pub block_id: usize,
pub y: f32,
pub height: f32,
}
#[derive(Clone, Debug, Default)]
pub struct TextFormat {
pub font_family: Option<String>,
pub font_weight: Option<u32>,
pub font_bold: Option<bool>,
pub font_italic: Option<bool>,
pub font_size: Option<f32>,
pub color: Option<[f32; 4]>,
}
pub struct SingleLineResult {
pub width: f32,
pub height: f32,
pub baseline: f32,
pub glyphs: Vec<GlyphQuad>,
}
impl RenderFrame {
pub(crate) fn new() -> Self {
Self {
atlas_dirty: false,
atlas_width: 0,
atlas_height: 0,
atlas_pixels: Vec::new(),
glyphs: Vec::new(),
images: Vec::new(),
decorations: Vec::new(),
block_glyphs: Vec::new(),
block_decorations: Vec::new(),
block_images: Vec::new(),
block_heights: std::collections::HashMap::new(),
}
}
}