Add base text layers

This commit is contained in:
2026-07-30 21:16:25 -04:00
parent 2308cc834e
commit 86e99b361a
3 changed files with 79 additions and 10 deletions
+24 -3
View File
@@ -6,6 +6,8 @@ static Layer *s_top_bar_layer;
static Layer *s_bottom_bar_layer;
static BitmapLayer *s_clock_bmp_layer;
static BitmapLayer *s_check_bmp_layer;
static TextLayer *s_remaining_txt_layer;
static TextLayer *s_setter_txt_layer;
// bitmaps
static GBitmap *s_clock_bmp;
@@ -30,16 +32,16 @@ static void rect_fill_layer_update_proc(Layer *layer, GContext *ctx) {
static void setter_window_load() {
// top&bottom bars
GRect top_bar_grect = GRect(0, 0, PBL_DISPLAY_WIDTH, s_edge_bar_height);
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, rect_fill_layer_update_proc);
GRect bottom_bar_grect = GRect(0, PBL_DISPLAY_HEIGHT - s_edge_bar_height, PBL_DISPLAY_WIDTH, s_edge_bar_height);
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, rect_fill_layer_update_proc);
// 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(8, 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), top_bar_grect.size.w, 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);
@@ -50,14 +52,33 @@ static void setter_window_load() {
bitmap_layer_set_bitmap(s_check_bmp_layer, s_check_bmp);
bitmap_layer_set_compositing_mode(s_check_bmp_layer, GCompOpSet);
// remaining time
s_remaining_txt_layer = text_layer_create(GRect(PBL_IF_ROUND_ELSE(0, 39), PBL_IF_ROUND_ELSE(37, (top_bar_grect.size.h / 2) - (top_bar_grect.size.h / 3)), PBL_IF_ROUND_ELSE(top_bar_grect.size.w, top_bar_grect.size.w - 39), 32));
text_layer_set_text_alignment(s_remaining_txt_layer, GTextAlignmentCenter);
text_layer_set_text_color(s_remaining_txt_layer, GColorWhite);
text_layer_set_background_color(s_remaining_txt_layer, GColorClear);
text_layer_set_font(s_remaining_txt_layer, fonts_get_system_font(FONT_KEY_LECO_32_BOLD_NUMBERS));
text_layer_set_text(s_remaining_txt_layer, "00:00:00");
// setter
s_setter_txt_layer = text_layer_create(GRect(0, (PBL_DISPLAY_HEIGHT / 2) - 39, PBL_DISPLAY_WIDTH, 60));
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_get_system_font(FONT_KEY_LECO_60_NUMBERS_AM_PM));
text_layer_set_text(s_setter_txt_layer, PBL_IF_ROUND_ELSE("00 : 00", "00:00"));
Layer *window_layer = window_get_root_layer(s_window);
layer_add_child(window_layer, s_top_bar_layer);
layer_add_child(window_layer, s_bottom_bar_layer);
layer_add_child(window_layer, bitmap_layer_get_layer(s_clock_bmp_layer));
layer_add_child(window_layer, bitmap_layer_get_layer(s_check_bmp_layer));
layer_add_child(window_layer, text_layer_get_layer(s_remaining_txt_layer));
layer_add_child(window_layer, text_layer_get_layer(s_setter_txt_layer));
}
static void setter_window_unload() {
text_layer_destroy(s_setter_txt_layer);
text_layer_destroy(s_remaining_txt_layer);
bitmap_layer_destroy(s_check_bmp_layer);
bitmap_layer_destroy(s_clock_bmp_layer);
gbitmap_destroy(s_check_bmp);