예제 #1
0
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;
}
예제 #2
0
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;
}
예제 #3
0
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);
}
예제 #4
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);
}
예제 #5
0
파일: firmbug.c 프로젝트: SetPebble/firmbug
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);
예제 #6
0
void init_animations() {

  property_animation_init_layer_frame(&up_animation, &text_time_layer.layer, &LOWER_TO_RECT, &UPPER_TO_RECT);

  animation_set_duration(&up_animation.animation, ANIMATION_DURATION_IN_MS);

  animation_set_curve(&up_animation.animation, AnimationCurveEaseOut);


  property_animation_init_layer_frame(&down_animation, &text_time_layer.layer, &UPPER_TO_RECT, &LOWER_TO_RECT);

  animation_set_duration(&down_animation.animation, ANIMATION_DURATION_IN_MS);

  animation_set_curve(&down_animation.animation, AnimationCurveEaseOut);

}
예제 #7
0
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));
}
예제 #8
0
static Animation *prv_create_intro_animation(void) {
  Animation *intro_animation = animation_create();
  animation_set_implementation(intro_animation, &s_intro_animation_implementation);
  animation_set_duration(intro_animation, 500);
  animation_set_curve(intro_animation, AnimationCurveEaseIn);
  return intro_animation;
}
예제 #9
0
void spin_globe(int delay, int direction) {
  s_globe_animation = animation_create();
  animation_set_delay((Animation*)s_globe_animation, delay);
  animation_set_duration((Animation*)s_globe_animation, ANIMATION_DURATION);
  animation_set_curve((Animation*)s_globe_animation, delay != 0 ? AnimationCurveEaseInOut : AnimationCurveEaseOut);
  animation_set_handlers((Animation*)s_globe_animation, (AnimationHandlers) {
    .started = anim_started_handler,
    .stopped = anim_stopped_handler
  }, NULL);
예제 #10
0
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 */);
예제 #11
0
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);
예제 #12
0
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);
void setup_text_layer(TextLayer* row, PropertyAnimation *this_anim, int x, int y, int oldx, int oldy, GFont font, int magic, bool delayed, bool black){
    int rectheight = 50;
    text_layer_set_text_color(row, GColorWhite);
    if (black) {
        text_layer_set_background_color(row, GColorBlack);
        rectheight = 37;
    } else {
        text_layer_set_background_color(row, GColorClear);
    }
    layer_add_child(&window.layer, &row->layer);
    text_layer_set_font(row,font);
    
    int speed = 1000;
    int distance = oldy - y;
    
    if (distance < 0) { distance *= -1; }
    
    if (firstblood) {
        speed = 600;
    } else if (x == -144) {
        speed = 1400;
    } else if (oldx == 144) {
        speed = 1000;
    } else {
        speed = 500;
    }
    
    GRect start_rect = GRect(oldx,oldy,144-oldx-1,rectheight);
    GRect target_rect = GRect(x,y,144-x-1,rectheight);
    
    if (magic == 1) { // disappear
        start_rect = GRect(oldx,oldy,144-oldx-1,rectheight);
        target_rect = GRect(-114,oldy,144-oldx-1,rectheight);
    } else if (magic == 2) { // reappear
        start_rect = GRect(144,y,144-x-1,rectheight);
        target_rect = GRect(x,y,144-x-1,rectheight);
    } else if (magic == 3) { // and stay down
        start_rect = GRect(0,0,0,0);
        target_rect = GRect(0,0,0,0);
        speed = 1;
    } else {
    }
    
    if (magic != 3) {
        layer_set_frame(&row->layer, start_rect);
        property_animation_init_layer_frame(this_anim, &row->layer, NULL, &target_rect);
        
        animation_set_duration(&this_anim->animation, speed);  
        animation_set_curve(&this_anim->animation, AnimationCurveEaseInOut);
        if (delayed) {
            animation_set_delay(&this_anim->animation, 100);
        }
        animation_schedule(&this_anim->animation);
    }
}
예제 #14
0
static void animate(int duration, int delay, AnimationImplementation *implementation, bool handlers) {
  Animation *anim = animation_create();
  animation_set_duration(anim, duration);
  animation_set_delay(anim, delay);
  animation_set_curve(anim, AnimationCurveEaseInOut);
  animation_set_implementation(anim, implementation);
  if(handlers) {
    animation_set_handlers(anim, (AnimationHandlers) {
      .started = animation_started,
      .stopped = animation_stopped
    }, NULL);
  }
예제 #15
0
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);
}
예제 #16
0
void batteryLineArc(GContext *ctx, float start_angle, float end_angle, GPoint centre, int radius, int thickness){
	
	float minus_bit = radius - thickness/2 + 0.5;// + (user_battery_colour <= 1 ? 0.5 : 0); //add 0.5 for the int casting, later !!! dark colours like 1.0, light better with 0.5
	float add_bit = (radius + thickness/2 + 0.5); 
	
	graphics_context_set_stroke_width(ctx, 1);
	
	if (start_angle == 0) {
		start_angle = 2.5;	// for some reason, 0 seems to start too far to the left....at least for my purposes
	}
	
	for (float i = start_angle; i <= end_angle; i+=0.5) {
		
		GPoint inside_point = (GPoint) {
			.x = (int16_t)(sin_lookup(i * TRIG_MAX_ANGLE / 360) * minus_bit / TRIG_MAX_RATIO) + centre.x,
			.y = (int16_t)(-cos_lookup(i * TRIG_MAX_ANGLE / 360) * minus_bit / TRIG_MAX_RATIO) + centre.y,
		};

		GPoint outside_point = (GPoint) {
			.x = (int16_t)(sin_lookup(i * TRIG_MAX_ANGLE / 360) * add_bit / TRIG_MAX_RATIO) + centre.x,
			.y = (int16_t)(-cos_lookup(i * TRIG_MAX_ANGLE / 360) * add_bit / TRIG_MAX_RATIO) + centre.y,
		};
		
		graphics_draw_line(ctx, inside_point, outside_point);
	}
}


