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/container.rs | 61 +--------------------------------------- 1 file changed, 1 insertion(+), 60 deletions(-) (limited to 'graphics/src/widget/container.rs') diff --git a/graphics/src/widget/container.rs b/graphics/src/widget/container.rs index aae3e1d8..811a0c7f 100644 --- a/graphics/src/widget/container.rs +++ b/graphics/src/widget/container.rs @@ -1,8 +1,6 @@ //! Decorate content and apply alignment. use crate::container; -use crate::defaults::{self, Defaults}; -use crate::{Backend, Primitive, Renderer}; -use iced_native::{Background, Color, Element, Layout, Point, Rectangle}; +use crate::{Backend, Renderer}; pub use iced_style::container::{Style, StyleSheet}; @@ -18,61 +16,4 @@ where B: Backend, { type Style = Box; - - fn draw( - &mut self, - defaults: &Defaults, - bounds: Rectangle, - cursor_position: Point, - viewport: &Rectangle, - style_sheet: &Self::Style, - content: &Element<'_, Message, Self>, - content_layout: Layout<'_>, - ) -> Self::Output { - let style = style_sheet.style(); - - let defaults = Defaults { - text: defaults::Text { - color: style.text_color.unwrap_or(defaults.text.color), - }, - }; - - let (content, mouse_interaction) = content.draw( - self, - &defaults, - content_layout, - cursor_position, - viewport, - ); - - if let Some(background) = background(bounds, &style) { - ( - Primitive::Group { - primitives: vec![background, content], - }, - mouse_interaction, - ) - } else { - (content, mouse_interaction) - } - } -} - -pub(crate) fn background( - bounds: Rectangle, - style: &container::Style, -) -> Option { - if style.background.is_some() || style.border_width > 0.0 { - Some(Primitive::Quad { - bounds, - background: style - .background - .unwrap_or(Background::Color(Color::TRANSPARENT)), - border_radius: style.border_radius, - border_width: style.border_width, - border_color: style.border_color, - }) - } else { - None - } } -- cgit From d61cb58d92b6fcd520f665deb093f3747ffd5e5c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 18 Oct 2021 15:36:32 +0700 Subject: Wire up `container` styling to `iced_native` --- graphics/src/widget/container.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'graphics/src/widget/container.rs') diff --git a/graphics/src/widget/container.rs b/graphics/src/widget/container.rs index 811a0c7f..c4c4e5ba 100644 --- a/graphics/src/widget/container.rs +++ b/graphics/src/widget/container.rs @@ -1,6 +1,5 @@ //! Decorate content and apply alignment. -use crate::container; -use crate::{Backend, Renderer}; +use crate::Renderer; pub use iced_style::container::{Style, StyleSheet}; @@ -10,10 +9,3 @@ pub use iced_style::container::{Style, StyleSheet}; /// `Renderer`. pub type Container<'a, Message, Backend> = iced_native::Container<'a, Message, Renderer>; - -impl iced_native::container::Renderer for Renderer -where - B: Backend, -{ - type Style = Box; -} -- 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/container.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'graphics/src/widget/container.rs') diff --git a/graphics/src/widget/container.rs b/graphics/src/widget/container.rs index c4c4e5ba..99996f3b 100644 --- a/graphics/src/widget/container.rs +++ b/graphics/src/widget/container.rs @@ -8,4 +8,4 @@ pub use iced_style::container::{Style, StyleSheet}; /// This is an alias of an `iced_native` container with a default /// `Renderer`. pub type Container<'a, Message, Backend> = - iced_native::Container<'a, Message, Renderer>; + iced_native::widget::Container<'a, Message, Renderer>; -- cgit