Repository navigation
Expand file tree
/
Copy pathDataFieldWithFiveValuesView.mc
More file actions
186 lines (167 loc) · 7.32 KB
/
Copy pathDataFieldWithFiveValuesView.mc
File metadata and controls
186 lines (167 loc) · 7.32 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
using Toybox.WatchUi;
using Toybox.Graphics;
class DataFieldWithFiveValuesView extends WatchUi.DataField {
protected var labelValue;
protected var mainValue;
protected var topLeftValue;
protected var topRightValue;
protected var bottomLeftValue;
protected var bottomRightValue;
function initialize() {
DataField.initialize();
labelValue = "";
mainValue = "";
topLeftValue = "";
topRightValue = "";
bottomLeftValue = "";
bottomRightValue = "";
}
// Set your layout here. Anytime the size of obscurity of
// the draw context is changed this will be called.
function onLayout(dc) {
var width = dc.getWidth();
var height = dc.getHeight();
switch (true) {
// edge 1030 1 Field Layout
// edge 1030 plus 1 Field Layout
// edge 1030 bontrager 1 Field Layout
case (width >= 282 && height >= 470):
View.setLayout(Rez.Layouts.HugeLayout1Field(dc));
View.findDrawableById("debug").setText("HugeLayout1Field" + " " + width + "x" + height);
// edge 830 1 Field Layout
// edge 530 1 Field Layout
// edge explore 240x400 1 Field Layout
case (width >= 240 && height >= 322):
View.setLayout(Rez.Layouts.LargeLayout1Field(dc));
View.findDrawableById("debug").setText("LargeLayout1Field" + " " + width + "x" + height);
break;
// edge 820 explore 200x264 1 Field Layout
case (width >= 200 && height >= 264):
View.setLayout(Rez.Layouts.MediumLayout1Field(dc));
View.findDrawableById("debug").setText("MediumLayout1Field" + " " + width + "x" + height);
break;
// edge 1030 2 Field Layout
// edge 1030 plus 2 Field Layout
// edge 1030 bontrager 2 Field Layout
// 282x234
case (width >= 282 && height >= 234):
View.setLayout(Rez.Layouts.HugeLayout2Field(dc));
View.findDrawableById("debug").setText("HugeLayout2Field" + " " + width + "x" + height);
break;
// edge explore 240x199 2 Field Layout
case (width >= 240 && height >= 199):
View.setLayout(Rez.Layouts.LargeLayout2Field(dc));
View.findDrawableById("debug").setText("LargeLayout2Field" + " " + width + "x" + height);
break;
// edge 830 2 Field Layout 246x160
// edge 530 2 Field Layout 246x160
case (width >= 240 && height >= 160):
View.setLayout(Rez.Layouts.MediumLayout2Field(dc));
View.findDrawableById("debug").setText("MediumLayout2Field" + " " + width + "x" + height);
break;
// edge 1030 3 Field Layout
// edge 1030 plus 3 Field Layout
// edge 1030 bontrager 3 Field Wide Layout
// 282x155
case (width >=282 && height >= 154):
View.setLayout(Rez.Layouts.HugeWideLayout3Field(dc));
View.findDrawableById("debug").setText("HugeWideLayout3Field" + " " + width + "x" + height);
break;
// edge explore 240x132 3 Field Wide Layout
case (width >=240 && height >= 132):
View.setLayout(Rez.Layouts.MediumWideLayout3Field(dc));
View.findDrawableById("debug").setText("MediumWideLayout3Field" + " " + width + "x" + height);
break;
// edge 830 240x105 3 Field Layout
// edge 530 240x105 3 Field Layout
case (width >=240 && height >= 104):
View.setLayout(Rez.Layouts.SmallWideLayout3Field(dc));
View.findDrawableById("debug").setText("SmallWideLayout3Field" + " " + width + "x" + height);
break;
// edge 1030 5 Field Layout
// edge 1030 plus 5 Field Layout
// edge 1030 bontrager 5 Field Layout
case (width >= 282 && height >= 92):
View.setLayout(Rez.Layouts.HugeWideLayout5Field(dc));
View.findDrawableById("debug").setText("HugeWideLayout5Field" + " " + width + "x" + height);
break;
// edge explore 78 5 Field Wide Layout
case (width >=240 && height >= 95):
View.setLayout(Rez.Layouts.MediumWideLayout5Field(dc));
View.findDrawableById("debug").setText("MediumWideLayout5Field" + " " + width + "x" + height);
break;
case (width >=240 && height >= 78):
View.setLayout(Rez.Layouts.MediumWideLayout5Field_2(dc));
View.findDrawableById("debug").setText("MediumWideLayout5Field_2" + " " + width + "x" + height);
break;
// edge 830 240x52 5 Field Layout
// edge 530 240x52 5 Field Layout
case (width >=240 && height >= 52):
View.setLayout(Rez.Layouts.SmallWideLayout5Field(dc));
View.findDrawableById("debug").setText("SmallWideLayout5Field" + " " + width + "x" + height);
break;
// egdge 1030 10 Field Layout
// edge 1030 plus 10 Field Layout
// edge 1030 bontrager 10 Field Layout
case (width >=140 && height >= 92):
View.setLayout(Rez.Layouts.HugeLayout10Field(dc));
View.findDrawableById("debug").setText("HugeLayout10Field" + " " + width + "x" + height);
break;
// edge explore 119x78 10 Field Layout
case (width >=119 && height >= 78):
View.setLayout(Rez.Layouts.MediumLayout10Field(dc));
View.findDrawableById("debug").setText("MediumLayout10Field" + " " + width + "x" + height);
break;
// edge 830 122x62 10 Field Layout
// edge 530 122x62 10 Field Layout
case (width >=122 && height >= 62):
View.setLayout(Rez.Layouts.SmallLayout10Field(dc));
View.findDrawableById("debug").setText("SmallLayout10Field" + " " + width + "x" + height);
break;
default:
View.setLayout(Rez.Layouts.SmallLayout10Field(dc));
View.findDrawableById("debug").setText("SmallLayout10Field " + " " + width + "x" + height);
break;
}
return true;
}
// The given info object contains all the current workout information.
// Calculate a value and save it locally in this method.
// Note that compute() and onUpdate() are asynchronous, and there is no
// guarantee that compute() will be called before onUpdate().
function compute(info) { }
function onUpdate(dc) {
setColors();
setValues();
View.findDrawableById("label").setText(self.labelValue);
View.onUpdate(dc);
}
function setValues()
{
View.findDrawableById("left_top_value").setText(topLeftValue);
View.findDrawableById("right_top_value").setText(topRightValue);
View.findDrawableById("left_bottom_value").setText(bottomLeftValue);
View.findDrawableById("right_bottom_value").setText(bottomRightValue);
View.findDrawableById("value").setText(mainValue);
}
function setColors()
{
View.findDrawableById("Background").setColor(getBackgroundColor());
View.findDrawableById("debug").locY = 999;
if (getBackgroundColor() == Graphics.COLOR_BLACK) {
View.findDrawableById("value").setColor(Graphics.COLOR_WHITE);
View.findDrawableById("label").setColor(Graphics.COLOR_WHITE);
View.findDrawableById("left_top_value").setColor(Graphics.COLOR_WHITE);
View.findDrawableById("right_top_value").setColor(Graphics.COLOR_WHITE);
View.findDrawableById("left_bottom_value").setColor(Graphics.COLOR_WHITE);
View.findDrawableById("right_bottom_value").setColor(Graphics.COLOR_WHITE);
} else {
View.findDrawableById("value").setColor(Graphics.COLOR_BLACK);
View.findDrawableById("label").setColor(Graphics.COLOR_BLACK);
View.findDrawableById("left_top_value").setColor(Graphics.COLOR_BLACK);
View.findDrawableById("right_top_value").setColor(Graphics.COLOR_BLACK);
View.findDrawableById("left_bottom_value").setColor(Graphics.COLOR_BLACK);
View.findDrawableById("right_bottom_value").setColor(Graphics.COLOR_BLACK);
}
}
}