2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/common/stage.h>
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>
29 #include <dali/public-api/dynamics/dynamics-world.h>
30 #include <dali/public-api/dynamics/dynamics-world-config.h>
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>
45 const Vector4 Stage::DEFAULT_BACKGROUND_COLOR(0.0f, 0.0f, 0.0f, 1.0f);
46 const Vector4 Stage::DEBUG_BACKGROUND_COLOR(0.2f, 0.5f, 0.2f, 1.0f);
48 const char* const Stage::SIGNAL_KEY_EVENT = "key-event";
49 const char* const Stage::SIGNAL_EVENT_PROCESSING_FINISHED = "event-processing-finished";
50 const char* const Stage::SIGNAL_TOUCHED = "touched";
60 Stage::Stage(const Stage& handle)
65 Stage& Stage::operator=(const Stage& rhs)
67 BaseHandle::operator=(rhs);
71 Stage& Stage::operator=(BaseHandle::NullType* rhs)
73 DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
78 Stage::Stage(Internal::Stage* internal)
79 : BaseHandle(internal)
83 Stage Stage::GetCurrent()
85 return Stage(Internal::Stage::GetCurrent());
88 bool Stage::IsInstalled()
90 return Internal::Stage::IsInstalled();
93 void Stage::Add(Actor& actor)
95 GetImplementation(*this).Add(GetImplementation(actor));
98 void Stage::Remove(Actor& actor)
100 GetImplementation(*this).Remove(GetImplementation(actor));
103 RenderTaskList Stage::GetRenderTaskList() const
105 return RenderTaskList( &GetImplementation(*this).GetRenderTaskList() );
108 Vector2 Stage::GetSize() const
110 return GetImplementation(*this).GetSize();
113 unsigned int Stage::GetLayerCount() const
115 return GetImplementation(*this).GetLayerCount();
118 Layer Stage::GetLayer(unsigned int depth) const
120 return GetImplementation(*this).GetLayer(depth);
123 Layer Stage::GetRootLayer() const
125 return GetImplementation(*this).GetRootLayer();
128 void Stage::SetBackgroundColor(Vector4 color)
130 GetImplementation(*this).SetBackgroundColor(color);
133 Vector4 Stage::GetBackgroundColor() const
135 return GetImplementation(*this).GetBackgroundColor();
138 Vector2 Stage::GetDpi() const
140 return GetImplementation(*this).GetDpi();
143 ObjectRegistry Stage::GetObjectRegistry() const
145 Internal::ObjectRegistry& internal = Internal::Stage::GetCurrent()->GetObjectRegistry();
147 return ObjectRegistry(&internal);
150 DynamicsWorld Stage::InitializeDynamics(DynamicsWorldConfig config)
152 #ifdef DYNAMICS_SUPPORT
153 Internal::DynamicsWorldConfigPtr configImpl( &(GetImplementation(config)) );
155 return DynamicsWorld( GetImplementation(*this).InitializeDynamics(configImpl).Get() );
157 return DynamicsWorld();
161 DynamicsWorld Stage::GetDynamicsWorld()
163 #ifdef DYNAMICS_SUPPORT
164 return DynamicsWorld( GetImplementation(*this).GetDynamicsWorld().Get() );
166 return DynamicsWorld();
170 void Stage::TerminateDynamics()
172 #ifdef DYNAMICS_SUPPORT
173 GetImplementation(*this).TerminateDynamics();
177 void Stage::KeepRendering( float durationSeconds )
179 GetImplementation(*this).KeepRendering( durationSeconds );
182 Stage::KeyEventSignalV2& Stage::KeyEventSignal()
184 return GetImplementation(*this).KeyEventSignal();
187 Stage::EventProcessingFinishedSignalV2& Stage::EventProcessingFinishedSignal()
189 return GetImplementation(*this).EventProcessingFinishedSignal();
192 Stage::TouchedSignalV2& Stage::TouchedSignal()
194 return GetImplementation(*this).TouchedSignal();
198 Stage::ContextStatusSignal& Stage::ContextLostSignal()
200 return GetImplementation(*this).ContextLostSignal();
203 Stage::ContextStatusSignal& Stage::ContextRegainedSignal()
205 return GetImplementation(*this).ContextRegainedSignal();