License conversion from Flora to Apache 2.0
[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 using namespace std;
39
40 namespace Dali
41 {
42
43 using Internal::Core;
44
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);
47
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";
51
52 Stage::Stage()
53 {
54 }
55
56 Stage::~Stage()
57 {
58 }
59
60 Stage::Stage(Internal::Stage* internal)
61 : BaseHandle(internal)
62 {
63 }
64
65 Stage Stage::GetCurrent()
66 {
67   return Stage(Internal::Stage::GetCurrent());
68 }
69
70 bool Stage::IsInstalled()
71 {
72   return Internal::Stage::IsInstalled();
73 }
74
75 void Stage::Add(Actor& actor)
76 {
77   GetImplementation(*this).Add(GetImplementation(actor));
78 }
79
80 void Stage::Remove(Actor& actor)
81 {
82   GetImplementation(*this).Remove(GetImplementation(actor));
83 }
84
85 RenderTaskList Stage::GetRenderTaskList() const
86 {
87   return RenderTaskList( &GetImplementation(*this).GetRenderTaskList() );
88 }
89
90 Vector2 Stage::GetSize() const
91 {
92   return GetImplementation(*this).GetSize();
93 }
94
95 unsigned int Stage::GetLayerCount() const
96 {
97   return GetImplementation(*this).GetLayerCount();
98 }
99
100 Layer Stage::GetLayer(unsigned int depth) const
101 {
102   return GetImplementation(*this).GetLayer(depth);
103 }
104
105 Layer Stage::GetRootLayer() const
106 {
107   return GetImplementation(*this).GetRootLayer();
108 }
109
110 void Stage::SetBackgroundColor(Vector4 color)
111 {
112   GetImplementation(*this).SetBackgroundColor(color);
113 }
114
115 Vector4 Stage::GetBackgroundColor() const
116 {
117   return GetImplementation(*this).GetBackgroundColor();
118 }
119
120 Vector2 Stage::GetDpi() const
121 {
122   return GetImplementation(*this).GetDpi();
123 }
124
125 ObjectRegistry Stage::GetObjectRegistry() const
126 {
127   Internal::ObjectRegistry& internal = Internal::Stage::GetCurrent()->GetObjectRegistry();
128
129   return ObjectRegistry(&internal);
130 }
131
132 DynamicsWorld Stage::InitializeDynamics(DynamicsWorldConfig config)
133 {
134 #ifdef DYNAMICS_SUPPORT
135   Internal::DynamicsWorldConfigPtr configImpl( &(GetImplementation(config)) );
136
137   return DynamicsWorld( GetImplementation(*this).InitializeDynamics(configImpl).Get() );
138 #else
139   return DynamicsWorld();
140 #endif
141 }
142
143 DynamicsWorld Stage::GetDynamicsWorld()
144 {
145 #ifdef DYNAMICS_SUPPORT
146   return DynamicsWorld( GetImplementation(*this).GetDynamicsWorld().Get() );
147 #else
148   return DynamicsWorld();
149 #endif
150 }
151
152 void Stage::TerminateDynamics()
153 {
154 #ifdef DYNAMICS_SUPPORT
155   GetImplementation(*this).TerminateDynamics();
156 #endif
157 }
158
159 void Stage::KeepRendering( float durationSeconds )
160 {
161   GetImplementation(*this).KeepRendering( durationSeconds );
162 }
163
164 Stage::KeyEventSignalV2& Stage::KeyEventSignal()
165 {
166   return GetImplementation(*this).KeyEventSignal();
167 }
168
169 Stage::EventProcessingFinishedSignalV2& Stage::EventProcessingFinishedSignal()
170 {
171   return GetImplementation(*this).EventProcessingFinishedSignal();
172 }
173
174 Stage::TouchedSignalV2& Stage::TouchedSignal()
175 {
176   return GetImplementation(*this).TouchedSignal();
177 }
178
179 } // namespace Dali