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