pebble-scalable 1.3.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.
Files changed (3) hide show
  1. package/README.md +40 -14
  2. package/dist.zip +0 -0
  3. 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 dimension only once.
4
+ sizes by defining their dimensions only once.
5
5
 
6
6
  - [Setting up](#setting-up)
7
7
  - [Dimensions](#dimensions)
@@ -37,11 +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, the x/y or w/h can be nudged by some pixels:
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
- // A rect nudged by 5px in x and 2px in y
44
- const GRect precise = scalable_nudge_xy(scalable_grect(100, 100, 200, 200), 5, 2);
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
+ );
50
+
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);
45
54
  ```
46
55
 
47
56
  ## Centering
@@ -63,28 +72,39 @@ const GRect centered = scalable_center(r);
63
72
 
64
73
  ## Fonts
65
74
 
66
- Use different fonts for different display sizes, based on a category of 'small',
67
- 'medium', or 'large'.
75
+ Use different fonts for different display sizes, based on a category of your
76
+ choosing. First, load the fonts, or use system fonts:
68
77
 
69
78
  ```c
70
79
  // Load fonts to use in each case
71
- static GFont s_gothic_18, s_gothic_24;
80
+ static GFont s_gothic_14, s_gothic_18, s_gothic_24, s_gothic_28;
72
81
 
73
82
  // During init
83
+ s_gothic_14 = fonts_get_system_font(FONT_KEY_GOTHIC_14);
74
84
  s_gothic_18 = fonts_get_system_font(FONT_KEY_GOTHIC_18);
75
85
  s_gothic_24 = fonts_get_system_font(FONT_KEY_GOTHIC_24);
86
+ s_gothic_28 = fonts_get_system_font(FONT_KEY_GOTHIC_28);
76
87
  ```
77
88
 
78
- Specify which fonts to use for each display size:
89
+ Next, define identifiers for each of your size categories:
79
90
 
80
91
  ```c
81
- // The 'small font' set ID
82
- #define FONT_ID_SMALL 0
92
+ typedef enum {
93
+ MFS_Small = 0,
94
+ MFS_Medium,
95
+ MFS_Large
96
+ } MyFontSizes;
97
+ ```
83
98
 
84
- ...
99
+ Now set which font to use per-platform shape for each category:
85
100
 
86
- // The small font - regular screens use Gothic 18, Chalk N/A Emery uses Gothic 24
87
- scalable_set_fonts(FONT_ID_SMALL, &s_gothic_18, NULL, &s_gothic_24);
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);
104
+
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);
88
108
  ```
89
109
 
90
110
  During layout or drawing, simply use the font by ID:
@@ -95,10 +115,16 @@ graphics_context_set_text_color(ctx, GColorBlack);
95
115
  graphics_draw_text(
96
116
  ctx,
97
117
  "This text should appear in the middle third on any platform or display size",
98
- scalable_get_font(FONT_ID_SMALL),
118
+ scalable_get_font(MFS_Small),
99
119
  scalable_grect(0, 330, 1000, 330),
100
120
  GTextOverflowModeTrailingEllipsis,
101
121
  GTextAlignmentCenter,
102
122
  NULL
103
123
  );
104
124
  ```
125
+
126
+ ## TODO
127
+
128
+ - [x] Support per-platform (per shape) values
129
+ - [ ] Solution for picking bitmaps (to work with their scalable GRects)
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.3.0",
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"