Skip to content

Conversation

anlumo
Copy link
Contributor

@anlumo anlumo commented Oct 16, 2025

Fixes #9755

  • If the change modifies a visible behavior, it changes the documentation accordingly
  • If possible, the change is auto-tested
  • If the changes fixes or close an existing issue, the commit message reference the issue with Fixes #xxx or Closes #xxx
  • If the change is noteworthy, the commit message should contain ChangeLog: ...

@anlumo anlumo self-assigned this Oct 16, 2025
@anlumo anlumo marked this pull request as ready for review October 16, 2025 14:46
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct LogicalInset {
/// The top inset in logical pixels.
pub top: f32,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use LogicalLength here?

Copy link
Contributor Author

@anlumo anlumo Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because LogicalLength is an euclid type, and we don't want to be tied to euclid in the public API (according to Simon).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, very good reason.

/// of the border between the safe area and the edges of the window.
#[derive(Debug, Default, Copy, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct LogicalInset {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the struct to the slint::LogicalInset public API? Right now, struct from this module are re-exported. I'm thinking we should try to limit the public API surface.

Since this is only used in the event, I'm thinking it could have top, bottom, ... fields instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it because returning the inset in safe_area_inset as a tuple of four lengths would be highly confusing (in which order would the lengths be?).


/// Return the inset of the safe area of the Window in physical pixels.
/// This is necessary to avoid overlapping system UI such as notches or system bars.
fn safe_area_inset(&self) -> PhysicalInset {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we do not need this function and have the platform send the SafeAreaChanged event instead. Would that work?

Copy link
Contributor Author

@anlumo anlumo Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The safe area is required to be read twice when no event occurs, in WindowInner::show and WindowInner::set_component. This is actually the main way to get the safe area, I don't think that it changes during the runtime of the application.

…ng the safe area to Slint.

Also includes the iOS implementation for this.
…S implementation. This is a breaking change!
@anlumo anlumo force-pushed the anlumo/9755-safe-area branch from 12902fc to 3393fe0 Compare October 20, 2025 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement "Safe Area" Concept

2 participants