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