void show_expanded() { destroy_animations(); Layer* current_card = (current%2 == 0)?card_layer_A:card_layer_B; int card_height = layer_get_frame(current_card).size.h; GRect card_from = layer_get_frame(current_card); GRect card_to = GRect(0,EXPAND_SIZE-card_from.size.h,144,card_from.size.h); GRect expanded_from = GRect(0,168, 144, 168-EXPAND_SIZE); GRect expanded_to = GRect(0, EXPAND_SIZE, 144, 168-EXPAND_SIZE); //animate card card_animation_old = property_animation_create_layer_frame(current_card, &card_from, &card_to); animation_set_curve((Animation*) card_animation_old, AnimationCurveEaseOut); animation_set_duration((Animation*) card_animation_old, 300); animation_schedule((Animation*) card_animation_old); //animate expanded layer expanded_animation = property_animation_create_layer_frame(expanded_layer, &expanded_from, &expanded_to); animation_set_curve((Animation*) expanded_animation, AnimationCurveEaseOut); animation_set_duration((Animation*) expanded_animation, 300); animation_schedule((Animation*) expanded_animation); expanded_visible = 1; }
static void update_time() { // Get a tm structure time_t temp = time(NULL); struct tm *t = localtime(&temp); srand((unsigned) time(&temp)); static PropertyAnimation *s_min_animation, *s_hour_animation, *s_ufo_animation; static GRect min_from_frame, min_to_frame, hour_to_frame, hour_from_frame, ufo_to_frame, ufo_from_frame; static int x1ufo, x2ufo, y1ufo, y2ufo; int min_distance = 64; int hour_distance = 40; int32_t min_angle = TRIG_MAX_ANGLE * t->tm_min/60; int32_t hour_angle = (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10))) / (12 * 6); xmin = (int16_t)(sin_lookup(min_angle) * min_distance / TRIG_MAX_RATIO) + 72 - 16; ymin = (int16_t)(-cos_lookup(min_angle) * min_distance / TRIG_MAX_RATIO) + 86 - 16; xhour = (int16_t)(sin_lookup(hour_angle) * hour_distance / TRIG_MAX_RATIO) + 72 - 14; yhour = (int16_t)(-cos_lookup(hour_angle) * hour_distance / TRIG_MAX_RATIO) + 86 - 14; min_from_frame = GRect(oldxmin, oldymin, 32, 32); min_to_frame = GRect(xmin, ymin, 32, 32); hour_from_frame = GRect(oldxhour, oldyhour, 28,28); hour_to_frame = GRect(xhour, yhour, 28,28); s_min_animation = property_animation_create_layer_frame((Layer *)s_min_layer, &min_from_frame, &min_to_frame); animation_set_duration((Animation *)s_min_animation,1000); s_hour_animation = property_animation_create_layer_frame((Layer *)s_hour_layer, &hour_from_frame, &hour_to_frame); animation_set_duration((Animation *)s_hour_animation,1000); animation_set_handlers((Animation*) s_min_animation, (AnimationHandlers) { .stopped = (AnimationStoppedHandler) animation_sunmoon_stopped, }, NULL);
void hide_watchface() { destroy_animations(); //watchface_visible = 0; resize_layers(); int card_height = layer_get_frame(card_layer_A).size.h; APP_LOG(APP_LOG_LEVEL_DEBUG, "%d", card_height); GRect card_from = GRect(0,168-MIN_CARD_HEIGHT,144,card_height);//SET THIS TO THE HEIGHT OF CARD TOP GRect card_to = GRect(0,168-card_height,144,card_height); GRect watchface_from = GRect(0,0,144,168); GRect watchface_to = GRect(0,-168,144,168); //animate card card_animation_new = property_animation_create_layer_frame(card_layer_A, &card_from, &card_to); animation_set_curve((Animation*) card_animation_new, AnimationCurveEaseOut); animation_set_duration((Animation*) card_animation_new, 300); animation_schedule((Animation*) card_animation_new); //animate watchface card_animation_old = property_animation_create_layer_frame(watchface_layer, &watchface_from, &watchface_to); animation_set_curve((Animation*) card_animation_old, AnimationCurveLinear); animation_set_duration((Animation*) card_animation_old, 300); animation_schedule((Animation*) card_animation_old); watchface_visible = 0; }
// Animate device cards to make it look like they are being scrolled // up or down when switching devices static void animate_cards(GRect *from, GRect *to) { s_pa_old = property_animation_create_layer_frame(s_devicecard_layer_old->layer, &s_rect_onscreen, to); s_pa_new = property_animation_create_layer_frame(s_devicecard_layer->layer, from, &s_rect_onscreen); animation_set_handlers(IF_32(property_animation_get_animation(s_pa_old), &(s_pa_old->animation)), (AnimationHandlers) { .stopped = devicecard_anim_old_stopped }, NULL);
static void init_animations() { Layer *layer = text_layer_get_layer(text_time_layer); up_animation = property_animation_create_layer_frame(layer, &LOWER_TO_RECT, &UPPER_TO_RECT); animation_set_duration((Animation*) up_animation, ANIMATION_DURATION_IN_MS); animation_set_curve((Animation*) up_animation, AnimationCurveEaseOut); down_animation = property_animation_create_layer_frame(layer, &UPPER_TO_RECT, &LOWER_TO_RECT); animation_set_duration((Animation*) down_animation, ANIMATION_DURATION_IN_MS); animation_set_curve((Animation*) down_animation, AnimationCurveEaseOut); }
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);
static void do_animation() { GRect red_start, red_finish; GRect blue_start, blue_finish; GRect yellow_start, yellow_finish; GRect time_start, time_finish; GRect date_start, date_finish; red_start = GRect(-42,0,42,168); red_finish = GRect(0,0,42,168); blue_start = GRect(0,-168,144,168); blue_finish = GRect(0,0,144,168); yellow_start = GRect(144,120,144,48); yellow_finish = GRect(0,120,144,48); time_start = GRect(144,0,144,168); time_finish = GRect(0,0,144,168); date_start = GRect(-144,0,144,168); date_finish = GRect(0,0,144,168); s_red_anim = property_animation_create_layer_frame(s_red_parent, &red_start, &red_finish); animation_set_duration((Animation*)s_red_anim, ANIM_DURATION); animation_set_delay((Animation*)s_red_anim, ANIM_RED_DELAY); animation_set_curve((Animation*)s_red_anim, AnimationCurveLinear); animation_schedule((Animation*)s_red_anim); s_blue_anim = property_animation_create_layer_frame(s_blue_layer, &blue_start, &blue_finish); animation_set_duration((Animation*)s_blue_anim, ANIM_DURATION); animation_set_delay((Animation*)s_blue_anim, ANIM_BLUE_DELAY); animation_set_curve((Animation*)s_blue_anim, AnimationCurveLinear); animation_schedule((Animation*)s_blue_anim); s_yellow_anim = property_animation_create_layer_frame(s_yellow_layer, &yellow_start, &yellow_finish); animation_set_duration((Animation*)s_yellow_anim, ANIM_DURATION); animation_set_delay((Animation*)s_yellow_anim, ANIM_YELLOW_DELAY); animation_set_curve((Animation*)s_yellow_anim, AnimationCurveLinear); animation_schedule((Animation*)s_yellow_anim); s_time_anim = property_animation_create_layer_frame(s_time_layer, &time_start, &time_finish); animation_set_duration((Animation*)s_time_anim, ANIM_DURATION); animation_set_delay((Animation*)s_time_anim, ANIM_TIME_DELAY); animation_set_curve((Animation*)s_time_anim, AnimationCurveLinear); animation_schedule((Animation*)s_time_anim); s_date_anim = property_animation_create_layer_frame(s_date_layer, &date_start, &date_finish); animation_set_duration((Animation*)s_date_anim, ANIM_DURATION); animation_set_delay((Animation*)s_date_anim, ANIM_TIME_DELAY); animation_set_curve((Animation*)s_date_anim, AnimationCurveLinear); animation_schedule((Animation*)s_date_anim); }
static void select_click_handler(ClickRecognizerRef recognizer, void *context) { ani_out = property_animation_create_layer_frame(animated_layer[active_layer], &GRect(0, 77, 144, 45), &GRect(-144, 77, 144, 45)); animation_schedule((Animation*)ani_out); active_layer = (active_layer + 1) % (NUM_LAYERS); ani_in = property_animation_create_layer_frame(animated_layer[active_layer], &GRect(144, 77, 144, 45), &GRect(0, 77, 144, 45)); animation_schedule((Animation*)ani_in); }
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); }
void pptoaster_handle_animation_in_stopped(Animation *animation, bool finished, void *property_animation_context) { if (!finished) return; static GRect toframe; GSize size = pptoaster.layer_frame.size; toframe.size = size; toframe.origin.x = PPTOASTER_EDGE_MARGIN; switch (pptoaster.direction) { case PPToasterAppearFromBottom: toframe.origin.y = pptoaster.window_size.h; break; case PPToasterAppearFromTop: toframe.origin.y = -size.h - PPTOASTER_EDGE_MARGIN; break; case PPToasterAppearFromMiddle: toframe.origin.y = pptoaster.window_size.h / 2; toframe.size.h = 1; break; } pptoaster_destroy_animation(); pptoaster.propanim = property_animation_create_layer_frame(pptoaster.layer, NULL, &toframe); Animation *internal_animation = &pptoaster.propanim->animation; animation_set_delay(internal_animation, pptoaster.show_duration); animation_set_duration(internal_animation, PPTOASTER_ANIMATION_DURATION); animation_set_handlers(internal_animation, (AnimationHandlers){.stopped = pptoaster_handle_animation_out_stopped}, NULL);
static void onWindowLoad(Window *window) { // 配置按键 window_set_click_config_provider(window, clickConfigProvider); // 窗口信息 Layer *layer = window_get_root_layer(window); bounds = layer_get_bounds(layer); // bitmap图层 GRect fromRect = GRect(0, 0, bounds.size.w, bounds.size.h); GRect toRect = GRect(0, bounds.size.h, bounds.size.w, bounds.size.h); bitmapLayer = bitmap_layer_create(fromRect); // bitmap对象 bitmap = gbitmap_create_with_resource(RESOURCE_ID_MY_LOGO); bitmap_layer_set_compositing_mode(bitmapLayer, GCompOpSet); bitmap_layer_set_bitmap(bitmapLayer, bitmap); // logo动画 PropertyAnimation *propAnim = property_animation_create_layer_frame((Layer *)bitmapLayer, &fromRect, &toRect); Animation *anim = property_animation_get_animation(propAnim); const int delay_ms = 1000; const int duration_ms = 3000; animation_set_curve(anim, AnimationCurveEaseOut); animation_set_delay(anim, delay_ms); animation_set_duration(anim, duration_ms); animation_schedule(anim); // 添加图层 layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(bitmapLayer)); }
static void select_long_click_handler(ClickRecognizerRef recognizer, void *context) { //slide layers in/out property_animation_destroy((PropertyAnimation*)ani_in); property_animation_destroy((PropertyAnimation*)ani_out); ani_out = property_animation_create_layer_frame(animated_layer[active_layer], &GRect(0, 124, 143, 45), &GRect(-138, 124, 143, 45)); animation_schedule((Animation*)ani_out); active_layer = (active_layer + 1) % (NUM_LAYERS); ani_in = property_animation_create_layer_frame(animated_layer[active_layer], &GRect(138, 124, 144, 45), &GRect(0, 124, 144, 45)); animation_schedule((Animation*)ani_in); }
void update_battery_level_display() { if (!battery_level_layer) return; GRect bounds = layer_get_frame(battery_level_layer); int third = (bounds.size.h - 4) / 3; //height of screen //int y = third * 33 / 100; //DEBUG int y = third * m_sBattState.charge_percent / 100; to_rect[5] = layer_get_frame(battery_level_layer); to_rect[4] = layer_get_frame(battery_level_layer); if (m_sBattState.is_charging) { to_rect[5].origin.y = -(2 + 3*third); //from to_rect[4].origin.y = -(2 + 3*third) + y; //Note: charge_percent seems incorrect when charging! (e.g. shows 10% instead of 60% actual capacity). } else { to_rect[5].origin.y = -2; //from to_rect[4].origin.y = -2 - y; } if (animations[4]) { property_animation_destroy(animations[4]); animations[4] = NULL; } animations[4] = property_animation_create_layer_frame(battery_level_layer, &to_rect[5], &to_rect[4]); animation_set_duration((Animation*) animations[4], 1500); animation_schedule((Animation*) animations[4]); }
void toast_shown(struct Animation* animation, bool finished, void* context) { animation_toast = property_animation_create_layer_frame(text_layer_get_layer(text_toast), NULL, &GRect((144 - size_toast.w) / 2, -size_toast.h, size_toast.w, size_toast.h)); animation_set_duration(&animation_toast->animation, kToastHide); animation_set_curve(&animation_toast->animation, AnimationCurveEaseIn); animation_set_handlers(&animation_toast->animation, (AnimationHandlers) { .stopped = toast_hidden }, NULL);
void scroll_layer_set_content_offset(ScrollLayer *l, GPoint offset, bool animated) { SCROLL_GET; if (gpoint_equal(&scroll->content_sublayer->frame.origin,&offset)) return; offset.x=0; GPoint oldOffset=scroll_layer_get_content_offset(l); GRect to=scroll_layer_get_new_content_rect(l,offset); if (animated) { if (scroll->animation) property_animation_destroy(scroll->animation); scroll->animation=property_animation_create_layer_frame(scroll->content_sublayer,0,&to); double duration=to.origin.y-oldOffset.y; if (duration<25||duration>-25) duration=abs(duration)*SCROLL_LAYER_SCROLL_SPEED; else duration=1; animation_set_duration((Animation*)scroll->animation,duration); animation_schedule((Animation*)scroll->animation); } else { scroll->content_sublayer->frame.origin=offset; layer_mark_dirty(scroll_layer); } if (scroll->callbacks.content_offset_changed_handler!=0) scroll->callbacks.content_offset_changed_handler(l,scroll->context); }
void animate_quote(int pixels_to_scroll_by) { GRect start_frame = GRect(0, (pixels_to_scroll_by < 0? 0 : -pixels_to_scroll_by), 144, 2000); GRect finish_frame = GRect(0, (pixels_to_scroll_by < 0? pixels_to_scroll_by : 0), 144, 2000); s_box_animation = property_animation_create_layer_frame(text_layer_get_layer(s_text_layer), &start_frame, &finish_frame); animation_set_handlers((Animation*)s_box_animation, (AnimationHandlers) { .stopped = anim_stopped_handler }, NULL);
void schedule_graph_animation(GRect start, GRect finish) { // Schedule the graph animation s_graph_animation = property_animation_create_layer_frame(s_graph_layer, &start, &finish); animation_set_duration((Animation*)s_graph_animation, ANIM_DURATION); animation_set_delay((Animation*)s_graph_animation, ANIM_DELAY); animation_set_curve((Animation*)s_graph_animation, AnimationCurveEaseInOut); animation_set_handlers((Animation*)s_graph_animation, (AnimationHandlers) { .started = anim_started_handler, .stopped = anim_stopped_handler }, NULL);
static void animate_in(TextLayer *tlayer, PropertyAnimation *anim, GRect r_rect, GRect c_rect, GRect l_rect, uint32_t delay) { Layer *layer = text_layer_get_layer(tlayer); anim = property_animation_create_layer_frame(layer, &r_rect, &c_rect); animation_set_duration((Animation*) anim, 400); animation_set_curve((Animation*) anim, AnimationCurveEaseOut); animation_set_delay((Animation*) anim, delay); animation_set_handlers((Animation*) anim, (AnimationHandlers) { .started = (AnimationStartedHandler) animation_started, .stopped = (AnimationStoppedHandler) animation_stopped }, NULL /* callback data */);
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 trigger_custom_animation_out(){ GRect from_frame = layer_get_frame(text_layer_get_layer(text_layer_body)); GRect to_frame = GRect(-144, 50, 144, 154); animation_set_duration((Animation*)text_layer_get_layer(text_layer_body), ANIM_DURATION); animation_set_curve((Animation*)text_layer_get_layer(text_layer_body), AnimationCurveEaseInOut); s_property_animation = property_animation_create_layer_frame(text_layer_get_layer(text_layer_body), &from_frame, &to_frame); animation_set_handlers((Animation*) s_property_animation, (AnimationHandlers) { .started = (AnimationStartedHandler) animation_started, .stopped = (AnimationStoppedHandler) animation_stopped, }, NULL);
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); }
static void shake_animation() { Layer *text_layer = text_layer_get_layer(s_text_layer); GRect start = layer_get_frame(text_layer); GRect finish = GRect(start.origin.x - TEXT_ANIMATION_WINDOW_DISTANCE, start.origin.y, start.size.w, start.size.h); PropertyAnimation *out_prop_anim = property_animation_create_layer_frame(text_layer, &start, &finish); Animation *out_anim = property_animation_get_animation(out_prop_anim); animation_set_curve(out_anim, AnimationCurveEaseInOut); animation_set_duration(out_anim, TEXT_ANIMATION_WINDOW_DURATION); animation_set_handlers(out_anim, (AnimationHandlers) { .stopped = out_stopped_handler }, NULL);
static void trigger_slide_animation_to(Layer *layer, GRect to_frame) { if (s_property_animation) return; GRect from_frame = layer_get_frame(layer); if ( grect_equal(&from_frame, &to_frame) ) { return; } s_property_animation = property_animation_create_layer_frame(layer, &from_frame, &to_frame); animation_set_handlers((Animation*) s_property_animation, (AnimationHandlers) { .stopped = anim_stopped_handler }, NULL);
/* preps for animations and schedules them */ static void set_for_animation() { /* calculate inactive layer */ int inactive = 1 - active; /* add layers to window */ Layer *w = window_get_root_layer(graphicWindow); layer_add_child(w, graphicBackgroundLayer); layer_add_child(w, graphicDrawLayer[inactive]); layer_add_child(w, text_layer_get_layer(graphicHeader[inactive])); /* set the 'to' frame for background layer */ int width = layer_get_frame(w).size.w - BAR_WIDTH; int height = layer_get_frame(w).size.h; GRect backgroundTo = GRect(0,0,width,height); /* set the 'to' frame for draw layer */ width = layer_get_frame(w).size.w - BAR_WIDTH - 2 * DETAIL_OFFSET; height = layer_get_frame(w).size.h - HEADER_HEIGHT - DETAIL_SPACE - DETAIL_OFFSET; GRect layerTo = GRect(DETAIL_OFFSET, HEADER_HEIGHT + DETAIL_SPACE, width, height); /* set the 'to' frame for header*/ GRect headerTo = GRect(0,0,HEADER_WIDTH,HEADER_HEIGHT); /* set layer frames */ animations[BACKGROUND] = property_animation_create_layer_frame(graphicBackgroundLayer, NULL, &backgroundTo); animations[LAYER] = property_animation_create_layer_frame(graphicDrawLayer[inactive], NULL, &layerTo); animations[HEADER] = property_animation_create_layer_frame(text_layer_get_layer(graphicHeader[inactive]), NULL, &headerTo); /* set timing */ animation_set_duration((Animation *)animations[BACKGROUND], ANIMATION_SPEED); animation_set_duration((Animation *)animations[LAYER], ANIMATION_SPEED); animation_set_duration((Animation *)animations[HEADER], ANIMATION_SPEED); /* set handler ONLY for layer */ animation_set_handlers((Animation *) animations[LAYER], (AnimationHandlers) { .started = (AnimationStartedHandler) NULL, .stopped = (AnimationStoppedHandler) layer_animation_ended, }, NULL);
static void animate_layer_bounds(Layer* layer, GRect toRect) { if(!animation_finished) { //APP_LOG(APP_LOG_LEVEL_DEBUG,"in cleanup..."); animation_unschedule((Animation*)animation); //property_animation_destroy(animation); animation_finished=true; layer_set_frame(text_layer_get_layer(description_layer),GRect(0, TEXT_OFFSET_Y, 5*SCREEN_WIDTH, 24)); } animation = property_animation_create_layer_frame(layer, NULL, &toRect); animation_set_handlers((Animation*) animation, (AnimationHandlers) { .stopped = (AnimationStoppedHandler) animation_stopped, }, NULL);
static void animate_hub_layer(GRect start, GRect finish) { if (animation_is_ongoing) { #ifdef PBL_SDK_2 animation_unschedule((Animation*)prop_anim); if (prop_anim) property_animation_destroy(prop_anim); prop_anim = NULL; #endif } animation_is_ongoing = true; prop_anim = property_animation_create_layer_frame(hub_layer, &start, &finish); animation_set_duration((Animation*)prop_anim, 1000); animation_set_handlers((Animation*)prop_anim, (AnimationHandlers) { .stopped = anim_stopped_handler }, NULL);
void animate_question(int pixels_to_scroll_by) { int len = pixels_to_scroll_by; if(pixels_to_scroll_by > 0) { len = pixels_to_scroll_by + 24; } else { len = pixels_to_scroll_by - 24; } GRect start_frame = GRect(0, (pixels_to_scroll_by < 0 ? 0 : -len), WINDOW_WIDTH, TEXTBOX_HEIGHT); GRect finish_frame = GRect(0, (pixels_to_scroll_by < 0 ? len : 0), WINDOW_WIDTH, TEXTBOX_HEIGHT); PropertyAnimation *box_animation = property_animation_create_layer_frame(text_layer_get_layer(s_output_layer), &start_frame, &finish_frame); animation_set_handlers((Animation*)box_animation, (AnimationHandlers) { .stopped = anim_stopped_handler }, NULL);
static void out_stopped_handler(Animation *animation, bool finished, void *context) { s_current_text += (s_current_text == 0) ? 1 : -1; text_layer_set_text(s_text_layer, s_text[s_current_text]); Layer *text_layer = text_layer_get_layer(s_text_layer); GRect frame = layer_get_frame(text_layer); GRect start = GRect(frame.origin.x + (2 * TEXT_ANIMATION_WINDOW_DISTANCE), frame.origin.y, frame.size.w, frame.size.h); GRect finish = GRect(frame.origin.x + TEXT_ANIMATION_WINDOW_DISTANCE, frame.origin.y, frame.size.w, frame.size.h); PropertyAnimation *in_prop_anim = property_animation_create_layer_frame(text_layer, &start, &finish); Animation *in_anim = property_animation_get_animation(in_prop_anim); animation_set_curve(in_anim, AnimationCurveEaseInOut); animation_set_duration(in_anim, TEXT_ANIMATION_WINDOW_DURATION); animation_schedule(in_anim); }
/** * Change the digit in given column, and animate the column by rolling * the newly selected digit into position (3rd row). **/ void set_digit(int col, int num) { Layer *layer = text_layer_get_layer(text_layer[col]); to_rect[col] = layer_get_frame(layer); to_rect[col].origin.y = (offsets[col][num] * -42) + center - 28; if (animations[col]) { property_animation_destroy(animations[col]); animations[col] = NULL; } animations[col] = property_animation_create_layer_frame(layer, NULL, &to_rect[col]); animation_set_duration((Animation*) animations[col], 1000); animation_schedule((Animation*) animations[col]); }
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 */);