feat: add fill_raw method and Raw associated type for text::Renderer
This commit is contained in:
parent
6bbe189809
commit
b26890f76e
7 changed files with 49 additions and 4 deletions
|
|
@ -5,7 +5,7 @@ use crate::core::{
|
|||
};
|
||||
use crate::graphics::damage;
|
||||
use crate::graphics::layer;
|
||||
use crate::graphics::text::{Editor, Paragraph, Text};
|
||||
use crate::graphics::text::{Editor, Paragraph, Raw, Text};
|
||||
use crate::graphics::{self, Image};
|
||||
|
||||
use std::sync::Arc;
|
||||
|
|
@ -70,6 +70,15 @@ impl Layer {
|
|||
self.text.push(Item::Live(editor));
|
||||
}
|
||||
|
||||
pub fn draw_raw(&mut self, raw: Raw, transformation: Transformation) {
|
||||
let raw = Text::Raw {
|
||||
raw,
|
||||
transformation,
|
||||
};
|
||||
|
||||
self.text.push(Item::Live(raw));
|
||||
}
|
||||
|
||||
pub fn draw_text(
|
||||
&mut self,
|
||||
text: core::Text,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ use crate::core::{
|
|||
use crate::engine::Engine;
|
||||
use crate::graphics::Viewport;
|
||||
use crate::graphics::compositor;
|
||||
use crate::graphics::text::{Editor, Paragraph};
|
||||
use crate::graphics::text::{Editor, Paragraph, Raw};
|
||||
|
||||
/// A [`tiny-skia`] graphics renderer for [`iced`].
|
||||
///
|
||||
|
|
@ -250,6 +250,7 @@ impl core::text::Renderer for Renderer {
|
|||
type Font = Font;
|
||||
type Paragraph = Paragraph;
|
||||
type Editor = Editor;
|
||||
type Raw = Raw;
|
||||
|
||||
const ICON_FONT: Font = Font::with_name("Iced-Icons");
|
||||
const CHECKMARK_ICON: char = '\u{f00c}';
|
||||
|
|
@ -293,6 +294,11 @@ impl core::text::Renderer for Renderer {
|
|||
layer.draw_editor(editor, position, color, clip_bounds, transformation);
|
||||
}
|
||||
|
||||
fn fill_raw(&mut self, raw: Self::Raw) {
|
||||
let (layer, transformation) = self.layers.current_mut();
|
||||
layer.draw_raw(raw, transformation);
|
||||
}
|
||||
|
||||
fn fill_text(
|
||||
&mut self,
|
||||
text: core::Text,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue