-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Window::safe_area
with Window::insets
#4008
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm not against the idea of other insets, but I think I'm kinda inclined to have it as separate methods? I.e. adding fn window_controls(&self) -> PhysicalInsets<u32>
instead.
That would match what we do elsewhere (e.g. we don't have fn size(&self, kind: SizeKind)
and enum SizeKind { Outer, Surface }
).
Or do you imagine other inset kinds than InsetKind::WindowControls
/ can you give a sketch of how you imagine that would work?
I remember it being talked about on Matrix, but I can't remember the details.
(That said, thanks for submitting the PR with such a change first, that makes it easier to make API decisions - I'm only lacking the context ;) ) |
In my eyes, the appeal of using an
As functions, all of these would be effectively But also, I think adding some conceptual separation between insets and windows is useful: for example, But at the end of the day, API design can be very subjective. I don't entirely mind which approach is used. Matrix context: https://matrix.to/#/!DGpLzJTRzBDTwZiogk:matrix.org/$2WKcLxzPkX47I6F9Ngc4qjCzOLWyEIOzO1PMUjDSV7w?via=matrix.org&via=mozilla.org&via=catgirl.cloud
|
changelog
module if knowledge of this change could be valuable to users#3890 added the
Window::safe_area
API, for getting the distances from the window edge which are safe to draw important content in. This PR replaceswindow.safe_area()
withwindow.insets(InsetKind::SafeArea)
:safe_area()
and addsinsets(InsetKind)
enum InsetKind
with only one variant (for now):SafeArea
safe_area
docs toInsetKind::SafeArea
This opens the door to being able to read the size of different window
InsetKind
s in the future, such as the inset of window control buttons, or the inset of a specific hardware feature like a camera notch. My use case is to be able to accessInsetKind::WindowControls
, to read how much space the window's native control buttons take up (if they're not rendered in the title bar).Tested on Wayland.