Remove Unnecessary Doxygen PREDEFINED
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-window.cpp
1 /*
2  * Copyright (c) 2020 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 "toolkit-window-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/actors/layer.h>
24 #include <dali/public-api/object/base-object.h>
25
26 #define DALI_WINDOW_H
27 #include <dali/integration-api/adaptor-framework/adaptor.h>
28 #include <toolkit-adaptor-impl.h>
29
30 using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
31
32 namespace Dali
33 {
34
35 class Window;
36
37 /********************************************************************************
38  * Stub for Dali::Internal::Adaptor::Window
39  ********************************************************************************/
40
41 namespace Internal
42 {
43 namespace Adaptor
44 {
45
46 Window::Window( const PositionSize& positionSize )
47 : SceneHolder( positionSize ),
48   mFocusChangeSignal(),
49   mResizeSignal(),
50   mRotationAngle(90), // dummy angle for test coverage
51   mVisibilityChangedSignal()
52 {
53 }
54
55 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
56 {
57   return new Window( positionSize );
58 }
59
60 } // Adaptor
61 } // Internal
62
63 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
64 {
65   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
66   BaseObject& object = window.GetBaseObject();
67   return static_cast<Internal::Adaptor::Window&>(object);
68 }
69
70 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
71 {
72   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
73   const BaseObject& object = window.GetBaseObject();
74   return static_cast<const Internal::Adaptor::Window&>(object);
75 }
76
77 Window::Window()
78 {
79 }
80
81 Window::~Window()
82 {
83 }
84
85 Window::Window( const Window& copy ) = default;
86
87 Window& Window::operator=( const Window& rhs ) = default;
88
89 Window::Window( Window&& rhs ) = default;
90
91 Window& Window::operator=( Window&& rhs ) = default;
92
93 Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent )
94 {
95   return New( windowPosition, name, "", isTransparent );
96 }
97
98 Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent )
99 {
100   Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent );
101
102   Dali::Window result( window );
103
104   // This will also emit the window created signals
105   AdaptorImpl::GetImpl( AdaptorImpl::Get() ).AddWindow( window );
106
107   return result;
108 }
109
110 Window::Window( Internal::Adaptor::Window* window )
111 : BaseHandle( window )
112 {
113 }
114
115 Integration::Scene Window::GetScene()
116 {
117   return GetImplementation( *this ).GetScene();
118 }
119
120 Dali::RenderSurfaceInterface& Window::GetRenderSurface()
121 {
122   return GetImplementation( *this ).GetRenderSurface();
123 }
124
125 void Window::Add( Actor actor )
126 {
127   GetImplementation( *this ).Add( actor );
128 }
129
130 void Window::Remove( Actor actor )
131 {
132   GetImplementation( *this ).Remove( actor );
133 }
134
135 Dali::Layer Window::GetRootLayer() const
136 {
137   return GetImplementation( *this ).GetRootLayer();
138 }
139
140 void Window::SetBackgroundColor( const Vector4& color )
141 {
142   GetImplementation( *this ).SetBackgroundColor( color );
143 }
144
145 Vector4 Window::GetBackgroundColor() const
146 {
147   return GetImplementation( *this ).GetBackgroundColor();
148 }
149
150 void Window::Raise()
151 {
152   GetImplementation( *this ).mFocusChangeSignal.Emit(*this, true);
153 }
154
155 void Window::Hide()
156 {
157   GetImplementation( *this ).mVisibilityChangedSignal.Emit( *this, false );
158 }
159
160 FocusChangeSignalType& Window::FocusChangeSignal()
161 {
162   return GetImplementation( *this ).mFocusChangeSignal;
163 }
164
165 ResizeSignalType& Window::ResizeSignal()
166 {
167   return GetImplementation( *this ).mResizeSignal;
168 }
169
170 Window::KeyEventSignalType& Window::KeyEventSignal()
171 {
172   return GetImplementation( *this ).KeyEventSignal();
173 }
174
175 Window::TouchEventSignalType& Window::TouchedSignal()
176 {
177   return GetImplementation( *this ).TouchedSignal();
178 }
179
180 namespace DevelWindow
181 {
182
183 Window Get( Actor actor )
184 {
185   Internal::Adaptor::Window* windowImpl = nullptr;
186
187   if ( Dali::Adaptor::IsAvailable() )
188   {
189     windowImpl = static_cast<Internal::Adaptor::Window*>( AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor ) );
190   }
191
192   return Dali::Window( windowImpl );
193 }
194
195 Window DownCast( BaseHandle handle )
196 {
197   Internal::Adaptor::Window* windowImpl = nullptr;
198   if ( Dali::Adaptor::IsAvailable() )
199   {
200     windowImpl = dynamic_cast<Dali::Internal::Adaptor::Window*>( handle.GetObjectPtr());
201   }
202   return Dali::Window( windowImpl );
203 }
204
205 void SetPositionSize(Window window, PositionSize positionSize)
206 {
207   Uint16Pair newSize(positionSize.width, positionSize.height);
208   GetImplementation( window ).mResizeSignal.Emit(window,newSize);
209 }
210
211 int GetPhysicalOrientation(Window window)
212 {
213   return GetImplementation( window ).mRotationAngle;
214 }
215
216 void AddFrameRenderedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId )
217 {
218   CallbackBase::Execute( *callback, frameId );
219 }
220
221 void AddFramePresentedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId )
222 {
223   CallbackBase::Execute( *callback, frameId );
224 }
225
226 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
227 {
228   return GetImplementation( window ).GetScene().EventProcessingFinishedSignal();
229 }
230
231 KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window )
232 {
233   return GetImplementation( window ).KeyEventGeneratedSignal();
234 }
235
236 WheelEventSignalType& WheelEventSignal( Window window )
237 {
238   return GetImplementation( window ).WheelEventSignal();
239 }
240
241 VisibilityChangedSignalType& VisibilityChangedSignal( Window window )
242 {
243   return GetImplementation( window ).mVisibilityChangedSignal;
244 }
245
246 } // namespace DevelWindow
247
248 } // Dali