From 27b42ca6b6585477fda0a5d07ec09bd74e501a1a Mon Sep 17 00:00:00 2001 From: Clark Moody Date: Thu, 17 Jun 2021 14:50:28 -0500 Subject: [PATCH 1/2] Allow overlay from pane grid title bar --- native/src/widget/pane_grid/content.rs | 16 ++++++++-------- native/src/widget/pane_grid/title_bar.rs | 8 ++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/native/src/widget/pane_grid/content.rs b/native/src/widget/pane_grid/content.rs index f028ec25..188c47e3 100644 --- a/native/src/widget/pane_grid/content.rs +++ b/native/src/widget/pane_grid/content.rs @@ -193,18 +193,18 @@ where &mut self, layout: Layout<'_>, ) -> Option> { - let body_layout = if self.title_bar.is_some() { + if let Some(title_bar) = self.title_bar.as_mut() { let mut children = layout.children(); + let title_bar_layout = children.next().unwrap(); - // Overlays only allowed in the pane body, for now at least. - let _title_bar_layout = children.next(); + if let Some(overlay) = title_bar.overlay(title_bar_layout) { + return Some(overlay); + } - children.next()? + self.body.overlay(children.next()?) } else { - layout - }; - - self.body.overlay(body_layout) + self.body.overlay(layout) + } } } diff --git a/native/src/widget/pane_grid/title_bar.rs b/native/src/widget/pane_grid/title_bar.rs index d9d85dbb..efdc1e54 100644 --- a/native/src/widget/pane_grid/title_bar.rs +++ b/native/src/widget/pane_grid/title_bar.rs @@ -1,6 +1,7 @@ use crate::container; use crate::event::{self, Event}; use crate::layout; +use crate::overlay; use crate::pane_grid; use crate::{ Clipboard, Element, Hasher, Layout, Padding, Point, Rectangle, Size, @@ -242,4 +243,11 @@ where control_status.merge(title_status) } + + pub(crate) fn overlay( + &mut self, + layout: Layout<'_>, + ) -> Option> { + self.content.overlay(layout) + } } From 15c17a72502e15393f6430424eaad576581f2e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 22 Jun 2021 11:29:06 +0200 Subject: [PATCH 2/2] Use `match` statement in `Content::overlay` ... to improve readability a bit. --- native/src/widget/pane_grid/content.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/native/src/widget/pane_grid/content.rs b/native/src/widget/pane_grid/content.rs index 188c47e3..b0110393 100644 --- a/native/src/widget/pane_grid/content.rs +++ b/native/src/widget/pane_grid/content.rs @@ -195,13 +195,12 @@ where ) -> Option> { if let Some(title_bar) = self.title_bar.as_mut() { let mut children = layout.children(); - let title_bar_layout = children.next().unwrap(); + let title_bar_layout = children.next()?; - if let Some(overlay) = title_bar.overlay(title_bar_layout) { - return Some(overlay); + match title_bar.overlay(title_bar_layout) { + Some(overlay) => Some(overlay), + None => self.body.overlay(children.next()?), } - - self.body.overlay(children.next()?) } else { self.body.overlay(layout) }