4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@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.
27 #include <sys/types.h>
36 #include <Elementary.h>
39 #include <animation.h>
45 static struct animation {
58 static void win_del(void *data, Evas_Object * obj, void *event_info)
60 _D("Window delete event received");
64 static Eina_Bool _end_cb(void *data)
66 _D("_end_cb is invoked");
67 printf("_end_cb is invoked\n");
68 if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0)
69 _E("Failed to set finished set");
71 return ECORE_CALLBACK_CANCEL;
74 static void _edje_cb(void *d, Evas_Object * obj, const char *e, const char *s)
76 _D("edje callback is invoked");
78 if (s_animation.state == TYPE_OFF || s_animation.state == TYPE_OFF_WITH_MSG) {
80 if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0)
81 _E("Failed to set finished set");
82 if (s_animation.txt) {
86 evas_object_size_hint_weight_set(s_animation.txt,
89 evas_object_size_hint_fill_set(s_animation.txt,
92 evas_object_resize(s_animation.txt, s_animation.w,
94 evas_object_color_set(s_animation.txt, 255, 255, 255,
96 evas_object_text_font_set(s_animation.txt,
97 "SLP:style=medium", 30);
98 evas_object_geometry_get(s_animation.txt, NULL, NULL,
100 evas_object_move(s_animation.txt,
101 (s_animation.w - w) >> 1,
102 (s_animation.h - h) >> 1);
103 evas_object_show(s_animation.txt);
105 ecore_timer_add(1, _end_cb, NULL);
111 #define DEFAULT_W 480
112 static void layout_file_set(int state)
114 _D("Layout file set according to resolution");
115 _D("Screen Width: %d, DEFAULT_WIDTH: %d", s_animation.w, DEFAULT_W);
117 if (s_animation.w < DEFAULT_W) {
118 if (state == TYPE_ON) {
119 _D("Set file: %s", WEARABLE_EDJ_ON);
120 elm_layout_file_set(s_animation.layout, WEARABLE_EDJ_ON, GRP_ON);
122 _D("Set file: %s", WEARABLE_EDJ_OFF);
123 elm_layout_file_set(s_animation.layout, WEARABLE_EDJ_OFF, GRP_OFF);
125 } else if (s_animation.w > DEFAULT_W) {
126 if (state == TYPE_ON) {
127 _D("Set file: %s", MOBILE_EDJ_ON);
128 elm_layout_file_set(s_animation.layout, MOBILE_EDJ_ON, GRP_ON);
130 _D("Set file: %s", MOBILE_EDJ_OFF);
131 elm_layout_file_set(s_animation.layout, MOBILE_EDJ_OFF, GRP_OFF);
134 if (state == TYPE_ON) {
135 _D("Set file: %s", DEFAULT_EDJ_ON);
136 elm_layout_file_set(s_animation.layout, DEFAULT_EDJ_ON, GRP_ON);
138 _D("Set file: %s", DEFAULT_EDJ_OFF);
139 elm_layout_file_set(s_animation.layout, DEFAULT_EDJ_OFF, GRP_OFF);
144 static int init_layout(const char *msg)
146 s_animation.layout = elm_layout_add(s_animation.win);
147 if (!s_animation.layout) {
148 _E("Failed to create layout");
152 layout_file_set(s_animation.state);
154 evas_object_size_hint_weight_set(s_animation.layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
155 _D("[Boot-ani] Start animation: %d mode", s_animation.state);
156 elm_win_resize_object_add(s_animation.win, s_animation.layout);
157 edje_object_signal_callback_add(elm_layout_edje_get(s_animation.layout), "end", "animation", _edje_cb, NULL);
158 evas_object_show(s_animation.layout);
161 if (!s_animation.txt) {
162 s_animation.txt = evas_object_text_add(s_animation.evas);
163 if (!s_animation.txt) {
164 _E("Failed to add text");
165 evas_object_del(s_animation.layout);
170 evas_object_text_text_set(s_animation.txt, msg);
171 evas_object_hide(s_animation.txt);
177 static void fini_layout(void)
179 if (s_animation.layout) {
180 evas_object_del(s_animation.layout);
183 if (s_animation.txt) {
184 evas_object_del(s_animation.txt);
185 s_animation.txt = NULL;
189 static int create_window(void)
192 printf("Create Window\n");
196 s_animation.win = elm_win_add(NULL, "BOOT_ANIMATION", ELM_WIN_NOTIFICATION);
197 elm_win_role_set(s_animation.win, "alert");
198 if (!s_animation.win) {
199 _E("Failed to create a new window");
200 printf("Failed to create a new window\n");
203 if (s_animation.state == TYPE_OFF || s_animation.state == TYPE_OFF_WITH_MSG) {
204 _D("We are turning off the Tizen");
205 elm_win_alpha_set(s_animation.win, EINA_TRUE);
207 evas_object_smart_callback_add(s_animation.win, "delete-request", win_del, NULL);
209 s_animation.evas = evas_object_evas_get(s_animation.win);
210 if (!s_animation.evas) {
211 evas_object_del(s_animation.win);
212 _E("Failed to get the evas object");
215 elm_win_screen_size_get(s_animation.win, &x, &y, &s_animation.w, &s_animation.h);
216 _D("Window size is x: %d, y: %d, w: %d, h: %d", x, y, s_animation.w, s_animation.h);
217 elm_win_borderless_set(s_animation.win, 1);
218 elm_win_indicator_mode_set(s_animation.win, ELM_WIN_INDICATOR_HIDE);
219 evas_object_move(s_animation.win, 0, 0);
221 if (s_animation.w > s_animation.h) {
223 elm_win_rotation_with_resize_set(s_animation.win, 90);
224 /* Update geometry infomration */
226 s_animation.w = s_animation.h;
230 evas_object_show(s_animation.win);
232 s_animation.ee = ecore_evas_ecore_evas_get(s_animation.evas);
233 if (!s_animation.ee) {
234 evas_object_del(s_animation.win);
235 _E("Failed to get the ecore evas object");
242 int init_animation(int state, const char *msg)
244 _D("Init animation");
245 printf("Init animation\n");
247 Ecore_Timer *timer = NULL;
249 s_animation.state = state;
251 if (create_window() == EXIT_FAILURE) {
252 _E("Failed to create a new window");
253 printf("Failed to create a new window\n");
257 if (init_layout(msg) == EXIT_FAILURE) {
258 _E("Failed to init the layout object");
260 evas_object_del(s_animation.txt);
262 evas_object_del(s_animation.win);
268 int fini_animation(void)
271 evas_object_del(s_animation.win);