Files
wf/source/Background/IBackground.mc
2025-11-05 17:59:54 +02:00

57 lines
1.6 KiB
MonkeyC

import Toybox.Application.Properties;
import Toybox.Graphics;
import Toybox.Lang;
import Toybox.WatchUi;
class IBackground extends Drawable {
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});
for (var s = 0; s < 60; s += 1) {
var markType = IMark.getMarkType(s);
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, {
:Identifier => markIdentifier,
:Seconds => s,
:Color => Properties.getValue(Lang.format("$1$/Color", [markIdentifier])) as ColorType,
});
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);
}
}
function drawBackground(dc as Dc) as Void {}
}