Merge "Removed troubleshooting section from README" into tizen
[platform/core/uifw/dali-adaptor.git] / adaptors / public-api / livebox-plugin.h
1 #ifndef __DALI_LIVEBOX_H__
2 #define __DALI_LIVEBOX_H__
3
4 /*
5  * Copyright (c) 2014 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 INCLUDS
22 #include <boost/function.hpp>
23 #include <string>
24 #include <dali/public-api/math/rect.h>
25
26 // INTERNAL INCLUDES
27 #include "device-layout.h"
28 #include "style-monitor.h"
29
30
31 namespace Dali DALI_IMPORT_API
32 {
33 typedef Dali::Rect<int> PositionSize;
34
35 /**
36 * Livebox's size types
37 * It refers "livebox-service.h"
38 */
39 enum LiveboxSizeType
40 {
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,
52 };
53
54 struct GlanceBarEventInfo
55 {
56   std::string emission;
57   std::string source;
58
59   struct
60   {
61     double x;
62     double y;
63     int down;
64   } pointer; ///< touch information for script
65
66   struct
67   {
68     double sx;
69     double sy;
70     double ex;
71     double ey;
72   } part; ///<part information for script
73 };
74
75 namespace Internal DALI_INTERNAL
76 {
77 namespace Adaptor
78 {
79
80 class LiveboxPlugin;
81 }
82 }
83
84 /**
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.
88  *
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.
93  *
94  * SLP and Linux Liveboxs should follow the example below:
95  *
96  * @code
97  * void CreateProgram(LiveboxPlugin& livebox)
98  * {
99  *   // Create Dali components...
100  *   // Can instantiate here, if required
101  * }
102  *
103  * int main (int argc, char **argv)
104  * {
105  *   LiveboxPlugin livebox(&argc, &argv);
106  *   livebox.InitSignal().Connect(&CreateProgram);
107  *   livebox.Run();
108  * }
109  * @endcode
110  *
111  * If required, you can also connect class member functions to a signal:
112  *
113  * @code
114  * MyLivebox livebox;
115  * livebox.SignalResumed().Connect(&app, &MyLivebox::OnResumed);
116  * @endcode
117  */
118 class LiveboxPlugin
119 {
120 public:
121
122   typedef SignalV2< void (LiveboxPlugin&) > LiveboxPluginSignalV2;
123
124 public:
125
126   /**
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.
131    */
132   LiveboxPlugin( int* argc, char **argv[] );
133
134   /**
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.
140    */
141   LiveboxPlugin( int* argc, char **argv[], const std::string& name );
142
143   /**
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
148    */
149   LiveboxPlugin( int* argc, char **argv[], const DeviceLayout& baseLayout );
150
151   /**
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
157    */
158   LiveboxPlugin( int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout );
159
160   /**
161    * Virtual destructor
162    */
163   virtual ~LiveboxPlugin();
164
165 public:
166
167   /**
168    * Set title string of the livebox
169    * @param[in] title title string
170    */
171   void SetTitle(const std::string& title);
172
173   /**
174    * Set content string of the livebox
175    * @param[in] content content string
176    */
177   void SetContent(const std::string& content);
178
179   /**
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
185    */
186   const PositionSize& GetGlanceBarGeometry() const;
187
188   /**
189    * Get glance bar's event information
190    * @return GlanceBarEventInfo structure for glance bar event
191    */
192   const GlanceBarEventInfo& GetGlanceBarEventInfo() const;
193
194   /**
195    * Get current size type of livebox
196    */
197   LiveboxSizeType GetLiveboxSizeType() const;
198
199   /**
200    * This starts the livebox providing.
201    */
202   void Run();
203
204   /**
205    * This quits the livebox providing.
206    */
207   void Quit();
208
209   /**
210    * Ensures that the function passed in is called from the main loop when it is idle.
211    *
212    * A callback of the following type may be used:
213    * @code
214    *   void MyFunction();
215    * @endcode
216    *
217    * @param[in]  callBack  The function to call.
218    * @return true if added successfully, false otherwise
219    */
220   bool AddIdle(boost::function<void(void)> callBack);
221
222   /**
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.
227    */
228   static LiveboxPlugin& Get();
229
230 public:  // Signals
231
232   /**
233    * The user should connect to this signal to determine when they should initialise
234    * their livebox
235    */
236   LiveboxPluginSignalV2& InitializedSignal();
237
238   /**
239    * The user should connect to this signal to determine when they should terminate
240    * their livebox
241    */
242   LiveboxPluginSignalV2& TerminatedSignal();
243
244   /**
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.
247    */
248   LiveboxPluginSignalV2& PausedSignal();
249
250   /**
251    * The user should connect to this signal if they need to perform any special
252    * activities when the livebox has resumed.
253    */
254   LiveboxPluginSignalV2& ResumedSignal();
255
256   /**
257    * This signal is emitted when the surface the livebox is rendering on is resized.
258    */
259   LiveboxPluginSignalV2& ResizedSignal();
260
261   /**
262    * This signal is emitted when the glance bar popup was created.
263    */
264   LiveboxPluginSignalV2& GlanceCreatedSignal();
265
266   /**
267    * This signal is emitted when the glance bar popup was destroyed.
268    */
269   LiveboxPluginSignalV2& GlanceDestroyedSignal();
270
271   /**
272    * This signal is emitted when the glance bar popup was touched.
273    */
274   LiveboxPluginSignalV2& GlanceTouchedSignal();
275
276   /**
277    * This signal is emitted when the glance bar popup was moved.
278    */
279   LiveboxPluginSignalV2& GlanceMovedSignal();
280
281   /**
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()
286    */
287   LiveboxPluginSignalV2& GlanceScriptEventSignal();
288
289   /**
290    * This signal is emitted when the language is changed on the device.
291    */
292   LiveboxPluginSignalV2& LanguageChangedSignal();
293
294 private:
295
296   // Undefined
297   LiveboxPlugin(const LiveboxPlugin&);
298   LiveboxPlugin& operator=(const LiveboxPlugin&);
299
300 private:
301
302   Internal::Adaptor::LiveboxPlugin *mImpl;
303   friend class Internal::Adaptor::LiveboxPlugin;
304 };
305
306 } // namespace Dali
307
308 #endif // __DALI_LIVEBOX_H__
309