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