/*************************** AnimationImplementation **************************/

static void animation_started(Animation *anim, void *context) {
  s_animating = true;
}

static void animation_stopped(Animation *anim, bool stopped, void *context) {
  s_animating = false;
}

static void animate(int duration, int delay, AnimationImplementation *implementation, bool handlers) {
  Animation *anim = animation_create();
  animation_set_duration(anim, duration);
  animation_set_delay(anim, delay);
  animation_set_curve(anim, AnimationCurveEaseInOut);
  animation_set_implementation(anim, implementation);
  
	if(handlers) {
    animation_set_handlers(anim, (AnimationHandlers) {
      .started = animation_started,
      .stopped = animation_stopped
    }, NULL);
  }
  animation_schedule(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);
예제 #18
0
/* segment_show draws a segment with an animation */
void segment_show(Quadrant *quadrant, int id) {
    GRect visible = Segments[id].visible;
    GRect invisible = Segments[id].invisible;

    /* Ensures the segment is not animating to prevent bugs */
    if(animation_is_scheduled(&quadrant->animations[id].animation)) {
        animation_unschedule(&quadrant->animations[id].animation);
    }
    
    property_animation_init_layer_frame(&quadrant->animations[id], &quadrant->segments[id], &invisible, &visible);
    animation_set_duration(&quadrant->animations[id].animation, AnimationTime);
    animation_set_curve(&quadrant->animations[id].animation, AnimationCurveLinear);
    animation_schedule(&quadrant->animations[id].animation);
}
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);
}
예제 #20
0
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 */);
예제 #21
0
void mario_jump_animation_stopped(Animation *animation, void *data)
{
    (void)animation;
    (void)data;

    text_layer_set_text(text_hour_layer, hour_text);
    text_layer_set_text(text_minute_layer, minute_text);

    if (!mario_animation_end) {
        mario_animation_end = property_animation_create_layer_frame(mario_layer,
                                                                    &mario_up_rect,
                                                                    &mario_down_rect);
        animation_set_duration((Animation *)mario_animation_end, MARIO_JUMP_DURATION);
        animation_set_curve((Animation *)mario_animation_end, AnimationCurveEaseIn);
        animation_set_handlers((Animation *)mario_animation_end, (AnimationHandlers){
            .started = (AnimationStartedHandler)mario_down_animation_started,
            .stopped = (AnimationStoppedHandler)mario_down_animation_stopped
        }, 0);
예제 #22
0
static Animation* prv_create_slide_settle_animation(Layer *layer) {
  SelectionLayerData *data = layer_get_data(layer);
  PropertyAnimation *slide_settle_anim = property_animation_create_layer_frame(layer, NULL, NULL);
  Animation *animation = property_animation_get_animation(slide_settle_anim);
  animation_set_curve(animation, AnimationCurveEaseOut);
  animation_set_duration(animation, SLIDE_SETTLE_DURATION_MS);
  AnimationHandlers anim_handler = {
      .stopped = prv_slide_settle_stopped,
  };
  animation_set_handlers(animation, anim_handler, layer);

  data->slide_settle_anim_impl = (AnimationImplementation) {
    .update = prv_slide_settle_impl,
  };
  animation_set_implementation(animation, &data->slide_settle_anim_impl);

  return animation;
}
예제 #23
0
void setup_bolt_animation()
{
	int total_send_delay = 0;
	for(int x = 0; x < FRAME_COUNT - 1; x++) //-1 because animate_bolt looks at the current frame and the next frame in the array
	{
		bolt_animation[x] = property_animation_create_layer_frame(bitmap_layer_get_layer(bolt), &bolt_frames[x].frame, &bolt_frames[x + 1].frame);
		animation_set_duration((Animation*) bolt_animation[x], bolt_frames[x].duration);
		animation_set_delay((Animation*) bolt_animation[x], total_send_delay);
		animation_set_curve((Animation*) bolt_animation[x], AnimationCurveLinear);
		total_send_delay += bolt_frames[x].duration;

		if(x == FRAME_COUNT - 2) //-2 because that is the last item when the condition to break is < X - 1
		{
			animation_set_handlers((Animation*) bolt_animation[x], (AnimationHandlers) {
    			.started = (AnimationStartedHandler) bolt_animation_started,
    			.stopped = (AnimationStoppedHandler) bolt_animation_stopped,
            }, NULL /* callback data */);
		}
예제 #24
0
void scrollTextLayer(int distance) {
    /*
       Initiates a scroll of the metar text field by distance pixels. Positive value of distance scrolls the
       text field downwards on screen.
       */
    // APP_LOG(APP_LOG_LEVEL_DEBUG, "A scroll of the weather field by %d has been requested.", distance);
    GRect from_frame = layer_get_frame((Layer *)weather_layer);
    GRect to_frame = (GRect) { .origin = { from_frame.origin.x, from_frame.origin.y + distance }, .size = from_frame.size };

    property_animation_destroy(weather_animation);

    weather_animation = property_animation_create_layer_frame((Layer *) weather_layer, &from_frame, &to_frame);
    animation_set_curve((Animation *) weather_animation, AnimationCurveEaseInOut);
    animation_set_duration((Animation *) weather_animation, 2000);

    animation_set_handlers((Animation*) weather_animation, (AnimationHandlers) {
                .started = (AnimationStartedHandler) scroll_animation_started,
                .stopped = (AnimationStoppedHandler) scroll_animation_stopped,
            }, NULL);
static void prv_auto_callback(void* data) {
  static int pos[4][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
  pos[1][0] = pos[2][0] = -s_max_point.x;
  pos[2][1] = pos[3][1] = -s_max_point.y;
  static uint8_t curr_pos = 0;
  s_accel_point = GPoint(pos[curr_pos][0], pos[curr_pos][1]); // animation target
  curr_pos = (curr_pos+1)%4;
  
  GRect bounds = layer_get_bounds(s_layer);
  s_reference_point = bounds.origin; // animation start
  
  static PropertyAnimation* animation;
  animation = property_animation_create_bounds_origin(s_layer, &s_reference_point, &s_accel_point);
  animation_set_duration((Animation*)animation, VIRTUAL_SCREEN_UPDATE_AUTO_ANIM_SPEED);
  animation_set_curve((Animation*)animation, AnimationCurveLinear);
  animation_schedule((Animation*)animation);
  
  s_timer = app_timer_register(VIRTUAL_SCREEN_UPDATE_AUTO_TIMEOUT_MS, prv_auto_callback, data);
}
예제 #26
0
static Animation* prv_create_bump_text_animation(Layer *layer) {
  SelectionLayerData *data = layer_get_data(layer);
  
  PropertyAnimation *bump_text_anim = property_animation_create_layer_frame(layer, NULL, NULL);
  Animation *animation = property_animation_get_animation(bump_text_anim);
  animation_set_curve(animation, AnimationCurveEaseIn);
  animation_set_duration(animation, BUMP_TEXT_DURATION_MS);
  AnimationHandlers anim_handler = {
      .stopped = prv_bump_text_stopped,
  };
  animation_set_handlers(animation, anim_handler, layer);

  data->bump_text_impl = (AnimationImplementation) {
    .update = prv_bump_text_impl,
  };
  animation_set_implementation(animation, &data->bump_text_impl);

  return animation;
}
예제 #27
0
void hide_expanded_down_press()
{
	animation_unschedule((Animation*)expanded_animation);
	
	//destroy memory used for previous animation
	if(expanded_animation != NULL)
		property_animation_destroy(expanded_animation);
	
	//make NULL to avoid redestroying memory
	expanded_animation = NULL;
	
	GRect expanded_from = GRect(0,EXPAND_SIZE, 144, 168-EXPAND_SIZE);
	GRect expanded_to = GRect(0, 0-(168-EXPAND_SIZE), 144, 168-EXPAND_SIZE);
	
	//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 = 0;
}
예제 #28
0
static void
text_layer(
	word_t * word,
	GRect frame,
	GFont font
)
{
	text_layer_setup(&window, &word->layer, frame, font);

	GRect frame_right = frame;
	frame_right.origin.x = 150;

	property_animation_init_layer_frame(
		&word->anim,
		&word->layer.layer,
		&frame_right,
		&frame
	);

	animation_set_duration(&word->anim.animation, 500);
	animation_set_curve(&word->anim.animation, AnimationCurveEaseIn);
}
예제 #29
0
// creator
ChartLayer* chart_layer_create(GRect frame) {
  // create "root" Layer
  ChartLayer* layer = (ChartLayer*)layer_create_with_data(frame, sizeof(ChartLayerData));
  if (!layer)
    return layer;

  // set defaults
  ChartLayerData* data = get_chart_data(layer);
  data->pXOrigData = NULL;
  data->pYOrigData = NULL;
  data->iNumOrigPoints = 0;
  data->pXData = NULL;
  data->pYData = NULL;
  data->iNumPoints = 0;
  data->bLayoutDirty = false;
  data->typePlot = eLINE;
  data->clrPlot = GColorWhite;
  data->clrCanvas = GColorBlack;
  data->bShowPoints = false;
  data->iMargin = 5;
  data->fXMin = NOT_SET;
  data->fXMax = NOT_SET;
  data->fYMin = NOT_SET;
  data->fYMax = NOT_SET;
  data->fXYRange = 30.0;
  data->bShowFrame = false;
  data->bAnimate = true;
  data->iAnimationDuration = 1500;
  data->pAnimation = animation_create();
  data->pAnimationImpl = (struct AnimationImplementation*) malloc(sizeof(struct AnimationImplementation));
  data->iPointsToDraw = 0;

  // extra animation setup
  animation_set_curve(data->pAnimation, AnimationCurveLinear);
  animation_set_handlers(data->pAnimation, 
			 ((AnimationHandlers) {
			   .started = (AnimationStartedHandler)animation_started,
			     .stopped = (AnimationStoppedHandler)animation_stopped
			     }), layer);
// Function to initialize our program -- keeping our main() block clean!
void init(void) {
    // Declare your variables!
    Layer *window_layer;

    // Create the main window
    window = window_create();
    window_stack_push(window, true);
    window_set_background_color(window, GColorBlack);

    // Grab this layer once now, instead of repeatedly calling the function later
    window_layer = window_get_root_layer(window);

    // FONT_KEY_ROBOTO_BOLD_SUBSET_49 is defined in pebble_fonts.h
    // GRect(0, 54, 144, 64) is roughly in the center of the Pebble screen
    text_time_layer = text_layer_create(GRect(0, 54, 144, 64));
    text_layer_set_text_color(text_time_layer, GColorWhite);
    text_layer_set_background_color(text_time_layer, GColorClear);
    text_layer_set_font(text_time_layer, fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49));
    text_layer_set_text_alignment(text_time_layer, GTextAlignmentCenter);
    layer_add_child(window_layer, text_layer_get_layer(text_time_layer));

    // Set inverter layer size to full screen
    inverter_layer = inverter_layer_create(GRect(0, 0, 144, 168));
    layer_add_child(window_layer, inverter_layer_get_layer(inverter_layer));

    // Create the animation for the layer and set some animation properties
    // The animation will start at the top of the screen (0, 0, 144, 168), and
    // scroll down to the bottom (0, 167, 144, 168).
    // Using AnimationCurveLinear so the animation speed is constant.
    // Duration is measured in milliseconds, so 1000 = 1 second and 60000 = 1 minute
    inverter_animation = property_animation_create_layer_frame(inverter_layer_get_layer(inverter_layer), &GRect(0, 0, 144, 168), &GRect(0, 167, 144, 168));
    animation_set_curve(&inverter_animation->animation, AnimationCurveLinear);
    animation_set_duration(&inverter_animation->animation, 60000);

    // Hook a function onto the timer
    tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
}