Add love.window.getSafeArea (resolves issue #1437). Returns a rectangle (x, y, w, h) inside the window which is known to be unobstructed by a system title bar, the iPhone X notch, etc. Useful for making sure UI elements can be seen by the user.

Currently it only has a proper implementation on iOS and will return the window's full size otherwise.
This commit is contained in:
Alex Szpakowski
2018-12-26 00:34:14 -04:00
parent 1c853cbcc3
commit d41aca836e
6 changed files with 81 additions and 3 deletions
+11
View File
@@ -365,6 +365,16 @@ int w_getPosition(lua_State *L)
return 3;
}
int w_getSafeArea(lua_State *L)
{
Rect area = instance()->getSafeArea();
lua_pushnumber(L, area.x);
lua_pushnumber(L, area.y);
lua_pushnumber(L, area.w);
lua_pushnumber(L, area.h);
return 4;
}
int w_setIcon(lua_State *L)
{
image::ImageData *i = luax_checktype<image::ImageData>(L, 1);
@@ -607,6 +617,7 @@ static const luaL_Reg functions[] =
{ "getDesktopDimensions", w_getDesktopDimensions },
{ "setPosition", w_setPosition },
{ "getPosition", w_getPosition },
{ "getSafeArea", w_getSafeArea },
{ "setIcon", w_setIcon },
{ "getIcon", w_getIcon },
{ "setVSync", w_setVSync },