//fonction de dessin de l'image actuelle au sein de l'animation pour les unités des heures void hour_unit_update_proc(Layer *layer, GContext *ctx) { //frame suivante GDrawCommandFrame *frame; if(hu_trigger_spe && hu_index_loop < LIMIT_LOOP) { frame = gdraw_command_sequence_get_frame_by_index(hour_unit_loop_sequence, hu_index_loop); } else { // Get the next frame frame = gdraw_command_sequence_get_frame_by_index(hour_unit_sequence, hu_index); } // If another frame was found, draw it if (frame) { gdraw_command_frame_draw(ctx, hour_unit_sequence, frame, GPoint(0, 0)); } // Advance to the next frame, wrapping if neccessary int num_frames = gdraw_command_sequence_get_num_frames(hour_unit_sequence); if(!hu_trigger_spe) { //si index différent de limite on incrémente if(hu_index != hu_limit) hu_index++; //si fin de l'animation on reboucle if (hu_index >= num_frames) { hu_index = 0; } } else { if(hu_index_loop != LIMIT_LOOP) hu_index_loop++; if(!hu_loop) { hu_trigger_spe = false; hu_index_loop = 0; } } }
static void update_proc(Layer *layer, GContext *ctx) { // Get the next frame GDrawCommandFrame *frame = gdraw_command_sequence_get_frame_by_index(s_command_seq, s_index); // If another frame was found, draw it if (frame) { gdraw_command_frame_draw(ctx, s_command_seq, frame, GPoint(0, 23)); } // Advance to the next frame, wrapping if neccessary int num_frames = gdraw_command_sequence_get_num_frames(s_command_seq); s_index++; if (s_index == num_frames) { s_index = 0; } }
static void prv_goal_reached_sequence_layer_update_proc(Layer *layer, GContext *ctx) { GoalStarGoalEventWindowData *data = window_get_user_data(layer_get_window(layer)); const GRect layer_bounds = layer_get_bounds(layer); GRect sequence_frame = (GRect) { .size = gdraw_command_sequence_get_bounds_size(data->goal_reached_sequence), }; grect_align(&sequence_frame, &layer_bounds, GAlignCenter, true /* clip */); sequence_frame.origin.y -= sequence_frame.origin.y / 4; GDrawCommandFrame *frame = gdraw_command_sequence_get_frame_by_index( data->goal_reached_sequence, data->goal_reached_sequence_frame_index); if (frame) { gdraw_command_frame_draw(ctx, data->goal_reached_sequence, frame, sequence_frame.origin); } const uint32_t num_frames = gdraw_command_sequence_get_num_frames(data->goal_reached_sequence); if (++data->goal_reached_sequence_frame_index >= num_frames) { app_timer_cancel(data->goal_reached_sequence_timer); const uint32_t timeout_ms = goal_star_configuration_get_goal_event_timeout_ms(); if (timeout_ms) { data->goal_reached_sequence_timer = app_timer_register(timeout_ms, prv_goal_reached_wait_timer_handler, data); } } char text[GOAL_STAR_CONFIGURATION_STRING_BUFFER_LENGTH] = {0}; goal_star_configuration_get_goal_summary_string(text); graphics_context_set_text_color(ctx, GColorBlack); const GFont font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD); const int16_t font_height = 24; const GRect text_frame = GRect(0, sequence_frame.origin.y + sequence_frame.size.h, layer_bounds.size.w, font_height); graphics_draw_text(ctx, text, font, text_frame, GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL); } static void prv_goal_reached_sequence_timer_handler(void *context) { GoalStarGoalEventWindowData *data = context; if (data) { layer_mark_dirty(data->goal_reached_sequence_layer); data->goal_reached_sequence_timer = app_timer_register(ANIMATION_FRAME_INTERVAL_MS, prv_goal_reached_sequence_timer_handler, data); } }
//fonction de dessin de l'image actuelle au sein de l'animation pour les dizaines d'heures void hour_doz_update_proc(Layer *layer, GContext *ctx) { // Get the next frame GDrawCommandFrame *frame = gdraw_command_sequence_get_frame_by_index(hour_doz_sequence, hd_index); // If another frame was found, draw it if (frame) { gdraw_command_frame_draw(ctx, hour_doz_sequence, frame, GPoint(0, 0)); } // Advance to the next frame, wrapping if neccessary int num_frames = gdraw_command_sequence_get_num_frames(hour_doz_sequence); //si index différent de limite on incrémente if(hd_index != hd_limit) hd_index++; //si fin de l'animation on reboucle if (hd_index >= num_frames) { hd_index = 0; } }