Skip to content

Conversation

@halx99
Copy link
Collaborator

@halx99 halx99 commented Sep 22, 2025

Introduce Device::resolveOrientation to deterministically choose the app’s effective orientation from supported, preferred, and physical orientations. The logic guarantees the result is always compatible with the supported mask and avoids transient incorrect sizes at startup (notably on iOS).

Key points:

  • Add resolveOrientation() in Device as the single public API for orientation decision.
  • iOS uses this to compute logical screen size before app->run(); Android can return current orientation for parity.

Why:

  • Centralize orientation decision in Device, decoupling it from view/sizing code.
  • Prevent initial flicker and wrong layout caused by UIKit’s portrait-based bounds at launch.
  • Improve readability and maintainability across platforms.

Impact:

  • No breaking changes to callers; RenderViewImpl-ios now consumes Device::resolveOrientation.
  • Orientation result is stable and in-mask; downstream size/viewport code becomes simpler.

Test plan:

  • Unit test matrix across (preferred x physical x supported) including Sensor*, concrete, and unknown cases.
  • Validate FaceUp/FaceDown → fallback behavior.
  • Manual on iOS: cold start in portrait/landscape/flat; verify initial frame matches resolved orientation.
  • Manual on Android: ensure parity and no regression in Activity orientation.

Describe your changes

Issue ticket number and link

Checklist before requesting a review

For each PR

  • Add Copyright if it missed:
    - "Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."

  • I have performed a self-review of my code.

    Optional:

    • I have checked readme and add important infos to this PR.
    • I have added/adapted some tests too.

For core/new feature PR

  • I have checked readme and add important infos to this PR.
  • I have added thorough tests.

Axmol 3.x ------------------------------------------------------------

For each 3.x PR

  • Check the '#include "axmol.h"' and replace it with the needed headers.

…ogic

Introduce Device::resolveOrientation to deterministically choose the app’s effective orientation
from supported, preferred, and physical orientations. The logic guarantees the result is always
compatible with the supported mask and avoids transient incorrect sizes at startup (notably on iOS).

Key points:
- Add resolveOrientation() in Device as the single public API for orientation decision.
- Implement compact resolution flow with tryUse helper to reduce duplication.
- Use resolvedOrientation naming (avoid C++ keyword 'final') for clarity.
- Keep FaceUp/FaceDown/Unknown safely falling back to supported defaults.
- iOS uses this to compute logical screen size before app->run(); Android can return current orientation for parity.

Why:
- Centralize orientation decision in Device, decoupling it from view/sizing code.
- Prevent initial flicker and wrong layout caused by UIKit’s portrait-based bounds at launch.
- Improve readability and maintainability across platforms.

Impact:
- No breaking changes to callers; RenderViewImpl-ios now consumes Device::resolveOrientation.
- Orientation result is stable and in-mask; downstream size/viewport code becomes simpler.

Test plan:
- Unit test matrix across (preferred x physical x supported) including Sensor*, concrete, and unknown cases.
- Validate FaceUp/FaceDown → fallback behavior.
- Manual on iOS: cold start in portrait/landscape/flat; verify initial frame matches resolved orientation.
- Manual on Android: ensure parity and no regression in Activity orientation.
@halx99 halx99 changed the title feat(device): add Device::resolveOrientation and compact resolution l… Add Device::resolveOrientation and compact resolution l… Sep 22, 2025
@halx99 halx99 changed the title Add Device::resolveOrientation and compact resolution l… Add Device::resolveOrientation and compact resolution logic Sep 22, 2025
@halx99 halx99 added this to the 2.9.0 milestone Sep 22, 2025
@halx99 halx99 added enhancement New feature or request platform:ios labels Sep 22, 2025
@halx99 halx99 merged commit 44833f4 into release/2.x Sep 23, 2025
14 of 15 checks passed
@halx99 halx99 deleted the api-resolve-orient branch September 23, 2025 04:26
tkzcfc pushed a commit to tkzcfc/axmol that referenced this pull request Sep 23, 2025
* release/2.x:
  Committing luabindings for commit 44833f4 (axmolengine#2794)
  Add Device::resolveOrientation and compact resolution logic (axmolengine#2792)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request platform:ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants