backend: add default clear animations
[platform/core/uifw/libpui.git] / backends / default_backend.c
index 7c7f6c9..789e0f9 100644 (file)
@@ -359,6 +359,46 @@ _find_directory(const char *path, Eina_List **json_list)
        return count;
 }
 
+default_ani_info *
+_create_default_ani_info(char *type)
+{
+       default_ani_info *ani_info = NULL;
+       int frame_len = 1;
+       int led_len = 12;
+
+       ani_info = (default_ani_info *)calloc(1, sizeof(default_ani_info));
+       ERROR_CHECK(ani_info, goto error, "Failed to alloc for animation info\n");
+
+       ani_info->id = strndup(type, strlen(type));
+       ani_info->interval = 50;
+
+       ani_info->num_key_frames = frame_len;
+       ani_info->frames = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), frame_len);
+       ERROR_CHECK(ani_info->frames, goto error, "Failed to alloc for default_frame_info_t\n");
+
+       ani_info->frames[0].frame_duration = 500;
+       ani_info->frames[0].num_led = led_len;
+       ani_info->max_leds = led_len;
+       ani_info->frames[0].leds = (default_led_info_t *)calloc(sizeof(default_led_info_t), led_len);
+       ERROR_CHECK(ani_info->frames[0].leds, goto error, "Failed to alloc for default_led_info_t\n");
+
+       return ani_info;
+
+error:
+       if (ani_info) {
+               if (ani_info->frames) {
+                       for (int i = 0; i < ani_info->num_key_frames; i++) {
+                               if (ani_info->frames[i].leds)
+                                       free(ani_info->frames[i].leds);
+                       }
+                       free(ani_info->frames);
+               }
+               free(ani_info->id);
+               free(ani_info);
+       }
+       return NULL;
+}
+
 
 pui_int_error
 _create_ani_collection(void)
@@ -373,6 +413,8 @@ _create_ani_collection(void)
 
        _find_directory(ANI_COLLECTION_DIR, &json_list);
 
+       pui_err("Start create ani collect...\n");
+
        EINA_LIST_FOREACH_SAFE(json_list, l, l_next, path)
        {
                ani_info = _read_json(path);
@@ -385,6 +427,18 @@ _create_ani_collection(void)
        }
 
        //TODO
+       ani_info = _create_default_ani_info("default/clear_fadeout");
+       if (ani_info) {
+               eina_hash_add(_animations_hash, ani_info->id, ani_info);
+               pui_err("Success to load default animation (id: %s)\n", ani_info->id);
+       }
+       ani_info = _create_default_ani_info("default/clear_immediate");
+       if (ani_info) {
+               eina_hash_add(_animations_hash, ani_info->id, ani_info);
+               pui_err("Success to load default animation (id: %s)\n", ani_info->id);
+       }
+
+       pui_err("End create ani collect...\n");
 
        return e;
 }
@@ -553,6 +607,14 @@ _ani_create(pui_id id)
        {
                pui_default_backend_ani_connected_func_set(ani_func);
        }
+       else if (!strncmp(ani_info->id, "default/clear_fadeout", sizeof("default/clear_fadeout")))
+       {
+               pui_default_backend_ani_clear_fadeout_func_set(ani_func);
+       }
+       else if (!strncmp(ani_info->id, "default/clear_immediate", sizeof("default/clear_immediate")))
+       {
+               pui_default_backend_ani_clear_immediate_func_set(ani_func);
+       }
        else
        {
                pui_info("%s animation has no animation handler, using default handler\n", ani_info->id);