From 9cfa42c45ef4ccfa764abab98a07d10ce7f24c95 Mon Sep 17 00:00:00 2001 From: chrisdugne Date: Sun, 31 May 2020 22:58:10 +0200 Subject: [PATCH] added safeArea constants --- .luacheckrc | 6 +++++- cherry/components/background.lua | 2 +- cherry/main.lua | 15 +++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index ce239e0..94fa9c6 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -25,8 +25,12 @@ stds.cherry = { 'string', 'table', 'unpack', + 'FULL_W', + 'FULL_H', 'W', - 'H' + 'H', + 'TOP', + 'BOTTOM' } } diff --git a/cherry/components/background.lua b/cherry/components/background.lua index af1f543..19f9a0d 100644 --- a/cherry/components/background.lua +++ b/cherry/components/background.lua @@ -60,7 +60,7 @@ function Background:init(options) ) if (options.color) then - self.bg = display.newRect(W / 2, H / 2, W, H) + self.bg = display.newRect(FULL_W / 2, FULL_H / 2, FULL_W, FULL_H) self.bg:setFillColor(colorize(options.color)) else local lightImage = options.light diff --git a/cherry/main.lua b/cherry/main.lua index 9ed26a7..48272b1 100644 --- a/cherry/main.lua +++ b/cherry/main.lua @@ -20,8 +20,19 @@ _G.Router = require 'cherry.core.router' -------------------------------------------------------------------------------- -_G.W = display.contentWidth -_G.H = display.contentHeight +_G.FULL_W = display.contentWidth +_G.FULL_H = display.contentHeight + +_G.W = display.safeActualContentWidth +_G.H = display.safeActualContentHeight + +_G.TOP = display.safeScreenOriginY +_G.BOTTOM = display.safeScreenOriginY + display.safeActualContentHeight + +-- local safeArea = display.newRect(W / 2, TOP + H / 2, W, H) +-- local colorize = require 'cherry.libs.colorize' +-- safeArea:setFillColor(colorize('#fff')) +-- safeArea.alpha = 0.2 -------------------------------------------------------------------------------- -- https://docs.coronalabs.com/tutorial/media/extendAnchors/index.html#extending-anchor-points-1