6d3d0bd345a46c36ef1fecaa1fdc03466ef5a5ef
[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 Unsets parent window of the window.
162  *
163  * After unsetting, the window is disconnected his parent window.
164  *
165  * @param[in] window The window instance
166  */
167 DALI_ADAPTOR_API void Unparent(Window window);
168
169 /**
170  * @brief Gets parent window of the window.
171  *
172  * @param[in] window The window instance
173  * @return The parent window of the window
174  */
175 DALI_ADAPTOR_API Window GetParent(Window window);
176
177 /**
178  * @brief Downcast sceneHolder to window
179  *
180  * @param[in] handle The handle need to downcast
181  * @return The window cast from SceneHolder
182  */
183 DALI_ADAPTOR_API Window DownCast(BaseHandle handle);
184
185 /**
186  * @brief Gets current orientation of the window.
187  *
188  * @param[in] window The window instance
189  * @return The current window orientation if previously set, or none
190  */
191 DALI_ADAPTOR_API WindowOrientation GetCurrentOrientation(Window window);
192
193 /**
194  * @brief Gets current physical orientation of the window.
195  *
196  * It means current physical rotation angle of the window.
197  * If the height of the display device's area is greater than the width,
198  * default current orientation is PORTRAIT and current physical orientation angle is 0.
199  * If the width of the display device's area is greater than the height,
200  * default current orientation is LANDSCAPE and current physical orientation angle is 0.
201  *
202  * @param[in] window The window instance
203  * @return The current physical orientation degree of the window. It is one of them as 0, 90, 180 and 270.
204  */
205 DALI_ADAPTOR_API int GetPhysicalOrientation(Window window);
206
207 /**
208  * @brief Sets available orientations of the window.
209  *
210  * This API is for setting several orientations one time.
211  *
212  * @param[in] window The window instance
213  * @param[in] orientations The available orientation list to add
214  */
215 DALI_ADAPTOR_API void SetAvailableOrientations(Window window, const Dali::Vector<WindowOrientation>& orientations);
216
217 /**
218  * @brief Gets current window ID.
219  *
220  * @param[in] window The window instance
221  */
222 DALI_ADAPTOR_API int32_t GetNativeId(Window window);
223
224 /**
225  * @brief Adds a callback that is called when the frame rendering is done by the graphics driver.
226  *
227  * @param[in] window The window instance
228  * @param[in] callback The function to call
229  * @param[in] frameId The Id to specify the frame. It will be passed when the callback is called.
230  *
231  * @note A callback of the following type may be used:
232  * @code
233  *   void MyFunction( int frameId );
234  * @endcode
235  * This callback will be deleted once it is called.
236  *
237  * @note Ownership of the callback is passed onto this class.
238  */
239 DALI_ADAPTOR_API void AddFrameRenderedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId);
240
241 /**
242  * @brief Adds a callback that is called when the frame is displayed on the display.
243  *
244  * @param[in] window The window instance
245  * @param[in] callback The function to call
246  * @param[in] frameId The Id to specify the frame. It will be passed when the callback is called.
247  *
248  * @note A callback of the following type may be used:
249  * @code
250  *   void MyFunction( int frameId );
251  * @endcode
252  * This callback will be deleted once it is called.
253  *
254  * @note Ownership of the callback is passed onto this class.
255  */
256 DALI_ADAPTOR_API void AddFramePresentedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId);
257
258   /**
259    * @brief Sets window position and size for specific orientation.
260    * This api reserves the position and size per orientation to display server.
261    * When the device is rotated, the window is moved/resized with the reserved position/size by display server.
262    *
263    * @param[in] window The window instance
264    * @param[in] positionSize The reserved position and size for the orientation
265    * @param[in] orientation The orientation
266    *
267    * @note Currently, it only works when the window's type is WindowType::IME.
268    * @note To set WindowType::IME, use Application New(... WindowType type), not Window::SetType().
269    * @note This function is only useful in Tizen world.
270    */
271 DALI_ADAPTOR_API void SetPositionSizeWithOrientation(Window window, PositionSize positionSize, WindowOrientation orientation);
272
273 } // namespace DevelWindow
274
275 } // namespace Dali
276
277 #endif // DALI_WINDOW_DEVEL_H