diff options
author | 2020-06-05 14:02:29 +0200 | |
---|---|---|
committer | 2020-06-05 14:02:29 +0200 | |
commit | 4dc5bffdfbfb09a017f35c12b484301fcf044876 (patch) | |
tree | 2175e006a72050aaef4789bc1bf8d5513274057f /graphics/src/widget/container.rs | |
parent | e8e656b3300093e384771a6083e25e9395bbeb50 (diff) | |
download | iced-4dc5bffdfbfb09a017f35c12b484301fcf044876.tar.gz iced-4dc5bffdfbfb09a017f35c12b484301fcf044876.tar.bz2 iced-4dc5bffdfbfb09a017f35c12b484301fcf044876.zip |
Draft draggable and graphics logic for `TitleBar`
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, + }) +} |