Skip to content
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

Add function to get mobile device's notch position and size on iOS (already implemented on Android) #3466

Open
Cykyrios opened this issue Oct 24, 2021 · 4 comments · Fixed by godotengine/godot#60551

Comments

@Cykyrios
Copy link

Describe the project you are working on

A non-game project that has a lot of GUI elements, but this could also apply to games for mobile devices.

Describe the problem or limitation you are having in your project

Since godotengine/godot#43104, it is possible to get the safe area of the screen (on Android, not sure about iOS). This helps avoid putting UI elements on parts of the screen that are hidden. However, this also means that part of the screen is not usable, while some apps or games could use the space to display UI elements (a less obtrusive menu button, for instance).

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Android (again, not sure about iOS) exposes functions to get the inactive areas' position and dimensions, which could be used to work the UI around those inactive areas, instead of removing the entire upper part of the screen.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

godotengine/godot#43104 already calls getDisplayCutout() to determine the safe area, this could also be used to return an array of Rect2 corresponding to all inactive areas. As a bonus, we could even get the notch's actual shape using getCutoutPath().

If this enhancement will not be used often, can it be worked around with a few lines of script?

I think the only way to work around this would be to write an Android plugin (I have no experience with those, but I assume it's doable).

Is there a reason why this should be core and not an add-on in the asset library?

Unless sensors behind the screen become the next standard, notches and punch holes are going to be visible on many phones to come, so having a built-in way to work around them (or with them) could be helpful.

@Cykyrios
Copy link
Author

I have a working implementation for Android based on 3.x (I know I should target master first, but I'm honestly slightly confused about some of the API changes and haven't quite checked everything yet). Should I make a PR for 3.x first anyway?

For reference, here's the result on my Asus Zenfone 8, with a test project that draws a Panel and changes its position and size accordingly:
inactive_area_landscape
I'm planning to link the test project to the PR so people can try on other phones, but I also got it working on the Android emulator with notches and corner holes as well. The only case that won't work properly is with 2 cutouts (do phones with 2 cutouts exist at all?), as I only return the first area found.

@Calinou
Copy link
Member

Calinou commented Oct 26, 2021

The only case that won't work properly is with 2 cutouts (do phones with 2 cutouts exist at all?),

I don't know of any such device. As of 2021, the 3 most popular options are a notch, a hole (cornered or centered), or an under-display camera with no notch or hole in sight.

@Calinou
Copy link
Member

Calinou commented May 2, 2022

For reference, this was implemented in 4.0 by godotengine/godot#60551, and in 3.5 by godotengine/godot#60552.

@madmiraal
Copy link

madmiraal commented May 3, 2022

godotengine/godot#60551 and godotengine/godot#60552 only implement this feature on Android. It still needs to be implemented on iPhone.

@Calinou Calinou reopened this May 3, 2022
@Calinou Calinou changed the title Add function to get mobile device's notch position and size Add function to get mobile device's notch position and size on iOS (already implemented on Android) May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready for Implementation
5 participants