e0fdb945413aac3af4fc1ea1f31519946f0d6cd3
[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   return Stage(Internal::Stage::GetCurrent());
77 }
78
79 bool Stage::IsInstalled()
80 {
81   return Internal::Stage::IsInstalled();
82 }
83
84 void Stage::Add(Actor& actor)
85 {
86   GetImplementation(*this).Add(GetImplementation(actor));
87 }
88
89 void Stage::Remove(Actor& actor)
90 {
91   GetImplementation(*this).Remove(GetImplementation(actor));
92 }
93
94 RenderTaskList Stage::GetRenderTaskList() const
95 {
96   return RenderTaskList( &GetImplementation(*this).GetRenderTaskList() );
97 }
98
99 Vector2 Stage::GetSize() const
100 {
101   return GetImplementation(*this).GetSize();
102 }
103
104 unsigned int Stage::GetLayerCount() const
105 {
106   return GetImplementation(*this).GetLayerCount();
107 }
108
109 Layer Stage::GetLayer(unsigned int depth) const
110 {
111   return GetImplementation(*this).GetLayer(depth);
112 }
113
114 Layer Stage::GetRootLayer() const
115 {
116   return GetImplementation(*this).GetRootLayer();
117 }
118
119 void Stage::SetBackgroundColor(Vector4 color)
120 {
121   GetImplementation(*this).SetBackgroundColor(color);
122 }
123
124 Vector4 Stage::GetBackgroundColor() const
125 {
126   return GetImplementation(*this).GetBackgroundColor();
127 }
128
129 Vector2 Stage::GetDpi() const
130 {
131   return GetImplementation(*this).GetDpi();
132 }
133
134 ObjectRegistry Stage::GetObjectRegistry() const
135 {
136   Internal::ObjectRegistry& internal = Internal::Stage::GetCurrent()->GetObjectRegistry();
137
138   return ObjectRegistry(&internal);
139 }
140
141 DynamicsWorld Stage::InitializeDynamics(DynamicsWorldConfig config)
142 {
143 #ifdef DYNAMICS_SUPPORT
144   Internal::DynamicsWorldConfigPtr configImpl( &(GetImplementation(config)) );
145
146   return DynamicsWorld( GetImplementation(*this).InitializeDynamics(configImpl).Get() );
147 #else
148   return DynamicsWorld();
149 #endif
150 }
151
152 DynamicsWorld Stage::GetDynamicsWorld()
153 {
154 #ifdef DYNAMICS_SUPPORT
155   return DynamicsWorld( GetImplementation(*this).GetDynamicsWorld().Get() );
156 #else
157   return DynamicsWorld();
158 #endif
159 }
160
161 void Stage::TerminateDynamics()
162 {
163 #ifdef DYNAMICS_SUPPORT
164   GetImplementation(*this).TerminateDynamics();
165 #endif
166 }
167
168 void Stage::KeepRendering( float durationSeconds )
169 {
170   GetImplementation(*this).KeepRendering( durationSeconds );
171 }
172
173 Stage::KeyEventSignalV2& Stage::KeyEventSignal()
174 {
175   return GetImplementation(*this).KeyEventSignal();
176 }
177
178 Stage::EventProcessingFinishedSignalV2& Stage::EventProcessingFinishedSignal()
179 {
180   return GetImplementation(*this).EventProcessingFinishedSignal();
181 }
182
183 Stage::TouchedSignalV2& Stage::TouchedSignal()
184 {
185   return GetImplementation(*this).TouchedSignal();
186 }
187
188 Stage::ContextStatusSignal& Stage::ContextLostSignal()
189 {
190   return GetImplementation(*this).ContextLostSignal();
191 }
192
193 Stage::ContextStatusSignal& Stage::ContextRegainedSignal()
194 {
195   return GetImplementation(*this).ContextRegainedSignal();
196 }
197
198 Stage::SceneCreatedSignalV2& Stage::SceneCreatedSignal()
199 {
200   return GetImplementation(*this).SceneCreatedSignal();
201 }
202
203 } // namespace Dali