4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
25 #include <Elementary.h>
26 #include <ui-gadget-engine.h>
29 #include "ug-efl-engine.h"
33 #define UG_ENGINE_API __attribute__ ((visibility("default")))
38 void(*hide_end_cb)(ui_gadget_h ug);
42 static void _on_hideonly_cb(void *data, Evas_Object *obj)
44 ui_gadget_h ug = (ui_gadget_h)data;
48 if (ug->layout_state == UG_LAYOUT_SHOW) {
49 ug->layout_state = UG_LAYOUT_HIDEEFFECT;
50 edje_object_signal_emit(elm_layout_edje_get(ug->effect_layout),
51 "elm,state,hideonly", "");
55 static void _signal_hideonly_finished(void *data, Evas_Object *obj,
56 const char *emission, const char *source)
58 ui_gadget_h ug = (ui_gadget_h)data;
62 evas_object_intercept_hide_callback_del(ug->layout, _on_hideonly_cb);
64 evas_object_hide(ug->layout);
65 elm_object_part_content_unset(ug->effect_layout, "elm.swallow.content");
67 if (ug->layout_state == UG_LAYOUT_NOEFFECT)
70 evas_object_hide(ug->effect_layout);
72 if (ug->layout_state == UG_LAYOUT_DESTROY)
73 edje_object_signal_emit(elm_layout_edje_get(ug->effect_layout),
74 "elm,state,hidealready", "");
76 ug->layout_state = UG_LAYOUT_HIDE;
79 static void _del_effect_layout(ui_gadget_h ug)
81 if (!ug || !ug->effect_layout)
84 evas_object_intercept_hide_callback_del(ug->layout, _on_hideonly_cb);
86 evas_object_hide(ug->layout);
87 elm_object_part_content_unset(ug->effect_layout, "elm.swallow.content");
88 evas_object_hide(ug->effect_layout);
89 evas_object_del(ug->effect_layout);
90 ug->effect_layout = NULL;
93 static void _signal_hide_finished(void *data, Evas_Object *obj,
94 const char *emission, const char *source)
96 struct cb_data *cb_d = (struct cb_data*)data;
101 ui_gadget_h ug = cb_d->ug;
103 _del_effect_layout(ug);
104 cb_d->hide_end_cb(ug);
108 static void _signal_hidealready_finished(void *data, Evas_Object *obj,
109 const char *emission, const char *source)
111 struct cb_data *cb_d = (struct cb_data*)data;
116 ui_gadget_h ug = cb_d->ug;
118 _del_effect_layout(ug);
119 cb_d->hide_end_cb(ug);
123 static void _do_destroy(ui_gadget_h ug, ui_gadget_h fv_top)
127 static int depth = 0;
130 child = ug->children;
132 trail = g_slist_next(child);
134 _do_destroy(child->data, fv_top);
140 _DBG("[UG Effect Plug-in] : start destroy. ug(%p), fv_top(%p),"
141 " depth(%d), layout_state(%d)\n",
142 ug, fv_top, depth, ug->layout_state);
144 /* fv_top is null while destroying frameview ug */
145 if (fv_top == NULL) {
146 _del_effect_layout(ug);
149 /* only show transition effect of top view UG */
152 _del_effect_layout(ug);
157 if (ug->layout_state == UG_LAYOUT_SHOW) {
158 evas_object_intercept_hide_callback_del(ug->layout,
160 edje_object_signal_emit(elm_layout_edje_get(ug->effect_layout),
161 "elm,state,hide", "");
162 } else if (ug->layout_state == UG_LAYOUT_HIDE
163 || ug->layout_state == UG_LAYOUT_NOEFFECT) {
164 edje_object_signal_emit(elm_layout_edje_get(ug->effect_layout),
165 "elm,state,hidealready", "");
166 } else if (ug->layout_state == UG_LAYOUT_HIDEEFFECT
167 || ug->layout_state == UG_LAYOUT_SHOWEFFECT) {
168 ug->layout_state = UG_LAYOUT_DESTROY;
170 _ERR("[UG Effect Plug-in] : layout state error!!");
174 static void on_destroy(ui_gadget_h ug, ui_gadget_h fv_top)
178 _do_destroy(ug, fv_top);
181 static void _signal_show_finished(void *data, Evas_Object *obj,
182 const char *emission, const char *source)
184 ui_gadget_h ug = (ui_gadget_h )data;
188 if (ug->layout_state == UG_LAYOUT_NOEFFECT)
191 if (ug->layout_state == UG_LAYOUT_DESTROY)
192 edje_object_signal_emit(elm_layout_edje_get(ug->effect_layout),
193 "elm,state,hide", "");
195 ug->layout_state = UG_LAYOUT_SHOW;
198 static void on_show_cb(void *data, Evas *e, Evas_Object *obj,
201 ui_gadget_h ug = (ui_gadget_h )data;
205 if (ug->layout_state == UG_LAYOUT_NOEFFECT) {
206 evas_object_hide(ug->effect_layout);
207 evas_object_show(ug->layout);
211 if (ug->layout_state == UG_LAYOUT_HIDE
212 || ug->layout_state == UG_LAYOUT_INIT) {
213 ug->layout_state = UG_LAYOUT_SHOWEFFECT;
214 evas_object_show(ug->effect_layout);
215 elm_object_part_content_set(ug->effect_layout, "elm.swallow.content",
217 evas_object_intercept_hide_callback_add(ug->layout,
218 _on_hideonly_cb, ug);
219 edje_object_signal_emit(elm_layout_edje_get(ug->effect_layout),
220 "elm,state,show", "");
224 static void *on_create(void *win, ui_gadget_h ug,
225 void (*hide_end_cb) (ui_gadget_h ug))
227 static const char *ug_effect_edj_name = "/usr/share/edje/ug_effect.edj";
228 struct cb_data *cb_d;
230 Evas_Object *ly = elm_layout_add((Evas_Object *) win);
235 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND,
237 elm_win_resize_object_add((Evas_Object *) win, ly);
238 elm_layout_file_set(ly, ug_effect_edj_name, "ug_effect");
239 evas_object_show(ly);
241 evas_object_hide(ug->layout);
243 cb_d = calloc(1, sizeof(struct cb_data));
245 cb_d->hide_end_cb = hide_end_cb;
247 edje_object_signal_callback_add(elm_layout_edje_get(ly),
248 "elm,action,hide,finished", "",
249 _signal_hide_finished, cb_d);
250 edje_object_signal_callback_add(elm_layout_edje_get(ly),
251 "elm,action,hidealready,finished", "",
252 _signal_hidealready_finished, cb_d);
253 edje_object_signal_callback_add(elm_layout_edje_get(ly),
254 "elm,action,hideonly,finished", "",
255 _signal_hideonly_finished, ug);
256 edje_object_signal_callback_add(elm_layout_edje_get(ly),
257 "elm,action,show,finished", "",
258 _signal_show_finished, ug);
260 evas_object_event_callback_add(ug->layout, EVAS_CALLBACK_SHOW,
263 ug->layout_state = UG_LAYOUT_INIT;
268 UG_ENGINE_API int UG_ENGINE_INIT(struct ug_engine_ops *ops)
273 ops->create = on_create;
274 ops->destroy = on_destroy;
279 UG_ENGINE_API void UG_ENGINE_EXIT(struct ug_engine_ops *ops)