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>
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);
54 Stage::Stage(const Stage& handle)
59 Stage& Stage::operator=(const Stage& rhs)
61 BaseHandle::operator=(rhs);
65 Stage::Stage(Internal::Stage* internal)
66 : BaseHandle(internal)
70 Stage Stage::GetCurrent()
72 Internal::Stage* stage = Internal::Stage::GetCurrent();
73 DALI_ASSERT_ALWAYS( stage && "Stage doesn't exist" );
74 return Stage( stage );
77 bool Stage::IsInstalled()
79 return Internal::Stage::IsInstalled();
82 void Stage::Add(Actor& actor)
84 GetImplementation(*this).Add(GetImplementation(actor));
87 void Stage::Remove(Actor& actor)
89 GetImplementation(*this).Remove(GetImplementation(actor));
92 RenderTaskList Stage::GetRenderTaskList() const
94 return RenderTaskList( &GetImplementation(*this).GetRenderTaskList() );
97 Vector2 Stage::GetSize() const
99 return GetImplementation(*this).GetSize();
102 unsigned int Stage::GetLayerCount() const
104 return GetImplementation(*this).GetLayerCount();
107 Layer Stage::GetLayer(unsigned int depth) const
109 return GetImplementation(*this).GetLayer(depth);
112 Layer Stage::GetRootLayer() const
114 return GetImplementation(*this).GetRootLayer();
117 void Stage::SetBackgroundColor(Vector4 color)
119 GetImplementation(*this).SetBackgroundColor(color);
122 Vector4 Stage::GetBackgroundColor() const
124 return GetImplementation(*this).GetBackgroundColor();
127 Vector2 Stage::GetDpi() const
129 return GetImplementation(*this).GetDpi();
132 ObjectRegistry Stage::GetObjectRegistry() const
134 Internal::ObjectRegistry& internal = Internal::Stage::GetCurrent()->GetObjectRegistry();
136 return ObjectRegistry(&internal);
139 DynamicsWorld Stage::InitializeDynamics(DynamicsWorldConfig config)
141 #ifdef DYNAMICS_SUPPORT
142 Internal::DynamicsWorldConfigPtr configImpl( &(GetImplementation(config)) );
144 return DynamicsWorld( GetImplementation(*this).InitializeDynamics(configImpl).Get() );
146 return DynamicsWorld();
150 DynamicsWorld Stage::GetDynamicsWorld()
152 #ifdef DYNAMICS_SUPPORT
153 return DynamicsWorld( GetImplementation(*this).GetDynamicsWorld().Get() );
155 return DynamicsWorld();
159 void Stage::TerminateDynamics()
161 #ifdef DYNAMICS_SUPPORT
162 GetImplementation(*this).TerminateDynamics();
166 void Stage::KeepRendering( float durationSeconds )
168 GetImplementation(*this).KeepRendering( durationSeconds );
171 Stage::KeyEventSignalType& Stage::KeyEventSignal()
173 return GetImplementation(*this).KeyEventSignal();
176 Stage::EventProcessingFinishedSignalType& Stage::EventProcessingFinishedSignal()
178 return GetImplementation(*this).EventProcessingFinishedSignal();
181 Stage::TouchedSignalType& Stage::TouchedSignal()
183 return GetImplementation(*this).TouchedSignal();
186 Stage::ContextStatusSignal& Stage::ContextLostSignal()
188 return GetImplementation(*this).ContextLostSignal();
191 Stage::ContextStatusSignal& Stage::ContextRegainedSignal()
193 return GetImplementation(*this).ContextRegainedSignal();
196 Stage::SceneCreatedSignalType& Stage::SceneCreatedSignal()
198 return GetImplementation(*this).SceneCreatedSignal();