diff options
author | 2021-10-31 16:13:03 +0700 | |
---|---|---|
committer | 2021-10-31 16:14:38 +0700 | |
commit | b3a01973c6c726e6539be959659f4306ef3234c6 (patch) | |
tree | 06e6ce43b5e47eb78f2707eb2c6177a2f9af91f4 /native/src/renderer | |
parent | 0aafcde0ef1533c9eeba0379de8c0082e30c7504 (diff) | |
download | iced-b3a01973c6c726e6539be959659f4306ef3234c6.tar.gz iced-b3a01973c6c726e6539be959659f4306ef3234c6.tar.bz2 iced-b3a01973c6c726e6539be959659f4306ef3234c6.zip |
Introduce first-class `text` module in `iced_native`
Diffstat (limited to '')
-rw-r--r-- | native/src/renderer.rs | 4 | ||||
-rw-r--r-- | native/src/renderer/null.rs | 6 | ||||
-rw-r--r-- | native/src/text.rs (renamed from native/src/renderer/text.rs) | 30 |
3 files changed, 18 insertions, 22 deletions
diff --git a/native/src/renderer.rs b/native/src/renderer.rs index 6d12edae..1e518936 100644 --- a/native/src/renderer.rs +++ b/native/src/renderer.rs @@ -19,10 +19,6 @@ //! [`text::Renderer`]: crate::widget::text::Renderer //! [`Checkbox`]: crate::widget::Checkbox //! [`checkbox::Renderer`]: crate::widget::checkbox::Renderer -pub mod text; - -pub use text::Text; - #[cfg(debug_assertions)] mod null; #[cfg(debug_assertions)] diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index e57841f4..263b38a9 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -1,5 +1,5 @@ use crate::renderer::{self, Renderer}; -use crate::widget::text; +use crate::text::{self, Text}; use crate::{Font, Point, Rectangle, Size, Vector}; /// A renderer that does nothing. @@ -30,7 +30,7 @@ impl Renderer for Null { fn fill_rectangle(&mut self, _quad: renderer::Quad) {} } -impl renderer::Text for Null { +impl text::Renderer for Null { type Font = Font; const ICON_FONT: Font = Font::Default; @@ -63,5 +63,5 @@ impl renderer::Text for Null { None } - fn fill_text(&mut self, _text: renderer::text::Section<'_, Self::Font>) {} + fn fill_text(&mut self, _text: Text<'_, Self::Font>) {} } diff --git a/native/src/renderer/text.rs b/native/src/text.rs index fc1a2c66..f112a8f3 100644 --- a/native/src/renderer/text.rs +++ b/native/src/text.rs @@ -1,9 +1,20 @@ use crate::alignment; -use crate::{Color, Point, Rectangle, Renderer, Size}; +use crate::{Color, Point, Rectangle, Size}; -pub use crate::widget::text::Hit; +pub use iced_core::text::Hit; -pub trait Text: Renderer { +#[derive(Debug, Clone, Copy)] +pub struct Text<'a, Font> { + pub content: &'a str, + pub bounds: Rectangle, + pub size: f32, + pub color: Color, + pub font: Font, + pub horizontal_alignment: alignment::Horizontal, + pub vertical_alignment: alignment::Vertical, +} + +pub trait Renderer: crate::Renderer { /// The font type used. type Font: Default + Copy; @@ -56,16 +67,5 @@ pub trait Text: Renderer { nearest_only: bool, ) -> Option<Hit>; - fn fill_text(&mut self, section: Section<'_, Self::Font>); -} - -#[derive(Debug, Clone, Copy)] -pub struct Section<'a, Font> { - pub content: &'a str, - pub bounds: Rectangle, - pub size: f32, - pub color: Color, - pub font: Font, - pub horizontal_alignment: alignment::Horizontal, - pub vertical_alignment: alignment::Vertical, + fn fill_text(&mut self, text: Text<'_, Self::Font>); } |