3d11e47f2178e480cc7f1029c3cc7ab879b3168e
[platform/framework/web/wrt.git] / src / wrt-client / splash_screen_support.cpp
1 /*
2  * Copyright (c) 2012 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  * @file        splash_screen_support.cpp
18  * @author      Andrzej Surdej (a.surdej@samsung.com)
19  * @brief       Implementation file for splash screen support
20  */
21
22 #include "splash_screen_support.h"
23 #include <dpl/log/log.h>
24 #include <Elementary.h>
25
26
27 SplashScreenSupport::SplashScreenSupport(Evas_Object* parent)
28 {
29     LogDebug("enter");
30     Evas_Coord x, y, w, h;
31     evas_object_geometry_get(parent, &x, &y, &w, &h);
32
33     m_splashScreen = elm_icon_add(parent);
34
35     evas_object_resize(m_splashScreen, w, h);
36     evas_object_image_fill_set(m_splashScreen, 0, 0, w, h);
37 }
38
39 SplashScreenSupport::~SplashScreenSupport()
40 {
41     LogDebug("enter");
42 }
43
44 bool SplashScreenSupport::createSplashScreen(const DPL::OptionalString imagePath)
45 {
46     LogDebug("initializing splash screen");
47
48     bool result = false;
49     if (!imagePath.IsNull()) {
50         setSplashImagePath((DPL::ToUTF8String(*imagePath)).c_str());
51         result = true;
52     } else {
53         result = false;
54     }
55     return result;
56 }
57
58 void SplashScreenSupport::startSplashScreen()
59 {
60     if (m_splashScreen) {
61         LogInfo("splashImageOn");
62         if (elm_image_animated_get(m_splashScreen) == EINA_TRUE) {
63             elm_image_animated_play_set(m_splashScreen, EINA_TRUE);
64         }
65         evas_object_show(m_splashScreen);
66     }
67 }
68
69 void SplashScreenSupport::stopSplashScreen()
70 {
71     LogDebug("splash screen stop");
72     if (m_splashScreen) {
73         LogInfo("splashImageOff");
74         if (elm_image_animated_get(m_splashScreen) == EINA_TRUE) {
75             elm_image_animated_play_set(m_splashScreen, EINA_FALSE);
76         }
77         evas_object_hide(m_splashScreen);
78     }
79 }
80
81 void SplashScreenSupport::setSplashImagePath(const char * image_path)
82 {
83     if (image_path) {
84         LogInfo("splash screen image path : " << image_path);
85
86         if (elm_image_file_set(m_splashScreen, image_path, NULL)) {
87             if (elm_image_animated_available_get(m_splashScreen)) {
88                 elm_image_animated_set(m_splashScreen, EINA_TRUE);
89                 elm_image_animated_play_set(m_splashScreen, EINA_FALSE);
90             } else {
91                 elm_image_animated_set(m_splashScreen, EINA_FALSE);
92             }
93         } else {
94             LogError("loading splash image has been failed");
95         }
96     }
97 }