diff options
author | 2020-07-10 01:25:49 +0200 | |
---|---|---|
committer | 2020-07-10 01:25:49 +0200 | |
commit | ce8cb228ef608b247c8a84f9d3a4a7faff68b355 (patch) | |
tree | 97102b9d90b1ce3ffcddc5b7faa9e26ce7ce340a /graphics/src/widget/container.rs | |
parent | 33e6682882cd09dd210da123eb3b893e33bd977d (diff) | |
parent | 46ce3a1f0004ddc527ba3de1ffe3dac3f41a06c3 (diff) | |
download | iced-ce8cb228ef608b247c8a84f9d3a4a7faff68b355.tar.gz iced-ce8cb228ef608b247c8a84f9d3a4a7faff68b355.tar.bz2 iced-ce8cb228ef608b247c8a84f9d3a4a7faff68b355.zip |
Merge branch 'master' into feature/overlay
Diffstat (limited to 'graphics/src/widget/container.rs')
-rw-r--r-- | graphics/src/widget/container.rs | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/graphics/src/widget/container.rs b/graphics/src/widget/container.rs index 070cb48b..576062d4 100644 --- a/graphics/src/widget/container.rs +++ b/graphics/src/widget/container.rs @@ -39,20 +39,10 @@ where 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, - }; - + if let Some(background) = background(bounds, &style) { ( Primitive::Group { - primitives: vec![quad, content], + primitives: vec![background, content], }, mouse_interaction, ) @@ -61,3 +51,22 @@ where } } } + +pub(crate) fn background( + bounds: Rectangle, + style: &container::Style, +) -> Option<Primitive> { + if style.background.is_none() && style.border_width > 0 { + return None; + } + + 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, + }) +} |