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 * @addtogroup CAPI_DALI_ADAPTOR_MODULE
27 #include <boost/function.hpp>
29 #include "tts-player.h"
30 #include <dali/public-api/signals/dali-signal-v2.h>
31 #include <dali/public-api/math/rect.h>
32 #include <dali/public-api/events/touch-event.h>
34 namespace Dali DALI_IMPORT_API
40 namespace Internal DALI_INTERNAL
49 * @brief An Adaptor object is used to initialize and control how Dali runs.
51 * It provides a lifecycle interface that allows the application
52 * writer to provide their own main loop and other platform related
55 * The Adaptor class provides a means for initialising the resources required by the Dali::Core.
57 * When dealing with platform events, the application writer MUST ensure that Dali is called in a
60 * As soon as the Adaptor class is created and started, the application writer can initialise their
61 * Dali::Actor objects straight away or as required by the main loop they intend to use (there is no
62 * need to wait for an initialise signal as per the Dali::Application class).
64 * The Adaptor does emit a Resize signal which informs the user when the surface is resized.
65 * Tizen and Linux Adaptors should follow the example below:
68 * void CreateProgram(DaliAdaptor& adaptor)
70 * // Create Dali components...
71 * // Can instantiate adaptor here instead, if required
76 * // Initialise platform
79 * // Create an 800 by 1280 window positioned at (0,0).
80 * Dali::PositionSize positionSize(0, 0, 800, 1280);
81 * Dali::Window window = Dali::Window::New( positionSize, "My Application" );
83 * // Create an adaptor which uses that window for rendering
84 * Dali::Adaptor adaptor = Dali::Adaptor::New( window );
87 * CreateProgram(adaptor);
88 * // Or use this as a callback function depending on the platform initialisation sequence.
90 * // Start Main Loop of your platform
91 * MyPlatform.StartMainLoop();
97 * If required, you can also connect class member functions to a signal:
100 * MyApplication application;
101 * adaptor.ResizedSignal().Connect(&application, &MyApplication::Resize);
110 typedef SignalV2< void (Adaptor&) > AdaptorSignalV2; ///< Generic Type for adaptor signals
114 * @brief Create a new adaptor using the window.
116 * @param[in] window The window to draw onto
117 * @note The default base layout DeviceLayout::DEFAULT_BASE_LAYOUT will be used.
118 * @return a reference to the adaptor handle
120 static Adaptor& New( Window window );
123 * @brief Create a new adaptor using the window.
125 * @param[in] window The window to draw onto
126 * @param[in] baseLayout The base layout that the application has been written for
127 * @return a reference to the adaptor handle
129 static Adaptor& New( Window window, const DeviceLayout& baseLayout );
132 * @brief Virtual Destructor.
139 * @brief Starts the Adaptor.
144 * @brief Pauses the Adaptor.
149 * @brief Resumes the Adaptor, if previously paused.
151 * @note If the adaptor is not paused, this does not do anything.
156 * @brief Stops the Adaptor.
161 * @brief Ensures that the function passed in is called from the main loop when it is idle.
163 * A callback of the following type may be used:
168 * @param[in] callBack The function to call.
169 * @return true if added successfully, false otherwise
171 bool AddIdle( boost::function<void(void)> callBack );
174 * @brief Get the render surface the adaptor is using to render to.
176 * @return reference to current render surface
178 RenderSurface& GetSurface();
181 * @brief Returns a reference to the instance of the adaptor used by the current thread.
183 * @return A reference to the adaptor.
184 * @pre The adaptor has been initialised.
185 * @note This is only valid in the main thread.
187 static Adaptor& Get();
190 * @brief Checks whether the adaptor is available.
192 * @return true, if it is available, false otherwise.
194 static bool IsAvailable();
197 * @brief Registers the singleton of Dali handle with its type info.
199 * The singleton will be kept alive for the life time of the
201 * @note This is not intended for application developers.
202 * @param[in] info The type info of the Dali handle generated by the compiler.
203 * @param[in] singleton The Dali handle to be registered
205 void RegisterSingleton(const std::type_info& info, BaseHandle singleton);
208 * @brief Gets the singleton for the given type.
210 * @note This is not intended for application developers.
211 * @param[in] info The type info of the given type.
212 * @return the Dali handle if it is registered as a singleton or an uninitialized handle.
214 BaseHandle GetSingleton(const std::type_info& info) const;
217 * @brief Call this method to notify Dali when the system language changes.
219 * Use this only when NOT using Dali::Application, As Application created using
220 * Dali::Application will automatically receive notification of language change.
221 * When Dali::Application is not used, the application developer should
222 * use app-core to receive language change notifications and should update Dali
223 * by calling this method.
225 void NotifyLanguageChanged();
228 * @brief Sets minimum distance in pixels that the fingers must move towards/away from each other in order to
229 * trigger a pinch gesture
231 * @param[in] distance The minimum pinch distance in pixels
233 void SetMinimumPinchDistance(float distance);
238 * @brief The user should connect to this signal if they need to perform any
239 * special activities when the surface Dali is being rendered on is resized.
241 * @return The signal to connect to
243 AdaptorSignalV2& ResizedSignal();
246 * @brief This signal is emitted when the language is changed on the device.
248 * @return The signal to connect to
250 AdaptorSignalV2& LanguageChangedSignal();
255 Adaptor(const Adaptor&);
256 Adaptor& operator=(Adaptor&);
261 * @brief Create an uninitialized Adaptor.
263 DALI_INTERNAL Adaptor();
265 Internal::Adaptor::Adaptor* mImpl; ///< Implementation object
266 friend class Internal::Adaptor::Adaptor;
274 #endif // __DALI_ADAPTOR_H__