Merge "Use WeakHandle in RenderSurfaceInterface" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / 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 <dali/public-api/adaptor-framework/window.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/actors/actor.h>
26 #include <dali/internal/window-system/common/window-impl.h>
27 #include <dali/internal/window-system/common/orientation-impl.h>
28
29 namespace Dali
30 {
31
32 Window Window::New(PositionSize posSize, const std::string& name, bool isTransparent)
33 {
34   return Dali::Window::New(posSize, name, "", isTransparent);
35 }
36
37 Window Window::New(PositionSize posSize, const std::string& name, const std::string& className, bool isTransparent)
38 {
39   Window newWindow;
40
41   const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable();
42   bool isNewWindowAllowed = true;
43
44   if (isAdaptorAvailable)
45   {
46     Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
47     isNewWindowAllowed = Internal::Adaptor::Adaptor::GetImplementation(adaptor).IsMultipleWindowSupported();
48   }
49
50   if (isNewWindowAllowed)
51   {
52     Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, className, isTransparent);
53
54     Integration::SceneHolder sceneHolder = Integration::SceneHolder(window);
55
56     if (isAdaptorAvailable)
57     {
58       Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
59       Internal::Adaptor::Adaptor::GetImplementation(adaptor).AddWindow(sceneHolder, name, className, isTransparent);
60     }
61     newWindow = Window(window);
62   }
63   else
64   {
65     DALI_LOG_ERROR("This device can't support multiple windows.\n");
66   }
67
68   return newWindow;
69 }
70
71 Window::Window()
72 {
73 }
74
75 Window::~Window()
76 {
77 }
78
79 Window::Window(const Window& handle)
80 : BaseHandle(handle)
81 {
82 }
83
84 Window& Window::operator=(const Window& rhs)
85 {
86   BaseHandle::operator=(rhs);
87   return *this;
88 }
89
90 void Window::Add( Dali::Actor actor )
91 {
92   GetImplementation( *this ).Add( actor );
93 }
94
95 void Window::Remove( Dali::Actor actor )
96 {
97   GetImplementation( *this ).Remove( actor );
98 }
99
100 void Window::SetBackgroundColor( const Vector4& color )
101 {
102   GetImplementation( *this ).SetBackgroundColor( color );
103 }
104
105 Vector4 Window::GetBackgroundColor() const
106 {
107   return GetImplementation( *this ).GetBackgroundColor();
108 }
109
110 Layer Window::GetRootLayer() const
111 {
112   return GetImplementation( *this ).GetRootLayer();
113 }
114
115 uint32_t Window::GetLayerCount() const
116 {
117   return GetImplementation( *this ).GetLayerCount();
118 }
119
120 Layer Window::GetLayer( uint32_t depth ) const
121 {
122   return GetImplementation( *this ).GetLayer( depth );
123 }
124
125 Uint16Pair Window::GetDpi() const
126 {
127   return GetImplementation(*this).GetDpi();
128 }
129
130 void Window::SetClass( std::string name, std::string klass )
131 {
132   GetImplementation(*this).SetClass( name, klass );
133 }
134
135 void Window::Raise()
136 {
137   GetImplementation(*this).Raise();
138 }
139
140 void Window::Lower()
141 {
142   GetImplementation(*this).Lower();
143 }
144
145 void Window::Activate()
146 {
147   GetImplementation(*this).Activate();
148 }
149
150 void Window::AddAvailableOrientation( WindowOrientation orientation )
151 {
152   GetImplementation(*this).AddAvailableOrientation( orientation );
153 }
154
155 void Window::RemoveAvailableOrientation( WindowOrientation orientation )
156 {
157   GetImplementation(*this).RemoveAvailableOrientation( orientation );
158 }
159
160 void Window::SetPreferredOrientation( WindowOrientation orientation )
161 {
162   GetImplementation(*this).SetPreferredOrientation( orientation );
163 }
164
165 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
166 {
167   return GetImplementation(*this).GetPreferredOrientation();
168 }
169
170 Any Window::GetNativeHandle() const
171 {
172   return GetImplementation(*this).GetNativeHandle();
173 }
174
175 Window::FocusChangeSignalType& Window::FocusChangeSignal()
176 {
177   return GetImplementation(*this).FocusChangeSignal();
178 }
179
180 void Window::SetAcceptFocus( bool accept )
181 {
182   GetImplementation(*this).SetAcceptFocus( accept );
183 }
184
185 bool Window::IsFocusAcceptable() const
186 {
187   return GetImplementation(*this).IsFocusAcceptable();
188 }
189
190 void Window::Show()
191 {
192   GetImplementation(*this).Show();
193 }
194
195 void Window::Hide()
196 {
197   GetImplementation(*this).Hide();
198 }
199
200 bool Window::IsVisible() const
201 {
202   return GetImplementation(*this).IsVisible();
203 }
204
205 unsigned int Window::GetSupportedAuxiliaryHintCount() const
206 {
207   return GetImplementation(*this).GetSupportedAuxiliaryHintCount();
208 }
209
210 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
211 {
212   return GetImplementation(*this).GetSupportedAuxiliaryHint( index );
213 }
214
215 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
216 {
217   return GetImplementation(*this).AddAuxiliaryHint( hint, value );
218 }
219
220 bool Window::RemoveAuxiliaryHint( unsigned int id )
221 {
222   return GetImplementation(*this).RemoveAuxiliaryHint( id );
223 }
224
225 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
226 {
227   return GetImplementation(*this).SetAuxiliaryHintValue( id, value );
228 }
229
230 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
231 {
232   return GetImplementation(*this).GetAuxiliaryHintValue( id );
233 }
234
235 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
236 {
237   return GetImplementation(*this).GetAuxiliaryHintId( hint );
238 }
239
240 void Window::SetInputRegion( const Rect< int >& inputRegion )
241 {
242   return GetImplementation(*this).SetInputRegion( inputRegion );
243 }
244
245 void Window::SetType( Window::Type type )
246 {
247   GetImplementation(*this).SetType( type );
248 }
249
250 Window::Type Window::GetType() const
251 {
252   return GetImplementation(*this).GetType();
253 }
254
255 bool Window::SetNotificationLevel( Window::NotificationLevel::Type level )
256 {
257   return GetImplementation(*this).SetNotificationLevel( level );
258 }
259
260 Window::NotificationLevel::Type Window::GetNotificationLevel() const
261 {
262   return GetImplementation(*this).GetNotificationLevel();
263 }
264
265 void Window::SetOpaqueState( bool opaque )
266 {
267   GetImplementation(*this).SetOpaqueState( opaque );
268 }
269
270 bool Window::IsOpaqueState() const
271 {
272   return GetImplementation(*this).IsOpaqueState();
273 }
274
275 bool Window::SetScreenOffMode(Window::ScreenOffMode::Type screenMode)
276 {
277   return GetImplementation(*this).SetScreenOffMode(screenMode);
278 }
279
280 Window::ScreenOffMode::Type Window::GetScreenOffMode() const
281 {
282   return GetImplementation(*this).GetScreenOffMode();
283 }
284
285 bool Window::SetBrightness( int brightness )
286 {
287   return GetImplementation(*this).SetBrightness( brightness );
288 }
289
290 int Window::GetBrightness() const
291 {
292   return GetImplementation(*this).GetBrightness();
293 }
294
295 Window::ResizedSignalType& Window::ResizedSignal()
296 {
297   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: ResizedSignal is deprecated and will be removed from next release.\n" );
298   return GetImplementation(*this).ResizedSignal();
299 }
300
301 Window::ResizeSignalType& Window::ResizeSignal()
302 {
303   return GetImplementation(*this).ResizeSignal();
304 }
305
306 void Window::SetSize( Window::WindowSize size )
307 {
308   GetImplementation(*this).SetSize( size );
309 }
310
311 Window::WindowSize Window::GetSize() const
312 {
313   return GetImplementation(*this).GetSize();
314 }
315
316 void Window::SetPosition( Window::WindowPosition position )
317 {
318   GetImplementation(*this).SetPosition( position );
319 }
320
321 Window::WindowPosition Window::GetPosition() const
322 {
323   return GetImplementation(*this).GetPosition();
324 }
325
326 void Window::SetTransparency( bool transparent )
327 {
328   GetImplementation(*this).SetTransparency( transparent );
329 }
330
331 Dali::RenderTaskList Window::GetRenderTaskList()
332 {
333   return GetImplementation(*this).GetRenderTaskList();
334 }
335
336 Window::KeyEventSignalType& Window::KeyEventSignal()
337 {
338   return GetImplementation(*this).KeyEventSignal();
339 }
340
341 Window::TouchSignalType& Window::TouchSignal()
342 {
343   return GetImplementation(*this).TouchSignal();
344 }
345
346 Window::Window( Internal::Adaptor::Window* window )
347 : BaseHandle( window )
348 {
349 }
350
351 } // namespace Dali