natiny.window.get_orientation

Lua
natiny.window.get_orientation(win) -> orientation

Returns the current window orientation derived from its dimensions.

Parameters

Name Type Description
win number Window handle from natiny.window.create

Returns

Type Description
number natiny.window.ORIENTATION_LANDSCAPE when width is greater than height, natiny.window.ORIENTATION_PORTRAIT otherwise, or 0 for an invalid handle

Example

Lua
if natiny.window.get_orientation(win) == natiny.window.ORIENTATION_LANDSCAPE then
    draw_toolbar_down_the_side()
else
    draw_toolbar_across_the_bottom()
end

Notes

  • The result is based on the current window width and height on every platform.
  • Square windows return natiny.window.ORIENTATION_PORTRAIT.
  • The function never returns natiny.window.ORIENTATION_PORTRAIT_FLIPPED or natiny.window.ORIENTATION_LANDSCAPE_FLIPPED because dimensions do not identify which edge is at the top.
  • 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.