1 #ifndef __DALI_ADAPTOR_H__
2 #define __DALI_ADAPTOR_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <boost/function.hpp>
24 #include "tts-player.h"
25 #include <dali/public-api/signals/dali-signal-v2.h>
26 #include <dali/public-api/math/rect.h>
27 #include <dali/public-api/events/touch-event.h>
29 namespace Dali DALI_IMPORT_API
35 namespace Internal DALI_INTERNAL
44 * @brief An Adaptor object is used to initialize and control how Dali runs.
46 * It provides a lifecycle interface that allows the application
47 * writer to provide their own main loop and other platform related
50 * The Adaptor class provides a means for initialising the resources required by the Dali::Core.
52 * When dealing with platform events, the application writer MUST ensure that Dali is called in a
55 * As soon as the Adaptor class is created and started, the application writer can initialise their
56 * Dali::Actor objects straight away or as required by the main loop they intend to use (there is no
57 * need to wait for an initialise signal as per the Dali::Application class).
59 * The Adaptor does emit a Resize signal which informs the user when the surface is resized.
60 * Tizen and Linux Adaptors should follow the example below:
63 * void CreateProgram(DaliAdaptor& adaptor)
65 * // Create Dali components...
66 * // Can instantiate adaptor here instead, if required
71 * // Initialise platform
74 * // Create an 800 by 1280 window positioned at (0,0).
75 * Dali::PositionSize positionSize(0, 0, 800, 1280);
76 * Dali::Window window = Dali::Window::New( positionSize, "My Application" );
78 * // Create an adaptor which uses that window for rendering
79 * Dali::Adaptor adaptor = Dali::Adaptor::New( window );
82 * CreateProgram(adaptor);
83 * // Or use this as a callback function depending on the platform initialisation sequence.
85 * // Start Main Loop of your platform
86 * MyPlatform.StartMainLoop();
92 * If required, you can also connect class member functions to a signal:
95 * MyApplication application;
96 * adaptor.ResizedSignal().Connect(&application, &MyApplication::Resize);
105 typedef SignalV2< void (Adaptor&) > AdaptorSignalV2; ///< Generic Type for adaptor signals
109 * @brief Create a new adaptor using the window.
111 * @param[in] window The window to draw onto
112 * @note The default base layout DeviceLayout::DEFAULT_BASE_LAYOUT will be used.
113 * @return a reference to the adaptor handle
115 static Adaptor& New( Window window );
118 * @brief Create a new adaptor using the window.
120 * @param[in] window The window to draw onto
121 * @param[in] baseLayout The base layout that the application has been written for
122 * @return a reference to the adaptor handle
124 static Adaptor& New( Window window, const DeviceLayout& baseLayout );
127 * @brief Virtual Destructor.
134 * @brief Starts the Adaptor.
139 * @brief Pauses the Adaptor.
144 * @brief Resumes the Adaptor, if previously paused.
146 * @note If the adaptor is not paused, this does not do anything.
151 * @brief Stops the Adaptor.
156 * @brief Ensures that the function passed in is called from the main loop when it is idle.
158 * A callback of the following type may be used:
163 * @param[in] callBack The function to call.
164 * @return true if added successfully, false otherwise
166 bool AddIdle( boost::function<void(void)> callBack );
169 * @brief Get the render surface the adaptor is using to render to.
171 * @return reference to current render surface
173 RenderSurface& GetSurface();
176 * @brief Returns a reference to the instance of the adaptor used by the current thread.
178 * @return A reference to the adaptor.
179 * @pre The adaptor has been initialised.
180 * @note This is only valid in the main thread.
182 static Adaptor& Get();
185 * @brief Checks whether the adaptor is available.
187 * @return true, if it is available, false otherwise.
189 static bool IsAvailable();
192 * @brief Registers the singleton of Dali handle with its type info.
194 * The singleton will be kept alive for the life time of the
196 * @note This is not intended for application developers.
197 * @param[in] info The type info of the Dali handle generated by the compiler.
198 * @param[in] singleton The Dali handle to be registered
200 void RegisterSingleton(const std::type_info& info, BaseHandle singleton);
203 * @brief Gets the singleton for the given type.
205 * @note This is not intended for application developers.
206 * @param[in] info The type info of the given type.
207 * @return the Dali handle if it is registered as a singleton or an uninitialized handle.
209 BaseHandle GetSingleton(const std::type_info& info) const;
212 * @brief Call this method to notify Dali when the system language changes.
214 * Use this only when NOT using Dali::Application, As Application created using
215 * Dali::Application will automatically receive notification of language change.
216 * When Dali::Application is not used, the application developer should
217 * use app-core to receive language change notifications and should update Dali
218 * by calling this method.
220 void NotifyLanguageChanged();
223 * @brief Sets minimum distance in pixels that the fingers must move towards/away from each other in order to
224 * trigger a pinch gesture
226 * @param[in] distance The minimum pinch distance in pixels
228 void SetMinimumPinchDistance(float distance);
233 * @brief The user should connect to this signal if they need to perform any
234 * special activities when the surface Dali is being rendered on is resized.
236 * @return The signal to connect to
238 AdaptorSignalV2& ResizedSignal();
241 * @brief This signal is emitted when the language is changed on the device.
243 * @return The signal to connect to
245 AdaptorSignalV2& LanguageChangedSignal();
250 Adaptor(const Adaptor&);
251 Adaptor& operator=(Adaptor&);
256 * @brief Create an uninitialized Adaptor.
258 DALI_INTERNAL Adaptor();
260 Internal::Adaptor::Adaptor* mImpl; ///< Implementation object
261 friend class Internal::Adaptor::Adaptor;
266 #endif // __DALI_ADAPTOR_H__