Merge "Remove CXX03 Build & old Tizen Version Builds" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/ref-object.h>
23 #include <dali/public-api/object/base-object.h>
24 #include <dali/public-api/actors/layer.h>
25 #include <dali/public-api/render-tasks/render-task-list.h>
26
27 #ifdef DALI_ADAPTOR_COMPILATION
28 #include <dali/integration-api/scene-holder-impl.h>
29 #else
30 #include <dali/integration-api/adaptors/scene-holder-impl.h>
31 #endif
32
33 // INTERNAL INCLUDES
34 #include <dali/public-api/adaptor-framework/window.h>
35 #include <dali/public-api/adaptor-framework/key-grab.h>
36 #include <dali/devel-api/adaptor-framework/drag-and-drop-detector.h>
37 #include <dali/devel-api/adaptor-framework/window-devel.h>
38
39 namespace Dali
40 {
41 class Adaptor;
42 class Actor;
43 class RenderSurfaceInterface;
44
45 namespace Internal
46 {
47 namespace Adaptor
48 {
49 class EventHandler;
50 class Orientation;
51 class RotationObserver;
52 class WindowRenderSurface;
53 class WindowBase;
54
55 class Window;
56 using WindowPtr = IntrusivePtr< Window >;
57 using OrientationPtr = IntrusivePtr< Orientation >;
58 using EventHandlerPtr = IntrusivePtr< EventHandler >;
59
60 /**
61  * Window provides a surface to render onto with orientation & indicator properties.
62  */
63 class Window : public Dali::Internal::Adaptor::SceneHolder, public ConnectionTracker
64 {
65 public:
66   typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
67   typedef Dali::Window::FocusSignalType FocusSignalType;
68   typedef Dali::Window::ResizedSignalType ResizedSignalType;
69   typedef Signal< void () > SignalType;
70
71   /**
72    * Create a new Window. This should only be called once by the Application class
73    * @param[in] positionSize The position and size of the window
74    * @param[in] name The window title
75    * @param[in] className The window class name
76    * @param[in] isTransparent Whether window is transparent
77    * @return A newly allocated Window
78    */
79   static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
80
81   /**
82    * @copydoc Dali::Window::ShowIndicator()
83    */
84   void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
85
86   /**
87    * @copydoc Dali::Window::SetIndicatorBgOpacity()
88    */
89   void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
90
91   /**
92    * @copydoc Dali::Window::RotateIndicator()
93    */
94   void RotateIndicator( Dali::Window::WindowOrientation orientation );
95
96   /**
97    * @copydoc Dali::Window::SetClass()
98    */
99   void SetClass( std::string name, std::string className );
100
101   /**
102    * @brief Gets the window class name.
103    * @return The class of the window
104    */
105   std::string GetClassName() const;
106
107   /**
108    * @copydoc Dali::Window::Raise()
109    */
110   void Raise();
111
112   /**
113    * @copydoc Dali::Window::Lower()
114    */
115   void Lower();
116
117   /**
118    * @copydoc Dali::Window::Activate()
119    */
120   void Activate();
121
122   /**
123    * @copydoc Dali::Window::GetLayerCount()
124    */
125   uint32_t GetLayerCount() const;
126
127   /**
128    * @copydoc Dali::Window::GetLayer()
129    */
130   Dali::Layer GetLayer( uint32_t depth ) const;
131
132   /**
133    * @copydoc Dali::Window::AddAvailableOrientation()
134    */
135   void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
136
137   /**
138    * @copydoc Dali::Window::RemoveAvailableOrientation()
139    */
140   void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
141
142   /**
143    * @copydoc Dali::Window::SetAvailableOrientations()
144    */
145   void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
146
147   /**
148    * @copydoc Dali::Window::GetAvailableOrientations()
149    */
150   const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
151
152   /**
153    * @copydoc Dali::Window::SetPreferredOrientation()
154    */
155   void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
156
157   /**
158    * @copydoc Dali::Window::GetPreferredOrientation()
159    */
160   Dali::Window::WindowOrientation GetPreferredOrientation();
161
162   /**
163    * @copydoc Dali::Window::GetDragAndDropDetector() const
164    */
165   Dali::DragAndDropDetector GetDragAndDropDetector() const;
166
167   /**
168    * @copydoc Dali::Window::SetAcceptFocus()
169    */
170   void SetAcceptFocus( bool accept );
171
172   /**
173    * @copydoc Dali::Window::IsFocusAcceptable()
174    */
175   bool IsFocusAcceptable() const;
176
177   /**
178    * @copydoc Dali::Window::Show()
179    */
180   void Show();
181
182   /**
183    * @copydoc Dali::Window::Hide()
184    */
185   void Hide();
186
187   /**
188    * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
189    */
190   unsigned int GetSupportedAuxiliaryHintCount() const;
191
192   /**
193    * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
194    */
195   std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
196
197   /**
198    * @copydoc Dali::Window::AddAuxiliaryHint()
199    */
200   unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
201
202   /**
203    * @copydoc Dali::Window::RemoveAuxiliaryHint()
204    */
205   bool RemoveAuxiliaryHint( unsigned int id );
206
207   /**
208    * @copydoc Dali::Window::SetAuxiliaryHintValue()
209    */
210   bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
211
212   /**
213    * @copydoc Dali::Window::GetAuxiliaryHintValue()
214    */
215   std::string GetAuxiliaryHintValue( unsigned int id ) const;
216
217   /**
218    * @copydoc Dali::Window::GetAuxiliaryHintId()
219    */
220   unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
221
222   /**
223    * @copydoc Dali::Window::SetInputRegion()
224    */
225   void SetInputRegion( const Rect< int >& inputRegion );
226
227   /**
228    * @copydoc Dali::Window::SetType()
229    */
230   void SetType( Dali::Window::Type type );
231
232   /**
233    * @copydoc Dali::Window::GetType() const
234    */
235   Dali::Window::Type GetType() const;
236
237   /**
238    * @copydoc Dali::Window::SetNotificationLevel()
239    */
240   bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level );
241
242   /**
243    * @copydoc Dali::Window::GetNotificationLevel()
244    */
245   Dali::Window::NotificationLevel::Type GetNotificationLevel() const;
246
247   /**
248    * @copydoc Dali::Window::SetOpaqueState()
249    */
250   void SetOpaqueState( bool opaque );
251
252   /**
253    * @copydoc Dali::Window::IsOpaqueState()
254    */
255   bool IsOpaqueState() const;
256
257   /**
258    * @copydoc Dali::Window::SetScreenOffMode()
259    */
260   bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode);
261
262   /**
263    * @copydoc Dali::Window::GetScreenOffMode()
264    */
265   Dali::Window::ScreenOffMode::Type GetScreenOffMode() const;
266
267   /**
268    * @copydoc Dali::Window::SetBrightness()
269    */
270   bool SetBrightness( int brightness );
271
272   /**
273    * @copydoc Dali::Window::GetBrightness()
274    */
275   int GetBrightness() const;
276
277   /**
278    * @copydoc Dali::Window::SetSize()
279    */
280   void SetSize( Dali::Window::WindowSize size );
281
282   /**
283    * @copydoc Dali::Window::GetSize()
284    */
285   Dali::Window::WindowSize GetSize() const;
286
287   /**
288    * @copydoc Dali::Window::SetPosition()
289    */
290   void SetPosition( Dali::Window::WindowPosition position );
291
292   /**
293    * @copydoc Dali::Window::GetPosition()
294    */
295   Dali::Window::WindowPosition GetPosition() const;
296
297   /**
298    * @copydoc Dali::DevelWindow::SetPositionSize()
299    */
300   void SetPositionSize( PositionSize positionSize );
301
302   /**
303    * @copydoc Dali::DevelWindow::GetRootLayer()
304    */
305   Dali::Layer GetRootLayer();
306
307   /**
308    * @copydoc Dali::Window::SetTransparency()
309    */
310   void SetTransparency( bool transparent );
311
312   /**
313    * @copydoc Dali::KeyGrab::GrabKey()
314    */
315   bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
316
317   /**
318    * @copydoc Dali::KeyGrab::UngrabKey()
319    */
320   bool UngrabKey( Dali::KEY key );
321
322   /**
323    * @copydoc Dali::KeyGrab::GrabKeyList()
324    */
325   bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
326
327   /**
328    * @copydoc Dali::KeyGrab::UngrabKeyList()
329    */
330   bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
331
332   /**
333    * Called from Orientation after the Change signal has been sent
334    */
335   void RotationDone( int orientation, int width, int height );
336
337   /**
338    * Set the rotation observer (note, some adaptors may not have a rotation observer)
339    * @param[in] observer The rotation observer
340    * @return If the rotation observer is set
341    */
342   bool SetRotationObserver( RotationObserver* observer );
343
344 public: // Dali::Internal::Adaptor::SceneHolder
345
346   /**
347    * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
348    */
349   Dali::Any GetNativeHandle() const override;
350
351   /**
352    * @copydoc Dali::Internal::Adaptor::SceneHolder::IsVisible
353    */
354   bool IsVisible() const override;
355
356 private:
357
358   /**
359    * Private constructor.
360    * @sa Window::New()
361    */
362   Window();
363
364   /**
365    * Destructor
366    */
367   virtual ~Window();
368
369   /**
370    * Second stage initialization
371    */
372   void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
373
374   /**
375    * Called when the window becomes iconified or deiconified.
376    */
377   void OnIconifyChanged( bool iconified );
378
379   /**
380    * Called when the window focus is changed.
381    */
382   void OnFocusChanged( bool focusIn );
383
384   /**
385    * Called when the output is transformed.
386    */
387   void OnOutputTransformed();
388
389   /**
390    * Called when the window receives a delete request.
391    */
392   void OnDeleteRequest();
393
394 private: // Dali::Internal::Adaptor::SceneHolder
395
396   /**
397    * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedTouchPoint
398    */
399   void FeedTouchPoint( TouchPoint& point, int timeStamp ) override;
400
401   /**
402    * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedWheelEvent
403    */
404   void FeedWheelEvent( WheelEvent& wheelEvent ) override;
405
406   /**
407    * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedKeyEvent
408    */
409   void FeedKeyEvent( KeyEvent& keyEvent ) override;
410
411   /**
412    * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
413    */
414   void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
415
416   /**
417    * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
418    */
419   void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
420
421   /**
422    * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
423    */
424   void OnPause() override;
425
426   /**
427    * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
428    */
429   void OnResume() override;
430
431 public: // Signals
432
433   /**
434    * The user should connect to this signal to get a timing when indicator was shown / hidden.
435    */
436   IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
437
438   /**
439    * @copydoc Dali::Window::FocusChangedSignal()
440    */
441   FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
442
443   /**
444    * @copydoc Dali::Window::ResizedSignal()
445    */
446   ResizedSignalType& ResizedSignal() { return mResizedSignal; }
447
448   /**
449    * This signal is emitted when the window is requesting to be deleted
450    */
451   SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
452
453   /**
454    * @copydoc Dali::Window::SignalEventProcessingFinished()
455    */
456   Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); };
457
458   /**
459    * @copydoc Dali::Window::KeyEventSignal()
460    */
461   Dali::DevelWindow::KeyEventSignalType& KeyEventSignal() { return mScene.KeyEventSignal(); };
462
463   /**
464     * @copydoc Dali::Window::TouchSignal()
465     */
466   Dali::DevelWindow::TouchSignalType& TouchSignal() { return mScene.TouchSignal(); };
467
468   /**
469    * @copydoc Dali::Window::WheelEventSignal()
470    */
471   Dali::DevelWindow::WheelEventSignalType& WheelEventSignal() { return mScene.WheelEventSignal(); };
472
473 private:
474
475   WindowRenderSurface*                  mWindowSurface;      ///< The window rendering surface
476   WindowBase*                           mWindowBase;
477   std::string                           mName;
478   std::string                           mClassName;
479   bool                                  mIsTransparent:1;
480   bool                                  mIsFocusAcceptable:1;
481   bool                                  mIconified:1;
482   bool                                  mOpaqueState:1;
483   bool                                  mResizeEnabled:1;
484   Dali::DragAndDropDetector             mDragAndDropDetector;
485   Dali::Window::Type                    mType;
486
487   OrientationPtr                               mOrientation;
488   std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
489   Dali::Window::WindowOrientation              mPreferredOrientation;
490
491   EventHandlerPtr                       mEventHandler;      ///< The window events handler
492
493   // Signals
494   IndicatorSignalType                   mIndicatorVisibilityChangedSignal;
495   FocusSignalType                       mFocusChangedSignal;
496   ResizedSignalType                     mResizedSignal;
497   SignalType                            mDeleteRequestSignal;
498
499
500 };
501
502 } // namespace Adaptor
503 } // namepsace Internal
504
505 // Helpers for public-api forwarding methods
506
507 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
508 {
509   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
510   BaseObject& object = window.GetBaseObject();
511   return static_cast<Internal::Adaptor::Window&>(object);
512 }
513
514 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
515 {
516   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
517   const BaseObject& object = window.GetBaseObject();
518   return static_cast<const Internal::Adaptor::Window&>(object);
519 }
520
521 } // namespace Dali
522
523 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_H