1 #ifndef __DALI_LIVEBOX_H__
2 #define __DALI_LIVEBOX_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 <dali/public-api/math/rect.h>
27 #include "device-layout.h"
28 #include "style-monitor.h"
31 namespace Dali DALI_IMPORT_API
33 typedef Dali::Rect<int> PositionSize;
36 * Livebox's size types
37 * It refers "livebox-service.h"
41 LIVEBOX_SIZE_TYPE_1x1 = 0x0001,
42 LIVEBOX_SIZE_TYPE_2x1 = 0x0002,
43 LIVEBOX_SIZE_TYPE_2x2 = 0x0004,
44 LIVEBOX_SIZE_TYPE_4x1 = 0x0008,
45 LIVEBOX_SIZE_TYPE_4x2 = 0x0010,
46 LIVEBOX_SIZE_TYPE_4x3 = 0x0020,
47 LIVEBOX_SIZE_TYPE_4x4 = 0x0040,
48 LIVEBOX_SIZE_TYPE_EASY_1x1 = 0x0100,
49 LIVEBOX_SIZE_TYPE_EASY_3x1 = 0x0200,
50 LIVEBOX_SIZE_TYPE_EASY_3x3 = 0x0400,
51 LIVEBOX_SIZE_TYPE_UNKNOWN = 0xFFFF,
54 struct GlanceBarEventInfo
64 } pointer; ///< touch information for script
72 } part; ///<part information for script
75 namespace Internal DALI_INTERNAL
85 * An LiveboxPlugin class object should be created by every livebox
86 * that wishes to use Dali. It provides a means for initialising the
87 * resources required by the Dali::Core.
89 * The LiveboxPlugin class emits several signals which the user can
90 * connect to. The user should not create any Dali objects in the main
91 * function and instead should connect to the Init signal of the
92 * LiveboxPlugin and create the Dali objects in the connected callback.
94 * SLP and Linux Liveboxs should follow the example below:
97 * void CreateProgram(LiveboxPlugin& livebox)
99 * // Create Dali components...
100 * // Can instantiate here, if required
103 * int main (int argc, char **argv)
105 * LiveboxPlugin livebox(&argc, &argv);
106 * livebox.InitSignal().Connect(&CreateProgram);
111 * If required, you can also connect class member functions to a signal:
115 * livebox.SignalResumed().Connect(&app, &MyLivebox::OnResumed);
122 typedef SignalV2< void (LiveboxPlugin&) > LiveboxPluginSignalV2;
127 * This is the constructor for Linux & SLP liveboxs.
128 * @param argc A pointer to the number of arguments
129 * @param argv A pointer the the argument list
130 * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
132 LiveboxPlugin( int* argc, char **argv[] );
135 * This is the constructor for Linux & SLP liveboxs with a name
136 * @param argc A pointer to the number of arguments
137 * @param argv A pointer the the argument list
138 * @param name A name of livebox
139 * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
141 LiveboxPlugin( int* argc, char **argv[], const std::string& name );
144 * This is the constructor for Linux & SLP liveboxs when a layout for the livebox is specified.
145 * @param argc A pointer to the number of arguments
146 * @param argv A pointer the the argument list
147 * @param baseLayout The base layout that the livebox has been written for
149 LiveboxPlugin( int* argc, char **argv[], const DeviceLayout& baseLayout );
152 * This is the constructor for Linux & SLP liveboxs with a name and when a layout for the livebox is specified.
153 * @param argc A pointer to the number of arguments
154 * @param argv A pointer the the argument list
155 * @param name A name of livebox
156 * @param baseLayout The base layout that the livebox has been written for
158 LiveboxPlugin( int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout );
163 virtual ~LiveboxPlugin();
168 * Set title string of the livebox
169 * @param[in] title title string
171 void SetTitle(const std::string& title);
174 * Set content string of the livebox
175 * @param[in] content content string
177 void SetContent(const std::string& content);
180 * Get glance bar's geometry information
181 * x, y mean arrow position
182 * w, h mean glance size
183 * User can use this method in the glance-created signal handler
184 * @return PositionSize structure for glance bar information. {-1, -1, -1, -1} means invalid status for glance
186 const PositionSize& GetGlanceBarGeometry() const;
189 * Get glance bar's event information
190 * @return GlanceBarEventInfo structure for glance bar event
192 const GlanceBarEventInfo& GetGlanceBarEventInfo() const;
195 * Get current size type of livebox
197 LiveboxSizeType GetLiveboxSizeType() const;
200 * This starts the livebox providing.
205 * This quits the livebox providing.
210 * Ensures that the function passed in is called from the main loop when it is idle.
212 * A callback of the following type may be used:
217 * @param[in] callBack The function to call.
218 * @return true if added successfully, false otherwise
220 bool AddIdle(boost::function<void(void)> callBack);
223 * Returns the local thread's instance of the LiveboxPlugin class.
224 * @return A reference to the local thread's LiveboxPlugin class instance.
225 * @pre The LiveboxPlugin class has been initialised.
226 * @note This is only valid in the main thread.
228 static LiveboxPlugin& Get();
233 * The user should connect to this signal to determine when they should initialise
236 LiveboxPluginSignalV2& InitializedSignal();
239 * The user should connect to this signal to determine when they should terminate
242 LiveboxPluginSignalV2& TerminatedSignal();
245 * The user should connect to this signal if they need to perform any special
246 * activities when the livebox is about to be paused.
248 LiveboxPluginSignalV2& PausedSignal();
251 * The user should connect to this signal if they need to perform any special
252 * activities when the livebox has resumed.
254 LiveboxPluginSignalV2& ResumedSignal();
257 * This signal is emitted when the surface the livebox is rendering on is resized.
259 LiveboxPluginSignalV2& ResizedSignal();
262 * This signal is emitted when the glance bar popup was created.
264 LiveboxPluginSignalV2& GlanceCreatedSignal();
267 * This signal is emitted when the glance bar popup was destroyed.
269 LiveboxPluginSignalV2& GlanceDestroyedSignal();
272 * This signal is emitted when the glance bar popup was touched.
274 LiveboxPluginSignalV2& GlanceTouchedSignal();
277 * This signal is emitted when the glance bar popup was moved.
279 LiveboxPluginSignalV2& GlanceMovedSignal();
282 * This signal is emitted when the glance bar popup was got script event callback.
283 * If application registered the edje file for glance bar,
284 * this signal will be emitted instead of SignalGlanceTouched.
285 * Application can get the event information by using GetGlanceBarEventInfo()
287 LiveboxPluginSignalV2& GlanceScriptEventSignal();
290 * This signal is emitted when the language is changed on the device.
292 LiveboxPluginSignalV2& LanguageChangedSignal();
297 LiveboxPlugin(const LiveboxPlugin&);
298 LiveboxPlugin& operator=(const LiveboxPlugin&);
302 Internal::Adaptor::LiveboxPlugin *mImpl;
303 friend class Internal::Adaptor::LiveboxPlugin;
308 #endif // __DALI_LIVEBOX_H__