66 lines
2.0 KiB
MonkeyC
66 lines
2.0 KiB
MonkeyC
import Toybox.Application.Properties;
|
|
import Toybox.Graphics;
|
|
import Toybox.Lang;
|
|
import Toybox.WatchUi;
|
|
|
|
class IBackground extends Drawable {
|
|
|
|
var Color as ColorType;
|
|
var Hands as Array<IHands> = [];
|
|
var Marks as Array<IMark> = [];
|
|
|
|
typedef BackgroundParams as {
|
|
:Identifier as Object,
|
|
:Color as ColorType,
|
|
};
|
|
|
|
enum BackgroundStyleType {
|
|
SOLID_BACKGROUND,
|
|
}
|
|
|
|
static function getBackground(style as BackgroundStyleType, options as BackgroundParams) as IBackground {
|
|
switch (style) {
|
|
case SOLID_BACKGROUND:
|
|
default:
|
|
return new SolidBackground(options);
|
|
}
|
|
}
|
|
|
|
function initialize(options as BackgroundParams) {
|
|
var identifier = options[:Identifier];
|
|
Drawable.initialize({:identifier => identifier});
|
|
|
|
Color = Properties.getValue(Lang.format("$1$/Background/Color", [identifier])) as ColorType;
|
|
|
|
for (var seconds = 0; seconds < 60; ++seconds) {
|
|
var markType = IMark.getMarkType(seconds);
|
|
|
|
var markIdentifier = Lang.format("$1$/Marks/$2$", [identifier, markType]);
|
|
var markStyle = Properties.getValue(Lang.format("$1$/Type", [markIdentifier])) as IMark.MarkStyleType;
|
|
|
|
var mark = IMark.getMark(markStyle, markType, {
|
|
:Identifier => markIdentifier,
|
|
:BackgroundColor => Color,
|
|
:Color => Properties.getValue(Lang.format("$1$/Color", [markIdentifier])) as ColorType,
|
|
:Seconds => seconds,
|
|
:Size => markType == IMark.TERTIARY_MARK ? 0.033 : 0.1,
|
|
});
|
|
if (mark != null) {
|
|
Marks.add(mark);
|
|
}
|
|
}
|
|
}
|
|
|
|
function draw(dc as Dc) as Void {
|
|
drawBackground(dc);
|
|
for (var i = 0; i < Marks.size(); ++i) {
|
|
Marks[i].draw(dc);
|
|
}
|
|
for (var i = 0; i < Hands.size(); ++i) {
|
|
Hands[i].draw(dc);
|
|
}
|
|
}
|
|
|
|
function drawBackground(dc as Dc) as Void {}
|
|
}
|