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