Add SetParent in 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) 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 typedef Signal<void()> EventProcessingFinishedSignalType; ///< Event Processing finished signal type
39
40 typedef Signal<void(const KeyEvent&)> KeyEventSignalType; ///< Key event signal type
41
42 typedef Signal<void(const TouchEvent&)> TouchEventSignalType; ///< Touch signal type
43
44 typedef Signal<void(const WheelEvent&)> WheelEventSignalType; ///< Touched signal type
45
46 typedef Signal<void(Window, bool)> VisibilityChangedSignalType; ///< Visibility changed signal type
47
48 typedef Signal<void(Window, WindowEffectState, WindowEffectType)> TransitionEffectEventSignalType; ///< Effect signal type and state
49
50 typedef Signal<void()> KeyboardRepeatSettingsChangedSignalType; ///< Keyboard repeat settings 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 Sets parent window of the window.
150  *
151  * After setting that, these windows do together when raise-up, lower and iconified/deiconified.
152  * Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
153  * If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
154  *
155  * @param[in] window The window instance
156  * @param[in] parent The parent window instance
157  */
158 DALI_ADAPTOR_API void SetParent(Window window, Window parent);
159
160 /**
161  * @brief Sets parent window of the window.
162  *
163  * After setting that, these windows do together when raise-up, lower and iconified/deiconified.
164  * This function has the additional flag whether the child is located above or below of the parent.
165  *
166  * @param[in] window The window instance
167  * @param[in] parent The parent window instance
168  * @param[in] belowParent The flag is whether the child is located above or below of the parent.
169  */
170 DALI_ADAPTOR_API void SetParent(Window window, Window parent, bool belowParent);
171
172 /**
173  * @brief Unsets parent window of the window.
174  *
175  * After unsetting, the window is disconnected his parent window.
176  *
177  * @param[in] window The window instance
178  */
179 DALI_ADAPTOR_API void Unparent(Window window);
180
181 /**
182  * @brief Gets parent window of the window.
183  *
184  * @param[in] window The window instance
185  * @return The parent window of the window
186  */
187 DALI_ADAPTOR_API Window GetParent(Window window);
188
189 /**
190  * @brief Downcast sceneHolder to window
191  *
192  * @param[in] handle The handle need to downcast
193  * @return The window cast from SceneHolder
194  */
195 DALI_ADAPTOR_API Window DownCast(BaseHandle handle);
196
197 /**
198  * @brief Gets current orientation of the window.
199  *
200  * @param[in] window The window instance
201  * @return The current window orientation if previously set, or none
202  */
203 DALI_ADAPTOR_API WindowOrientation GetCurrentOrientation(Window window);
204
205 /**
206  * @brief Gets current physical orientation of the window.
207  *
208  * It means current physical rotation angle of the window.
209  * If the height of the display device's area is greater than the width,
210  * default current orientation is PORTRAIT and current physical orientation angle is 0.
211  * If the width of the display device's area is greater than the height,
212  * default current orientation is LANDSCAPE and current physical orientation angle is 0.
213  *
214  * @param[in] window The window instance
215  * @return The current physical orientation degree of the window. It is one of them as 0, 90, 180 and 270.
216  */
217 DALI_ADAPTOR_API int GetPhysicalOrientation(Window window);
218
219 /**
220  * @brief Sets available orientations of the window.
221  *
222  * This API is for setting several orientations one time.
223  *
224  * @param[in] window The window instance
225  * @param[in] orientations The available orientation list to add
226  */
227 DALI_ADAPTOR_API void SetAvailableOrientations(Window window, const Dali::Vector<WindowOrientation>& orientations);
228
229 /**
230  * @brief Gets current window ID.
231  *
232  * @param[in] window The window instance
233  */
234 DALI_ADAPTOR_API int32_t GetNativeId(Window window);
235
236 /**
237  * @brief Adds a callback that is called when the frame rendering is done by the graphics driver.
238  *
239  * @param[in] window The window instance
240  * @param[in] callback The function to call
241  * @param[in] frameId The Id to specify the frame. It will be passed when the callback is called.
242  *
243  * @note A callback of the following type may be used:
244  * @code
245  *   void MyFunction( int frameId );
246  * @endcode
247  * This callback will be deleted once it is called.
248  *
249  * @note Ownership of the callback is passed onto this class.
250  */
251 DALI_ADAPTOR_API void AddFrameRenderedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId);
252
253 /**
254  * @brief Adds a callback that is called when the frame is displayed on the display.
255  *
256  * @param[in] window The window instance
257  * @param[in] callback The function to call
258  * @param[in] frameId The Id to specify the frame. It will be passed when the callback is called.
259  *
260  * @note A callback of the following type may be used:
261  * @code
262  *   void MyFunction( int frameId );
263  * @endcode
264  * This callback will be deleted once it is called.
265  *
266  * @note Ownership of the callback is passed onto this class.
267  */
268 DALI_ADAPTOR_API void AddFramePresentedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId);
269
270 /**
271  * @brief Sets window position and size for specific orientation.
272  * This api reserves the position and size per orientation to display server.
273  * When the device is rotated, the window is moved/resized with the reserved position/size by display server.
274  *
275  * @param[in] window The window instance
276  * @param[in] positionSize The reserved position and size for the orientation
277  * @param[in] orientation The orientation
278  *
279  * @note Currently, it only works when the window's type is WindowType::IME.
280  * @note To set WindowType::IME, use Application New(... WindowType type), not Window::SetType().
281  * @note This function is only useful in Tizen world.
282  */
283 DALI_ADAPTOR_API void SetPositionSizeWithOrientation(Window window, PositionSize positionSize, WindowOrientation orientation);
284
285 /**
286  * @brief Requests to display server for the window is moved by display server.
287  *
288  * This function should be called in mouse down event callback function.
289  * After this function is called in mouse down event callback function, the window is moved with mouse move event.
290  * When mouse up event happens, the window moved work is finished.
291  *
292  * @param[in] window The window instance
293  */
294 DALI_ADAPTOR_API void RequestMoveToServer(Window window);
295
296 /**
297  * @brief Requests to display server for the window is resized by display server.
298  *
299  * This function should be called in mouse down event callback function.
300  * After this function is called in mouse down event callback function, the window is resized with mouse move event.
301  * The direction is selected one of eight ways.
302  * When mouse up event happens, the window resized work is finished.
303  *
304  * @param[in] window The window instance
305  * @param[in] direction it is indicated the window's side or edge for starting point.
306  */
307 DALI_ADAPTOR_API void RequestResizeToServer(Window window, WindowResizeDirection direction);
308
309 /**
310  * @brief Enables the floating mode of window.
311  *
312  * The floating mode is to support making partial size window easliy.
313  * It is useful to make popup style window and this window is always upper than the other normal window.
314  * In addition, it is easy to change between popup style and normal style window.
315  *
316  * A special display server(as a Tizen display server) supports this mode.
317  *
318  * @param[in] window The window instance.
319  * @param[in] enable Enable floating mode or not.
320  */
321 DALI_ADAPTOR_API void EnableFloatingMode(Window window, bool enable);
322
323 /**
324  * @brief Includes input region.
325  *
326  * This function inlcudes input regions.
327  * It can be used multiple times and supports multiple regions.
328  * It means input region will be extended.
329  *
330  * This input is related to mouse and touch event.
331  * If device has touch screen, this function is useful.
332  * Otherwise device does not have that, we can use it after connecting mouse to the device.
333  *
334  * @param[in] window The window instance.
335  * @param[in] inputRegion The added region to accept input events.
336  */
337 DALI_ADAPTOR_API void IncludeInputRegion(Window window, const Rect<int>& inputRegion);
338
339 /**
340  * @brief Excludes input region.
341  *
342  * This function excludes input regions.
343  * It can be used multiple times and supports multiple regions.
344  * It means input region will be reduced.
345  * Nofice, should be set input area by IncludeInputRegion() before this function is used.
346  *
347  * This input is related to mouse and touch event.
348  * If device has touch screen, this function is useful.
349  * Otherwise device does not have that, we can use it after connecting mouse to the device.
350  *
351  * @param[in] window The window instance.
352  * @param[in] inputRegion The subtracted region to except input events.
353  */
354 DALI_ADAPTOR_API void ExcludeInputRegion(Window window, const Rect<int>& inputRegion);
355
356 } // namespace DevelWindow
357
358 } // namespace Dali
359
360 #endif // DALI_WINDOW_DEVEL_H