Significant platform-specific design work (TODO: b&w support + shift sleep time GRect depending on if time or error)
This commit is contained in:
23
package.json
23
package.json
@@ -38,14 +38,33 @@
|
||||
{
|
||||
"type": "raw",
|
||||
"name": "PIN_ICON",
|
||||
"file": "pin.pdc"
|
||||
"file": "pin.pdc",
|
||||
"targetPlatforms": [
|
||||
"basalt",
|
||||
"diorite",
|
||||
"flint",
|
||||
"emery"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "raw",
|
||||
"name": "PIN_ROUND_JELLYFIN_ICON",
|
||||
"file": "pin_round_jellyfin.pdc",
|
||||
"targetPlatforms": [
|
||||
"chalk",
|
||||
"gabbro"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"sdkVersion": "3",
|
||||
"targetPlatforms": [
|
||||
"basalt",
|
||||
"diorite",
|
||||
"chalk",
|
||||
"emery"
|
||||
"flint",
|
||||
"emery",
|
||||
"gabbro"
|
||||
],
|
||||
"uuid": "3097b48e-552c-4a78-92b2-566b9128640e",
|
||||
"watchapp": {
|
||||
|
||||
BIN
resources/pin_round_jellyfin.pdc
Normal file
BIN
resources/pin_round_jellyfin.pdc
Normal file
Binary file not shown.
51
src/c/main.c
51
src/c/main.c
@@ -81,27 +81,32 @@ static void pin_icon_update_proc(Layer *layer, GContext *ctx) {
|
||||
}
|
||||
|
||||
static void main_window_load(Window *window) {
|
||||
// sleep bar
|
||||
s_sleep_bar_layer = layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_IF_ROUND_ELSE(49, 31)));
|
||||
layer_set_update_proc(s_sleep_bar_layer, sleep_bar_update_proc);
|
||||
|
||||
// sleep icon
|
||||
s_sleep_icon_layer = layer_create(GRect(PBL_IF_ROUND_ELSE((PBL_DISPLAY_WIDTH / 2) - 13, 4), 4, PBL_DISPLAY_WIDTH, 50));
|
||||
s_sleep_icon_layer = layer_create(GRect(PBL_IF_ROUND_ELSE((PBL_DISPLAY_WIDTH / 2) - 13, 4), 4, 25, 25));
|
||||
layer_set_update_proc(s_sleep_icon_layer, sleep_icon_update_proc);
|
||||
|
||||
// pin icon
|
||||
s_pin_icon_layer = layer_create(GRect(PBL_DISPLAY_WIDTH-25, (PBL_DISPLAY_HEIGHT/2)-13, 50, 50));
|
||||
s_pin_icon_layer = layer_create(GRect(PBL_DISPLAY_WIDTH - PBL_IF_ROUND_ELSE(27, 25), (PBL_DISPLAY_HEIGHT / 2) - 13, 25, 25));
|
||||
layer_set_update_proc(s_pin_icon_layer, pin_icon_update_proc);
|
||||
|
||||
// sleep time
|
||||
s_sleep_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(24, -2), PBL_DISPLAY_WIDTH, 30));
|
||||
text_layer_set_background_color(s_sleep_time_layer, GColorClear);
|
||||
#if PBL_DISPLAY_WIDTH >= 200
|
||||
#if PBL_DISPLAY_WIDTH >= 200
|
||||
s_sleep_bar_layer = layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_IF_ROUND_ELSE(53, 31)));
|
||||
s_sleep_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(21, -2), PBL_DISPLAY_WIDTH, 30));
|
||||
s_last_watched_layer = text_layer_create(GRect(0, PBL_DISPLAY_HEIGHT / 2 - 20, PBL_DISPLAY_WIDTH - 4, PBL_DISPLAY_HEIGHT));
|
||||
text_layer_set_font(s_sleep_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
|
||||
#else
|
||||
text_layer_set_font(s_sleep_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
|
||||
#endif
|
||||
text_layer_set_text_alignment(s_sleep_time_layer, GTextAlignmentCenter);
|
||||
text_layer_set_font(s_last_watched_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
|
||||
#else
|
||||
s_sleep_bar_layer = layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_IF_ROUND_ELSE(49, 31)));
|
||||
s_sleep_time_layer = text_layer_create(GRect(PBL_IF_ROUND_ELSE(0, 31), PBL_IF_ROUND_ELSE(24, 6), PBL_DISPLAY_WIDTH, 30));
|
||||
s_last_watched_layer = text_layer_create(GRect(0, PBL_DISPLAY_HEIGHT / 2 - 17, PBL_DISPLAY_WIDTH - 4, PBL_DISPLAY_HEIGHT));
|
||||
text_layer_set_font(s_sleep_time_layer, fonts_get_system_font(PBL_IF_ROUND_ELSE(FONT_KEY_GOTHIC_18_BOLD, FONT_KEY_GOTHIC_14_BOLD)));
|
||||
text_layer_set_text_alignment(s_sleep_time_layer, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentLeft));
|
||||
text_layer_set_font(s_last_watched_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
|
||||
#endif
|
||||
|
||||
// sleep time
|
||||
text_layer_set_background_color(s_sleep_time_layer, GColorClear);
|
||||
text_layer_set_text_color(s_sleep_time_layer, GColorWhite);
|
||||
if (s_sleep_timestamp != 0) {
|
||||
static char buffer[8];
|
||||
@@ -112,15 +117,11 @@ static void main_window_load(Window *window) {
|
||||
text_layer_set_text(s_sleep_time_layer, "No sleep last night");
|
||||
}
|
||||
|
||||
// watched title
|
||||
s_last_watched_layer = text_layer_create(GRect(0, PBL_DISPLAY_HEIGHT / 2 - 24, PBL_DISPLAY_WIDTH - 4, PBL_DISPLAY_HEIGHT));
|
||||
// misc. properties
|
||||
layer_set_update_proc(s_sleep_bar_layer, sleep_bar_update_proc);
|
||||
text_layer_set_background_color(s_last_watched_layer, GColorClear);
|
||||
text_layer_set_text_color(s_last_watched_layer, GColorWhite);
|
||||
#if PBL_DISPLAY_WIDTH >= 200
|
||||
text_layer_set_font(s_last_watched_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
|
||||
#else
|
||||
text_layer_set_font(s_last_watched_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
|
||||
#endif
|
||||
|
||||
if (s_sleep_data_accessible) {
|
||||
text_layer_set_text(s_last_watched_layer, "N/A"); // default - will be updated before display
|
||||
} else {
|
||||
@@ -129,14 +130,14 @@ static void main_window_load(Window *window) {
|
||||
|
||||
// add layers as children to windows
|
||||
Layer *window_layer = window_get_root_layer(window);
|
||||
#if PBL_ROUND
|
||||
#if PBL_ROUND
|
||||
text_layer_set_text_alignment(s_last_watched_layer, GTextAlignmentCenter);
|
||||
#else
|
||||
#else
|
||||
// button bar
|
||||
s_button_bar_layer = layer_create(GRect(PBL_DISPLAY_WIDTH - 25, 0, 25, PBL_DISPLAY_HEIGHT));
|
||||
layer_set_update_proc(s_button_bar_layer, button_bar_update_proc);
|
||||
layer_add_child(window_layer, s_button_bar_layer);
|
||||
#endif
|
||||
#endif
|
||||
layer_add_child(window_layer, s_pin_icon_layer);
|
||||
layer_add_child(window_layer, s_sleep_bar_layer);
|
||||
layer_add_child(window_layer, s_sleep_icon_layer);
|
||||
@@ -176,7 +177,11 @@ static void init() {
|
||||
|
||||
// load PDCs
|
||||
s_sleep_icon = gdraw_command_image_create_with_resource(RESOURCE_ID_SLEEP_ICON);
|
||||
#if PBL_ROUND
|
||||
s_pin_icon = gdraw_command_image_create_with_resource(RESOURCE_ID_PIN_ROUND_JELLYFIN_ICON);
|
||||
#else
|
||||
s_pin_icon = gdraw_command_image_create_with_resource(RESOURCE_ID_PIN_ICON);
|
||||
#endif
|
||||
|
||||
window_stack_push(s_main_window, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user