From 03b34931383e701c39c653a7662a616fe21a0947 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 14 Oct 2021 16:07:22 +0700 Subject: Remove trait-specific draw logic in `iced_native` --- graphics/src/widget/text.rs | 43 ++----------------------------------------- 1 file changed, 2 insertions(+), 41 deletions(-) (limited to 'graphics/src/widget/text.rs') diff --git a/graphics/src/widget/text.rs b/graphics/src/widget/text.rs index d6d446d3..2ccd18a1 100644 --- a/graphics/src/widget/text.rs +++ b/graphics/src/widget/text.rs @@ -1,10 +1,8 @@ //! Write some text for your users to read. use crate::backend::{self, Backend}; -use crate::{Primitive, Renderer}; -use iced_native::alignment; -use iced_native::mouse; +use crate::Renderer; use iced_native::text; -use iced_native::{Color, Font, Point, Rectangle, Size}; +use iced_native::{Font, Point, Size}; /// A paragraph of text. /// @@ -52,41 +50,4 @@ where nearest_only, ) } - - fn draw( - &mut self, - defaults: &Self::Defaults, - bounds: Rectangle, - content: &str, - size: u16, - font: Font, - color: Option, - horizontal_alignment: alignment::Horizontal, - vertical_alignment: alignment::Vertical, - ) -> Self::Output { - let x = match horizontal_alignment { - alignment::Horizontal::Left => bounds.x, - alignment::Horizontal::Center => bounds.center_x(), - alignment::Horizontal::Right => bounds.x + bounds.width, - }; - - let y = match vertical_alignment { - alignment::Vertical::Top => bounds.y, - alignment::Vertical::Center => bounds.center_y(), - alignment::Vertical::Bottom => bounds.y + bounds.height, - }; - - ( - Primitive::Text { - content: content.to_string(), - size: f32::from(size), - bounds: Rectangle { x, y, ..bounds }, - color: color.unwrap_or(defaults.text.color), - font, - horizontal_alignment, - vertical_alignment, - }, - mouse::Interaction::default(), - ) - } } -- cgit From 3a0c503db99eb3d45ac971132904df419ee566b6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 14 Oct 2021 16:59:19 +0700 Subject: Implement `Widget::draw` for `Text` --- graphics/src/widget/text.rs | 2 -- 1 file changed, 2 deletions(-) (limited to 'graphics/src/widget/text.rs') diff --git a/graphics/src/widget/text.rs b/graphics/src/widget/text.rs index 2ccd18a1..4ee2c616 100644 --- a/graphics/src/widget/text.rs +++ b/graphics/src/widget/text.rs @@ -15,8 +15,6 @@ impl text::Renderer for Renderer where B: Backend + backend::Text, { - type Font = Font; - fn default_size(&self) -> u16 { self.backend().default_size() } -- cgit From e914888f57394e4b67b40e42f1ad9df4ae8147e6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Oct 2021 18:40:39 +0700 Subject: Implement `Widget::draw` for `TextInput` --- graphics/src/widget/text.rs | 44 -------------------------------------------- 1 file changed, 44 deletions(-) (limited to 'graphics/src/widget/text.rs') diff --git a/graphics/src/widget/text.rs b/graphics/src/widget/text.rs index 4ee2c616..ec0349f9 100644 --- a/graphics/src/widget/text.rs +++ b/graphics/src/widget/text.rs @@ -1,51 +1,7 @@ //! Write some text for your users to read. -use crate::backend::{self, Backend}; use crate::Renderer; -use iced_native::text; -use iced_native::{Font, Point, Size}; /// A paragraph of text. /// /// This is an alias of an `iced_native` text with an `iced_wgpu::Renderer`. pub type Text = iced_native::Text>; - -use std::f32; - -impl text::Renderer for Renderer -where - B: Backend + backend::Text, -{ - fn default_size(&self) -> u16 { - self.backend().default_size() - } - - fn measure( - &self, - content: &str, - size: u16, - font: Font, - bounds: Size, - ) -> (f32, f32) { - self.backend() - .measure(content, f32::from(size), font, bounds) - } - - fn hit_test( - &self, - content: &str, - size: f32, - font: Font, - bounds: Size, - point: Point, - nearest_only: bool, - ) -> Option { - self.backend().hit_test( - content, - size, - font, - bounds, - point, - nearest_only, - ) - } -} -- cgit From 0aafcde0ef1533c9eeba0379de8c0082e30c7504 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 15:35:12 +0700 Subject: Remove `widget` module re-exports in `iced_native` --- graphics/src/widget/text.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics/src/widget/text.rs') diff --git a/graphics/src/widget/text.rs b/graphics/src/widget/text.rs index ec0349f9..43516fca 100644 --- a/graphics/src/widget/text.rs +++ b/graphics/src/widget/text.rs @@ -4,4 +4,4 @@ use crate::Renderer; /// A paragraph of text. /// /// This is an alias of an `iced_native` text with an `iced_wgpu::Renderer`. -pub type Text = iced_native::Text>; +pub type Text = iced_native::widget::Text>; -- cgit