pebble-scalable 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -17
- package/dist.zip +0 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# pebble-scalable
|
|
2
2
|
|
|
3
3
|
Package aiming to make it easy to make scaling layouts for different display
|
|
4
|
-
sizes by defining their
|
|
4
|
+
sizes by defining their dimensions only once.
|
|
5
5
|
|
|
6
6
|
- [Setting up](#setting-up)
|
|
7
7
|
- [Dimensions](#dimensions)
|
|
@@ -37,14 +37,20 @@ const int half_h = scalable_y(500);
|
|
|
37
37
|
const GRect center_rect = scalable_grect(330, 330, 330, 330);
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
If a percentage isn't precise enough,
|
|
40
|
+
If a single percentage isn't precise enough, use 'per platform' variants to
|
|
41
|
+
specify values up to 5% (50/1000 thousands) in precision for each platform
|
|
42
|
+
(order is 'regular' shape, then 'emery' shape):
|
|
41
43
|
|
|
42
44
|
```c
|
|
43
|
-
//
|
|
44
|
-
GRect
|
|
45
|
+
// Larger only on Emery (x/y: 10%, w/h per platform)
|
|
46
|
+
const GRect emery = scalable_grect_pp(
|
|
47
|
+
GRect(100, 100, 200, 200),
|
|
48
|
+
GRect(100, 100, 250, 250)
|
|
49
|
+
);
|
|
45
50
|
|
|
46
|
-
//
|
|
47
|
-
|
|
51
|
+
// Further to the right and down on Emery
|
|
52
|
+
const int x = scalable_x_pp(110, 120);
|
|
53
|
+
const int y = scalable_y_pp(450, 480);
|
|
48
54
|
```
|
|
49
55
|
|
|
50
56
|
## Centering
|
|
@@ -66,28 +72,39 @@ const GRect centered = scalable_center(r);
|
|
|
66
72
|
|
|
67
73
|
## Fonts
|
|
68
74
|
|
|
69
|
-
Use different fonts for different display sizes, based on a category of
|
|
70
|
-
|
|
75
|
+
Use different fonts for different display sizes, based on a category of your
|
|
76
|
+
choosing. First, load the fonts, or use system fonts:
|
|
71
77
|
|
|
72
78
|
```c
|
|
73
79
|
// Load fonts to use in each case
|
|
74
|
-
static GFont s_gothic_18, s_gothic_24;
|
|
80
|
+
static GFont s_gothic_14, s_gothic_18, s_gothic_24, s_gothic_28;
|
|
75
81
|
|
|
76
82
|
// During init
|
|
83
|
+
s_gothic_14 = fonts_get_system_font(FONT_KEY_GOTHIC_14);
|
|
77
84
|
s_gothic_18 = fonts_get_system_font(FONT_KEY_GOTHIC_18);
|
|
78
85
|
s_gothic_24 = fonts_get_system_font(FONT_KEY_GOTHIC_24);
|
|
86
|
+
s_gothic_28 = fonts_get_system_font(FONT_KEY_GOTHIC_28);
|
|
79
87
|
```
|
|
80
88
|
|
|
81
|
-
|
|
89
|
+
Next, define identifiers for each of your size categories:
|
|
82
90
|
|
|
83
91
|
```c
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
typedef enum {
|
|
93
|
+
MFS_Small = 0,
|
|
94
|
+
MFS_Medium,
|
|
95
|
+
MFS_Large
|
|
96
|
+
} MyFontSizes;
|
|
97
|
+
```
|
|
86
98
|
|
|
87
|
-
|
|
99
|
+
Now set which font to use per-platform shape for each category:
|
|
100
|
+
|
|
101
|
+
```c
|
|
102
|
+
// The small font - regular screens use Gothic 14, Emery uses Gothic 18
|
|
103
|
+
scalable_set_fonts(MFS_Small, &s_gothic_14, &s_gothic_18);
|
|
88
104
|
|
|
89
|
-
//
|
|
90
|
-
scalable_set_fonts(
|
|
105
|
+
// Same with larger categories
|
|
106
|
+
scalable_set_fonts(MFS_Medium, &s_gothic_18, &s_gothic_24);
|
|
107
|
+
scalable_set_fonts(MFS_Large, &s_gothic_24, &s_gothic_28);
|
|
91
108
|
```
|
|
92
109
|
|
|
93
110
|
During layout or drawing, simply use the font by ID:
|
|
@@ -98,7 +115,7 @@ graphics_context_set_text_color(ctx, GColorBlack);
|
|
|
98
115
|
graphics_draw_text(
|
|
99
116
|
ctx,
|
|
100
117
|
"This text should appear in the middle third on any platform or display size",
|
|
101
|
-
scalable_get_font(
|
|
118
|
+
scalable_get_font(MFS_Small),
|
|
102
119
|
scalable_grect(0, 330, 1000, 330),
|
|
103
120
|
GTextOverflowModeTrailingEllipsis,
|
|
104
121
|
GTextAlignmentCenter,
|
|
@@ -108,5 +125,6 @@ graphics_draw_text(
|
|
|
108
125
|
|
|
109
126
|
## TODO
|
|
110
127
|
|
|
128
|
+
- [x] Support per-platform (per shape) values
|
|
111
129
|
- [ ] Solution for picking bitmaps (to work with their scalable GRects)
|
|
112
|
-
- [ ]
|
|
130
|
+
- [ ] Chalk? It's so different layouts might not be at all similar...
|
package/dist.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pebble-scalable",
|
|
3
3
|
"author": "Chris Lewis",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist.zip"
|
|
7
7
|
],
|
|
8
8
|
"keywords": [
|
|
9
9
|
"pebble-package"
|
|
10
10
|
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"prepublish": "pebble clean && pebble build"
|
|
13
|
+
},
|
|
11
14
|
"dependencies": {},
|
|
12
15
|
"pebble": {
|
|
13
16
|
"projectType": "package",
|
|
@@ -15,7 +18,6 @@
|
|
|
15
18
|
"targetPlatforms": [
|
|
16
19
|
"aplite",
|
|
17
20
|
"basalt",
|
|
18
|
-
"chalk",
|
|
19
21
|
"diorite",
|
|
20
22
|
"emery",
|
|
21
23
|
"flint"
|