natiny_window_get_orientation

C
uint32_t natiny_window_get_orientation(NatinyWindow id);

Returns the current window orientation derived from its dimensions.

Parameters

Name Type Description
id NatinyWindow Window handle from natiny_window_create

Returns

Type Description
uint32_t NATINY_ORIENTATION_LANDSCAPE when width is greater than height, NATINY_ORIENTATION_PORTRAIT otherwise, or 0 for an invalid handle

Example

C
if (natiny_window_get_orientation(win) == NATINY_ORIENTATION_LANDSCAPE)
    draw_toolbar_down_the_side();
else
    draw_toolbar_across_the_bottom();

Notes

  • The result is based on the current window width and height on every platform.
  • NATINY_ORIENTATION_PORTRAIT_FLIPPED and NATINY_ORIENTATION_LANDSCAPE_FLIPPED are never returned because dimensions do not identify which edge is at the top.
  • Square windows return NATINY_ORIENTATION_PORTRAIT.
  • The result changes in the same frame as natiny_window_get_width and natiny_window_get_height.
  • Use natiny_window_set_orientation to set the allowed Android orientations. This function does not return that mask.