Fix build error due to changing app-common
[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 <Elementary.h>
18 #include <Eina.h>
19 #include <Ecore.h>
20 #include <aul.h>
21
22 #include "define.h"
23 #include "common.h"
24 #include "dbg.h"
25 #include <AppCommon.h>
26 #include "Popup.h"
27
28 #define MAX_POPUP_TIME 10 /* seconds */
29 #define POPUP_ICON_SIZE 48
30
31 struct SPopup {
32         Evas_Object *popup;
33         Elm_Transit *transit;
34 };
35
36 bool CPopup::Create(Evas_Object* base)
37 {
38         ASSERT(base);
39
40         if (m)
41                 return false;
42
43         m = new SPopup;
44         if (!m)
45                 return false;
46
47         Evas_Object *popup, *label, *icon;
48         double scale;
49         char buf[MAX_LENGTH];
50
51         popup = elm_popup_add(base);
52         if (!popup)
53                 return NULL;
54
55         elm_object_style_set(popup, FBR_STYLE_LOADING_POPUP);
56         elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP_RIGHT);
57         elm_popup_timeout_set(popup, MAX_POPUP_TIME);
58         evas_object_show(popup);
59
60         label = elm_label_add(popup);
61         if (!label)
62                 goto error;
63
64         elm_object_style_set(label, FBR_STYLE_LOADING_LABEL);
65         elm_object_text_set(label, _(FBR_TEXT_LOADING));
66         elm_object_content_set(popup, label);
67         scale = elm_config_scale_get();
68
69         icon = elm_icon_add(popup);
70         if (!icon)
71                 goto error;
72
73         snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, FBR_IMAGE_LOADING);
74         elm_image_file_set(icon, buf, NULL);
75         elm_image_animated_set(icon, EINA_TRUE);
76         elm_image_animated_play_set(icon, EINA_TRUE);
77         evas_object_size_hint_min_set(icon, POPUP_ICON_SIZE * scale,
78                 POPUP_ICON_SIZE * scale);
79         elm_object_part_content_set(popup, FBR_POPUP_SWALLOW_ICON, icon);
80
81         m->transit = elm_transit_add();
82         if (!m->transit)
83                 goto error;
84
85         elm_transit_object_add(m->transit, icon);
86         elm_transit_effect_rotation_add(m->transit, 0, 360);
87         elm_transit_duration_set(m->transit, 1);
88         elm_transit_repeat_times_set(m->transit, 5);
89         elm_transit_objects_final_state_keep_set(m->transit, EINA_TRUE);
90         elm_transit_go(m->transit);
91
92         return true;
93
94 error:
95         evas_object_del(popup);
96
97         return false;
98 }
99
100 void CPopup::Destroy(void)
101 {
102         if (!m)
103                 return;
104
105         if (m->transit) {
106                 elm_transit_del(m->transit);
107         }
108         evas_object_del(m->popup);
109
110         delete m;
111         m = NULL;
112 }