![]() # Objective #### Goals * Stop layout updates from overwriting `ScrollPosition`. * Make `ScrollPosition` respect scale factor. * Automatically allocate space for a scrollbar on an axis when `OverflowAxis::Scroll` is set. #### Non-Goals * Overflow-auto support (I was certain Taffy had this already, but apparently I was hallucinating). * Implement any sort of scrollbar widgets. * Stability (not needed because no overflow-auto support). * Maybe in the future we could make a `ScrollbarWidth` enum to more closely match the CSS API with its auto/narrow/none options. For now `scrollbar_width` is just an `f32` which matches Taffy's API. ## Solution * Layout updates no longer overwrite `ScrollPosition`'s value. * Added the field `scrollbar_width: f32` to `Node`. This is sent to `Taffy` which will automatically allocate space for scrollbars with this width in the layout as needed. * Added the fields `scrollbar_width: f32` and `scroll_position: Vec2` to `ComputedNode`. These are updated automatically during layout. * `ScrollPosition` now respects scale factor. * `ScrollPosition` is no longer automatically added to every UI node entity by `ui_layout_system`. If every node needs it, it should just be required by (or be a field on) `Node`. Not sure if that's necessary or not. ## Testing For testing you can look at: * The `scrollbars` example, which should work as before. * The new example `drag_to_scroll`. * The `scroll` example which automatically allocates space for scrollbars on the left hand scrolling list. Did not implement actual scrollbars so you'll just see a gap atm. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md |