Implement `Widget::overlay` for `PaneGrid`
This commit is contained in:
parent
1070b61f34
commit
f24e03eae8
|
@ -29,8 +29,8 @@ pub use state::{Focus, State};
|
||||||
pub use title_bar::TitleBar;
|
pub use title_bar::TitleBar;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
container, keyboard, layout, mouse, row, text, Clipboard, Element, Event,
|
container, keyboard, layout, mouse, overlay, row, text, Clipboard, Element,
|
||||||
Hasher, Layout, Length, Point, Rectangle, Size, Vector, Widget,
|
Event, Hasher, Layout, Length, Point, Rectangle, Size, Vector, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A collection of panes distributed using either vertical or horizontal splits
|
/// A collection of panes distributed using either vertical or horizontal splits
|
||||||
|
@ -636,6 +636,17 @@ where
|
||||||
element.hash_layout(state);
|
element.hash_layout(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn overlay(
|
||||||
|
&mut self,
|
||||||
|
layout: Layout<'_>,
|
||||||
|
) -> Option<overlay::Element<'_, Message, Renderer>> {
|
||||||
|
self.elements
|
||||||
|
.iter_mut()
|
||||||
|
.zip(layout.children())
|
||||||
|
.filter_map(|((_, pane), layout)| pane.overlay(layout))
|
||||||
|
.next()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The renderer of a [`PaneGrid`].
|
/// The renderer of a [`PaneGrid`].
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::container;
|
use crate::container;
|
||||||
use crate::layout;
|
use crate::layout;
|
||||||
|
use crate::overlay;
|
||||||
use crate::pane_grid::{self, TitleBar};
|
use crate::pane_grid::{self, TitleBar};
|
||||||
use crate::{Clipboard, Element, Event, Hasher, Layout, Point, Size};
|
use crate::{Clipboard, Element, Event, Hasher, Layout, Point, Size};
|
||||||
|
|
||||||
|
@ -184,6 +185,24 @@ where
|
||||||
pub(crate) fn hash_layout(&self, state: &mut Hasher) {
|
pub(crate) fn hash_layout(&self, state: &mut Hasher) {
|
||||||
self.body.hash_layout(state);
|
self.body.hash_layout(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn overlay(
|
||||||
|
&mut self,
|
||||||
|
layout: Layout<'_>,
|
||||||
|
) -> Option<overlay::Element<'_, Message, Renderer>> {
|
||||||
|
let body_layout = if self.title_bar.is_some() {
|
||||||
|
let mut children = layout.children();
|
||||||
|
|
||||||
|
// Overlays only allowed in the pane body, for now at least.
|
||||||
|
let _title_bar_layout = children.next();
|
||||||
|
|
||||||
|
children.next()?
|
||||||
|
} else {
|
||||||
|
layout
|
||||||
|
};
|
||||||
|
|
||||||
|
self.body.overlay(body_layout)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, Message, Renderer> From<T> for Content<'a, Message, Renderer>
|
impl<'a, T, Message, Renderer> From<T> for Content<'a, Message, Renderer>
|
||||||
|
|
Loading…
Reference in New Issue