Cached 'has' result in initialize()

Also amended a bit of README that was missed and added a memory usage in the RootView for widgets here memory is limited, to serve as a warning to users who are likely to complain.
This commit is contained in:
Philip Abbey
2024-01-14 19:59:18 +00:00
parent 84aaa44995
commit 81762fbf7d
11 changed files with 92 additions and 22 deletions

View File

@ -29,12 +29,13 @@ using Toybox.Timer;
class Alert extends WatchUi.View {
private static const bRadius = 10;
private var mTimer as Timer.Timer;
private var mTimeout as Lang.Number;
private var mText as Lang.String;
private var mFont as Graphics.FontType;
private var mFgcolor as Graphics.ColorType;
private var mBgcolor as Graphics.ColorType;
private var mTimer as Timer.Timer;
private var mTimeout as Lang.Number;
private var mText as Lang.String;
private var mFont as Graphics.FontType;
private var mFgcolor as Graphics.ColorType;
private var mBgcolor as Graphics.ColorType;
private var mAntiAlias as Lang.Boolean = false;
function initialize(params as Lang.Dictionary) {
View.initialize();
@ -64,6 +65,10 @@ class Alert extends WatchUi.View {
mTimeout = 2000;
}
if (Graphics.Dc has :setAntiAlias) {
mAntiAlias = true;
}
mTimer = new Timer.Timer();
}
@ -75,7 +80,7 @@ class Alert extends WatchUi.View {
mTimer.stop();
}
function onUpdate(dc) {
function onUpdate(dc as Graphics.Dc) {
var tWidth = dc.getTextWidthInPixels(mText, mFont);
var tHeight = dc.getFontHeight(mFont);
var bWidth = tWidth + 20;
@ -83,7 +88,7 @@ class Alert extends WatchUi.View {
var bX = (dc.getWidth() - bWidth) / 2;
var bY = (dc.getHeight() - bHeight) / 2;
if (dc has :setAntiAlias) {
if (mAntiAlias) {
dc.setAntiAlias(true);
}