示例#1
0
文件: layer.c 项目: Helco/PLocalSim
void layer_set_frame(Layer *layer, GRect frame) {
    if (!grect_equal(&layer->frame,&frame)) {
        layer->frame = frame;
        //extend bounds
        if (layer->bounds.origin.x+layer->bounds.size.w<layer->frame.size.w)
            layer->bounds.size.w=layer->frame.size.w-layer->bounds.origin.x;
        if (layer->bounds.origin.y+layer->bounds.size.h<layer->frame.size.h)
            layer->bounds.size.h=layer->frame.size.h-layer->bounds.origin.y;
        layer_mark_dirty (layer);
    }
}
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);
示例#3
0
GBitmap* bitmaps_get_sub_bitmap(uint32_t res_id, GRect rect) {
  if (! bitmaps) {
    return NULL;
  }
  GBitmap* parent = NULL;
  uint8_t count = linked_list_count(bitmaps);
  for (uint8_t b = 0; b < count; b += 1) {
    AppBitmap* bmp = (AppBitmap*)linked_list_get(bitmaps, b);
    if (bmp->res_id == res_id) {
      if (bmp->is_sub) {
        if (grect_equal(bmp->rect, &rect)) {
          return bmp->bitmap;
        }
      }
      else {
        parent = bmp->bitmap;
      }
    }
  }
  if (! parent) {
    parent = bitmaps_get_bitmap(res_id);
    if (! parent) {
      return NULL;
    }
  }
  AppBitmap* app_bmp = malloc(sizeof(AppBitmap));
  if (app_bmp == NULL) {
    return NULL;
  }
  app_bmp->res_id = res_id;
  app_bmp->bitmap = gbitmap_create_as_sub_bitmap(parent, rect);
  if (app_bmp->bitmap == NULL) {
    return NULL;
  }
  app_bmp->rect = malloc(sizeof(GRect));
  app_bmp->rect->origin = rect.origin;
  app_bmp->rect->size = rect.size;
  app_bmp->is_sub = true;
  linked_list_append(bitmaps, app_bmp);
  return app_bmp->bitmap;
}
示例#4
0
文件: layer.c 项目: Helco/PLocalSim
void layer_set_bounds(Layer *layer, GRect bounds) {
    if (!grect_equal(&layer->bounds,&bounds)) {
        layer->bounds = bounds;
        layer_mark_dirty(layer);
    }
}