2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <Elementary.h>
21 #include "livebox/livebox_animator.h"
23 #include "livebox/livebox_panel.h"
24 #include "homescreen-efl.h"
25 #include "page_scroller.h"
28 #define FRAME (1.0/30.0)
31 static Eina_Bool __livebox_animator_set_grid_frame(void *data, double pos);
32 static Eina_Bool __livebox_animator_set_geometry_frame(void *data, double pos);
33 static void __livebox_animator_create(Evas_Object *obj,
35 Ecore_Pos_Map map, float map_var_1, float map_var_2,
36 Eina_Rectangle *geometry_start, Eina_Rectangle *geometry_end,
38 Anim_Data_t **ad_out);
41 void livebox_animator_del_grid(Anim_Data_t **ad)
44 LOGE("(*ad) == NULL");
49 ecore_animator_del((*ad)->animator);
50 (*ad)->animator = NULL;
51 (*ad)->anim_is_running = false;
52 eina_rectangle_free((*ad)->geometry_start);
53 eina_rectangle_free((*ad)->geometry_end);
59 void livebox_animator_play_grid_pack_set(Evas_Object *obj,
61 Ecore_Pos_Map map, float map_var_1, float map_var_2,
62 Eina_Rectangle *geometry_start, Eina_Rectangle *geometry_end,
66 __livebox_animator_create(obj, anim_time, map, map_var_1, map_var_2,
67 geometry_start, geometry_end, on_end, ad_out);
70 LOGE("Failed to create animation");
74 (*ad_out)->animator = ecore_animator_timeline_add(anim_time,
75 __livebox_animator_set_grid_frame, ad_out);
77 if (!(*ad_out)->animator) {
78 LOGE("Failed to create animator");
79 livebox_animator_del_grid(ad_out);
84 void livebox_animator_play_geometry_set(Evas_Object *obj,
86 Ecore_Pos_Map map, float map_var_1, float map_var_2,
87 Eina_Rectangle *geometry_start, Eina_Rectangle *geometry_end,
91 __livebox_animator_create(obj, anim_time, map, map_var_1, map_var_2,
92 geometry_start, geometry_end, on_end, ad_out);
95 LOGE("Failed to create animation");
99 (*ad_out)->animator = ecore_animator_timeline_add(anim_time,
100 __livebox_animator_set_geometry_frame, ad_out);
102 if (!(*ad_out)->animator) {
103 LOGE("Failed to create animator");
104 livebox_animator_del_grid(ad_out);
109 static void __livebox_animator_create(Evas_Object *obj,
111 Ecore_Pos_Map map, float map_var_1, float map_var_2,
112 Eina_Rectangle *geometry_start, Eina_Rectangle *geometry_end,
113 Anim_Grid_End on_end,
114 Anim_Data_t **ad_out)
116 *ad_out = (Anim_Data_t *) calloc(1, sizeof(Anim_Data_t));
118 LOGE("Failed to allocate ad_out");
122 (*ad_out)->anim_time = anim_time;
123 (*ad_out)->obj = obj;
124 (*ad_out)->map = map;
125 (*ad_out)->map_var_1 = map_var_1;
126 (*ad_out)->map_var_2 = map_var_2;
127 (*ad_out)->geometry_start = geometry_start;
128 (*ad_out)->geometry_end = geometry_end;
129 (*ad_out)->on_end = on_end;
130 (*ad_out)->anim_is_running = true;
134 static Eina_Bool __livebox_animator_set_geometry_frame(void *data, double pos)
138 Anim_Data_t **ad = (Anim_Data_t **)data;
140 LOGE("(*ad) == NULL");
141 return ECORE_CALLBACK_CANCEL;
144 int xs = (*ad)->geometry_start->x;
145 int ys = (*ad)->geometry_start->y;
146 int ws = (*ad)->geometry_start->w;
147 int hs = (*ad)->geometry_start->h;
149 int xe = (*ad)->geometry_end->x;
150 int ye = (*ad)->geometry_end->y;
151 int we = (*ad)->geometry_end->w;
152 int he = (*ad)->geometry_end->h;
159 frame = ecore_animator_pos_map(pos, (*ad)->map, (*ad)->map_var_1,
162 evas_object_move((*ad)->obj, xs + xd * frame, ys + yd * frame);
163 evas_object_resize((*ad)->obj, ws + wd * frame, hs + hd * frame);
170 livebox_animator_del_grid(ad);
173 return ECORE_CALLBACK_CANCEL;
176 return ECORE_CALLBACK_RENEW;
180 static Eina_Bool __livebox_animator_set_grid_frame(void *data, double pos)
184 Anim_Data_t **ad = (Anim_Data_t **)data;
186 LOGE("(*ad) == NULL");
187 return ECORE_CALLBACK_CANCEL;
190 int xs = (*ad)->geometry_start->x;
191 int ys = (*ad)->geometry_start->y;
192 int ws = (*ad)->geometry_start->w;
193 int hs = (*ad)->geometry_start->h;
195 int xe = (*ad)->geometry_end->x;
196 int ye = (*ad)->geometry_end->y;
197 int we = (*ad)->geometry_end->w;
198 int he = (*ad)->geometry_end->h;
205 frame = ecore_animator_pos_map(pos, (*ad)->map, (*ad)->map_var_1,
208 elm_grid_pack_set((*ad)->obj,
220 livebox_animator_del_grid(ad);
223 return ECORE_CALLBACK_CANCEL;
226 return ECORE_CALLBACK_RENEW;