Revert "[Tizen] Revert "Support multiple window rendering""
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / window.h
1 #ifndef __DALI_WINDOW_H__
2 #define __DALI_WINDOW_H__
3
4 /*
5  * Copyright (c) 2018 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 <string>
23 #include <dali/public-api/math/rect.h>
24 #include <dali/public-api/math/uint-16-pair.h>
25 #include <dali/public-api/math/vector2.h>
26 #include <dali/public-api/math/vector4.h>
27 #include <dali/public-api/object/base-handle.h>
28 #include <dali/public-api/object/any.h>
29 #include <dali/public-api/signals/dali-signal.h>
30
31 // INTERNAL INCLUDES
32 #include <dali/public-api/dali-adaptor-common.h>
33
34 namespace Dali
35 {
36 /**
37  * @addtogroup dali_adaptor_framework
38  * @{
39  */
40
41 typedef Dali::Rect<int> PositionSize;
42
43 namespace Internal DALI_INTERNAL
44 {
45 namespace Adaptor
46 {
47 class Window;
48 }
49 }
50
51 class DragAndDropDetector;
52 class Orientation;
53 class Actor;
54 class Layer;
55
56 /**
57  * @brief The window class is used internally for drawing.
58  *
59  * A Window has an orientation and indicator properties.
60  * You can get a valid Window handle by calling Dali::Application::GetWindow().
61  * @SINCE_1_0.0
62  */
63 class DALI_ADAPTOR_API Window : public BaseHandle
64 {
65 public:
66
67   typedef Uint16Pair WindowSize;          ///< Window size type @SINCE_1_2.60
68   typedef Uint16Pair WindowPosition;      ///< Window position type @SINCE_1_2.60
69
70   typedef Signal< void (bool) > IndicatorSignalType;  ///< @DEPRECATED_1_4.9 @brief Indicator state signal type @SINCE_1_0.0
71   typedef Signal< void (bool) > FocusSignalType;         ///< Window focus signal type @SINCE_1_2.60
72   typedef Signal< void (WindowSize) > ResizedSignalType; ///< Window resized signal type @SINCE_1_2.60
73
74 public:
75
76   // Enumerations
77
78   /**
79    * @brief Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
80    * @SINCE_1_0.0
81    */
82   enum WindowOrientation
83   {
84     PORTRAIT = 0,  ///< Portrait orientation. The height of the display area is greater than the width. @SINCE_1_0.0
85     LANDSCAPE = 90,  ///< Landscape orientation. A wide view area is needed. @SINCE_1_0.0
86     PORTRAIT_INVERSE = 180,  ///< Portrait inverse orientation @SINCE_1_0.0
87     LANDSCAPE_INVERSE = 270  ///< Landscape inverse orientation @SINCE_1_0.0
88   };
89
90   /**
91    * @DEPRECATED_1_4.9
92    * @brief Enumeration for opacity of the indicator.
93    * @SINCE_1_0.0
94    */
95   enum IndicatorBgOpacity
96   {
97     OPAQUE = 100, ///< @DEPRECATED_1_4.9 @brief Fully opaque indicator Bg @SINCE_1_0.0
98     TRANSLUCENT = 50, ///< @DEPRECATED_1_4.9 @brief Semi translucent indicator Bg @SINCE_1_0.0
99     TRANSPARENT = 0 ///< @DEPRECATED_1_4.9 @brief Fully transparent indicator Bg @SINCE_1_0.0
100   };
101
102   /**
103    * @DEPRECATED_1_4.9
104    * @brief Enumeration for visible mode of the indicator.
105    * @SINCE_1_0.0
106    */
107   enum IndicatorVisibleMode
108   {
109     INVISIBLE = 0, ///< @DEPRECATED_1_4.9 @brief Hide indicator @SINCE_1_0.0
110     VISIBLE = 1, ///< @DEPRECATED_1_4.9 @brief Show indicator @SINCE_1_0.0
111     AUTO = 2 ///< @DEPRECATED_1_4.9 @brief Hide in default, will show when necessary @SINCE_1_0.0
112   };
113
114   /**
115    * @brief An enum of Window types.
116    * @SINCE_1_2.60
117    */
118   enum Type
119   {
120     NORMAL,           ///< A default window type. Indicates a normal, top-level window. Almost every window will be created with this type. @SINCE_1_2.60
121     NOTIFICATION,     ///< A notification window, like a warning about battery life or a new E-Mail received. @SINCE_1_2.60
122     UTILITY,          ///< A persistent utility window, like a toolbox or palette. @SINCE_1_2.60
123     DIALOG            ///< Used for simple dialog windows. @SINCE_1_2.60
124   };
125
126   /**
127    * @brief An enum of screen mode.
128    * @SINCE_1_2.60
129    */
130   struct NotificationLevel
131   {
132     /**
133      * @brief An enum of screen mode.
134      * @SINCE_1_2.60
135      */
136     enum Type
137     {
138       NONE   = -1,    ///< No notification level. Default level. This value makes the notification window place in the layer of the normal window. @SINCE_1_2.60
139       BASE   = 10,    ///< Base notification level. @SINCE_1_2.60
140       MEDIUM = 20,    ///< Higher notification level than base. @SINCE_1_2.60
141       HIGH   = 30,    ///< Higher notification level than medium. @SINCE_1_2.60
142       TOP    = 40     ///< The highest notification level. @SINCE_1_2.60
143     };
144   };
145
146   /**
147    * @brief An enum of screen mode.
148    * @SINCE_1_2.60
149    */
150   struct ScreenOffMode
151   {
152     /**
153      * @brief An enum of screen mode.
154      * @SINCE_1_2.60
155      */
156     enum Type
157     {
158       TIMEOUT,              ///< The mode which turns the screen off after a timeout. @SINCE_1_2.60
159       NEVER,                ///< The mode which keeps the screen turned on. @SINCE_1_2.60
160     };
161
162     static constexpr Type DEFAULT { TIMEOUT }; ///< The default mode. @SINCE_1_2.60
163   };
164
165   // Methods
166
167   /**
168    * @brief Creates an initialized handle to a new Window.
169    * @SINCE_1_0.0
170    * @param[in] windowPosition The position and size of the Window
171    * @param[in] name The Window title
172    * @param[in] isTransparent Whether Window is transparent
173    * @return A new window
174    */
175   static Window New(PositionSize windowPosition, const std::string& name, bool isTransparent = false);
176
177   /**
178    * @brief Creates an initialized handle to a new Window.
179    * @SINCE_1_0.0
180    * @param[in] windowPosition The position and size of the Window
181    * @param[in] name The Window title
182    * @param[in] className The Window class name
183    * @param[in] isTransparent Whether Window is transparent
184    * @return A new Window
185    */
186   static Window New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent = false);
187
188   /**
189    * @brief Creates an uninitialized handle.
190    *
191    * This can be initialized using Dali::Application::GetWindow() or
192    * Dali::Window::New().
193    * @SINCE_1_0.0
194    */
195   Window();
196
197   /**
198    * @brief Destructor.
199    *
200    * This is non-virtual since derived Handle types must not contain data or virtual methods.
201    * @SINCE_1_0.0
202    */
203   ~Window();
204
205   /**
206    * @brief This copy constructor is required for (smart) pointer semantics.
207    *
208    * @SINCE_1_0.0
209    * @param[in] handle A reference to the copied handle
210    */
211   Window(const Window& handle);
212
213   /**
214    * @brief This assignment operator is required for (smart) pointer semantics.
215    *
216    * @SINCE_1_0.0
217    * @param[in] rhs A reference to the copied handle
218    * @return A reference to this
219    */
220   Window& operator=(const Window& rhs);
221
222   /**
223    * @DEPRECATED_1_4.9
224    * @brief This sets whether the indicator bar should be shown or not.
225    * @SINCE_1_0.0
226    * @param[in] visibleMode Visible mode for indicator bar, VISIBLE in default
227    */
228   void ShowIndicator( IndicatorVisibleMode visibleMode ) DALI_DEPRECATED_API;
229
230   /**
231    * @DEPRECATED_1_4.9
232    * @brief This sets the opacity mode of indicator bar.
233    * @SINCE_1_0.0
234    * @param[in] opacity The opacity mode
235    */
236   void SetIndicatorBgOpacity( IndicatorBgOpacity opacity ) DALI_DEPRECATED_API;
237
238   /**
239    * @DEPRECATED_1_4.9
240    * @brief This sets the orientation of indicator bar.
241    *
242    * It does not implicitly show the indicator if it is currently hidden.
243    * @SINCE_1_0.0
244    * @param[in] orientation The orientation
245    */
246   void RotateIndicator(WindowOrientation orientation) DALI_DEPRECATED_API;
247
248   /**
249    * @brief Sets the window name and class string.
250    * @SINCE_1_0.0
251    * @param[in] name The name of the window
252    * @param[in] klass The class of the window
253    */
254   void SetClass(std::string name, std::string klass);
255
256   /**
257    * @brief Raises window to the top of Window stack.
258    * @SINCE_1_0.0
259    */
260   void Raise();
261
262   /**
263    * @brief Lowers window to the bottom of Window stack.
264    * @SINCE_1_0.0
265    */
266   void Lower();
267
268   /**
269    * @brief Activates window to the top of Window stack even it is iconified.
270    * @SINCE_1_0.0
271    */
272   void Activate();
273
274   /**
275    * @brief Adds an orientation to the list of available orientations.
276    * @SINCE_1_0.0
277    * @param[in] orientation The available orientation to add
278    */
279   void AddAvailableOrientation( WindowOrientation orientation );
280
281   /**
282    * @brief Removes an orientation from the list of available orientations.
283    * @SINCE_1_0.0
284    * @param[in] orientation The available orientation to remove
285    */
286   void RemoveAvailableOrientation( WindowOrientation orientation );
287
288   /**
289    * @brief Sets a preferred orientation.
290    * @SINCE_1_0.0
291    * @param[in] orientation The preferred orientation
292    * @pre Orientation is in the list of available orientations.
293    */
294   void SetPreferredOrientation( WindowOrientation orientation );
295
296   /**
297    * @brief Gets the preferred orientation.
298    * @SINCE_1_0.0
299    * @return The preferred orientation if previously set, or none
300    */
301   WindowOrientation GetPreferredOrientation();
302
303   /**
304    * @brief Returns the Drag & drop detector which can be used to receive drag & drop events.
305    * @note  Not intended for application developers.
306    * @SINCE_1_0.0
307    * @return A handle to the DragAndDropDetector
308    */
309   DragAndDropDetector GetDragAndDropDetector() const;
310
311   /**
312    * @brief Gets the native handle of the window.
313    *
314    * When users call this function, it wraps the actual type used by the underlying window system.
315    * @SINCE_1_0.0
316    * @return The native handle of the Window or an empty handle
317    */
318   Any GetNativeHandle() const;
319
320   /**
321    * @brief Sets whether window accepts focus or not.
322    *
323    * @SINCE_1_2.60
324    * @param[in] accept If focus is accepted or not. Default is true.
325    */
326   void SetAcceptFocus( bool accept );
327
328   /**
329    * @brief Returns whether window accepts focus or not.
330    *
331    * @SINCE_1_2.60
332    * @return True if the window accept focus, false otherwise
333    */
334   bool IsFocusAcceptable() const;
335
336   /**
337    * @brief Shows the window if it is hidden.
338    * @SINCE_1_2.60
339    */
340   void Show();
341
342   /**
343    * @brief Hides the window if it is showing.
344    * @SINCE_1_2.60
345    */
346   void Hide();
347
348   /**
349    * @brief Returns whether the window is visible or not.
350    * @SINCE_1_2.60
351    * @return True if the window is visible, false otherwise.
352    */
353   bool IsVisible() const;
354
355   /**
356    * @brief Gets the count of supported auxiliary hints of the window.
357    * @SINCE_1_2.60
358    * @return The number of supported auxiliary hints.
359    *
360    * @note The window auxiliary hint is the value which is used to decide which actions should be made available to the user by the window manager.
361    * If you want to set specific hint to your window, then you should check whether it exists in the supported auxiliary hints.
362    */
363   unsigned int GetSupportedAuxiliaryHintCount() const;
364
365   /**
366    * @brief Gets the supported auxiliary hint string of the window.
367    * @SINCE_1_2.60
368    * @param[in] index The index of the supported auxiliary hint lists
369    * @return The auxiliary hint string of the index.
370    *
371    * @note The window auxiliary hint is the value which is used to decide which actions should be made available to the user by the window manager.
372    * If you want to set specific hint to your window, then you should check whether it exists in the supported auxiliary hints.
373    */
374   std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
375
376   /**
377    * @brief Creates an auxiliary hint of the window.
378    * @SINCE_1_2.60
379    * @param[in] hint The auxiliary hint string.
380    * @param[in] value The value string.
381    * @return The ID of created auxiliary hint, or @c 0 on failure.
382    */
383   unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
384
385   /**
386    * @brief Removes an auxiliary hint of the window.
387    * @SINCE_1_2.60
388    * @param[in] id The ID of the auxiliary hint.
389    * @return True if no error occurred, false otherwise.
390    */
391   bool RemoveAuxiliaryHint( unsigned int id );
392
393   /**
394    * @brief Changes a value of the auxiliary hint.
395    * @SINCE_1_2.60
396    * @param[in] id The auxiliary hint ID.
397    * @param[in] value The value string to be set.
398    * @return True if no error occurred, false otherwise.
399    */
400   bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
401
402   /**
403    * @brief Gets a value of the auxiliary hint.
404    * @SINCE_1_2.60
405    * @param[in] id The auxiliary hint ID.
406    * @return The string value of the auxiliary hint ID, or an empty string if none exists.
407    */
408   std::string GetAuxiliaryHintValue( unsigned int id ) const;
409
410   /**
411    * @brief Gets a ID of the auxiliary hint string.
412    * @SINCE_1_2.60
413    * @param[in] hint The auxiliary hint string.
414    * @return The ID of the auxiliary hint string, or @c 0 if none exists.
415    */
416   unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
417
418   /**
419    * @brief Sets a region to accept input events.
420    * @SINCE_1_2.60
421    * @param[in] inputRegion The region to accept input events.
422    */
423   void SetInputRegion( const Rect< int >& inputRegion );
424
425   /**
426    * @brief Sets a window type.
427    * @SINCE_1_2.60
428    * @param[in] type The window type.
429    * @remarks The default window type is NORMAL.
430    */
431   void SetType( Type type );
432
433   /**
434    * @brief Gets a window type.
435    * @SINCE_1_2.60
436    * @return A window type.
437    */
438   Type GetType() const;
439
440   /**
441    * @brief Sets a priority level for the specified notification window.
442    * @SINCE_1_2.60
443    * @param[in] level The notification window level.
444    * @return True if no error occurred, false otherwise.
445    * @PRIVLEVEL_PUBLIC
446    * @PRIVILEGE_WINDOW_PRIORITY
447    * @remarks This can be used for a notification type window only. The default level is NotificationLevel::NONE.
448    */
449   bool SetNotificationLevel( NotificationLevel::Type level );
450
451   /**
452    * @brief Gets a priority level for the specified notification window.
453    * @SINCE_1_2.60
454    * @return The notification window level.
455    * @remarks This can be used for a notification type window only.
456    */
457   NotificationLevel::Type GetNotificationLevel() const;
458
459   /**
460    * @brief Sets a transparent window's visual state to opaque.
461    * @details If a visual state of a transparent window is opaque,
462    * then the window manager could handle it as an opaque window when calculating visibility.
463    * @SINCE_1_2.60
464    * @param[in] opaque Whether the window's visual state is opaque.
465    * @remarks This will have no effect on an opaque window.
466    * It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
467    */
468   void SetOpaqueState( bool opaque );
469
470   /**
471    * @brief Returns whether a transparent window's visual state is opaque or not.
472    * @SINCE_1_2.60
473    * @return True if the window's visual state is opaque, false otherwise.
474    * @remarks The return value has no meaning on an opaque window.
475    */
476   bool IsOpaqueState() const;
477
478   /**
479    * @brief Sets a window's screen off mode.
480    * @details This API is useful when the application needs to keep the display turned on.
481    * If the application sets the screen mode to #::Dali::Window::ScreenOffMode::NEVER to its window and the window is shown,
482    * the window manager requests the display system to keep the display on as long as the window is shown.
483    * If the window is no longer shown, then the window manager requests the display system to go back to normal operation.
484    * @SINCE_1_2.60
485    * @param[in] screenOffMode The screen mode.
486    * @return True if no error occurred, false otherwise.
487    * @PRIVLEVEL_PUBLIC
488    * @PRIVILEGE_DISPLAY
489    */
490   bool SetScreenOffMode(ScreenOffMode::Type screenOffMode);
491
492   /**
493    * @brief Gets a screen off mode of the window.
494    * @SINCE_1_2.60
495    * @return The screen off mode.
496    */
497   ScreenOffMode::Type GetScreenOffMode() const;
498
499   /**
500    * @brief Sets preferred brightness of the window.
501    * @details This API is useful when the application needs to change the brightness of the screen when it is appeared on the screen.
502    * If the brightness has been set and the window is shown, the window manager requests the display system to change the brightness to the provided value.
503    * If the window is no longer shown, then the window manager requests the display system to go back to default brightness.
504    * A value less than 0 results in default brightness and a value greater than 100 results in maximum brightness.
505    * @SINCE_1_2.60
506    * @param[in] brightness The preferred brightness (0 to 100).
507    * @return True if no error occurred, false otherwise.
508    * @PRIVLEVEL_PUBLIC
509    * @PRIVILEGE_DISPLAY
510    */
511   bool SetBrightness( int brightness );
512
513   /**
514    * @brief Gets preferred brightness of the window.
515    * @SINCE_1_2.60
516    * @return The preferred brightness.
517    */
518   int GetBrightness() const;
519
520   /**
521    * @brief Sets a size of the window.
522    *
523    * @SINCE_1_2.60
524    * @param[in] size The new window size
525    */
526   void SetSize( WindowSize size );
527
528   /**
529    * @brief Gets a size of the window.
530    *
531    * @SINCE_1_2.60
532    * @return The size of the window
533    */
534   WindowSize GetSize() const;
535
536   /**
537    * @brief Sets a position of the window.
538    *
539    * @SINCE_1_2.60
540    * @param[in] position The new window position
541    */
542   void SetPosition( WindowPosition position );
543
544   /**
545    * @brief Gets a position of the window.
546    *
547    * @SINCE_1_2.60
548    * @return The position of the window
549    */
550   WindowPosition GetPosition() const;
551
552   /**
553    * @brief Sets whether the window is transparent or not.
554    *
555    * @SINCE_1_2.60
556    * @param[in] transparent Whether the window is transparent
557    */
558   void SetTransparency( bool transparent );
559
560 public: // Signals
561   /**
562    * @DEPRECATED_1_4.9
563    * @brief The user should connect to this signal to get a timing when indicator was shown / hidden.
564    * @SINCE_1_0.0
565    * @return The signal to connect to
566    */
567   IndicatorSignalType& IndicatorVisibilityChangedSignal() DALI_DEPRECATED_API;
568
569   /**
570    * @brief The user should connect to this signal to get a timing when window gains focus or loses focus.
571    *
572    * A callback of the following type may be connected:
573    * @code
574    *   void YourCallbackName( bool focusIn );
575    * @endcode
576    * The parameter is true if window gains focus, otherwise false.
577    *
578    * @SINCE_1_2.60
579    * @return The signal to connect to
580    */
581   FocusSignalType& FocusChangedSignal();
582
583   /**
584    * @brief This signal is emitted when the window is resized.
585    *
586    * A callback of the following type may be connected:
587    * @code
588    *   void YourCallbackName( int width, int height );
589    * @endcode
590    * The parameters are the resized width and height.
591    *
592    * @SINCE_1_2.60
593    * @return The signal to connect to
594    */
595   ResizedSignalType& ResizedSignal();
596
597 public: // Not intended for application developers
598   /// @cond internal
599   /**
600    * @brief This constructor is used by Dali::Application::GetWindow().
601    * @SINCE_1_0.0
602    * @param[in] window A pointer to the Window
603    */
604   explicit DALI_INTERNAL Window( Internal::Adaptor::Window* window );
605   /// @endcond
606 };
607
608 /**
609  * @}
610  */
611 } // namespace Dali
612
613 #endif // __DALI_WINDOW_H__