Exemplo n.º 1
0
void destroy_animations()
{
	//unschedule any previous animation
	animation_unschedule((Animation*)back_animation_old);
	animation_unschedule((Animation*)back_animation_new);
	animation_unschedule((Animation*)card_animation_old);
	animation_unschedule((Animation*)card_animation_new);
	animation_unschedule((Animation*)expanded_animation);
	
	//destroy memory used for previous animation
	if(back_animation_old != NULL)
		property_animation_destroy(back_animation_old);
	if(back_animation_new != NULL)
		property_animation_destroy(back_animation_new);
	if(card_animation_old != NULL)
		property_animation_destroy(card_animation_old);
	if(card_animation_new != NULL)
		property_animation_destroy(card_animation_new);
	if(expanded_animation != NULL)
		property_animation_destroy(expanded_animation);
	
	//make NULL to avoid redestroying memory
	back_animation_old = NULL;
	back_animation_new = NULL;
	card_animation_old = NULL;
	card_animation_new = NULL;
	expanded_animation = NULL;
}
Exemplo n.º 2
0
static void deinit(void) {
  property_animation_destroy(up_animation);
  property_animation_destroy(down_animation);

  text_layer_destroy(text_time_layer);
  window_destroy(window);
}
Exemplo n.º 3
0
void handle_deinit()
{
    tick_timer_service_unsubscribe();

    animation_unschedule_all();

    property_animation_destroy(mario_animation_beg);
    property_animation_destroy(mario_animation_end);
    property_animation_destroy(block_animation_beg);
    property_animation_destroy(block_animation_end);
    property_animation_destroy(hour_animation_slide_in);
    property_animation_destroy(hour_animation_slide_away);
    property_animation_destroy(minute_animation_slide_in);
    property_animation_destroy(minute_animation_slide_away);

    gbitmap_destroy(mario_normal_bmp);
    gbitmap_destroy(mario_jump_bmp);
    gbitmap_destroy(ground_bmp);

    text_layer_destroy(date_layer);
    text_layer_destroy(text_minute_layer);
    text_layer_destroy(text_hour_layer);

    layer_destroy(ground_layer);
    layer_destroy(mario_layer);
    layer_destroy(blocks_layer);

    window_destroy(window);
}
Exemplo n.º 4
0
void on_animation_stopped_callback(Animation *anim, bool finished, void *context) {
	#ifdef PBL_SDK_2
		property_animation_destroy((PropertyAnimation*) anim);
		anim = NULL;
	#endif
	animation_control();
}
Exemplo n.º 5
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.º 6
0
static void anim_stopped_handler(Animation *animation, bool finished, void *context) {
#ifdef PBL_SDK_2
  if (prop_anim) property_animation_destroy(prop_anim);
	prop_anim = NULL;
#endif
animation_is_ongoing = false;	
}
Exemplo n.º 7
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.º 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
// Event for when the animation of the old device being switched away from finishes
static void devicecard_anim_old_stopped(Animation *animation, bool finished, void *context) {
  if (s_devicecard_layer_old != NULL) {
    layer_remove_from_parent(s_devicecard_layer_old->layer);
    devicecard_layer_destroy(s_devicecard_layer_old);
    s_devicecard_layer_old = NULL;
  }
  property_animation_destroy((PropertyAnimation*)animation);
}
Exemplo n.º 10
0
void animation_sunmoon_stopped(Animation *animation, bool finished, void *data) {
   
  #ifdef PBL_COLOR
    // Do nothing, Basalt does this automagically
  #else  
    property_animation_destroy((PropertyAnimation*) animation);
  #endif
}
Exemplo n.º 11
0
void animation_ufo_stopped(Animation *animation, bool finished, void *data) {
   
  layer_set_hidden((Layer *)s_ufo_layer, true);
  
  #ifdef PBL_COLOR
    // Do nothing, Basalt does this automagically
  #else  
    property_animation_destroy((PropertyAnimation*) animation);
  #endif
}
Exemplo n.º 12
0
void scroll_layer_destroy (ScrollLayer* l) {
    if (l!=0) {
        SCROLL_GET;
        if (scroll->animation)
            property_animation_destroy(scroll->animation);
        layer_destroy(scroll->content_sublayer);
        layer_destroy(scroll->shadow_sublayer);
        layer_destroy(scroll_layer);
    }
}
Exemplo n.º 13
0
static void animation_stopped(PropertyAnimation *animation, bool finished, void *data) {
#ifdef PBL_SDK_2  
  property_animation_destroy(animation);
#endif
  animation_finished=true;
  layer_set_frame(text_layer_get_layer(description_layer),GRect(0, TEXT_OFFSET_Y, 5*SCREEN_WIDTH, 24));
#ifdef PBL_ROUND
  layer_set_hidden(text_layer_get_layer(description_layer), true);
#endif
}
Exemplo n.º 14
0
//Animation
static void anim_stopped_handler(Animation *animation, bool finished, void *context) {
#ifdef PBL_SDK_2
  // Free the animation only on SDK 2.x
  property_animation_destroy(s_box_animation);
#endif

  // Schedule the next one, unless the app is exiting
  if (finished) {
    next_animation();
  }
}
Exemplo n.º 15
0
void destroy_property_animation(PropertyAnimation **animation) {
	if (*animation == NULL)
		return;
	if (animation_is_scheduled((Animation*) *animation))
		animation_unschedule((Animation*) *animation);
	// can happen if there is a stop handler which destroys the animation
	if (*animation == NULL)
		return;
	property_animation_destroy(*animation);
	*animation = NULL;
}
Exemplo n.º 16
0
void destroy_property_animation(PropertyAnimation **prop_animation) {
    if (*prop_animation == NULL) {
        return;
    }

    if (animation_is_scheduled((Animation*) *prop_animation)) {
        animation_unschedule((Animation*) *prop_animation);
    }

    property_animation_destroy(*prop_animation);
    *prop_animation = NULL;
}
Exemplo n.º 17
0
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);
Exemplo n.º 18
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]);
}
Exemplo n.º 19
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);
Exemplo n.º 20
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;
}
Exemplo n.º 21
0
/**
 * create propertyanimation
 */
