Merge "Use existing callback ID for recurring callbacks" into devel/master
[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) 2020 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.h>
26 #include <dali/public-api/common/vector-wrapper.h>
27 #include <dali/public-api/adaptor-framework/window-enumerations.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 /**
54  * @brief Creates an initialized handle to a new Window.
55  *
56  * @param[in] surface Can be a window or pixmap.
57  * @param[in] windowPosition The position and size of the Window
58  * @param[in] name The Window title
59  * @param[in] isTransparent Whether Window is transparent
60  * @return A new window
61  * @note This creates an extra window in addition to the default main window
62 */
63 DALI_ADAPTOR_API Window New(Any surface, PositionSize windowPosition, const std::string& name, bool isTransparent = false);
64
65 /**
66  * @brief Creates an initialized handle to a new Window.
67  *
68  * @param[in] surface Can be a window or pixmap.
69  * @param[in] windowPosition The position and size of the Window
70  * @param[in] name The Window title
71  * @param[in] className The Window class name
72  * @param[in] isTransparent Whether Window is transparent
73  * @note This creates an extra window in addition to the default main window
74  * @return A new Window
75  */
76 DALI_ADAPTOR_API Window New(Any surface, PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent = false);
77
78 /**
79  * @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.
80  *
81  * @param[in] window The window instance
82  * @param[in] positionSize The new window position and size
83  */
84 DALI_ADAPTOR_API void SetPositionSize(Window window, PositionSize positionSize);
85
86 /**
87  * @brief Retrieve the window that the given actor is added to.
88  *
89  * @param[in] actor The actor
90  * @return The window the actor is added to or an empty handle if the actor is not added to any window.
91  */
92 DALI_ADAPTOR_API Window Get(Actor actor);
93
94 /**
95  * @brief This signal is emitted just after the event processing is finished.
96  *
97  * @param[in] window The window instance
98  * @return The signal to connect to
99  */
100 DALI_ADAPTOR_API EventProcessingFinishedSignalType& EventProcessingFinishedSignal(Window window);
101
102 /**
103  * @brief This signal is emitted when wheel event is received.
104  *
105  * A callback of the following type may be connected:
106  * @code
107  *   void YourCallbackName(const WheelEvent& event);
108  * @endcode
109  * @param[in] window The window instance
110  * @return The signal to connect to
111  */
112 DALI_ADAPTOR_API WheelEventSignalType& WheelEventSignal(Window window);
113
114 /**
115  * @brief This signal is emitted when the window is shown or hidden.
116  *
117  * A callback of the following type may be connected:
118  * @code
119  *   void YourCallbackName( Window window, bool visible );
120  * @endcode
121  * @param[in] window The window instance
122  * @return The signal to connect to
123  */
124 DALI_ADAPTOR_API VisibilityChangedSignalType& VisibilityChangedSignal(Window window);
125
126 /**
127  * @brief This signal is emitted for transition effect.
128  *
129  * The transition animation is appeared when the window is shown/hidden.
130  * When the animation is started, START signal is emitted.
131  * Then the animation is ended, END signal is emitted, too.
132  * A callback of the following type may be connected:
133  * @code
134  *   void YourCallbackName( Window window, EffectState state, EffectType type );
135  * @endcode
136  * @param[in] window The window instance
137  * @return The signal to connect to
138  */
139 DALI_ADAPTOR_API TransitionEffectEventSignalType& TransitionEffectEventSignal(Window window);
140
141 /**
142  * @brief This signal is emitted just after the keyboard repeat setting is changed globally.
143  *
144  * @param[in] window The window instance
145  * @return The signal to connect to
146  */
147 DALI_ADAPTOR_API KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal(Window window);
148
149 /**
150  * @brief Sets parent window of the window.
151  *
152  * After setting that, these windows do together when raise-up, lower and iconified/deiconified.
153  * Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
154  * If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
155  *
156  * @param[in] window The window instance
157  * @param[in] parent The parent window instance
158  */
159 DALI_ADAPTOR_API void SetParent(Window window, Window parent);
160
161 /**
162  * @brief Unsets parent window of the window.
163  *
164  * After unsetting, the window is disconnected his parent window.
165  *
166  * @param[in] window The window instance
167  */
168 DALI_ADAPTOR_API void Unparent(Window window);
169
170 /**
171  * @brief Gets parent window of the window.
172  *
173  * @param[in] window The window instance
174  * @return The parent window of the window
175  */
176 DALI_ADAPTOR_API Window GetParent(Window window);
177
178 /**
179  * @brief Downcast sceneHolder to window
180  *
181  * @param[in] handle The handle need to downcast
182  * @return The window cast from SceneHolder
183  */
184 DALI_ADAPTOR_API Window DownCast(BaseHandle handle);
185
186 /**
187  * @brief Gets current orientation of the window.
188  *
189  * @param[in] window The window instance
190  * @return The current window orientation if previously set, or none
191  */
192 DALI_ADAPTOR_API WindowOrientation GetCurrentOrientation(Window window);
193
194 /**
195  * @brief Sets available orientations of the window.
196  *
197  * This API is for setting several orientations one time.
198  *
199  * @param[in] window The window instance
200  * @param[in] orientations The available orientation list to add
201  */
202 DALI_ADAPTOR_API void SetAvailableOrientations(Window window, const Dali::Vector<WindowOrientation>& orientations);
203
204 /**
205  * @brief Gets current window ID.
206  *
207  * @param[in] window The window instance
208  */
209 DALI_ADAPTOR_API int32_t GetNativeId(Window window);
210
211 /**
212  * @brief Adds a callback that is called when the frame rendering is done by the graphics driver.
213  *
214  * @param[in] window The window instance
215  * @param[in] callback The function to call
216  * @param[in] frameId The Id to specify the frame. It will be passed when the callback is called.
217  *
218  * @note A callback of the following type may be used:
219  * @code
220  *   void MyFunction( int frameId );
221  * @endcode
222  * This callback will be deleted once it is called.
223  *
224  * @note Ownership of the callback is passed onto this class.
225  */
226 DALI_ADAPTOR_API void AddFrameRenderedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId);
227
228 /**
229  * @brief Adds a callback that is called when the frame is displayed on the display.
230  *
231  * @param[in] window The window instance
232  * @param[in] callback The function to call
233  * @param[in] frameId The Id to specify the frame. It will be passed when the callback is called.
234  *
235  * @note A callback of the following type may be used:
236  * @code
237  *   void MyFunction( int frameId );
238  * @endcode
239  * This callback will be deleted once it is called.
240  *
241  * @note Ownership of the callback is passed onto this class.
242  */
243 DALI_ADAPTOR_API void AddFramePresentedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId);
244
245 } // namespace DevelWindow
246
247 } // namespace Dali
248
249 #endif // DALI_WINDOW_DEVEL_H