-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwatchface-pp.xml
More file actions
169 lines (161 loc) · 6.54 KB
/
Copy pathwatchface-pp.xml
File metadata and controls
169 lines (161 loc) · 6.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<WatchFace
clipShape="CIRCLE"
height="450"
width="450">
<Metadata
key="CLOCK_TYPE"
value="ANALOG" />
<Define>
COMPLIC_DIA = 200
COMPLIC_MARGIN = 10
COMPLIC_FILL_DEFAULT = "#002040"
COMPLIC_FILL_ALTERNATIVE = "#004020"
COMPLIC_TEXT_HEIGHT = 50
COMPLIC_TEXT_SIZE = 40
COMPLIC_TEXT_Y = 60
COMPLIC_TEXT_COLOUR = "#ffffff"
COMPLIC_TEXT_WEIGHT = "SEMI_BOLD"
COMPLIC_TEXT_PADDING = 15 # optional amount by which to increase text y
COMPLIC_TITLE_HEIGHT = 40
COMPLIC_TITLE_SIZE = 26
COMPLIC_TITLE_Y = 105
COMPLIC_TITLE_COLOUR = "#80c0ff"
COMPLIC_TITLE_WEIGHT = COMPLIC_TEXT_WEIGHT
def centre(parent_size, self_size):
pp_log(parent_size/2, "centre() parent_size halved:")
return round((parent_size-self_size)/2)
def generateSquares(count, width, height):
# Returns XML for a row of count squares, to fit within a PartDraw of width and height.
xIncrement = (width - height) / (count - 1)
# Because we want to return more than one top-level element, we must use Dummy root:
root = xmlpp_ET.Element("Dummy")
for i in range(count):
rect = xmlpp_ET.SubElement(
root,
"Rectangle",
{"x":f"{i*xIncrement}", "y":"0", "width":f"{height}", "height":f"{height}"}
)
xmlpp_ET.SubElement(rect, "Fill", {"color":"#00FF00"})
return root
SCREENSHOT = False # True to display values desired in screenshot
</Define>
<Import href="widgets/ranged-complic/ranged-complic.xml" />
<Symbol id="shortTextComplic">
<ComplicationSlot
displayName="complic"
height="{COMPLIC_DIA}"
isCustomizable="TRUE"
slotId="1"
supportedTypes="SHORT_TEXT EMPTY"
width="{SELF.height}"
x="{pp_log(COMPLIC_MARGIN if SELF.slotId==1 else PARENT.width - COMPLIC_MARGIN - SELF.width, 'Slot.x:')}"
y="{centre(PARENT.height, SELF.height)}"
data-text-padding="0" >
<BoundingOval
height="{PARENT}"
width="{PARENT}"
x="0"
y="0" />
<Complication type="SHORT_TEXT">
<!-- Background -->
<PartDraw
x="0"
y="0"
height="{PARENT}"
width="{PARENT}">
<Variant mode="AMBIENT" target="alpha" value="0" />
<Ellipse
height="{PARENT}"
width="{PARENT}"
x="0"
y="0">
<Fill color="{COMPLIC_FILL_DEFAULT}" />
</Ellipse>
</PartDraw>
<!-- Text -->
<PartText
height="{COMPLIC_TEXT_HEIGHT}"
width="{PARENT}"
x="0"
y="{COMPLIC_TEXT_Y + PARENT.data-text-padding}">
<Text
align="CENTER"
ellipsis="TRUE">
<Font
color="{COMPLIC_TEXT_COLOUR}"
family="SYNC_TO_DEVICE"
size="{COMPLIC_TEXT_SIZE}"
slant="NORMAL"
weight="{COMPLIC_TEXT_WEIGHT}">
<Template>%s
<If condition="{SCREENSHOT==False}">
<Parameter expression="[COMPLICATION.TEXT]" />
</If>
<If condition="{SCREENSHOT==True}">
<Parameter expression="My Text" />
</If>
</Template>
</Font>
</Text>
</PartText>
<!-- Title -->
<PartText
height="{COMPLIC_TITLE_HEIGHT}"
width="{PARENT}"
x="0"
y="{COMPLIC_TITLE_Y}">
<Text
align="CENTER"
ellipsis="TRUE">
<Font
color="{COMPLIC_TITLE_COLOUR}"
family="SYNC_TO_DEVICE"
size="{COMPLIC_TITLE_SIZE}"
slant="NORMAL"
weight="{COMPLIC_TITLE_WEIGHT}">
<Template>%s
<Parameter expression="[COMPLICATION.TITLE]" />
</Template>
</Font>
</Text>
</PartText>
</Complication>
</ComplicationSlot>
</Symbol>
<Scene backgroundColor="#ff000000">
<!-- Squares across top (demonstrating Python generation of XML): -->
<PartDraw width="250" height="30" x="{centre(PARENT.width, SELF.width)}" y="65">
{generateSquares(5, SELF.width, SELF.height)}
</PartDraw>
<!-- Digits across top (demonstrating <Repeat>): -->
<Repeat for="n" in="range(5)"> <!-- 0 to 4 -->
<PartText
width="50"
height="50"
x="{round(centre(PARENT.width, SELF.width) + 55 * (n - 2))}"
y="54">
<Text>
<Font
family="SYNC_TO_DEVICE"
size="35"
color="#000000">
<Template>%s
<Parameter expression="{n}" />
</Template>
</Font>
</Text>
</PartText>
</Repeat>
<!-- Left complication slot: -->
<Use href="shortTextComplic" />
<!-- Right complication slot (with extra text padding): -->
<Use href="shortTextComplic" slotId="2" data-text-padding="{COMPLIC_TEXT_PADDING}">
<!-- Change background colour: -->
<Transform href=".//Fill" target="color" value="{COMPLIC_FILL_ALTERNATIVE}" />
<!-- Remove title: -->
<Delete href="ComplicationSlot/Complication/PartText[2]" />
</Use>
<!-- Bottom complication slot: -->
<Use href="rangedValueComplic" y="350" slotId="3"/>
</Scene>
</WatchFace>