Merge unnecessary split widget modules
This commit is contained in:
parent
c2e0c52ce0
commit
e618091248
28 changed files with 1032 additions and 1037 deletions
|
|
@ -1,5 +1,8 @@
|
|||
//! Decorate content and apply alignment.
|
||||
use crate::Renderer;
|
||||
use crate::container;
|
||||
use crate::defaults::{self, Defaults};
|
||||
use crate::{Backend, Primitive, Renderer};
|
||||
use iced_native::{Background, Color, Element, Layout, Point, Rectangle};
|
||||
|
||||
pub use iced_style::container::{Style, StyleSheet};
|
||||
|
||||
|
|
@ -9,3 +12,52 @@ pub use iced_style::container::{Style, StyleSheet};
|
|||
/// `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,
|
||||
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);
|
||||
|
||||
if style.background.is_some() || style.border_width > 0 {
|
||||
let quad = 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,
|
||||
};
|
||||
|
||||
(
|
||||
Primitive::Group {
|
||||
primitives: vec![quad, content],
|
||||
},
|
||||
mouse_interaction,
|
||||
)
|
||||
} else {
|
||||
(content, mouse_interaction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue