Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / animations / FUiAnim_RootVisualElement.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_RootVisualElement.cpp
20  * @brief       This is the implementation file for the _RootVisualElement class.
21  *
22  * This file contains implementation _RootVisualElement class.
23  */
24
25 #include <new>
26 #include <FBaseSysLog.h>
27 #include "FUiAnim_DisplayManager.h"
28 #include "FUiAnim_RootVisualElement.h"
29 #include "FUiAnim_NativeLayer.h"
30 #include "FUiAnim_VisualElementImpl.h"
31
32 namespace Tizen { namespace Ui { namespace Animations
33 {
34
35 // Root Element implementation
36 _RootVisualElement::_RootVisualElement(void)
37         : __needsUpdateFromRoot(false)
38         , __isModel(true)
39         , __pLayer(null)
40 {
41         _pVisualElementImpl->__isRoot = true;
42         _pVisualElementImpl->__isInternal = true;
43         _pVisualElementImpl->__isImplicitAnimationEnabled = false;
44 }
45
46 _RootVisualElement::_RootVisualElement(const _RootVisualElement& rhs)
47         : _VisualElement(rhs)
48         , __needsUpdateFromRoot(false)
49         , __isModel(false)
50         , __pLayer(rhs.__pLayer)
51 {
52
53 }
54
55 _RootVisualElement::~_RootVisualElement(void)
56 {
57
58         if(__pLayer)
59         {
60                 SysLogException(NID_UI_ANIM, E_INVALID_STATE,"[E_INVALID_STATE] The RootVisualElement instance has been destroyed, but the layer information was not cleaned.");
61 //              __pLayer->_pRootVisualElement = NULL;
62         }
63         __pLayer = NULL;
64 }
65
66
67 VisualElement*
68 _RootVisualElement::CloneN(void) const
69 {
70         return new (std::nothrow) _RootVisualElement(*this);
71 }
72
73 result
74 _RootVisualElement::SetNativeLayer(_NativeLayer* pLayer)
75 {
76         if (__pLayer == pLayer)
77         {
78                 return E_SUCCESS;
79         }
80
81         SysTryReturnResult(NID_UI_ANIM, !__pLayer || (__pLayer && pLayer == null), E_INVALID_STATE, "The layer is already assigned to another RootVisualElement instance.");
82         __pLayer = pLayer;
83
84         _RootVisualElement* pPresentation = null;
85         if (_pVisualElementImpl && _pVisualElementImpl->__pPresentation)
86         {
87                 pPresentation = dynamic_cast<_RootVisualElement*>(_pVisualElementImpl->__pPresentation->__pPublicInstance);
88         }
89         SysTryReturnResult(NID_UI_ANIM, pPresentation, E_INVALID_STATE, "The presentation instance is not available.");
90
91         pPresentation->__pLayer = pLayer;
92
93         return E_SUCCESS;
94 }
95
96 }}} //namespace Tizen { namespace Ui { namespace Animations {
97