summaryrefslogtreecommitdiffstats
path: root/graphics/src/widget/container.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-07-10 00:35:15 +0200
committerLibravatar GitHub <noreply@github.com>2020-07-10 00:35:15 +0200
commit46ce3a1f0004ddc527ba3de1ffe3dac3f41a06c3 (patch)
tree66449eec70609f8fc03a5e4e90ce39a7346d02fb /graphics/src/widget/container.rs
parent5c4f5ae5ecb36703a95cafb2cd58692529c9466d (diff)
parent3c5921f30c17bcbe0af74a30b6a256a3fa03515c (diff)
downloadiced-46ce3a1f0004ddc527ba3de1ffe3dac3f41a06c3.tar.gz
iced-46ce3a1f0004ddc527ba3de1ffe3dac3f41a06c3.tar.bz2
iced-46ce3a1f0004ddc527ba3de1ffe3dac3f41a06c3.zip
Merge pull request #442 from hecrj/feature/pane-grid-titlebar
Title bar support for `PaneGrid`
Diffstat (limited to '')
-rw-r--r--graphics/src/widget/container.rs33
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,
+ })
+}