Initial alarm UI
This commit is contained in:
+7
-5
@@ -47,11 +47,7 @@
|
|||||||
"characterRegex": "[:0-9]",
|
"characterRegex": "[:0-9]",
|
||||||
"file": "lecoish_mono_bold_20.bdf",
|
"file": "lecoish_mono_bold_20.bdf",
|
||||||
"name": "FONT_LECOISH_MONO_BOLD_20",
|
"name": "FONT_LECOISH_MONO_BOLD_20",
|
||||||
"type": "font",
|
"type": "font"
|
||||||
"targetPlatforms": [
|
|
||||||
"emery",
|
|
||||||
"gabbro"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"characterRegex": "[:0-9]",
|
"characterRegex": "[:0-9]",
|
||||||
@@ -70,6 +66,12 @@
|
|||||||
"targetPlatforms": [
|
"targetPlatforms": [
|
||||||
"gabbro"
|
"gabbro"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"characterRegex": "[type:θ=]",
|
||||||
|
"file": "mansalva_regular.ttf",
|
||||||
|
"name": "FONT_MANSALVA_REGULAR_22",
|
||||||
|
"type": "font"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
+59
-23
@@ -11,16 +11,24 @@ typedef struct TheTime {
|
|||||||
|
|
||||||
// layer-age
|
// layer-age
|
||||||
static Window *s_window;
|
static Window *s_window;
|
||||||
//// setter
|
|
||||||
static Layer *s_top_bar_layer;
|
static Layer *s_top_bar_layer;
|
||||||
static Layer *s_bottom_bar_layer;
|
static Layer *s_bottom_bar_layer;
|
||||||
|
//// setter
|
||||||
static BitmapLayer *s_clock_bmp_layer;
|
static BitmapLayer *s_clock_bmp_layer;
|
||||||
static BitmapLayer *s_check_bmp_layer;
|
static BitmapLayer *s_check_bmp_layer;
|
||||||
static TextLayer *s_countdown_txt_layer;
|
static TextLayer *s_countdown_txt_layer;
|
||||||
static TextLayer *s_setter_txt_layer;
|
static TextLayer *s_setter_txt_layer;
|
||||||
static Layer *s_highlight_layer;
|
static Layer *s_highlight_layer;
|
||||||
//// alarm
|
//// alarm
|
||||||
static TextLayer *s_alarm_txt_layer;
|
static TextLayer *s_type_txt_layer;
|
||||||
|
static TextLayer *s_theta_txt_layer;
|
||||||
|
|
||||||
|
// fonts
|
||||||
|
//// setter
|
||||||
|
GFont s_font_lecoish_big;
|
||||||
|
GFont s_font_lecoish_small;
|
||||||
|
//// alarm
|
||||||
|
GFont s_font_mansalva;
|
||||||
|
|
||||||
// bitmaps
|
// bitmaps
|
||||||
//// setter
|
//// setter
|
||||||
@@ -35,6 +43,8 @@ static struct TheTime s_the_time;
|
|||||||
// constants
|
// constants
|
||||||
//// setter
|
//// setter
|
||||||
static const uint8_t s_edge_bar_height = ((PBL_DISPLAY_HEIGHT / 7) * 2);
|
static const uint8_t s_edge_bar_height = ((PBL_DISPLAY_HEIGHT / 7) * 2);
|
||||||
|
static const GRect s_top_bar_grect = GRect(0, 0, PBL_DISPLAY_WIDTH, s_edge_bar_height);
|
||||||
|
static const GRect s_bottom_bar_grect = GRect(0, PBL_DISPLAY_HEIGHT - s_edge_bar_height, PBL_DISPLAY_WIDTH, s_edge_bar_height);
|
||||||
static const GColor s_primary_color = GColorJaegerGreen;
|
static const GColor s_primary_color = GColorJaegerGreen;
|
||||||
static const GColor s_highlight_color = GColorMediumAquamarine;
|
static const GColor s_highlight_color = GColorMediumAquamarine;
|
||||||
#define STORAGE_KEY_ALARM_HOUR 0
|
#define STORAGE_KEY_ALARM_HOUR 0
|
||||||
@@ -211,6 +221,15 @@ static void bottom_bar_layer_update_proc(Layer *layer, GContext *ctx) {
|
|||||||
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
|
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void add_bar_layers_to_window(Layer *window_layer) {
|
||||||
|
s_top_bar_layer = layer_create(s_top_bar_grect);
|
||||||
|
layer_set_update_proc(s_top_bar_layer, top_bar_layer_update_proc);
|
||||||
|
layer_add_child(window_layer, s_top_bar_layer);
|
||||||
|
s_bottom_bar_layer = layer_create(s_bottom_bar_grect);
|
||||||
|
layer_set_update_proc(s_bottom_bar_layer, bottom_bar_layer_update_proc);
|
||||||
|
layer_add_child(window_layer, s_bottom_bar_layer);
|
||||||
|
}
|
||||||
|
|
||||||
static void highlight_layer_update_proc(Layer *layer, GContext *ctx) {
|
static void highlight_layer_update_proc(Layer *layer, GContext *ctx) {
|
||||||
GRect fill_area = layer_get_bounds(layer);
|
GRect fill_area = layer_get_bounds(layer);
|
||||||
fill_area.size.w = PBL_DISPLAY_WIDTH / 2;
|
fill_area.size.w = PBL_DISPLAY_WIDTH / 2;
|
||||||
@@ -230,18 +249,11 @@ static void setter_window_load() {
|
|||||||
Layer *window_layer = window_get_root_layer(s_window);
|
Layer *window_layer = window_get_root_layer(s_window);
|
||||||
|
|
||||||
// top&bottom bars
|
// top&bottom bars
|
||||||
static const GRect top_bar_grect = GRect(0, 0, PBL_DISPLAY_WIDTH, s_edge_bar_height);
|
add_bar_layers_to_window(window_layer);
|
||||||
s_top_bar_layer = layer_create(top_bar_grect);
|
|
||||||
layer_set_update_proc(s_top_bar_layer, top_bar_layer_update_proc);
|
|
||||||
layer_add_child(window_layer, s_top_bar_layer);
|
|
||||||
static const GRect bottom_bar_grect = GRect(0, PBL_DISPLAY_HEIGHT - s_edge_bar_height, PBL_DISPLAY_WIDTH, s_edge_bar_height);
|
|
||||||
s_bottom_bar_layer = layer_create(bottom_bar_grect);
|
|
||||||
layer_set_update_proc(s_bottom_bar_layer, bottom_bar_layer_update_proc);
|
|
||||||
layer_add_child(window_layer, s_bottom_bar_layer);
|
|
||||||
|
|
||||||
// clock icon
|
// clock icon
|
||||||
s_clock_bmp = gbitmap_create_with_resource(RESOURCE_ID_CLOCK35);
|
s_clock_bmp = gbitmap_create_with_resource(RESOURCE_ID_CLOCK35);
|
||||||
s_clock_bmp_layer = bitmap_layer_create(GRect(PBL_IF_ROUND_ELSE(0, 8), PBL_IF_ROUND_ELSE(6, 0), top_bar_grect.size.w, top_bar_grect.size.h));
|
s_clock_bmp_layer = bitmap_layer_create(GRect(PBL_IF_ROUND_ELSE(0, 8), PBL_IF_ROUND_ELSE(6, 0), s_top_bar_grect.size.w, s_top_bar_grect.size.h));
|
||||||
bitmap_layer_set_bitmap(s_clock_bmp_layer, s_clock_bmp);
|
bitmap_layer_set_bitmap(s_clock_bmp_layer, s_clock_bmp);
|
||||||
bitmap_layer_set_alignment(s_clock_bmp_layer, PBL_IF_ROUND_ELSE(GAlignTop, GAlignLeft));
|
bitmap_layer_set_alignment(s_clock_bmp_layer, PBL_IF_ROUND_ELSE(GAlignTop, GAlignLeft));
|
||||||
bitmap_layer_set_compositing_mode(s_clock_bmp_layer, GCompOpSet);
|
bitmap_layer_set_compositing_mode(s_clock_bmp_layer, GCompOpSet);
|
||||||
@@ -249,30 +261,32 @@ static void setter_window_load() {
|
|||||||
|
|
||||||
// check icon
|
// check icon
|
||||||
s_check_bmp = gbitmap_create_with_resource(RESOURCE_ID_CHECK);
|
s_check_bmp = gbitmap_create_with_resource(RESOURCE_ID_CHECK);
|
||||||
s_check_bmp_layer = bitmap_layer_create(bottom_bar_grect);
|
s_check_bmp_layer = bitmap_layer_create(s_bottom_bar_grect);
|
||||||
bitmap_layer_set_bitmap(s_check_bmp_layer, s_check_bmp);
|
bitmap_layer_set_bitmap(s_check_bmp_layer, s_check_bmp);
|
||||||
bitmap_layer_set_compositing_mode(s_check_bmp_layer, GCompOpSet);
|
bitmap_layer_set_compositing_mode(s_check_bmp_layer, GCompOpSet);
|
||||||
layer_add_child(window_layer, bitmap_layer_get_layer(s_check_bmp_layer));
|
layer_add_child(window_layer, bitmap_layer_get_layer(s_check_bmp_layer));
|
||||||
|
|
||||||
// countdown
|
// countdown
|
||||||
s_countdown_txt_layer = text_layer_create(GRect(PBL_IF_ROUND_ELSE(0, 39), (top_bar_grect.size.h / 2) + PBL_IF_ROUND_ELSE(10, -10), PBL_IF_ROUND_ELSE(top_bar_grect.size.w, top_bar_grect.size.w - 39), 32));
|
s_font_lecoish_small = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LECOISH_MONO_BOLD_20));
|
||||||
|
s_countdown_txt_layer = text_layer_create(GRect(PBL_IF_ROUND_ELSE(0, 39), (s_top_bar_grect.size.h / 2) + PBL_IF_ROUND_ELSE(10, -10), PBL_IF_ROUND_ELSE(s_top_bar_grect.size.w, s_top_bar_grect.size.w - 39), 32));
|
||||||
text_layer_set_text_alignment(s_countdown_txt_layer, GTextAlignmentCenter);
|
text_layer_set_text_alignment(s_countdown_txt_layer, GTextAlignmentCenter);
|
||||||
text_layer_set_text_color(s_countdown_txt_layer, GColorWhite);
|
text_layer_set_text_color(s_countdown_txt_layer, GColorWhite);
|
||||||
text_layer_set_background_color(s_countdown_txt_layer, GColorClear);
|
text_layer_set_background_color(s_countdown_txt_layer, GColorClear);
|
||||||
text_layer_set_font(s_countdown_txt_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LECOISH_MONO_BOLD_20)));
|
text_layer_set_font(s_countdown_txt_layer, s_font_lecoish_small);
|
||||||
layer_add_child(window_layer, text_layer_get_layer(s_countdown_txt_layer));
|
layer_add_child(window_layer, text_layer_get_layer(s_countdown_txt_layer));
|
||||||
update_countdown_display();
|
update_countdown_display();
|
||||||
|
|
||||||
// highlighter
|
// highlighter
|
||||||
s_highlight_layer = layer_create(GRect(0, top_bar_grect.size.h, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT - (2 * top_bar_grect.size.h)));
|
s_highlight_layer = layer_create(GRect(0, s_top_bar_grect.size.h, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT - (2 * s_top_bar_grect.size.h)));
|
||||||
layer_set_update_proc(s_highlight_layer, highlight_layer_update_proc);
|
layer_set_update_proc(s_highlight_layer, highlight_layer_update_proc);
|
||||||
layer_add_child(window_layer, s_highlight_layer);
|
layer_add_child(window_layer, s_highlight_layer);
|
||||||
|
|
||||||
// setter
|
// setter
|
||||||
|
s_font_lecoish_big = fonts_load_custom_font(resource_get_handle(PBL_IF_ROUND_ELSE(RESOURCE_ID_FONT_LECOISH_MONO_BOLD_60, RESOURCE_ID_FONT_LECOISH_MONO_BOLD_40)));
|
||||||
s_setter_txt_layer = text_layer_create(GRect(0, (PBL_DISPLAY_HEIGHT / 2) - PBL_IF_ROUND_ELSE(30, 20), PBL_DISPLAY_WIDTH, PBL_IF_ROUND_ELSE(60, 40)));
|
s_setter_txt_layer = text_layer_create(GRect(0, (PBL_DISPLAY_HEIGHT / 2) - PBL_IF_ROUND_ELSE(30, 20), PBL_DISPLAY_WIDTH, PBL_IF_ROUND_ELSE(60, 40)));
|
||||||
text_layer_set_text_alignment(s_setter_txt_layer, GTextAlignmentCenter);
|
text_layer_set_text_alignment(s_setter_txt_layer, GTextAlignmentCenter);
|
||||||
text_layer_set_background_color(s_setter_txt_layer, GColorClear);
|
text_layer_set_background_color(s_setter_txt_layer, GColorClear);
|
||||||
text_layer_set_font(s_setter_txt_layer, fonts_load_custom_font(resource_get_handle(PBL_IF_ROUND_ELSE(RESOURCE_ID_FONT_LECOISH_MONO_BOLD_60, RESOURCE_ID_FONT_LECOISH_MONO_BOLD_40))));
|
text_layer_set_font(s_setter_txt_layer, s_font_lecoish_big);
|
||||||
layer_add_child(window_layer, text_layer_get_layer(s_setter_txt_layer));
|
layer_add_child(window_layer, text_layer_get_layer(s_setter_txt_layer));
|
||||||
update_setter_display();
|
update_setter_display();
|
||||||
|
|
||||||
@@ -281,8 +295,10 @@ static void setter_window_load() {
|
|||||||
|
|
||||||
static void setter_window_unload() {
|
static void setter_window_unload() {
|
||||||
text_layer_destroy(s_setter_txt_layer);
|
text_layer_destroy(s_setter_txt_layer);
|
||||||
|
fonts_unload_custom_font(s_font_lecoish_big);
|
||||||
layer_destroy(s_highlight_layer);
|
layer_destroy(s_highlight_layer);
|
||||||
text_layer_destroy(s_countdown_txt_layer);
|
text_layer_destroy(s_countdown_txt_layer);
|
||||||
|
fonts_unload_custom_font(s_font_lecoish_small);
|
||||||
bitmap_layer_destroy(s_check_bmp_layer);
|
bitmap_layer_destroy(s_check_bmp_layer);
|
||||||
bitmap_layer_destroy(s_clock_bmp_layer);
|
bitmap_layer_destroy(s_clock_bmp_layer);
|
||||||
gbitmap_destroy(s_check_bmp);
|
gbitmap_destroy(s_check_bmp);
|
||||||
@@ -314,19 +330,38 @@ static void alarm_seconds_handler(struct tm *tick_time, TimeUnits units_changed)
|
|||||||
static void alarm_window_load() {
|
static void alarm_window_load() {
|
||||||
Layer *window_layer = window_get_root_layer(s_window);
|
Layer *window_layer = window_get_root_layer(s_window);
|
||||||
|
|
||||||
s_alarm_txt_layer = text_layer_create(GRect(0, (PBL_DISPLAY_HEIGHT / 2) - 27, PBL_DISPLAY_WIDTH, 34));
|
// top&bottom bars
|
||||||
text_layer_set_text_alignment(s_alarm_txt_layer, GTextAlignmentCenter);
|
add_bar_layers_to_window(window_layer);
|
||||||
text_layer_set_background_color(s_alarm_txt_layer, GColorClear);
|
|
||||||
text_layer_set_font(s_alarm_txt_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
|
// type text
|
||||||
text_layer_set_text(s_alarm_txt_layer, "IMAGINE THIS IS A TRIANGLE");
|
s_font_mansalva = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MANSALVA_REGULAR_22));
|
||||||
layer_add_child(window_layer, text_layer_get_layer(s_alarm_txt_layer));
|
s_type_txt_layer = text_layer_create(GRect(PBL_IF_ROUND_ELSE(0, 8), PBL_IF_ROUND_ELSE(4, 16), PBL_DISPLAY_WIDTH, 26));
|
||||||
|
text_layer_set_text_alignment(s_type_txt_layer, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentLeft));
|
||||||
|
text_layer_set_background_color(s_type_txt_layer, GColorClear);
|
||||||
|
text_layer_set_text_color(s_type_txt_layer, GColorWhite);
|
||||||
|
text_layer_set_font(s_type_txt_layer, s_font_mansalva);
|
||||||
|
text_layer_set_text(s_type_txt_layer, "type:");
|
||||||
|
layer_add_child(window_layer, text_layer_get_layer(s_type_txt_layer));
|
||||||
|
|
||||||
|
// theta text
|
||||||
|
s_theta_txt_layer = text_layer_create(GRect(PBL_IF_ROUND_ELSE(0, 8), s_bottom_bar_grect.origin.y + PBL_IF_ROUND_ELSE(47, 16), PBL_DISPLAY_WIDTH, 26));
|
||||||
|
text_layer_set_text_alignment(s_theta_txt_layer, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentLeft));
|
||||||
|
text_layer_set_background_color(s_theta_txt_layer, GColorClear);
|
||||||
|
text_layer_set_text_color(s_theta_txt_layer, GColorWhite);
|
||||||
|
text_layer_set_font(s_theta_txt_layer, s_font_mansalva);
|
||||||
|
text_layer_set_text(s_theta_txt_layer, PBL_IF_ROUND_ELSE("= θ", "θ ="));
|
||||||
|
layer_add_child(window_layer, text_layer_get_layer(s_theta_txt_layer));
|
||||||
|
|
||||||
schedule_fallback_alarm();
|
schedule_fallback_alarm();
|
||||||
tick_timer_service_subscribe(SECOND_UNIT, alarm_seconds_handler);
|
tick_timer_service_subscribe(SECOND_UNIT, alarm_seconds_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void alarm_window_unload() {
|
static void alarm_window_unload() {
|
||||||
text_layer_destroy(s_alarm_txt_layer);
|
text_layer_destroy(s_theta_txt_layer);
|
||||||
|
fonts_unload_custom_font(s_font_mansalva);
|
||||||
|
text_layer_destroy(s_type_txt_layer);
|
||||||
|
layer_destroy(s_bottom_bar_layer);
|
||||||
|
layer_destroy(s_top_bar_layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG: logic will eventually be mapped to when triangle is solved
|
// DEBUG: logic will eventually be mapped to when triangle is solved
|
||||||
@@ -360,6 +395,7 @@ static void init() {
|
|||||||
s_the_time.MinuteSet = s_the_time.MinuteWIP;
|
s_the_time.MinuteSet = s_the_time.MinuteWIP;
|
||||||
|
|
||||||
switch (launch_reason()) {
|
switch (launch_reason()) {
|
||||||
|
case APP_LAUNCH_PHONE: // DEBUG, REMOVE PRIOR TO RELEASE!
|
||||||
case APP_LAUNCH_WAKEUP:
|
case APP_LAUNCH_WAKEUP:
|
||||||
window_set_window_handlers(
|
window_set_window_handlers(
|
||||||
s_window,
|
s_window,
|
||||||
|
|||||||
Reference in New Issue
Block a user