Exemplo n.º 1
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;
}
Exemplo n.º 2
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;
}
static void prv_run_value_change_animation(Layer *layer) {
  SelectionLayerData *data = layer_get_data(layer);
  
  Animation *bump_text = prv_create_bump_text_animation(layer);
#ifdef PBL_SDK_3
  Animation *bump_settle = prv_create_bump_settle_animation(layer);
  data->value_change_animation = animation_sequence_create(bump_text, bump_settle, NULL);
  animation_schedule(data->value_change_animation);
#else
  animation_schedule(bump_text);
#endif
}
static void prv_run_slide_animation(Layer *layer) {
  SelectionLayerData *data = layer_get_data(layer);
  
  Animation *over_animation = prv_create_slide_animation(layer);
#ifdef PBL_SDK_3
  Animation *settle_animation = prv_create_slide_settle_animation(layer);
  data->next_cell_animation = animation_sequence_create(over_animation, settle_animation, NULL);
  animation_schedule(data->next_cell_animation);
#else
  animation_schedule(over_animation);
#endif
}
Exemplo n.º 5
0
void animation_stopped(Animation *animation, void *data) {
	(void)animation;
	(void)data;
	
	text_layer_set_text(&text_time_layer, time_text);
	
	property_animation_init_layer_frame(&mouth_animation_end, &mouth_layer, &mouth_to_rect, &mouth_from_rect);
	property_animation_init_layer_frame(&jaw_animation_end, &jaw_layer, &jaw_to_rect, &jaw_from_rect);
	
	animation_schedule(&mouth_animation_end.animation);
	animation_schedule(&jaw_animation_end.animation);
}
Exemplo n.º 6
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);
}
Exemplo n.º 7
0
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);

}
Exemplo n.º 8
0
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);
}
Exemplo n.º 9
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);
}
Exemplo n.º 10
0
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]);
}
Exemplo n.º 11
0
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);
}
Exemplo n.º 12
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));
}
void handle_tap(AccelAxisType axis, int32_t direction) {
	static BatteryChargeState chargeState;
	int i, s;
	
    if (splashEnded && !animRunning) {
		if (animation_is_scheduled(anim)) {
			animation_unschedule(anim);
		}

 		animRunning = true;

		chargeState = battery_state_service_peek();
        s = chargeState.charge_percent;
                
		for (i=0; i<NUMSLOTS; i++) {
            slot[i].prevDigit = slot[i].curDigit;
        }

		slot[4].curDigit = 'B' - '0';
		slot[5].curDigit = 'A' - '0';
		slot[6].curDigit = 'T' - '0';
		slot[7].curDigit = SPACE_D;
		slot[8].curDigit = (s==100)?1:SPACE_D;
		slot[9].curDigit = (s<100)?s/10:0;
		slot[10].curDigit = (s<100)?s/100:0;
		slot[11].curDigit = PERCENT;
		
        animation_schedule(anim);
       	app_timer_register(BATTERYDELAY, handle_timer, NULL);
	}
}
// Function to convert the time value into a string and update the time layer
void handle_minute_tick(struct tm *tick_time, TimeUnits units_changed) {
    // We're converting into military time because it requires less code
    strftime(time_text, sizeof(time_text), "%R", tick_time);
    text_layer_set_text(text_time_layer, time_text);

    // Start the animation
    animation_schedule(&inverter_animation->animation);
}
void handle_tick(AppContextRef ctx, PebbleTickEvent *evt) {
	PblTm now;
	int ho, mi, da, mo, i;

    if (splashEnded) {
        if (animation_is_scheduled(&anim))
            animation_unschedule(&anim);
        
        get_time(&now);
        
        ho = get_display_hour(now.tm_hour);
        mi = now.tm_min;
        da = now.tm_mday;
        mo = now.tm_mon+1;
        
        for (i=0; i<NUMSLOTS; i++) {
            slot[i].prevDigit = slot[i].curDigit;
        }
        
        slot[0].curDigit = ho/10;
        slot[1].curDigit = ho%10;
        slot[2].curDigit = mi/10;
        slot[3].curDigit = mi%10;
		if (US_DATE) {
			slot[6].curDigit = da/10;
			slot[7].curDigit = da%10;
			slot[4].curDigit = mo/10;
			slot[5].curDigit = mo%10;
		} else {
			slot[4].curDigit = da/10;
			slot[5].curDigit = da%10;
			slot[6].curDigit = mo/10;
			slot[7].curDigit = mo%10;
		}
		
		if (NO_ZERO) {
			if (slot[0].curDigit == 0) {
				slot[0].curDigit = 10;
				if (slot[0].prevDigit == 10) {
					slot[0].curDigit++;
				}
			}
			if (slot[4].curDigit == 0) {
				slot[4].curDigit = 10;
				if (slot[4].prevDigit == 10) {
					slot[4].curDigit++;
				}
			}
			if (slot[6].curDigit == 0) {
				slot[6].curDigit = 10;
				if (slot[6].prevDigit == 10) {
					slot[6].curDigit++;
				}
			}
		}
        animation_schedule(&anim);
    }
}
void handle_bluetooth(bool connected) {
	int i;
	
	if (lastBluetoothStatus == connected) {
		return;
	} else {
		lastBluetoothStatus = connected;
	
		if (splashEnded && !animRunning) {
			if (animation_is_scheduled(anim)) {
				animation_unschedule(anim);
			}
			
			animRunning = true;
			
			for (i=0; i<NUMSLOTS; i++) {
				slot[i].prevDigit = slot[i].curDigit;
			}
			
			slot[0].curDigit = 'B' - '0';
			slot[1].curDigit = 'T' - '0';
			
			if (connected) {
				slot[2].curDigit = 'O' - '0';
				slot[3].curDigit = 'K' - '0';

				slot[4].curDigit  = SPACE_D;
				slot[5].curDigit  = SPACE_D;
				slot[6].curDigit  = SPACE_D;
				slot[7].curDigit  = SPACE_D;
				slot[8].curDigit  = SPACE_D;
				slot[9].curDigit  = SPACE_D;
				slot[10].curDigit = SPACE_D;
				slot[11].curDigit = SPACE_D;

				vibes_double_pulse();
			} else {
				slot[2].curDigit = SPACE_L;
				slot[3].curDigit = SPACE_R;

				slot[4].curDigit  = SPACE_D;
				slot[5].curDigit  = 'F' - '0';
				slot[6].curDigit  = 'A' - '0';
				slot[7].curDigit  = 'I' - '0';
				slot[8].curDigit  = 'L' - '0';
				slot[9].curDigit  = 'E' - '0';
				slot[10].curDigit = 'D' - '0';
				slot[11].curDigit = SPACE_D;

				vibes_long_pulse();
			}
			
			animation_schedule(anim);
			app_timer_register(BATTERYDELAY, handle_timer, NULL);
		}
	}
}
Exemplo n.º 17
0
static void prv_start_intro_animation(void) {
  SprinklesAppData *data = s_app_data;
  if (!data) {
    return;
  }

  Animation *intro_animation = prv_create_intro_animation();
  animation_schedule(intro_animation);
}
Exemplo n.º 18
0
static void
update_word(
	word_t * const word
)
{
	text_layer_set_text(&word->layer, word->text);
	if (word->text != word->old_text)
		animation_schedule(&word->anim.animation);
}
Exemplo n.º 19
0
static void make_animation() {
  s_data->animation = animation_create();
  animation_set_duration(s_data->animation, ANIMATION_DURATION_INFINITE);
                  // the animation will stop itself
  static const struct AnimationImplementation s_animation_implementation = {
    .update = animation_update,
  };
  animation_set_implementation(s_data->animation, &s_animation_implementation);
  animation_schedule(s_data->animation);
}
Exemplo n.º 20
0
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);
}
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);
    }
}
Exemplo n.º 22
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);
}
Exemplo n.º 23
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);
}
void handle_tap(AccelAxisType axis, int32_t direction) {
	static BatteryChargeState chargeState;
	int i, s;
	
    if (splashEnded) {
	
		if (showBattery) {
			showBattery = false;
			app_timer_cancel(timerBattery);
			handle_timer(NULL);
		} else {
			if (animation_is_scheduled(anim)) {
				animation_unschedule(anim);
			}
			
			for (i=0; i<NUMSLOTS; i++) {
				slot[i].prevDigit = slot[i].curDigit;
			}
			
			chargeState = battery_state_service_peek();
			s = chargeState.charge_percent / 10;
					
			if (s<1) {
				s = 1;
			} else if (s>9) {
				s = 9;
			}
			
			s--;
			
			//for (i=0; i<4; i++) {
			//	slot[i].curDigit = BATTERYOFFSET + 4*s + i;
			//}
			
			slot[4].curDigit = 'B' - '0';
			slot[5].curDigit = 'A' - '0';
			slot[6].curDigit = 'T' - '0';
			slot[7].curDigit = 'T' - '0';
			slot[8].curDigit = SPACE_D;
			slot[9].curDigit = s+1;
			slot[10].curDigit = 0;
			slot[11].curDigit = PERCENT;
			
			showBattery = true;
			
			animation_schedule(anim);
			timerBattery = app_timer_register(BATTERYDELAY, handle_timer, NULL);
		}
	}	
}
Exemplo n.º 25
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);
}
Exemplo n.º 26
0
void schedule_animation(PblTm *tick_time) {

  static bool use_upper_to_rect = false;

  int32_t animation_delay_required_in_ms = 60000 - (tick_time->tm_sec * 1000) - (ANIMATION_DURATION_IN_MS - 100);

  if (animation_delay_required_in_ms < 0) {
    // In the hopefully rare case that we don't have time to schedule the animation
    // before the value is due to change we just let it change in place.
    return;
  }

  if (use_upper_to_rect) {
    animation_set_delay(&up_animation.animation, animation_delay_required_in_ms);
    animation_schedule(&up_animation.animation);
  } else {
    animation_set_delay(&down_animation.animation, animation_delay_required_in_ms);
    animation_schedule(&down_animation.animation);
  }

  use_upper_to_rect = !use_upper_to_rect;

}
Exemplo n.º 27
0
void handle_init(AppContextRef ctx) {

  window_init(&window, "Animation Demo");
  window_stack_push(&window, false);

  text_layer_init(&text_layer, GRect(0, 0, 60, 60));
  text_layer_set_text(&text_layer, "Text!");
  layer_add_child(&window.layer, &text_layer.layer);

  GRect to_rect = GRect(84, 92, 60, 60);

  property_animation_init_layer_frame(&prop_animation, &text_layer.layer, NULL, &to_rect);

  animation_schedule(&prop_animation.animation);
}
Exemplo n.º 28
0
static void animate(int duration, int delay, AnimationImplementation *implementation, bool handlers) {
  Animation *anim = animation_create();
  if(anim) {
    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);
  }
Exemplo n.º 29
0
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);
}
Exemplo n.º 30
0
/**
 * 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]);
}