Images!
This commit is contained in:
@@ -5,6 +5,7 @@ use std::ops::Range;
|
||||
use cosmic_text::CacheKey;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::ImageResource;
|
||||
use crate::text::TextSelectionStyle;
|
||||
use crate::trace_targets;
|
||||
use crate::tree::ElementId;
|
||||
@@ -133,6 +134,14 @@ pub struct PreparedText {
|
||||
pub glyphs: Vec<GlyphInstance>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct PreparedImage {
|
||||
pub element_id: Option<ElementId>,
|
||||
pub resource: ImageResource,
|
||||
pub rect: Rect,
|
||||
pub uv_rect: (f32, f32, f32, f32),
|
||||
}
|
||||
|
||||
impl PreparedText {
|
||||
pub fn monospace(
|
||||
text: impl Into<String>,
|
||||
@@ -456,6 +465,7 @@ fn classify_word_char(ch: char) -> WordClass {
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum DisplayItem {
|
||||
Quad(Quad),
|
||||
Image(PreparedImage),
|
||||
Text(PreparedText),
|
||||
PushClip(Rect),
|
||||
PopClip,
|
||||
@@ -506,6 +516,10 @@ impl SceneSnapshot {
|
||||
self.push_item(DisplayItem::Text(text))
|
||||
}
|
||||
|
||||
pub fn push_image(&mut self, image: PreparedImage) -> &mut Self {
|
||||
self.push_item(DisplayItem::Image(image))
|
||||
}
|
||||
|
||||
pub fn push_clip(&mut self, rect: Rect) -> &mut Self {
|
||||
self.push_item(DisplayItem::PushClip(rect))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user