Merge remote-tracking branch 'origin/tizen' into devel/new_mesh
[platform/core/uifw/dali-core.git] / dali / public-api / common / stage.cpp
1 /*
2  * Copyright (c) 2015 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 Stage::Stage()
47 {
48 }
49
50 Stage::~Stage()
51 {
52 }
53
54 Stage::Stage(const Stage& handle)
55 : BaseHandle(handle)
56 {
57 }
58
59 Stage& Stage::operator=(const Stage& rhs)
60 {
61   BaseHandle::operator=(rhs);
62   return *this;
63 }
64
65 Stage::Stage(Internal::Stage* internal)
66 : BaseHandle(internal)
67 {
68 }
69
70 Stage Stage::GetCurrent()
71 {
72   Internal::Stage* stage = Internal::Stage::GetCurrent();
73   DALI_ASSERT_ALWAYS( stage && "Stage doesn't exist" );
74   return Stage( stage );
75 }
76
77 bool Stage::IsInstalled()
78 {
79   return Internal::Stage::IsInstalled();
80 }
81
82 void Stage::Add(Actor& actor)
83 {
84   GetImplementation(*this).Add(GetImplementation(actor));
85 }
86
87 void Stage::Remove(Actor& actor)
88 {
89   GetImplementation(*this).Remove(GetImplementation(actor));
90 }
91
92 RenderTaskList Stage::GetRenderTaskList() const
93 {
94   return RenderTaskList( &GetImplementation(*this).GetRenderTaskList() );
95 }
96
97 Vector2 Stage::GetSize() const
98 {
99   return GetImplementation(*this).GetSize();
100 }
101
102 unsigned int Stage::GetLayerCount() const
103 {
104   return GetImplementation(*this).GetLayerCount();
105 }
106
107 Layer Stage::GetLayer(unsigned int depth) const
108 {
109   return GetImplementation(*this).GetLayer(depth);
110 }
111
112 Layer Stage::GetRootLayer() const
113 {
114   return GetImplementation(*this).GetRootLayer();
115 }
116
117 void Stage::SetBackgroundColor(Vector4 color)
118 {
119   GetImplementation(*this).SetBackgroundColor(color);
120 }
121
122 Vector4 Stage::GetBackgroundColor() const
123 {
124   return GetImplementation(*this).GetBackgroundColor();
125 }
126
127 Vector2 Stage::GetDpi() const
128 {
129   return GetImplementation(*this).GetDpi();
130 }
131
132 ObjectRegistry Stage::GetObjectRegistry() const
133 {
134   Internal::ObjectRegistry& internal = Internal::Stage::GetCurrent()->GetObjectRegistry();
135
136   return ObjectRegistry(&internal);
137 }
138
139 DynamicsWorld Stage::InitializeDynamics(DynamicsWorldConfig config)
140 {
141 #ifdef DYNAMICS_SUPPORT
142   Internal::DynamicsWorldConfigPtr configImpl( &(GetImplementation(config)) );
143
144   return DynamicsWorld( GetImplementation(*this).InitializeDynamics(configImpl).Get() );
145 #else
146   return DynamicsWorld();
147 #endif
148 }
149
150 DynamicsWorld Stage::GetDynamicsWorld()
151 {
152 #ifdef DYNAMICS_SUPPORT
153   return DynamicsWorld( GetImplementation(*this).GetDynamicsWorld().Get() );
154 #else
155   return DynamicsWorld();
156 #endif
157 }
158
159 void Stage::TerminateDynamics()
160 {
161 #ifdef DYNAMICS_SUPPORT
162   GetImplementation(*this).TerminateDynamics();
163 #endif
164 }
165
166 void Stage::KeepRendering( float durationSeconds )
167 {
168   GetImplementation(*this).KeepRendering( durationSeconds );
169 }
170
171 Stage::KeyEventSignalType& Stage::KeyEventSignal()
172 {
173   return GetImplementation(*this).KeyEventSignal();
174 }
175
176 Stage::EventProcessingFinishedSignalType& Stage::EventProcessingFinishedSignal()
177 {
178   return GetImplementation(*this).EventProcessingFinishedSignal();
179 }
180
181 Stage::TouchedSignalType& Stage::TouchedSignal()
182 {
183   return GetImplementation(*this).TouchedSignal();
184 }
185
186 Stage::ContextStatusSignal& Stage::ContextLostSignal()
187 {
188   return GetImplementation(*this).ContextLostSignal();
189 }
190
191 Stage::ContextStatusSignal& Stage::ContextRegainedSignal()
192 {
193   return GetImplementation(*this).ContextRegainedSignal();
194 }
195
196 Stage::SceneCreatedSignalType& Stage::SceneCreatedSignal()
197 {
198   return GetImplementation(*this).SceneCreatedSignal();
199 }
200
201 } // namespace Dali