dbg.h file is removed.
[profile/tv/apps/native/filebrowser.git] / src / views / BaseView / Popup.cpp
1 /*
2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 #include <Ecore.h>
18 #include <aul.h>
19
20 #include "define.h"
21 #include "common.h"
22
23 #include <AppCommon.h>
24 #include "Popup.h"
25
26 #define MAX_POPUP_TIME 10 /* seconds */
27 #define POPUP_ICON_SIZE 48
28
29 struct SPopup {
30         Evas_Object *popup;
31         Elm_Transit *transit;
32 };
33
34 bool CPopup::Create(Evas_Object* base)
35 {
36         ASSERT(base);
37
38         if (m)
39                 return false;
40
41         m = new SPopup;
42         if (!m)
43                 return false;
44
45         Evas_Object *popup, *label, *icon;
46         double scale;
47         char buf[MAX_LENGTH];
48
49         popup = elm_popup_add(base);
50         if (!popup)
51                 return NULL;
52
53         elm_object_style_set(popup, FBR_STYLE_LOADING_POPUP);
54         elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP_RIGHT);
55         elm_popup_timeout_set(popup, MAX_POPUP_TIME);
56         evas_object_show(popup);
57
58         label = elm_label_add(popup);
59         if (!label)
60                 goto error;
61
62         elm_object_style_set(label, FBR_STYLE_LOADING_LABEL);
63         elm_object_text_set(label, _(FBR_TEXT_LOADING));
64         elm_object_content_set(popup, label);
65         scale = elm_config_scale_get();
66
67         icon = elm_icon_add(popup);
68         if (!icon)
69                 goto error;
70
71         snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, FBR_IMAGE_LOADING);
72         elm_image_file_set(icon, buf, NULL);
73         elm_image_animated_set(icon, EINA_TRUE);
74         elm_image_animated_play_set(icon, EINA_TRUE);
75         evas_object_size_hint_min_set(icon, POPUP_ICON_SIZE * scale,
76                 POPUP_ICON_SIZE * scale);
77         elm_object_part_content_set(popup, FBR_POPUP_SWALLOW_ICON, icon);
78
79         m->transit = elm_transit_add();
80         if (!m->transit)
81                 goto error;
82
83         elm_transit_object_add(m->transit, icon);
84         elm_transit_effect_rotation_add(m->transit, 0, 360);
85         elm_transit_duration_set(m->transit, 1);
86         elm_transit_repeat_times_set(m->transit, 5);
87         elm_transit_objects_final_state_keep_set(m->transit, EINA_TRUE);
88         elm_transit_go(m->transit);
89
90         return true;
91
92 error:
93         evas_object_del(popup);
94
95         return false;
96 }
97
98 void CPopup::Destroy(void)
99 {
100         if (!m)
101                 return;
102
103         if (m->transit) {
104                 elm_transit_del(m->transit);
105         }
106         evas_object_del(m->popup);
107
108         delete m;
109         m = NULL;
110 }