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