diff --git a/src/c/main.c b/src/c/main.c index ffed98f..ff43820 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -4,21 +4,22 @@ #define COUNT_DEFAULT 0 #define REPEAT_INTERVAL 50 -Window *window; -TextLayer *text_layer; +static Window *s_window; +static TextLayer *s_text_layer; -GBitmap *action_icon_plus; -GBitmap *action_icon_minus; -GBitmap *action_icon_reset; +static GBitmap *s_action_icon_plus; +static GBitmap *s_action_icon_minus; +static GBitmap *s_action_icon_reset; -ActionBarLayer *action_bar; +static ActionBarLayer *s_action_bar; +static StatusBarLayer *s_status_bar; static int count = COUNT_DEFAULT; void update() { static char buffer[10]; snprintf(buffer, sizeof(buffer), "%i", count); - text_layer_set_text(text_layer, buffer); + text_layer_set_text(s_text_layer, buffer); } void increment() { @@ -55,54 +56,58 @@ void click_config_provider(void *context) { } void window_load(Window *window) { - action_bar = action_bar_layer_create(); - action_bar_layer_add_to_window(action_bar, window); - action_bar_layer_set_click_config_provider(action_bar, click_config_provider); + s_action_bar = action_bar_layer_create(); + action_bar_layer_add_to_window(s_action_bar, window); + action_bar_layer_set_click_config_provider(s_action_bar, click_config_provider); - action_bar_layer_set_icon(action_bar, BUTTON_ID_UP, action_icon_reset); - action_bar_layer_set_icon(action_bar, BUTTON_ID_SELECT, action_icon_plus); - action_bar_layer_set_icon(action_bar, BUTTON_ID_DOWN, action_icon_minus); + action_bar_layer_set_icon(s_action_bar, BUTTON_ID_UP, s_action_icon_reset); + action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_action_icon_plus); + action_bar_layer_set_icon(s_action_bar, BUTTON_ID_DOWN, s_action_icon_minus); Layer *layer = window_get_root_layer(window); GRect bounds = layer_get_frame(layer); const int16_t width = layer_get_frame(layer).size.w - ACTION_BAR_WIDTH - 3; - text_layer = text_layer_create(GRect(0, 44, width, bounds.size.h)); - text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); - text_layer_set_background_color(text_layer, GColorClear); + s_text_layer = text_layer_create(GRect(0, 44, width, bounds.size.h)); + text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); + text_layer_set_background_color(s_text_layer, GColorClear); update(); - text_layer_set_text_alignment(text_layer, GTextAlignmentCenter); - layer_add_child(layer, text_layer_get_layer(text_layer)); + text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter); + layer_add_child(layer, text_layer_get_layer(s_text_layer)); + + s_status_bar = status_bar_layer_create(); + layer_add_child(layer, status_bar_layer_get_layer(s_status_bar)); } void window_unload(Window *window) { - text_layer_destroy(text_layer); - action_bar_layer_destroy(action_bar); + status_bar_layer_destroy(s_status_bar); + text_layer_destroy(s_text_layer); + action_bar_layer_destroy(s_action_bar); } void init() { - action_icon_plus = gbitmap_create_with_resource(RESOURCE_ID_PLUS); - action_icon_minus = gbitmap_create_with_resource(RESOURCE_ID_MINUS); - action_icon_reset = gbitmap_create_with_resource(RESOURCE_ID_RESET); + s_action_icon_plus = gbitmap_create_with_resource(RESOURCE_ID_PLUS); + s_action_icon_minus = gbitmap_create_with_resource(RESOURCE_ID_MINUS); + s_action_icon_reset = gbitmap_create_with_resource(RESOURCE_ID_RESET); - window = window_create(); + s_window = window_create(); - window_set_window_handlers(window, (WindowHandlers){ - .load = window_load, - .unload = window_unload, - }); + window_set_window_handlers(s_window, (WindowHandlers){ + .load = window_load, + .unload = window_unload, + }); count = persist_exists(COUNT_PKEY) ? persist_read_int(COUNT_PKEY) : COUNT_DEFAULT; - window_stack_push(window, true); + window_stack_push(s_window, true); } void deinit() { persist_write_int(COUNT_PKEY, count); - window_destroy(window); - gbitmap_destroy(action_icon_plus); - gbitmap_destroy(action_icon_minus); - gbitmap_destroy(action_icon_reset); + window_destroy(s_window); + gbitmap_destroy(s_action_icon_plus); + gbitmap_destroy(s_action_icon_minus); + gbitmap_destroy(s_action_icon_reset); } int main() {