Add pin icon
This commit is contained in:
13
src/c/main.c
13
src/c/main.c
@@ -9,7 +9,9 @@ static TextLayer *s_last_watched_layer;
|
||||
static Layer *s_button_bar_layer;
|
||||
static Layer *s_sleep_bar_layer;
|
||||
static Layer *s_sleep_icon_layer;
|
||||
static Layer *s_pin_icon_layer;
|
||||
static GDrawCommandImage *s_sleep_icon;
|
||||
static GDrawCommandImage *s_pin_icon;
|
||||
|
||||
// declare time tracking statics
|
||||
static time_t s_sleep_timestamp;
|
||||
@@ -73,6 +75,11 @@ static void sleep_icon_update_proc(Layer *layer, GContext *ctx) {
|
||||
gdraw_command_image_draw(ctx, s_sleep_icon, GPoint(0, 0));
|
||||
}
|
||||
|
||||
static void pin_icon_update_proc(Layer *layer, GContext *ctx) {
|
||||
graphics_context_set_antialiased(ctx, false);
|
||||
gdraw_command_image_draw(ctx, s_pin_icon, GPoint(0, 0));
|
||||
}
|
||||
|
||||
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)));
|
||||
@@ -82,6 +89,10 @@ static void main_window_load(Window *window) {
|
||||
s_sleep_icon_layer = layer_create(GRect(PBL_IF_ROUND_ELSE((PBL_DISPLAY_WIDTH / 2) - 13, 4), 4, PBL_DISPLAY_WIDTH, 50));
|
||||
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));
|
||||
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);
|
||||
@@ -126,6 +137,7 @@ static void main_window_load(Window *window) {
|
||||
layer_set_update_proc(s_button_bar_layer, button_bar_update_proc);
|
||||
layer_add_child(window_layer, s_button_bar_layer);
|
||||
#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);
|
||||
layer_add_child(window_layer, text_layer_get_layer(s_sleep_time_layer));
|
||||
@@ -164,6 +176,7 @@ static void init() {
|
||||
|
||||
// load PDCs
|
||||
s_sleep_icon = gdraw_command_image_create_with_resource(RESOURCE_ID_SLEEP_ICON);
|
||||
s_pin_icon = gdraw_command_image_create_with_resource(RESOURCE_ID_PIN_ICON);
|
||||
|
||||
window_stack_push(s_main_window, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user