Skip to content

Commit

Permalink
Add function to fill a Raw
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Dec 20, 2023
1 parent 81de422 commit 611ce16
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions core/src/renderer/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl text::Renderer for Null {
type Font = Font;
type Paragraph = ();
type Editor = ();
type Raw = ();

const ICON_FONT: Font = Font::DEFAULT;
const CHECKMARK_ICON: char = '0';
Expand Down Expand Up @@ -77,6 +78,8 @@ impl text::Renderer for Null {
) {
}

fn fill_raw(&mut self, _raw: Self::Raw) {}

fn fill_text(
&mut self,
_paragraph: Text<'_, Self::Font>,
Expand Down
6 changes: 6 additions & 0 deletions core/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ pub trait Renderer: crate::Renderer {
/// The [`Editor`] of this [`Renderer`].
type Editor: Editor<Font = Self::Font> + 'static;

/// The [`Raw`] of this [`Renderer`].

Check failure on line 176 in core/src/text.rs

View workflow job for this annotation

GitHub Actions / all

unresolved link to `Raw`
type Raw;

/// The icon font of the backend.
const ICON_FONT: Self::Font;

Expand Down Expand Up @@ -215,6 +218,9 @@ pub trait Renderer: crate::Renderer {
clip_bounds: Rectangle,
);

/// Draws the given [`Raw`]

Check failure on line 221 in core/src/text.rs

View workflow job for this annotation

GitHub Actions / all

unresolved link to `Raw`
fn fill_raw(&mut self, raw: Self::Raw);

/// Draws the given [`Text`] at the given position and with the given
/// [`Color`].
fn fill_text(
Expand Down
5 changes: 5 additions & 0 deletions graphics/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ where
type Font = Font;
type Paragraph = text::Paragraph;
type Editor = text::Editor;
type Raw = text::Raw;

const ICON_FONT: Font = Font::with_name("Iced-Icons");
const CHECKMARK_ICON: char = '\u{f00c}';
Expand Down Expand Up @@ -189,6 +190,10 @@ where
});
}

fn fill_raw(&mut self, raw: Self::Raw) {
self.primitives.push(Primitive::RawText(raw));
}

fn fill_text(
&mut self,
text: Text<'_, Self::Font>,
Expand Down
8 changes: 6 additions & 2 deletions renderer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ pub use geometry::Geometry;
use crate::core::renderer;
use crate::core::text::{self, Text};
use crate::core::{Background, Color, Font, Pixels, Point, Rectangle, Vector};
use crate::graphics::text::Editor;
use crate::graphics::text::Paragraph;
use crate::graphics::text::{Editor, Paragraph, Raw};
use crate::graphics::Mesh;

use std::borrow::Cow;
Expand Down Expand Up @@ -152,6 +151,7 @@ impl<T> text::Renderer for Renderer<T> {
type Font = Font;
type Paragraph = Paragraph;
type Editor = Editor;
type Raw = Raw;

const ICON_FONT: Font = iced_tiny_skia::Renderer::<T>::ICON_FONT;
const CHECKMARK_ICON: char = iced_tiny_skia::Renderer::<T>::CHECKMARK_ICON;
Expand Down Expand Up @@ -198,6 +198,10 @@ impl<T> text::Renderer for Renderer<T> {
);
}

fn fill_raw(&mut self, raw: Self::Raw) {
delegate!(self, renderer, renderer.fill_raw(raw));
}

fn fill_text(
&mut self,
text: Text<'_, Self::Font>,
Expand Down

0 comments on commit 611ce16

Please sign in to comment.