[Tizen] Add window move/resize completed signal
[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 Maximizes window's size.
431  * If this function is called with true, window will be resized with screen size.
432  * Otherwise window will be resized with previous size.
433  * It is for the window's MAX button in window's border.
434  *
435  * It is for client application.
436  * If window border is supported by display server, it is not necessary.
437  *
438  * @param[in] window The window instance.
439  * @param[in] maximize If window is maximized or unmaximized.
440  */
441 DALI_ADAPTOR_API void Maximize(Window window, bool maximize);
442
443 /**
444  * @brief Returns whether the window is maximized or not.
445  *
446  * @param[in] window The window instance.
447  * @return True if the window is maximized, false otherwise.
448  */
449 DALI_ADAPTOR_API bool IsMaximized(Window window);
450
451 /**
452  * @brief Sets window's maximum size.
453  *
454  * It is to set the maximized size when window is maximized or the window's size is increased by RequestResizeToServer().
455  * Although the size is set by this function, window's size can be increased over the limitation by SetPositionSize() or SetSize().
456  *
457  * After setting, if Maximize() is called, window is resized with the setting size and move the center.
458  *
459  * @param[in] window The window instance.
460  * @param[in] size the maximum size
461  */
462 DALI_ADAPTOR_API void SetMaximumSize(Window window, Dali::Window::WindowSize size);
463
464 /**
465  * @brief Minimizes window's size.
466  * If this function is called with true, window will be iconified.
467  * Otherwise window will be activated.
468  * It is for the window's MIN button in window border.
469  *
470  * It is for client application.
471  * If window border is supported by display server, it is not necessary.
472  *
473  * @param[in] window The window instance.
474  * @param[in] minimize If window is minimized or unminimized(activated).
475  */
476 DALI_ADAPTOR_API void Minimize(Window window, bool minimize);
477
478 /**
479  * @brief Returns whether the window is minimized or not.
480  *
481  * @param[in] window The window instance.
482  * @return True if the window is minimized, false otherwise.
483  */
484 DALI_ADAPTOR_API bool IsMinimized(Window window);
485
486 /**
487  * @brief Sets window's minimum size.
488  *
489  * It is to set the minimum size when window's size is decreased by RequestResizeToServer().
490  * Although the size is set by this function, window's size can be decreased over the limitation by SetPositionSize() or SetSize().
491  *
492  * @param[in] window The window instance.
493  * @param[in] size the minimum size
494  */
495 DALI_ADAPTOR_API void SetMimimumSize(Window window, Dali::Window::WindowSize size);
496
497 /**
498  * @brief Query whether window is rotating or not.
499  *
500  * @param[in] window The window instance.
501  * @return true if window is rotating, false otherwise.
502  */
503 DALI_ADAPTOR_API bool IsWindowRotating(Window window);
504
505 /**
506  * @brief Gets the last key event the window gets.
507  *
508  * @param[in] window The window instance.
509  * @return The last key event the window gets.
510  */
511 DALI_ADAPTOR_API const KeyEvent& GetLastKeyEvent(Window window);
512
513 /**
514  * @brief Gets the last touch event the window gets.
515  *
516  * @param[in] window The window instance.
517  * @return The last touch event the window gets.
518  * @note It returns the raw event the window gets. There is no hit-actor and local position information.
519  */
520 DALI_ADAPTOR_API const TouchEvent& GetLastTouchEvent(Window window);
521
522 /**
523  * @brief The user would connect to this signal to intercept a KeyEvent at window.
524  *
525  * Intercepts KeyEvents in the window before dispatching KeyEvents to the control.
526  * If a KeyEvent is consumed, no KeyEvent is delivered to the control.
527  *
528  * @param[in] window The window instance.
529  * @return The signal to connect to
530  */
531 DALI_ADAPTOR_API InterceptKeyEventSignalType& InterceptKeyEventSignal(Window window);
532
533 /**
534  * @brief This signal is emitted when the window is moved.
535  *
536  * A callback of the following type may be connected:
537  * @code
538  *   void YourCallbackName( Window window, Dali::Window::WindowPosition position );
539  * @endcode
540  * The parameters are the moved x and y coordinates.
541  * and window means this signal was called from what window
542  *
543  * @param[in] window The window instance.
544  * @return The signal to connect to
545  */
546 DALI_ADAPTOR_API MovedSignalType& MovedSignal(Window window);
547
548 /**
549  * @brief This signal is emitted when the window orientation is changed.
550  *
551  * To emit Window Orientation signal, AddAvailableOrientation() or SetPreferredOrientation() should be called before device is rotated.
552  * Most of cases, AddAvailableOrientation() or SetPreferredOrientation() is callled in onCreate().
553  *
554  * A callback of the following type may be connected:
555  * @code
556  *   void YourCallbackName( Window window, Dali::WindowOrientation orientation );
557  * @endcode
558  * The parameter is the changed window orientation.
559  * and window means this signal was called from what window
560  *
561  * @param[in] window The window instance.
562  * @return The signal to connect to
563  */
564 DALI_ADAPTOR_API OrientationChangedSignalType& OrientationChangedSignal(Window window);
565
566 /**
567  * @brief This signal is emitted when the mouse in or out event is received.
568  *
569  * A callback of the following type may be connected:
570  * @code
571  *   void YourCallbackName( Window window, Dali::MouseInOutEvent event );
572  * @endcode
573  *
574  * @param[in] window The window instance.
575  * @return The signal to connect to
576  */
577 DALI_ADAPTOR_API MouseInOutEventSignalType& MouseInOutEventSignal(Window window);
578
579 /**
580  * @brief This signal is emitted when window has been moved by the display server.
581  * To make the window move by display server, RequestMoveToServer() should be called.
582  * After the moving job is completed, this function will be called.
583  *
584  * A callback of the following type may be connected:
585  * @code
586  *   void YourCallbackName( Window window, Dali::Window::WindowPosition position );
587  * @endcode
588  * The parameters are the moved x and y coordinates.
589  * and window means this signal was called from what window
590  *
591  * @param[in] window The window instance.
592  * @return The signal to connect to
593  */
594 DALI_ADAPTOR_API MoveCompletedSignalType& MoveCompletedSignal(Window window);
595
596 /**
597  * @brief This signal is emitted when window has been resized by the display server.
598  * To make the window move by display server, RequestResizeToServer() should be called.
599  * After the resizing job is completed, this function will be called.
600  *
601  * A callback of the following type may be connected:
602  * @code
603  *   void YourCallbackName( Window window, Dali::Window::WindowPosition position );
604  * @endcode
605  * The parameters are the resized width and height coordinates.
606  * and window means this signal was called from what window
607  *
608  * @param[in] window The window instance.
609  * @return The signal to connect to
610  */
611 DALI_ADAPTOR_API ResizeCompletedSignalType& ResizeCompletedSignal(Window window);
612
613 } // namespace DevelWindow
614
615 } // namespace Dali
616
617 #endif // DALI_WINDOW_DEVEL_H