pebble-scalable 1.4.0 → 1.5.1

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 +35 -17
  2. package/dist.zip +0 -0
  3. package/package.json +4 -1
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,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, 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
- GRect precise = scalable_nudge(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
+ );
45
50
 
46
- // Nudge more only on Emery
47
- precise = scalable_nudge_emery(precise, 5, 2);
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 'small',
70
- '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:
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
- Specify which fonts to use for each display size:
89
+ Next, define identifiers for each of your size categories:
82
90
 
83
91
  ```c
84
- // The 'small font' set ID
85
- #define FONT_ID_SMALL 0
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
- // The small font - regular screens use Gothic 18, Chalk N/A Emery uses Gothic 24
90
- scalable_set_fonts(FONT_ID_SMALL, &s_gothic_18, NULL, &s_gothic_24);
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(FONT_ID_SMALL),
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
- - [ ] Functions per-platform
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.0",
4
+ "version": "1.5.1",
5
5
  "files": [
6
6
  "dist.zip"
7
7
  ],
8
8
  "keywords": [
9
9
  "pebble-package"
10
10
  ],
11
+ "scripts": {
12
+ "prepublishOnly": "pebble clean && pebble build"
13
+ },
11
14
  "dependencies": {},
12
15
  "pebble": {
13
16
  "projectType": "package",