Revert " modify license, permission and remove ^M char"
[framework/osp/uifw.git] / src / ui / scenes / FUiScenes_SceneTransitionImpl.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 #include <FBaseInteger.h>
19 #include <FBaseSysLog.h>
20 #include "FUiScenes_SceneTransitionImpl.h"
21
22 using namespace Tizen::Base;
23
24 namespace Tizen { namespace Ui { namespace Scenes
25 {
26
27 _SceneTransitionImpl::_SceneTransitionImpl(void)
28         : __direction(SCENE_TRANSITION_DIRECTION_FORWARD)
29         , __destinationSceneId("")
30         , __animationType(SCENE_TRANSITION_ANIMATION_TYPE_NONE)
31         , __historyOption(SCENE_HISTORY_OPTION_ADD_HISTORY)
32         , __destroyOption(SCENE_DESTROY_OPTION_KEEP)
33 {
34
35 }
36
37 _SceneTransitionImpl::_SceneTransitionImpl(const _SceneTransitionImpl& rhs)
38         : __direction(rhs.__direction)
39         , __destinationSceneId(rhs.__destinationSceneId)
40         , __animationType(rhs.__animationType)
41         , __historyOption(rhs.__historyOption)
42         , __destroyOption(rhs.__destroyOption)
43 {
44
45 }
46
47 _SceneTransitionImpl::_SceneTransitionImpl(SceneTransitionDirection direction, const SceneId& destinationSceneId,
48                                                                                    SceneTransitionAnimationType animationType,
49                                                                                    SceneHistoryOption historyOption, SceneDestroyOption destroyOption)
50         : __direction(direction)
51         , __destinationSceneId(destinationSceneId)
52         , __animationType(animationType)
53         , __historyOption(historyOption)
54         , __destroyOption(destroyOption)
55 {
56
57 }
58
59 _SceneTransitionImpl
60 _SceneTransitionImpl::operator=(const _SceneTransitionImpl& rhs)
61 {
62         if (this != &rhs)
63         {
64                 __direction = rhs.__direction;
65                 __destinationSceneId = rhs.__destinationSceneId;
66                 __animationType = rhs.__animationType;
67                 __historyOption = rhs.__historyOption;
68                 __destroyOption = rhs.__destroyOption;
69         }
70         return *this;
71 }
72
73 bool
74 _SceneTransitionImpl::Equals(const _SceneTransitionImpl& rhs) const
75 {
76         return ((__direction == rhs.__direction) &&
77                         (__destinationSceneId == rhs.__destinationSceneId) &&
78                         (__animationType == rhs.__animationType) &&
79                         (__historyOption == rhs.__historyOption) &&
80                         (__destroyOption == rhs.__destroyOption));
81 }
82
83 int
84 _SceneTransitionImpl::GetHashCode(void) const
85 {
86         String hashMaker;
87         Integer intValue;
88
89         intValue = Integer(static_cast<int>(__direction));
90         hashMaker += intValue.ToString();
91
92         hashMaker += __destinationSceneId;
93
94         intValue = Integer(static_cast<int>(__animationType));
95         hashMaker += intValue.ToString();
96
97         intValue = Integer(static_cast<int>(__historyOption));
98         hashMaker += intValue.ToString();
99
100         intValue = Integer(static_cast<int>(__destroyOption));
101         hashMaker += intValue.ToString();
102
103         return hashMaker.GetHashCode();
104 }
105
106 _SceneTransitionImpl::~_SceneTransitionImpl(void)
107 {
108         // Nothing to do.
109 }
110
111 result
112 _SceneTransitionImpl::SetDirection(SceneTransitionDirection direction)
113 {
114         SysTryReturnResult(NID_UI_SCENES,
115                                            ((direction == SCENE_TRANSITION_DIRECTION_FORWARD) || (direction == SCENE_TRANSITION_DIRECTION_BACKWARD)),
116                                            E_INVALID_ARG, "Invalid argument is used.");
117         __direction = direction;
118         return E_SUCCESS;
119 }
120
121 SceneTransitionDirection
122 _SceneTransitionImpl::GetDirection(void) const
123 {
124         return __direction;
125 }
126
127 result
128 _SceneTransitionImpl::SetDestinationSceneId(const SceneId& sceneId)
129 {
130         SysTryReturnResult(NID_UI_SCENES, (sceneId.GetLength()>0), E_INVALID_ARG, "Invalid argument is used.");
131         __destinationSceneId = sceneId;
132         return E_SUCCESS;
133 }
134
135 SceneId
136 _SceneTransitionImpl::GetDestinationSceneId(void) const
137 {
138         return __destinationSceneId;
139 }
140
141 result
142 _SceneTransitionImpl::SetAnimationType(SceneTransitionAnimationType animationType)
143 {
144         SysTryReturnResult(NID_UI_SCENES, (SCENE_TRANSITION_ANIMATION_TYPE_LEFT <= animationType &&
145                                           animationType <= SCENE_TRANSITION_ANIMATION_TYPE_DEPTH_OUT),
146                                           E_INVALID_ARG, "Invalid argument is used.");
147         __animationType = animationType;
148         return E_SUCCESS;
149 }
150
151 SceneTransitionAnimationType
152 _SceneTransitionImpl::GetAnimationType(void) const
153 {
154         return __animationType;
155 }
156
157 result
158 _SceneTransitionImpl::SetHistoryOption(SceneHistoryOption historyOption)
159 {
160         SysTryReturnResult(NID_UI_SCENES,
161                                          ((historyOption == SCENE_HISTORY_OPTION_ADD_HISTORY) || (historyOption == SCENE_HISTORY_OPTION_NO_HISTORY)),
162                                          E_INVALID_ARG, "Invalid argument is used.");
163         __historyOption = historyOption;
164         return E_SUCCESS;
165 }
166
167 SceneHistoryOption
168 _SceneTransitionImpl::GetHistoryOption(void) const
169 {
170         return __historyOption;
171 }
172
173 result
174 _SceneTransitionImpl::SetDestroyOption(SceneDestroyOption destroyOption)
175 {
176         SysTryReturnResult(NID_UI_SCENES,
177                                          ((destroyOption == SCENE_DESTROY_OPTION_KEEP) || (destroyOption == SCENE_DESTROY_OPTION_DESTROY)),
178                                          E_INVALID_ARG, "Invalid argument is used.");
179         __destroyOption = destroyOption;
180         return E_SUCCESS;
181 }
182
183 SceneDestroyOption
184 _SceneTransitionImpl::GetDestroyOption(void) const
185 {
186         return __destroyOption;
187 }
188
189 _SceneTransitionImpl*
190 _SceneTransitionImpl::GetInstance(SceneTransition& scene)
191 {
192         return scene.__pSceneTransitionImpl;
193 }
194
195 const _SceneTransitionImpl*
196 _SceneTransitionImpl::GetInstance(const SceneTransition& scene)
197 {
198         return scene.__pSceneTransitionImpl;
199 }
200
201 } } } // Tizen::Ui::Scenes