Merge "Use another framework in OffscreenApplication" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / window-devel.h
1 #ifndef DALI_WINDOW_DEVEL_H
2 #define DALI_WINDOW_DEVEL_H
3
4 /*
5  * Copyright (c) 2023 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 <memory>
23
24 // INTERNAL INCLUDES
25 #include <dali/devel-api/adaptor-framework/mouse-in-out-event.h>
26 #include <dali/public-api/adaptor-framework/window-enumerations.h>
27 #include <dali/public-api/adaptor-framework/window.h>
28 #include <dali/public-api/common/vector-wrapper.h>
29
30 namespace Dali
31 {
32 class KeyEvent;
33 class TouchEvent;
34 class WheelEvent;
35 class RenderTaskList;
36 struct TouchPoint;
37
38 namespace DevelWindow
39 {
40 typedef Signal<void()>                                                               EventProcessingFinishedSignalType;       ///< Event Processing finished signal type
41 typedef Signal<void(const KeyEvent&)>                                                KeyEventSignalType;                      ///< Key event signal type
42 typedef Signal<void(const TouchEvent&)>                                              TouchEventSignalType;                    ///< Touch signal type
43 typedef Signal<void(const WheelEvent&)>                                              WheelEventSignalType;                    ///< Wheel signal type
44 typedef Signal<void(Window, bool)>                                                   VisibilityChangedSignalType;             ///< Visibility changed signal type
45 typedef Signal<void(Window, WindowEffectState, WindowEffectType)>                    TransitionEffectEventSignalType;         ///< Effect signal type and state
46 typedef Signal<void()>                                                               KeyboardRepeatSettingsChangedSignalType; ///< Keyboard repeat settings changed signal type
47 typedef Signal<void(const std::string&, const std::string&, const Property::Array&)> AuxiliaryMessageSignalType;              ///< Auxiliary message signal type
48 typedef Signal<void(Window, bool)>                                                   AccessibilityHighlightSignalType;        ///< Accessibility Highlight signal type
49 typedef Signal<bool(const KeyEvent&)>                                                InterceptKeyEventSignalType;             ///< Intercept Key event signal type
50 typedef Signal<void(Window, Dali::Window::WindowPosition)>                           MovedSignalType;                         ///< Window Moved signal type
51 typedef Signal<void(Window, Dali::WindowOrientation)>                                OrientationChangedSignalType;            ///< Window orientation changed signal type
52 typedef Signal<void(Window, const Dali::DevelWindow::MouseInOutEvent&)>              MouseInOutEventSignalType;               ///< MouseInOutEvent signal type
53 typedef Signal<void(Window, Dali::Window::WindowPosition)>                           MoveCompletedSignalType;                 ///< Window Moved by Server signal type
54 typedef Signal<void(Window, Dali::Window::WindowSize)>                               ResizeCompletedSignalType;               ///< Window Resized by Server signal type
55
56 /**
57  * @brief Creates an initialized handle to a new Window.
58  *
59  * @param[in] surface Can be a window or pixmap.
60  * @param[in] windowPosition The position and size of the Window
61  * @param[in] name The Window title
62  * @param[in] isTransparent Whether Window is transparent
63  * @return A new window
64  * @note This creates an extra window in addition to the default main window
65  */
66 DALI_ADAPTOR_API Window New(Any surface, PositionSize windowPosition, const std::string& name, bool isTransparent = false);
67
68 /**
69  * @brief Creates an initialized handle to a new Window.
70  *
71  * @param[in] surface Can be a window or pixmap.
72  * @param[in] windowPosition The position and size of the Window
73  * @param[in] name The Window title
74  * @param[in] className The Window class name
75  * @param[in] isTransparent Whether Window is transparent
76  * @note This creates an extra window in addition to the default main window
77  * @return A new Window
78  */
79 DALI_ADAPTOR_API Window New(Any surface, PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent = false);
80
81 /**
82  * @brief Sets position and size of the window. This API guarantees that both moving and resizing of window will appear on the screen at once.
83  *
84  * @param[in] window The window instance
85  * @param[in] positionSize The new window position and size
86  */
87 DALI_ADAPTOR_API void SetPositionSize(Window window, PositionSize positionSize);
88
89 /**
90  * @brief Retrieve the window that the given actor is added to.
91  *
92  * @param[in] actor The actor
93  * @return The window the actor is added to or an empty handle if the actor is not added to any window.
94  */
95 DALI_ADAPTOR_API Window Get(Actor actor);
96
97 /**
98  * @brief This signal is emitted just after the event processing is finished.
99  *
100  * @param[in] window The window instance
101  * @return The signal to connect to
102  */
103 DALI_ADAPTOR_API EventProcessingFinishedSignalType& EventProcessingFinishedSignal(Window window);
104
105 /**
106  * @brief This signal is emitted when wheel event is received.
107  *
108  * A callback of the following type may be connected:
109  * @code
110  *   void YourCallbackName(const WheelEvent& event);
111  * @endcode
112  * @param[in] window The window instance
113  * @return The signal to connect to
114  */
115 DALI_ADAPTOR_API WheelEventSignalType& WheelEventSignal(Window window);
116
117 /**
118  * @brief This signal is emitted when the window is shown or hidden.
119  *
120  * A callback of the following type may be connected:
121  * @code
122  *   void YourCallbackName( Window window, bool visible );
123  * @endcode
124  * @param[in] window The window instance
125  * @return The signal to connect to
126  */
127 DALI_ADAPTOR_API VisibilityChangedSignalType& VisibilityChangedSignal(Window window);
128
129 /**
130  * @brief This signal is emitted for transition effect.
131  *
132  * The transition animation is appeared when the window is shown/hidden.
133  * When the animation is started, START signal is emitted.
134  * Then the animation is ended, END signal is emitted, too.
135  * A callback of the following type may be connected:
136  * @code
137  *   void YourCallbackName( Window window, EffectState state, EffectType type );
138  * @endcode
139  * @param[in] window The window instance
140  * @return The signal to connect to
141  */
142 DALI_ADAPTOR_API TransitionEffectEventSignalType& TransitionEffectEventSignal(Window window);
143
144 /**
145  * @brief This signal is emitted just after the keyboard repeat setting is changed globally.
146  *
147  * @param[in] window The window instance
148  * @return The signal to connect to
149  */
150 DALI_ADAPTOR_API KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal(Window window);
151
152 /**
153  * @brief This signal is emitted when window's auxiliary was changed then display server sent the message.
154  *
155  * Auxiliary message is sent by display server.
156  * When client application added the window's auxiliary hint and if the auxiliary is changed,
157  * display server send the auxiliary message.
158  * Auxiliary message has the key, value and options.
159  *
160  * @param[in] window The window instance
161  * @return The signal to connect to
162  */
163 DALI_ADAPTOR_API AuxiliaryMessageSignalType& AuxiliaryMessageSignal(Window window);
164
165 /**
166  * @brief This signal is emitted when the window needs to grab or clear accessibility highlight.
167  * The highlight indicates that it is an object to interact with the user regardless of focus.
168  * After setting the highlight on the object, you can do things that the object can do, such as
169  * giving or losing focus.
170  *
171  * This signal is emitted by Dali::Accessibility::Component::GrabHighlight
172  * and Dali::Accessibility::Component::ClearHighlight
173  *
174  * A callback of the following type may be connected:
175  * @code
176  *   void YourCallbackName( Window window, bool highlight );
177  * @endcode
178  *
179  * @param[in] window The window instance
180  * @return The signal to connect to
181  */
182 DALI_ADAPTOR_API AccessibilityHighlightSignalType& AccessibilityHighlightSignal(Window window);
183
184 /**
185  * @brief Sets parent window of the window.
186  *
187  * After setting that, these windows do together when raise-up, lower and iconified/deiconified.
188  * Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
189  * If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
190  *
191  * @param[in] window The window instance
192  * @param[in] parent The parent window instance
193  */
194 DALI_ADAPTOR_API void SetParent(Window window, Window parent);
195
196 /**
197  * @brief Sets parent window of the window.
198  *
199  * After setting that, these windows do together when raise-up, lower and iconified/deiconified.
200  * This function has the additional flag whether the child is located above or below of the parent.
201  *
202  * @param[in] window The window instance
203  * @param[in] parent The parent window instance
204  * @param[in] belowParent The flag is whether the child is located above or below of the parent.
205  */
206 DALI_ADAPTOR_API void SetParent(Window window, Window parent, bool belowParent);
207
208 /**
209  * @brief Unsets parent window of the window.
210  *
211  * After unsetting, the window is disconnected his parent window.
212  *
213  * @param[in] window The window instance
214  */
215 DALI_ADAPTOR_API void Unparent(Window window);
216
217 /**
218  * @brief Gets parent window of the window.
219  *
220  * @param[in] window The window instance
221  * @return The parent window of the window
222  */
223 DALI_ADAPTOR_API Window GetParent(Window window);
224
225 /**
226  * @brief Gets current orientation of the window.
227  *
228  * @param[in] window The window instance
229  * @return The current window orientation if previously set, or none
230  */
231 DALI_ADAPTOR_API WindowOrientation GetCurrentOrientation(Window window);
232
233 /**
234  * @brief Gets current physical orientation of the window.
235  *
236  * It means current physical rotation angle of the window.
237  * If the height of the display device's area is greater than the width,
238  * default current orientation is PORTRAIT and current physical orientation angle is 0.
239  * If the width of the display device's area is greater than the height,
240  * default current orientation is LANDSCAPE and current physical orientation angle is 0.
241  *
242  * @param[in] window The window instance
243  * @return The current physical orientation degree of the window. It is one of them as 0, 90, 180 and 270.
244  */
245 DALI_ADAPTOR_API int GetPhysicalOrientation(Window window);
246
247 /**
248  * @brief Sets available orientations of the window.
249  *
250  * This API is for setting several orientations one time.
251  *
252  * @param[in] window The window instance
253  * @param[in] orientations The available orientation list to add
254  */
255 DALI_ADAPTOR_API void SetAvailableOrientations(Window window, const Dali::Vector<WindowOrientation>& orientations);
256
257 /**
258  * @brief Gets current window ID.
259  *
260  * @param[in] window The window instance
261  */
262 DALI_ADAPTOR_API int32_t GetNativeId(Window window);
263
264 /**
265  * @brief Adds a callback that is called when the frame rendering is done by the graphics driver.
266  *
267  * @param[in] window The window instance
268  * @param[in] callback The function to call
269  * @param[in] frameId The Id to specify the frame. It will be passed when the callback is called.
270  *
271  * @note A callback of the following type may be used:
272  * @code
273  *   void MyFunction( int frameId );
274  * @endcode
275  * This callback will be deleted once it is called.
276  *
277  * @note Ownership of the callback is passed onto this class.
278  */
279 DALI_ADAPTOR_API void AddFrameRenderedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId);
280
281 /**
282  * @brief Adds a callback that is called when the frame is displayed on the display.
283  *
284  * @param[in] window The window instance
285  * @param[in] callback The function to call
286  * @param[in] frameId The Id to specify the frame. It will be passed when the callback is called.
287  *
288  * @note A callback of the following type may be used:
289  * @code
290  *   void MyFunction( int frameId );
291  * @endcode
292  * This callback will be deleted once it is called.
293  *
294  * @note Ownership of the callback is passed onto this class.
295  */
296 DALI_ADAPTOR_API void AddFramePresentedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId);
297
298 /**
299  * @brief Sets window position and size for specific orientation.
300  * This api reserves the position and size per orientation to display server.
301  * When the device is rotated, the window is moved/resized with the reserved position/size by display server.
302  *
303  * @param[in] window The window instance
304  * @param[in] positionSize The reserved position and size for the orientation
305  * @param[in] orientation The orientation
306  *
307  * @note Currently, it only works when the window's type is WindowType::IME.
308  * @note To set WindowType::IME, use Application New(... WindowType type), not Window::SetType().
309  * @note This function is only useful in Tizen world.
310  */
311 DALI_ADAPTOR_API void SetPositionSizeWithOrientation(Window window, PositionSize positionSize, WindowOrientation orientation);
312
313 /**
314  * @brief Requests to display server for the window is moved by display server.
315  *
316  * This function should be called in mouse down event callback function.
317  * After this function is called in mouse down event callback function, the window is moved with mouse move event.
318  * When mouse up event happens, the window moved work is finished.
319  *
320  * @param[in] window The window instance
321  */
322 DALI_ADAPTOR_API void RequestMoveToServer(Window window);
323
324 /**
325  * @brief Requests to display server for the window is resized by display server.
326  *
327  * This function should be called in mouse down event callback function.
328  * After this function is called in mouse down event callback function, the window is resized with mouse move event.
329  * The direction is selected one of eight ways.
330  * When mouse up event happens, the window resized work is finished.
331  *
332  * @param[in] window The window instance
333  * @param[in] direction it is indicated the window's side or edge for starting point.
334  */
335 DALI_ADAPTOR_API void RequestResizeToServer(Window window, WindowResizeDirection direction);
336
337 /**
338  * @brief Enables the floating mode of window.
339  *
340  * The floating mode is to support making partial size window easliy.
341  * It is useful to make popup style window and this window is always upper than the other normal window.
342  * In addition, it is easy to change between popup style and normal style window.
343  *
344  * A special display server(as a Tizen display server) supports this mode.
345  *
346  * @param[in] window The window instance.
347  * @param[in] enable Enable floating mode or not.
348  */
349 DALI_ADAPTOR_API void EnableFloatingMode(Window window, bool enable);
350
351 /**
352  * @brief Includes input region.
353  *
354  * This function inlcudes input regions.
355  * It can be used multiple times and supports multiple regions.
356  * It means input region will be extended.
357  *
358  * This input is related to mouse and touch event.
359  * If device has touch screen, this function is useful.
360  * Otherwise device does not have that, we can use it after connecting mouse to the device.
361  *
362  * @param[in] window The window instance.
363  * @param[in] inputRegion The added region to accept input events.
364  */
365 DALI_ADAPTOR_API void IncludeInputRegion(Window window, const Rect<int>& inputRegion);
366
367 /**
368  * @brief Excludes input region.
369  *
370  * This function excludes input regions.
371  * It can be used multiple times and supports multiple regions.
372  * It means input region will be reduced.
373  * Nofice, should be set input area by IncludeInputRegion() before this function is used.
374  *
375  * This input is related to mouse and touch event.
376  * If device has touch screen, this function is useful.
377  * Otherwise device does not have that, we can use it after connecting mouse to the device.
378  *
379  * @param[in] window The window instance.
380  * @param[in] inputRegion The subtracted region to except input events.
381  */
382 DALI_ADAPTOR_API void ExcludeInputRegion(Window window, const Rect<int>& inputRegion);
383
384 /**
385  * @brief Sets the necessary for window rotation Acknowledgement.
386  * After this function called, SendRotationCompletedAcknowledgement() should be called to complete window rotation.
387  *
388  * This function is supprot that application has the window rotation acknowledgement's control.
389  * It means display server waits when application's rotation work is finished.
390  * It is useful application has the other rendering engine which works asynchronous.
391  * For instance, GlView.
392  * It only works on Tizen device.
393  *
394  * @param[in] window The window instance.
395  * @param[in] needAcknowledgement the flag is true if window rotation acknowledge is sent.
396  */
397 DALI_ADAPTOR_API void SetNeedsRotationCompletedAcknowledgement(Window window, bool needAcknowledgement);
398
399 /**
400  * @brief send the Acknowledgement to complete window rotation.
401  * For this function, SetNeedsRotationCompletedAcknowledgement should be already called with true.
402  *
403  * @param[in] window The window instance.
404  */
405 DALI_ADAPTOR_API void SendRotationCompletedAcknowledgement(Window window);
406
407 /**
408  * @brief Feed (Send) touch event to window
409  * @param[in] window The window instance
410  * @param[in] point The touch point
411  * @param[in] timeStamp The time stamp
412  */
413 DALI_ADAPTOR_API void FeedTouchPoint(Window window, const Dali::TouchPoint& point, int32_t timeStamp);
414
415 /**
416  * @brief Feed (Send) wheel event to window
417  * @param[in] window The window instance
418  * @param[in] wheelEvent The wheel event
419  */
420 DALI_ADAPTOR_API void FeedWheelEvent(Window window, const Dali::WheelEvent& wheelEvent);
421
422 /**
423  * @brief Feed (Send) key event to window
424  * @param[in] window The window instance
425  * @param[in] keyEvent The key event holding the key information.
426  */
427 DALI_ADAPTOR_API void FeedKeyEvent(Window window, const Dali::KeyEvent& keyEvent);
428
429 /**
430  * @brief Feed (Send) hover event to window
431  * @param[in] window The window instance
432  * @param[in] point The touch point that create a hover event
433  */
434 DALI_ADAPTOR_API void FeedHoverEvent(Window window, const Dali::TouchPoint& point);
435
436 /**
437  * @brief Maximizes window's size.
438  * If this function is called with true, window will be resized with screen size.
439  * Otherwise window will be resized with previous size.
440  * It is for the window's MAX button in window's border.
441  *
442  * It is for client application.
443  * If window border is supported by display server, it is not necessary.
444  *
445  * @param[in] window The window instance.
446  * @param[in] maximize If window is maximized or unmaximized.
447  */
448 DALI_ADAPTOR_API void Maximize(Window window, bool maximize);
449
450 /**
451  * @brief Returns whether the window is maximized or not.
452  *
453  * @param[in] window The window instance.
454  * @return True if the window is maximized, false otherwise.
455  */
456 DALI_ADAPTOR_API bool IsMaximized(Window window);
457
458 /**
459  * @brief Sets window's maximum size.
460  *
461  * It is to set the maximized size when window is maximized or the window's size is increased by RequestResizeToServer().
462  * Although the size is set by this function, window's size can be increased over the limitation by SetPositionSize() or SetSize().
463  *
464  * After setting, if Maximize() is called, window is resized with the setting size and move the center.
465  *
466  * @param[in] window The window instance.
467  * @param[in] size the maximum size
468  */
469 DALI_ADAPTOR_API void SetMaximumSize(Window window, Dali::Window::WindowSize size);
470
471 /**
472  * @brief Minimizes window's size.
473  * If this function is called with true, window will be iconified.
474  * Otherwise window will be activated.
475  * It is for the window's MIN button in window border.
476  *
477  * It is for client application.
478  * If window border is supported by display server, it is not necessary.
479  *
480  * @param[in] window The window instance.
481  * @param[in] minimize If window is minimized or unminimized(activated).
482  */
483 DALI_ADAPTOR_API void Minimize(Window window, bool minimize);
484
485 /**
486  * @brief Returns whether the window is minimized or not.
487  *
488  * @param[in] window The window instance.
489  * @return True if the window is minimized, false otherwise.
490  */
491 DALI_ADAPTOR_API bool IsMinimized(Window window);
492
493 /**
494  * @brief Sets window's minimum size.
495  *
496  * It is to set the minimum size when window's size is decreased by RequestResizeToServer().
497  * Although the size is set by this function, window's size can be decreased over the limitation by SetPositionSize() or SetSize().
498  *
499  * @param[in] window The window instance.
500  * @param[in] size the minimum size
501  */
502 DALI_ADAPTOR_API void SetMimimumSize(Window window, Dali::Window::WindowSize size);
503
504 /**
505  * @brief Query whether window is rotating or not.
506  *
507  * @param[in] window The window instance.
508  * @return true if window is rotating, false otherwise.
509  */
510 DALI_ADAPTOR_API bool IsWindowRotating(Window window);
511
512 /**
513  * @brief Gets the last key event the window gets.
514  *
515  * @param[in] window The window instance.
516  * @return The last key event the window gets.
517  */
518 DALI_ADAPTOR_API const KeyEvent& GetLastKeyEvent(Window window);
519
520 /**
521  * @brief Gets the last touch event the window gets.
522  *
523  * @param[in] window The window instance.
524  * @return The last touch event the window gets.
525  * @note It returns the raw event the window gets. There is no hit-actor and local position information.
526  */
527 DALI_ADAPTOR_API const TouchEvent& GetLastTouchEvent(Window window);
528
529 /**
530  * @brief The user would connect to this signal to intercept a KeyEvent at window.
531  *
532  * Intercepts KeyEvents in the window before dispatching KeyEvents to the control.
533  * If a KeyEvent is consumed, no KeyEvent is delivered to the control.
534  *
535  * @param[in] window The window instance.
536  * @return The signal to connect to
537  */
538 DALI_ADAPTOR_API InterceptKeyEventSignalType& InterceptKeyEventSignal(Window window);
539
540 /**
541  * @brief This signal is emitted when the window is moved.
542  *
543  * A callback of the following type may be connected:
544  * @code
545  *   void YourCallbackName( Window window, Dali::Window::WindowPosition position );
546  * @endcode
547  * The parameters are the moved x and y coordinates.
548  * and window means this signal was called from what window
549  *
550  * @param[in] window The window instance.
551  * @return The signal to connect to
552  */
553 DALI_ADAPTOR_API MovedSignalType& MovedSignal(Window window);
554
555 /**
556  * @brief This signal is emitted when the window orientation is changed.
557  *
558  * To emit Window Orientation signal, AddAvailableOrientation() or SetPreferredOrientation() should be called before device is rotated.
559  * Most of cases, AddAvailableOrientation() or SetPreferredOrientation() is callled in onCreate().
560  *
561  * A callback of the following type may be connected:
562  * @code
563  *   void YourCallbackName( Window window, Dali::WindowOrientation orientation );
564  * @endcode
565  * The parameter is the changed window orientation.
566  * and window means this signal was called from what window
567  *
568  * @param[in] window The window instance.
569  * @return The signal to connect to
570  */
571 DALI_ADAPTOR_API OrientationChangedSignalType& OrientationChangedSignal(Window window);
572
573 /**
574  * @brief This signal is emitted when the mouse in or out event is received.
575  *
576  * A callback of the following type may be connected:
577  * @code
578  *   void YourCallbackName( Window window, Dali::MouseInOutEvent event );
579  * @endcode
580  *
581  * @param[in] window The window instance.
582  * @return The signal to connect to
583  */
584 DALI_ADAPTOR_API MouseInOutEventSignalType& MouseInOutEventSignal(Window window);
585
586 /**
587  * @brief This signal is emitted when window has been moved by the display server.
588  * To make the window move by display server, RequestMoveToServer() should be called.
589  * After the moving job is completed, this function will be called.
590  *
591  * A callback of the following type may be connected:
592  * @code
593  *   void YourCallbackName( Window window, Dali::Window::WindowPosition position );
594  * @endcode
595  * The parameters are the moved x and y coordinates.
596  * and window means this signal was called from what window
597  *
598  * @param[in] window The window instance.
599  * @return The signal to connect to
600  */
601 DALI_ADAPTOR_API MoveCompletedSignalType& MoveCompletedSignal(Window window);
602
603 /**
604  * @brief This signal is emitted when window has been resized by the display server.
605  * To make the window move by display server, RequestResizeToServer() should be called.
606  * After the resizing job is completed, this function will be called.
607  *
608  * A callback of the following type may be connected:
609  * @code
610  *   void YourCallbackName( Window window, Dali::Window::WindowPosition position );
611  * @endcode
612  * The parameters are the resized width and height coordinates.
613  * and window means this signal was called from what window
614  *
615  * @param[in] window The window instance.
616  * @return The signal to connect to
617  */
618 DALI_ADAPTOR_API ResizeCompletedSignalType& ResizeCompletedSignal(Window window);
619
620 } // namespace DevelWindow
621
622 } // namespace Dali
623
624 #endif // DALI_WINDOW_DEVEL_H