void ca_initialize(animationchain* self, TextLayer* layer, char* text, enum animationdirection dir, int duration, int delay) {

   // check previous animations
   if (self->prop != NULL) {
      property_animation_destroy(self->prop);
   }

	// set the rects
   GRect  frame  = layer_get_frame((Layer*)layer);
   
   ca_calc_rect(frame, self, dir);

	strcpy (self->textbuffer, text); // to avoid static vars all the time
   APP_LOG(APP_LOG_LEVEL_DEBUG, "initialized with %s", self->textbuffer);
   self->layer = layer;
   
   self->prop = property_animation_create_layer_frame((Layer*)layer, &self->from, &self->to);
   
   // set handler
   animation_set_handlers((Animation*) self->prop, (AnimationHandlers) {
       .started = (AnimationStartedHandler) ca_started,
       .stopped = NULL
     }, self);
Exemplo n.º 22
0
static void anim_stopped_handler(Animation *animation, bool finished, void *context) {
  // Free the animation
#ifdef PBL_PLATFORM_APLITE   
  property_animation_destroy((PropertyAnimation*)animation);
#endif
}
Exemplo n.º 23
0
// Event for when the animation of the new device being switched in finishes
static void devicecard_anim_new_stopped(Animation *animation, bool finished, void *context) {
  property_animation_destroy((PropertyAnimation*)animation);
}
static void anim_stopped_handler(Animation *animation, bool finished, void *context) {
    property_animation_destroy(s_property_animation);
    s_property_animation = NULL;
}
// Function to clean up our program -- keeping our main() block clean!
// This is so small that it *could* fit into our main() block,
//  but having a dedicated deinit() function is a good habit for when
//  more complex programs need to deinitialize multiple objects.
// It also pairs nicely with the init() function.
void deinit(void) {
    tick_timer_service_unsubscribe();
    property_animation_destroy(inverter_animation);
    inverter_layer_destroy(inverter_layer);
    text_layer_destroy(text_time_layer);
}
Exemplo n.º 26
0
static void animation_stopped_handler(Animation* animation, bool finished, void *context) {
  property_animation_destroy((PropertyAnimation*)animation);
}
Exemplo n.º 27
0
static void anim_stop_destroy(Animation *animation, bool finished, void *context) {
  // Free
  property_animation_destroy((PropertyAnimation*)animation);
}
Exemplo n.º 28
0
void clear_animations() {
    for (int i=0; i<FRAME_COUNT; i++) property_animation_destroy(bolt_animation[i]);
    property_animation_destroy(explosion_animation);
}