Introduce Layer trait
This commit is contained in:
parent
c901f40fd6
commit
f064f0482b
12 changed files with 252 additions and 54 deletions
|
|
@ -2,8 +2,8 @@
|
|||
use std::hash::Hash;
|
||||
|
||||
use crate::{
|
||||
layout, Align, Clipboard, Element, Event, Hasher, Layout, Length, Point,
|
||||
Widget,
|
||||
layout, Align, Clipboard, Element, Event, Hasher, Layout, Length, Overlay,
|
||||
Point, Widget,
|
||||
};
|
||||
|
||||
use std::u32;
|
||||
|
|
@ -204,6 +204,17 @@ where
|
|||
child.widget.hash_layout(state);
|
||||
}
|
||||
}
|
||||
|
||||
fn overlay(
|
||||
&mut self,
|
||||
layout: Layout<'_>,
|
||||
) -> Option<Overlay<'a, Message, Renderer>> {
|
||||
self.children
|
||||
.iter_mut()
|
||||
.zip(layout.children())
|
||||
.filter_map(|(child, layout)| child.widget.overlay(layout))
|
||||
.next()
|
||||
}
|
||||
}
|
||||
|
||||
/// The renderer of a [`Column`].
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
use std::hash::Hash;
|
||||
|
||||
use crate::{
|
||||
layout, Align, Clipboard, Element, Event, Hasher, Layout, Length, Point,
|
||||
Rectangle, Widget,
|
||||
layout, Align, Clipboard, Element, Event, Hasher, Layout, Length, Overlay,
|
||||
Point, Rectangle, Widget,
|
||||
};
|
||||
|
||||
use std::u32;
|
||||
|
|
@ -214,6 +214,13 @@ where
|
|||
|
||||
self.content.hash_layout(state);
|
||||
}
|
||||
|
||||
fn overlay(
|
||||
&mut self,
|
||||
layout: Layout<'_>,
|
||||
) -> Option<Overlay<'a, Message, Renderer>> {
|
||||
self.content.overlay(layout.children().next().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
/// The renderer of a [`Container`].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue