diff options
author | 2021-11-07 15:15:33 +0700 | |
---|---|---|
committer | 2021-11-07 15:15:33 +0700 | |
commit | eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253 (patch) | |
tree | 76413948c9c9723075189d51d4c2e02c0f8fdd23 /graphics/src/widget/container.rs | |
parent | 61c747b53589d98f477fea95f85d2ea5349666d3 (diff) | |
parent | 07b5097bc92ced376d09115d787ff1d2ebe00836 (diff) | |
download | iced-eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253.tar.gz iced-eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253.tar.bz2 iced-eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253.zip |
Merge pull request #1110 from iced-rs/remove-renderer-traits
Reduce the surface of the `Renderer` APIs
Diffstat (limited to 'graphics/src/widget/container.rs')
-rw-r--r-- | graphics/src/widget/container.rs | 71 |
1 files changed, 2 insertions, 69 deletions
diff --git a/graphics/src/widget/container.rs b/graphics/src/widget/container.rs index aae3e1d8..99996f3b 100644 --- a/graphics/src/widget/container.rs +++ b/graphics/src/widget/container.rs @@ -1,8 +1,5 @@ //! 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::Renderer; pub use iced_style::container::{Style, StyleSheet}; @@ -11,68 +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<Backend>>; - -impl<B> iced_native::container::Renderer for Renderer<B> -where - B: Backend, -{ - type Style = Box<dyn container::StyleSheet>; - - fn draw<Message>( - &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<Primitive> { - 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 - } -} + iced_native::widget::Container<'a, Message, Renderer<Backend>>; |