5e2b0f904acd198f641869f06c2343d4c9c17cbb
[platform/core/uifw/dali-core.git] / dali / public-api / common / stage.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
18 // CLASS HEADER
19 #include <dali/public-api/common/stage.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/render-tasks/render-task-list.h>
24 #include <dali/internal/event/common/stage-impl.h>
25 #include <dali/internal/common/core-impl.h>
26 #include <dali/public-api/actors/layer.h>
27 #include <dali/public-api/object/object-registry.h>
28
29 #include <dali/public-api/dynamics/dynamics-world.h>
30 #include <dali/public-api/dynamics/dynamics-world-config.h>
31
32 #ifdef DYNAMICS_SUPPORT
33 #include <dali/internal/event/dynamics/dynamics-declarations.h>
34 #include <dali/internal/event/dynamics/dynamics-world-config-impl.h>
35 #include <dali/internal/event/dynamics/dynamics-world-impl.h>
36 #endif
37
38 namespace Dali
39 {
40
41 using Internal::Core;
42
43 const Vector4 Stage::DEFAULT_BACKGROUND_COLOR(0.0f, 0.0f, 0.0f, 1.0f);
44 const Vector4 Stage::DEBUG_BACKGROUND_COLOR(0.2f, 0.5f, 0.2f, 1.0f);
45
46 const char* const Stage::SIGNAL_KEY_EVENT = "key-event";
47 const char* const Stage::SIGNAL_EVENT_PROCESSING_FINISHED = "event-processing-finished";
48 const char* const Stage::SIGNAL_TOUCHED = "touched";
49
50 Stage::Stage()
51 {
52 }
53
54 Stage::~Stage()
55 {
56 }
57
58 Stage::Stage(const Stage& handle)
59 : BaseHandle(handle)
60 {
61 }
62
63 Stage& Stage::operator=(const Stage& rhs)
64 {
65   BaseHandle::operator=(rhs);
66   return *this;
67 }
68
69 Stage::Stage(Internal::Stage* internal)
70 : BaseHandle(internal)
71 {
72 }
73
74 Stage Stage::GetCurrent()
75 {
76   Internal::Stage* stage = Internal::Stage::GetCurrent();
77   DALI_ASSERT_ALWAYS( stage && "Stage doesn't exist" );
78   return Stage( stage );
79 }
80
81 bool Stage::IsInstalled()
82 {
83   return Internal::Stage::IsInstalled();
84 }
85
86 void Stage::Add(Actor& actor)
87 {
88   GetImplementation(*this).Add(GetImplementation(actor));
89 }
90
91 void Stage::Remove(Actor& actor)
92 {
93   GetImplementation(*this).Remove(GetImplementation(actor));
94 }
95
96 RenderTaskList Stage::GetRenderTaskList() const
97 {
98   return RenderTaskList( &GetImplementation(*this).GetRenderTaskList() );
99 }
100
101 Vector2 Stage::GetSize() const
102 {
103   return GetImplementation(*this).GetSize();
104 }
105
106 unsigned int Stage::GetLayerCount() const
107 {
108   return GetImplementation(*this).GetLayerCount();
109 }
110
111 Layer Stage::GetLayer(unsigned int depth) const
112 {
113   return GetImplementation(*this).GetLayer(depth);
114 }
115
116 Layer Stage::GetRootLayer() const
117 {
118   return GetImplementation(*this).GetRootLayer();
119 }
120
121 void Stage::SetBackgroundColor(Vector4 color)
122 {
123   GetImplementation(*this).SetBackgroundColor(color);
124 }
125
126 Vector4 Stage::GetBackgroundColor() const
127 {
128   return GetImplementation(*this).GetBackgroundColor();
129 }
130
131 Vector2 Stage::GetDpi() const
132 {
133   return GetImplementation(*this).GetDpi();
134 }
135
136 ObjectRegistry Stage::GetObjectRegistry() const
137 {
138   Internal::ObjectRegistry& internal = Internal::Stage::GetCurrent()->GetObjectRegistry();
139
140   return ObjectRegistry(&internal);
141 }
142
143 DynamicsWorld Stage::InitializeDynamics(DynamicsWorldConfig config)
144 {
145 #ifdef DYNAMICS_SUPPORT
146   Internal::DynamicsWorldConfigPtr configImpl( &(GetImplementation(config)) );
147
148   return DynamicsWorld( GetImplementation(*this).InitializeDynamics(configImpl).Get() );
149 #else
150   return DynamicsWorld();
151 #endif
152 }
153
154 DynamicsWorld Stage::GetDynamicsWorld()
155 {
156 #ifdef DYNAMICS_SUPPORT
157   return DynamicsWorld( GetImplementation(*this).GetDynamicsWorld().Get() );
158 #else
159   return DynamicsWorld();
160 #endif
161 }
162
163 void Stage::TerminateDynamics()
164 {
165 #ifdef DYNAMICS_SUPPORT
166   GetImplementation(*this).TerminateDynamics();
167 #endif
168 }
169
170 void Stage::KeepRendering( float durationSeconds )
171 {
172   GetImplementation(*this).KeepRendering( durationSeconds );
173 }
174
175 Stage::KeyEventSignalType& Stage::KeyEventSignal()
176 {
177   return GetImplementation(*this).KeyEventSignal();
178 }
179
180 Stage::EventProcessingFinishedSignalType& Stage::EventProcessingFinishedSignal()
181 {
182   return GetImplementation(*this).EventProcessingFinishedSignal();
183 }
184
185 Stage::TouchedSignalType& Stage::TouchedSignal()
186 {
187   return GetImplementation(*this).TouchedSignal();
188 }
189
190 Stage::ContextStatusSignal& Stage::ContextLostSignal()
191 {
192   return GetImplementation(*this).ContextLostSignal();
193 }
194
195 Stage::ContextStatusSignal& Stage::ContextRegainedSignal()
196 {
197   return GetImplementation(*this).ContextRegainedSignal();
198 }
199
200 Stage::SceneCreatedSignalType& Stage::SceneCreatedSignal()
201 {
202   return GetImplementation(*this).SceneCreatedSignal();
203 }
204
205 } // namespace Dali