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 `Event::WindowScale` and `Ctx::scale` for easier scale handling. #2335

Closed xStrom closed 1 year ago

xStrom commented 1 year ago

Event::WindowScale wasn't fully connected, but the druid-shell part of it is somewhat functional, although not complete. Still, it's better to move this forward and surface the event to widgets.

The Ctx::scale method is added to every context and makes accessing the current window's scale as easy as accessing the widget's size. This is really a convenience method to improve ergonomics and doesn't enable new functionality.

Additionally I cleaned up the new SVG widget (from #2106) and it now makes use of this scale information to properly render the SVG at various scale factors.

Fixes #2333

james-lawrence commented 1 year ago

@jneem no i didn't. =)

james-lawrence commented 1 year ago

@xStrom all looks good to me. =)