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