diff --git a/package.json b/package.json index d0159b3..a1c4254 100644 --- a/package.json +++ b/package.json @@ -47,11 +47,7 @@ "characterRegex": "[:0-9]", "file": "lecoish_mono_bold_20.bdf", "name": "FONT_LECOISH_MONO_BOLD_20", - "type": "font", - "targetPlatforms": [ - "emery", - "gabbro" - ] + "type": "font" }, { "characterRegex": "[:0-9]", @@ -70,6 +66,12 @@ "targetPlatforms": [ "gabbro" ] + }, + { + "characterRegex": "[type:θ=]", + "file": "mansalva_regular.ttf", + "name": "FONT_MANSALVA_REGULAR_22", + "type": "font" } ] } diff --git a/resources/mansalva_regular.ttf b/resources/mansalva_regular.ttf new file mode 100644 index 0000000..9f38827 Binary files /dev/null and b/resources/mansalva_regular.ttf differ diff --git a/src/c/main.c b/src/c/main.c index 6c73f06..187866d 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -11,16 +11,24 @@ typedef struct TheTime { // layer-age static Window *s_window; -//// setter static Layer *s_top_bar_layer; static Layer *s_bottom_bar_layer; +//// setter static BitmapLayer *s_clock_bmp_layer; static BitmapLayer *s_check_bmp_layer; static TextLayer *s_countdown_txt_layer; static TextLayer *s_setter_txt_layer; static Layer *s_highlight_layer; //// 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 //// setter @@ -35,6 +43,8 @@ static struct TheTime s_the_time; // constants //// setter 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_highlight_color = GColorMediumAquamarine; #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); } +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) { GRect fill_area = layer_get_bounds(layer); 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); // top&bottom bars - static const GRect top_bar_grect = GRect(0, 0, PBL_DISPLAY_WIDTH, s_edge_bar_height); - 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); + add_bar_layers_to_window(window_layer); // clock icon 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_alignment(s_clock_bmp_layer, PBL_IF_ROUND_ELSE(GAlignTop, GAlignLeft)); bitmap_layer_set_compositing_mode(s_clock_bmp_layer, GCompOpSet); @@ -249,30 +261,32 @@ static void setter_window_load() { // check icon 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_compositing_mode(s_check_bmp_layer, GCompOpSet); layer_add_child(window_layer, bitmap_layer_get_layer(s_check_bmp_layer)); // 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_color(s_countdown_txt_layer, GColorWhite); 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)); update_countdown_display(); // 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_add_child(window_layer, s_highlight_layer); // 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))); text_layer_set_text_alignment(s_setter_txt_layer, GTextAlignmentCenter); 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)); update_setter_display(); @@ -281,8 +295,10 @@ static void setter_window_load() { static void setter_window_unload() { text_layer_destroy(s_setter_txt_layer); + fonts_unload_custom_font(s_font_lecoish_big); layer_destroy(s_highlight_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_clock_bmp_layer); 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() { 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)); - text_layer_set_text_alignment(s_alarm_txt_layer, GTextAlignmentCenter); - 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)); - text_layer_set_text(s_alarm_txt_layer, "IMAGINE THIS IS A TRIANGLE"); - layer_add_child(window_layer, text_layer_get_layer(s_alarm_txt_layer)); + // top&bottom bars + add_bar_layers_to_window(window_layer); + + // type text + s_font_mansalva = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MANSALVA_REGULAR_22)); + 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(); tick_timer_service_subscribe(SECOND_UNIT, alarm_seconds_handler); } 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 @@ -360,6 +395,7 @@ static void init() { s_the_time.MinuteSet = s_the_time.MinuteWIP; switch (launch_reason()) { + case APP_LAUNCH_PHONE: // DEBUG, REMOVE PRIOR TO RELEASE! case APP_LAUNCH_WAKEUP: window_set_window_handlers( s_window,