4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@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.
21 #include <setting-display-smart-screen-smart-rotation.h>
24 static int setting_display_smart_screen_smart_rotation_create(void *cb);
25 static int setting_display_smart_screen_smart_rotation_destroy(void *cb);
26 static int setting_display_smart_screen_smart_rotation_update(void *cb);
27 static int setting_display_smart_screen_smart_rotation_cleanup(void *cb);
29 setting_view setting_view_display_smart_screen_smart_rotation = {
30 .create = setting_display_smart_screen_smart_rotation_create,
31 .destroy = setting_display_smart_screen_smart_rotation_destroy,
32 .update = setting_display_smart_screen_smart_rotation_update,
33 .cleanup = setting_display_smart_screen_smart_rotation_cleanup,
36 static int setting_display_smart_screen_smart_rotation_create(void *cb)
40 setting_retvm_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "cb is NULL");
41 SettingDisplayUG *ad = (SettingDisplayUG *) cb;
43 Elm_Object_Item *nav_item = NULL;
44 Evas_Object *sub_layout = elm_layout_add(ad->win_main_layout);
45 elm_layout_file_set(sub_layout, SETTING_THEME_EDJ_NAME, "smart_tryit");
47 edje_object_part_text_set(_EDJ(sub_layout), "top_popup.text", _(KeyStr_Smart_Top_Popup_Text));
48 Evas_Object *smart_icon = setting_create_image(sub_layout, IMG_SMART_SCREEN_ICON);
49 elm_object_part_content_set(sub_layout, "smart_icon", smart_icon);
50 /*elm_object_signal_emit(sub_layout,"elm,state,top,show","elm"); */
52 edje_object_part_text_set(_EDJ(sub_layout), "center_popup.text", _(KeyStr_Smart_Rotation_Center_Popup_Text));
53 ad->smart_rotation_sublayout = sub_layout;
54 Evas_Object *scroller = elm_scroller_add(sub_layout);
55 elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_TRUE);
57 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
58 evas_object_show(scroller);
59 elm_object_part_content_set(ad->smart_rotation_sublayout, "bg_swallow", scroller);
62 ad->smart_rotation_image = evas_object_image_add(ad->evas);
65 app_device_orientation_e m = elm_win_rotation_get(ad->win_get);
66 if (APP_DEVICE_ORIENTATION_90 == m || APP_DEVICE_ORIENTATION_270 == m) {
67 /*ecore_x_window_size_get(ecore_x_window_root_first_get(), &h, &w); */
68 h = SAMRT_SCREEN_TRY_IT_IAMGE_LANDSCAPE_H;
69 w = SAMRT_SCREEN_TRY_IT_IAMGE_LANDSCAPE_W;
71 evas_object_image_file_set(ad->smart_rotation_image, SMART_SCREEN_TRY_IT_IMAGE_L, NULL);
74 /*ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h); */
75 h = SAMRT_SCREEN_TRY_IT_IAMGE_PORTRAIT_H;
76 w = SAMRT_SCREEN_TRY_IT_IAMGE_PORTRAIT_W;
77 evas_object_image_file_set(ad->smart_rotation_image, SMART_SCREEN_TRY_IT_IMAGE_P, NULL);
81 /*evas_object_image_load_size_set(palm_start_image, ad->original_img_w, h); */
82 evas_object_size_hint_weight_set(ad->smart_rotation_image, 0.0, EVAS_HINT_EXPAND);
83 evas_object_image_fill_set(ad->smart_rotation_image, 0, 0, w, h);
84 evas_object_image_border_set(ad->smart_rotation_image, 16, 16, 16, 16); /*for round corner */
85 evas_object_image_filled_set(ad->smart_rotation_image, 1); /*to full fill */
86 evas_object_size_hint_min_set(ad->smart_rotation_image, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h));
87 evas_object_size_hint_max_set(ad->smart_rotation_image, w, h);
89 elm_object_part_content_set(ad->smart_rotation_sublayout, "bg_swallow", scroller);
90 elm_object_content_set(scroller, ad->smart_rotation_image);
92 /*setting_resize_object(ad->smart_rotation_image, w, h); */
93 elm_scroller_region_bring_in(scroller, 0, 0, 0, 0);
94 setting_disable_evas_object(scroller);
96 if (ad->view_to_load == &setting_view_display_smart_screen_smart_rotation) {
97 ad->ly_main = setting_create_layout_navi_bar(ad->win_main_layout, ad->win_get,
102 __setting_display_smart_screen_smart_rotation_click_softkey_back_cb,
104 ad, sub_layout, &ad->navi_bar, NULL);
105 nav_item = elm_naviframe_top_item_get(ad->navi_bar);
107 nav_item = setting_push_layout_navi_bar(NULL,
111 __setting_display_smart_screen_smart_rotation_click_softkey_back_cb,
113 NULL, ad, sub_layout, ad->navi_bar, NULL);
115 elm_naviframe_item_pop_cb_set(nav_item, (Elm_Naviframe_Item_Pop_Cb)__setting_display_smart_screen_smart_rotation_click_softkey_back_cb, ad);
116 elm_naviframe_item_title_enabled_set(nav_item, EINA_FALSE, EINA_FALSE);
118 /*if smart rotation is on, show guide popup*/
119 /*if smart rotation is off, show guide popuup after user click enable*/
120 int smart_rotation_status = 0;
121 vconf_get_bool(VCONFKEY_SETAPPL_SMARTSCREEN_SMART_ROTATION, &smart_rotation_status);
122 if (smart_rotation_status && !safeStrCmp(ad->uri, URI_SMART_ROTATION)) {
123 if (ad->smart_rotation_sublayout) {
124 elm_object_signal_emit(ad->smart_rotation_sublayout, "elm,state,top,show", "elm");
125 ad->timer_show_guide = ecore_timer_add(4, (Ecore_Task_Cb)__show_smartrotation_guide_popup, ad);
127 SETTING_TRACE("layout is null");
132 setting_view_display_smart_screen_smart_rotation.is_create = 1;
133 return SETTING_RETURN_SUCCESS;
137 static int setting_display_smart_screen_smart_rotation_destroy(void *cb)
141 setting_retvm_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "cb is NULL");
142 retv_if(!(setting_view_display_smart_screen_smart_rotation.is_create), SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
143 SettingDisplayUG *ad = (SettingDisplayUG *) cb;
144 if (ad->timer_show_guide) {
145 ecore_timer_del(ad->timer_show_guide);
146 ad->timer_show_guide = NULL;
148 if (&setting_view_display_smart_screen_smart_rotation == ad->view_to_load) {
150 evas_object_del(ad->ly_main);
154 elm_naviframe_item_pop(ad->navi_bar);
156 setting_view_display_smart_screen_smart_rotation.is_create = 0;
158 return SETTING_RETURN_SUCCESS;
161 static int setting_display_smart_screen_smart_rotation_update(void *cb)
165 setting_retvm_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "cb is NULL");
167 return SETTING_RETURN_SUCCESS;
170 static int setting_display_smart_screen_smart_rotation_cleanup(void *cb)
173 setting_retvm_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "cb is NULL");
175 SettingDisplayUG *ad = (SettingDisplayUG *) cb;
177 setting_display_smart_screen_smart_rotation_destroy(ad);
179 return SETTING_RETURN_SUCCESS;
182 /* ***************************************************
186 ***************************************************/
188 static void __setting_display_smart_screen_smart_rotation_click_softkey_back_cb(void *data, Evas_Object *obj, void *event_info)
192 setting_retm_if(data == NULL,
193 "[Setting > Display] Data parameter is NULL");
195 SettingDisplayUG *ad = (SettingDisplayUG *) data;
196 if (&setting_view_display_smart_screen_smart_rotation == ad->view_to_load) {
197 /* Send destroy request */
198 ug_destroy_me(ad->ug);
201 setting_view_cleanup(&setting_view_display_smart_screen_smart_rotation, ad);