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.
19 #ifdef ENABLE_CAPTURE_ANIMATION
20 #include "cam_animation.h"
21 #include "camera_utils.h"
23 static void __cam_app_shutter_animation_finished(void *data, Evas_Object *obj,
27 cam_debug(LOG_MM, " __cam_app_shutter_animation_finished \n\n ");
28 struct appdata *ad = (struct appdata *)data;
29 // edje_object_signal_emit(_EDJ(ad->shutter_screen), "bright", "");
30 DEL_EVAS_OBJECT(ad->shutter_screen);
31 DEL_EVAS_OBJECT(ad->rect_image);
33 ad->is_capture_animation_processing = FALSE;
36 static void __cam_animation_get_preview_coordinate_by_direction(int *preview_offset_x,
37 int *preview_offset_y,
42 struct appdata *ad = (struct appdata *)data;
43 cam_retm_if(ad == NULL, "appdata is NULL");
44 switch (ad->target_direction) {
45 case CAM_TARGET_DIRECTION_LANDSCAPE:
46 case CAM_TARGET_DIRECTION_LANDSCAPE_INVERSE:
47 *preview_offset_x = ad->preview_offset_x;
48 *preview_offset_y = ad->preview_offset_y;
49 *preview_w = ad->preview_w;
50 *preview_h = ad->preview_h;
52 case CAM_TARGET_DIRECTION_PORTRAIT:
53 case CAM_TARGET_DIRECTION_PORTRAIT_INVERSE:
54 *preview_offset_x = ad->preview_offset_y;
55 *preview_offset_y = ad->preview_offset_x;
56 *preview_w = ad->preview_h;
57 *preview_h = ad->preview_w;
60 DEBUG_TRACE("reached unable reached codes. error");
64 void cam_animation_create_rect_image(void *data)
66 struct appdata *ad = data;
67 Evas_Coord witdh = 0, height = 0;
69 char *group_name = "shutter_rect";
71 DEL_EVAS_OBJECT(ad->rect_image);
73 ad->rect_image = cam_app_load_edj(ad->ug_base, CAM_MAIN_LAYOUT_EDJ_NAME, group_name);
74 cam_retm_if(ad->rect_image == NULL, "rect_image load failed");
76 ecore_x_window_size_get(ad->main_xid, &witdh, &height);
77 evas_object_resize(ad->rect_image, witdh, height);
78 edje_object_signal_callback_add(_EDJ(ad->rect_image),
79 "shutter_rect,finish", "*",
80 __cam_app_shutter_animation_finished,
86 Eina_Bool cam_start_capture_animation(void *data)
88 cam_debug(LOG_MM, " cam_start_capture_animation \n\n ");
90 struct appdata *ad = (struct appdata *)data;
91 CamAppData *camapp = NULL;
93 Evas_Coord x, y, w, h;
96 int window_width, window_height;
97 int pre_width, pre_height;
100 cam_retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "appdata is NULL");
101 camapp = ad->camapp_handle;
102 cam_retvm_if(camapp == NULL, ECORE_CALLBACK_CANCEL, "camapp_handle is NULL");
104 window_width = ad->win_width;
105 window_height = ad->win_height;
106 pre_width = ad->preview_w;
107 pre_height = ad->preview_h;
109 __cam_animation_get_preview_coordinate_by_direction(&pre_x, &pre_y, &pre_width, &pre_height, ad);
110 if (ad->preview_w <= ad->win_width) {
111 ad->shutter_src_rect.x = pre_x;
112 ad->shutter_src_rect.width = pre_width;
114 ad->shutter_src_rect.x = 0;
115 ad->shutter_src_rect.width = pre_width;
118 if (ad->preview_h <= ad->win_height) {
119 ad->shutter_src_rect.y = pre_y;
120 ad->shutter_src_rect.height = pre_height;
122 ad->shutter_src_rect.y = 0;
123 ad->shutter_src_rect.height = pre_height;
126 ad->shutter_des_rect.x = ad->shutter_src_rect.x;
127 ad->shutter_des_rect.y = y ;
128 ad->shutter_des_rect.width = w;
129 ad->shutter_des_rect.height = h;
131 evas_object_stack_above(ad->rect_image, ad->shutter_screen);
132 evas_object_resize(ad->rect_image, ad->shutter_src_rect.width, ad->shutter_src_rect.height);
133 evas_object_move(ad->rect_image, ad->shutter_src_rect.x, ad->shutter_src_rect.y);
134 evas_object_show(ad->rect_image);
135 edje_object_signal_emit(_EDJ(ad->rect_image), "shutter_rect,start", "prog");
140 gboolean cam_app_create_start_animation(void *data)
142 struct appdata *ad = (struct appdata *)data;
143 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
145 ad->is_capture_animation_processing = TRUE;
147 cam_app_create_shutter_screen(ad);
148 cam_animation_create_rect_image(ad);
149 cam_start_capture_animation(ad);
154 gboolean cam_app_create_screennail_and_start_animation(void *user_data)
156 struct appdata *ad = (struct appdata *)user_data;
157 cam_retvm_if(ad == NULL, FALSE, "appdata is NULL");
158 #if 1/*note: using pipe handle*/
159 cam_utils_request_main_pipe_handler(ad, NULL, CAM_MAIN_PIPE_OP_TYPE_SHUTTER_ANIMATION);
161 cam_app_create_start_animation(ad);
166 gboolean cam_app_create_shutter_screen(void *data)
168 struct appdata *ad = data;
169 Evas_Coord witdh = 0, height = 0;
171 char *group_name = "shutter_image";
173 DEL_EVAS_OBJECT(ad->shutter_screen);
175 ad->shutter_screen = cam_app_load_edj(ad->ug_base, CAM_MAIN_LAYOUT_EDJ_NAME, group_name);
176 if (ad->shutter_screen == NULL) {
177 cam_critical(LOG_UI, "shutter_screen load failed ");
181 ecore_x_window_size_get(ad->main_xid, &witdh, &height);
182 evas_object_resize(ad->shutter_screen, witdh, height);
184 /*evas_object_lower(ad->shutter_screen);*/
185 evas_object_show(ad->shutter_screen);
186 evas_object_show(ad->win_main);
188 /*edje_object_signal_emit(_EDJ(ad->shutter_screen), "start_animation", "");*/
190 edje_object_signal_callback_add(_EDJ(ad->shutter_screen),
191 "animation_finish", "*",
192 __cam_app_shutter_animation_finished,