fruiframework / frui

A developer-friendly framework for building user interfaces in Rust
Apache License 2.0
1.09k stars 19 forks source link

feat: Implementation of basic box-model widgets. #8

Closed xanahopper closed 1 year ago

xanahopper commented 2 years ago

Widgets

Traits

toiglak commented 2 years ago

Sorry to keep you waiting.

You added the BoxLayoutWidget trait, but we lay out widgets using “box constraints'' by default in Frui. You can see this in the layout method of RenderWidget which takes the Constraints argument – the same as in RenderBox in Flutter.

As for the compute_max_intrinsic_width method and the similar, I think we can add them directly to the RenderWidget. Alternatively (and I really would like to try this option out) we could implement the measure method from Xilem, which seems to do the exact thing we need here!

xanahopper commented 2 years ago

Yes, adding toRenderWidget directly and splitting the layout into measure and layout are considered. BoxLayoutWidget is declared because I want to keep a position for the Scrolling/Sliver model, but now it seems unnecessary.

And I'm trying some patterns to simulate the OOP abstraction design and defined some default behaviors that can be overridden, but I think it's not suitable for Rust.

I'll change these directly to RenderWidget later in this PR.

xanahopper commented 2 years ago

@toiglak BoxLayoutWidget has been removed, and methods in this move to RenderWidget with the default implementation.

xanahopper commented 1 year ago

Flex PR #9 is based on this.