Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / animations / FUiAnim_NativeLayer.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FUiAnim_NativeLayer.cpp
20  * @brief       This file contains implementation of _NativeLayer class
21  *
22  * This file contains implementation _NativeLayer class.
23  */
24
25 #include <new>
26 #include <FBaseSysLog.h>
27
28 #include "FUiAnim_RootVisualElement.h"
29 #include "FUiAnim_NativeLayer.h"
30 #include "FUiAnim_DisplayManager.h"
31 #include "FUiAnim_EflLayer.h"
32
33 namespace Tizen { namespace Ui { namespace Animations
34 {
35
36 _NativeLayer::_NativeLayer(void)
37         : _pRootVisualElement(null)
38 {
39
40 }
41 _NativeLayer::~_NativeLayer(void)
42 {
43         if(_pRootVisualElement)
44         {
45                 _DisplayManager* pDisplayManager = _DisplayManager::GetInstance();
46                 if(pDisplayManager)
47                 {
48                         pDisplayManager->UnregisterRoot(*_pRootVisualElement);
49                 }
50                 _pRootVisualElement->SetNativeLayer(null);
51                 _pRootVisualElement->Destroy();
52                 _pRootVisualElement = null;
53         }
54 }
55
56 _NativeLayer*
57 _NativeLayer::CreateInstanceN(void)
58 {
59 #if defined(VE_EFL)
60         _EflLayer* pLayer = new (std::nothrow) _EflLayer;
61
62         if (pLayer)
63         {
64                 pLayer->Construct();
65         }
66         return pLayer;
67
68 #else ////#elif defined(VE_OPENGL)
69
70         return null;
71
72 #endif
73
74 }
75
76 result
77 _NativeLayer::Construct(void)
78 {
79         SysAssertf(_pRootVisualElement == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
80
81         _pRootVisualElement = new _RootVisualElement();
82         result r = _pRootVisualElement->Construct();
83         SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Propagating.");
84         _pRootVisualElement->SetShowState(true);
85
86         _DisplayManager* pDisplayManager = _DisplayManager::GetInstance();
87         if(pDisplayManager)
88         {
89                 pDisplayManager->RegisterRoot(*_pRootVisualElement);
90         }
91
92         r = OnConstructed();
93         SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Constructing failed.");
94
95         _pRootVisualElement->SetNativeLayer(this);
96
97         r = Configure(*_pRootVisualElement);
98         SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Configuring failed.");
99
100         return E_SUCCESS;
101 }
102
103 _RootVisualElement*
104 _NativeLayer::GetRootVisualElement(void) const
105 {
106         return _pRootVisualElement;
107 }
108
109 }}}