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

Adjust viewport work area for mobile platforms #7823

Closed
pdoane opened this issue Jul 27, 2024 · 5 comments
Closed

Adjust viewport work area for mobile platforms #7823

pdoane opened this issue Jul 27, 2024 · 5 comments

Comments

@pdoane
Copy link

pdoane commented Jul 27, 2024

Version/Branch of Dear ImGui:

v1.90.8-docking

Back-ends:

custom

Compiler, OS:

NA

Full config/build information:

No response

Details:

I would like for ImGui applications to respect the mobile work area constraints (e.g. status bar, navigation bar, notch). I think that the existing machinery is sufficient but I am not sure there is an API/path for the backend to communicate requirements.

  • Monitors have MainPos/MainSize + WorkPos/WorkSize to indicate where it is safe for Windows to exist.
  • Viewports have WorkPos/WorkSize used for ImGui constructs like the menu bar.

Maybe for mobile, the Monitor MainArea == Monitor WorkArea, but the viewport WorkArea is inset as needed by a value provided by the backend?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

@ocornut
Copy link
Owner

ocornut commented Jul 27, 2024

It seems adequate to modify the monitor WorkPos/WorkSize values to convey this. Monitor data is submitted by backends already.

But maybe it is going to be more practical for backend or user app to fill a separate field that I don’t know. It would depend on where the data comes up and if it is easy for us to add it to many backends.

@pdoane
Copy link
Author

pdoane commented Jul 28, 2024

Thanks for the quick reply! I looked into setting the Monitor data, but it is ignored for this purpose (and I think correctly so). Window Pos/Size are synchronized between ImGui and the backend as the window could be technically anywhere. If the app isn't fullscreen (e.g. split mode with two apps), then the monitor WorkArea wouldn't make sense to apply.

iOS exposes this as a view property which makes sense to me. While uncommon, mobile devices can have multiple screens/views and there are view settings to show/hide these extra elements.

It's also unusual compared to the desktop paradigm that this space is shared between app and system. The app can render there, and it will be displayed behind the system contents.

The design I would investigate is a new Platform callback to query the WorkPos/WorkArea. It's easy to leave them as nullptr, and the system work as it is today.

ocornut added a commit that referenced this issue Aug 1, 2024
…top-right0 into WorkInset (positive everywhere). (#7823)
@ocornut
Copy link
Owner

ocornut commented Aug 1, 2024

After a discussion with Patrick I have pushed two commits:

  • cfd2395 preliminary: rephrase WorkOffset as WorkInset to match iOS/Android standards).
  • a18f020 added platform_io.Platform_GetWindowWorkAreaInsets() hook to setup initial values.

This is solved AFAIK.

@pdoane
Copy link
Author

pdoane commented Aug 6, 2024

This is working for me on iOS and expected Android should be fine as well - thanks! One minor issue is that Platform_GetWindowWorkAreaInsets is called prior to Platform_CreateWindow.

ocornut added a commit that referenced this issue Aug 7, 2024
@ocornut
Copy link
Owner

ocornut commented Aug 7, 2024

One minor issue is that Platform_GetWindowWorkAreaInsets is called prior to Platform_CreateWindow.

Fixed with 7b6314f

@ocornut ocornut closed this as completed Aug 7, 2024
ocornut added a commit that referenced this issue Sep 3, 2024
…oken using BeginViewportSideBar() with ImGuiDir_Down, regression from 1.91.0. (#7940, #7823)

Amend cfd2395
ocornut added a commit that referenced this issue Sep 3, 2024
Among other things:
- merged cfd2395 (#7940, #7823), also see ac64b65 (#6716): moved above on 2023/08/14 in both branches.
- moving the RenderDimmedBackgrounds() call, from f422e78, see 676497f intently undoing ac64b65 -> confusing. (#6716)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants