void handle_minute_tick(struct tm *tick_time, TimeUnits units_changed) { destroy_property_animation(&mouth_animation_beg); destroy_property_animation(&jaw_animation_beg); mouth_animation_beg = property_animation_create_layer_frame(bitmap_layer_get_layer(mouth_layer), &mouth_from_rect, &mouth_to_rect); jaw_animation_beg = property_animation_create_layer_frame(bitmap_layer_get_layer(jaw_layer), &jaw_from_rect, &jaw_to_rect); animation_set_handlers((Animation*) mouth_animation_beg, (AnimationHandlers) { .started = (AnimationStartedHandler) animation_started, .stopped = (AnimationStoppedHandler) animation_stopped }, 0);
void animation_stopped(Animation *animation, void *data) { (void)animation; (void)data; memcpy(time_text, time_text_buffer, strlen(time_text)+1); text_layer_set_text(text_time_layer, time_text); destroy_property_animation(&mouth_animation_end); destroy_property_animation(&jaw_animation_end); mouth_animation_end = property_animation_create_layer_frame(bitmap_layer_get_layer(mouth_layer), &mouth_to_rect, &mouth_from_rect); jaw_animation_end = property_animation_create_layer_frame(bitmap_layer_get_layer(jaw_layer), &jaw_to_rect, &jaw_from_rect); animation_schedule((Animation*) mouth_animation_end); animation_schedule((Animation*) jaw_animation_end); }
static void show_state(int from, int to) { int height = bounds.size.h; destroy_property_animation(&state_layer_animation); GRect from_rect = GRect(0, from * bounds.size.h, bounds.size.w, height); GRect to_rect = GRect(0, to * bounds.size.h, bounds.size.w, height); state_layer_animation = property_animation_create_layer_frame(state_layer, &from_rect, &to_rect); animation_set_duration((Animation*) state_layer_animation, 400); animation_schedule((Animation*) state_layer_animation); }
static void animate_out(TextLayer *tlayer, PropertyAnimation *anim, GRect r_rect, GRect c_rect, GRect l_rect, uint32_t delay) { Layer *layer = text_layer_get_layer(tlayer); destroy_property_animation(&anim); anim = property_animation_create_layer_frame(layer, NULL, &l_rect); animation_set_duration((Animation*) anim, 400); animation_set_curve((Animation*) anim, AnimationCurveEaseIn); animation_set_delay((Animation*) anim, delay); // animation_set_handlers((Animation*) anim, (AnimationHandlers) { // .stopped = (AnimationStoppedHandler) animation_stopped // }, NULL /* callback data */); animation_schedule((Animation*) anim); }
void animation_proceed(void) { Layer *layer = text_layer_get_layer(finish_text); GRect middle_rect = GRect(50, 74, 100, 24); destroy_property_animation(&prop_animation); prop_animation = property_animation_create_layer_frame(layer, NULL, &middle_rect); animation_set_duration((Animation*) prop_animation, 500); animation_set_curve((Animation*) prop_animation, AnimationCurveEaseInOut); animation_set_handlers((Animation*) prop_animation, (AnimationHandlers) { .started = (AnimationStartedHandler) animation_started, .stopped = (AnimationStoppedHandler) animation_stopped, }, NULL /* callback data */);
static void show_event(int index) { int screen_count = s_active_item_count + 1; int height = bounds.size.h * (screen_count + 2); destroy_property_animation(&prop_animation); bool invert = false; GRect from_rect = GRect(0, -(current_item + 1) * bounds.size.h, bounds.size.w, height); if(index < 0) { index = screen_count - 1; from_rect.origin.y = -(screen_count + 1) * bounds.size.h; invert = true; } else if(index >= screen_count) { index = 0; from_rect.origin.y = 0; invert = true; } GRect to_rect = GRect(0, -(index + 1) * bounds.size.h, bounds.size.w, height); prop_animation = property_animation_create_layer_frame(events_layer, &from_rect, &to_rect); animation_set_duration((Animation*) prop_animation, 400); animation_schedule((Animation*) prop_animation); // if state is about to be shown or hidden then animate it if (index == 0 || current_item == 0) { int stateFrom = 0, stateTo = 0; if (current_item == 1) stateFrom = -1; else if (current_item > 1) stateFrom = 1; if (index == 1) stateTo = -1; else if (index > 1) stateTo = 1; if (invert && screen_count == 2) { stateFrom = -stateFrom; stateTo = -stateTo; } show_state(stateFrom, stateTo); } current_item = index; layer_mark_dirty(navi_layer); }
void animation_done(Animation *animation, bool finished, void *context) { destroy_property_animation((PropertyAnimation**) &animation); }