initial commit

This commit is contained in:
2025-10-09 14:37:45 +03:00
commit 077259c534
22 changed files with 692 additions and 0 deletions

View File

@ -0,0 +1,84 @@
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,
:Hands as Array<IHands.HandType>,
};
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);
}
}
var hands = options[:Hands];
for (var i = 0; i < hands.size(); ++i) {
var handType = hands[i];
var handIdentifier = Lang.format("$1$/Hands/$2$", [identifier, handType]);
var handStyle = Properties.getValue(Lang.format("$1$/Type", [handIdentifier])) as IHands.HandStyleType;
var hand = IHands.getHands(handStyle, {
:Identifier => handIdentifier,
:BackgroundColor => Color,
:Color => Properties.getValue(Lang.format("$1$/Color", [handIdentifier])) as ColorType,
:Type => handType,
});
if (hand != null) {
Hands.add(hand);
}
}
}
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 {}
}