Revert "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 Flora License, Version 1.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://floralicense.org/license/
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 // CLASS HEADER
18 #include <dali/public-api/common/stage.h>
19
20 // INTERNAL INCLUDES
21 #include <dali/public-api/actors/actor.h>
22 #include <dali/public-api/render-tasks/render-task-list.h>
23 #include <dali/internal/event/common/stage-impl.h>
24 #include <dali/internal/common/core-impl.h>
25 #include <dali/public-api/actors/layer.h>
26 #include <dali/public-api/object/object-registry.h>
27
28 #include <dali/public-api/dynamics/dynamics-world.h>
29 #include <dali/public-api/dynamics/dynamics-world-config.h>
30
31 #ifdef DYNAMICS_SUPPORT
32 #include <dali/internal/event/dynamics/dynamics-declarations.h>
33 #include <dali/internal/event/dynamics/dynamics-world-config-impl.h>
34 #include <dali/internal/event/dynamics/dynamics-world-impl.h>
35 #endif
36
37 using namespace std;
38
39 namespace Dali
40 {
41
42 using Internal::Core;
43
44 const Vector4 Stage::DEFAULT_BACKGROUND_COLOR(0.0f, 0.0f, 0.0f, 1.0f);
45 const Vector4 Stage::DEBUG_BACKGROUND_COLOR(0.2f, 0.5f, 0.2f, 1.0f);
46
47 const char* const Stage::SIGNAL_KEY_EVENT = "key-event";
48 const char* const Stage::SIGNAL_EVENT_PROCESSING_FINISHED = "event-processing-finished";
49 const char* const Stage::SIGNAL_TOUCHED = "touched";
50
51 Stage::Stage()
52 {
53 }
54
55 Stage::~Stage()
56 {
57 }
58
59 Stage::Stage(Internal::Stage* internal)
60 : BaseHandle(internal)
61 {
62 }
63
64 Stage Stage::GetCurrent()
65 {
66   return Stage(Internal::Stage::GetCurrent());
67 }
68
69 bool Stage::IsInstalled()
70 {
71   return Internal::Stage::IsInstalled();
72 }
73
74 void Stage::Add(Actor& actor)
75 {
76   GetImplementation(*this).Add(GetImplementation(actor));
77 }
78
79 void Stage::Remove(Actor& actor)
80 {
81   GetImplementation(*this).Remove(GetImplementation(actor));
82 }
83
84 RenderTaskList Stage::GetRenderTaskList() const
85 {
86   return RenderTaskList( &GetImplementation(*this).GetRenderTaskList() );
87 }
88
89 Vector2 Stage::GetSize() const
90 {
91   return GetImplementation(*this).GetSize();
92 }
93
94 unsigned int Stage::GetLayerCount() const
95 {
96   return GetImplementation(*this).GetLayerCount();
97 }
98
99 Layer Stage::GetLayer(unsigned int depth) const
100 {
101   return GetImplementation(*this).GetLayer(depth);
102 }
103
104 Layer Stage::GetRootLayer() const
105 {
106   return GetImplementation(*this).GetRootLayer();
107 }
108
109 void Stage::SetBackgroundColor(Vector4 color)
110 {
111   GetImplementation(*this).SetBackgroundColor(color);
112 }
113
114 Vector4 Stage::GetBackgroundColor() const
115 {
116   return GetImplementation(*this).GetBackgroundColor();
117 }
118
119 Vector2 Stage::GetDpi() const
120 {
121   return GetImplementation(*this).GetDpi();
122 }
123
124 ObjectRegistry Stage::GetObjectRegistry() const
125 {
126   Internal::ObjectRegistry& internal = Internal::Stage::GetCurrent()->GetObjectRegistry();
127
128   return ObjectRegistry(&internal);
129 }
130
131 DynamicsWorld Stage::InitializeDynamics(DynamicsWorldConfig config)
132 {
133 #ifdef DYNAMICS_SUPPORT
134   Internal::DynamicsWorldConfigPtr configImpl( &(GetImplementation(config)) );
135
136   return DynamicsWorld( GetImplementation(*this).InitializeDynamics(configImpl).Get() );
137 #else
138   return DynamicsWorld();
139 #endif
140 }
141
142 DynamicsWorld Stage::GetDynamicsWorld()
143 {
144 #ifdef DYNAMICS_SUPPORT
145   return DynamicsWorld( GetImplementation(*this).GetDynamicsWorld().Get() );
146 #else
147   return DynamicsWorld();
148 #endif
149 }
150
151 void Stage::TerminateDynamics()
152 {
153 #ifdef DYNAMICS_SUPPORT
154   GetImplementation(*this).TerminateDynamics();
155 #endif
156 }
157
158 void Stage::KeepRendering( float durationSeconds )
159 {
160   GetImplementation(*this).KeepRendering( durationSeconds );
161 }
162
163 Stage::KeyEventSignalV2& Stage::KeyEventSignal()
164 {
165   return GetImplementation(*this).KeyEventSignal();
166 }
167
168 Stage::EventProcessingFinishedSignalV2& Stage::EventProcessingFinishedSignal()
169 {
170   return GetImplementation(*this).EventProcessingFinishedSignal();
171 }
172
173 Stage::TouchedSignalV2& Stage::TouchedSignal()
174 {
175   return GetImplementation(*this).TouchedSignal();
176 }
177
178 } // namespace Dali