linebender / druid

A data-first Rust-native UI design toolkit.
https://linebender.org/druid/
Apache License 2.0
9.45k stars 569 forks source link

Add the ViewportHeader widget #2312

Open xarvic opened 1 year ago

xarvic commented 1 year ago

Add functionality based on the ViewContextChanged lifecycle event, which provides widgets with information about the viewport.

The ViewportHeader widget has a header child and a content child and moves the header over the content if this helps to keep the header inside the viewport. This way the header widget sticks to the border of the viewport. For an example this is useful if you have multiple large widgets in a scroll view and always want to know which element you are currently looking at. ScrollToView request also work, since the ViewportHeader widget intercept and transforms the requests.

The Align widget gains the ability to only consider its visible part for aligning its child.

xStrom commented 1 year ago

Please rebase on master so we can pass the CI without unrelated clippy errors. Also please run cargo fmt.

Additionally, please give a short description of what the purpose of the ViewportHeader widget is. I see that there is an example, which is excellent. I'll check that out when we pass CI.

xarvic commented 1 year ago

@xStrom i edited the description of the ViewportHeader widget and also improved the example.