So I think this is a gray area for me... it's definitely getting outside of what AppKit/UIKit offer by default, but cacao's taken the opinionated position before so I could be convinced to support this.
I would say a few changes come to mind tho:
-
The layout anchor getters could probably be safely thrown onto the Layout
trait without much issue, to reduce trait importing (mental) overhead.
-
top_to_bottom
would be improved (IMO) with the following api:
pub struct ColumnLayout {
pub spacing: usize // psuedocode, do whatever type here
}
pub fn column<I, C>(parent: &Layout, layout: ColumnLayout, children: I)
where
I: IntoIterator<Item = &C>,
C: Layout,
{
// Manage adding views, setting spacing, etc
}
This feels more declarative in nature to me, e.g I could then write:
impl MyGenericView {
pub fn build(&self) {
column(&self.view_handle, ColumnLayout {
spacing: 8
}, [
&self.child_view_1,
&self.child_view_2,
// etc
]);
}
}
The above is all pseudocode and not tested but hopefully showcases the idea.
fill_safe_area
I'm less enthused about and might want that in a contrib
or helpers
module, but I'll muse on that one for a bit. on Add trait to get layout anchors for a view
2 weeks ago