1 #ifndef __DALI_INTERNAL_LIVEBOX_H__
2 #define __DALI_INTERNAL_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/bind.hpp>
23 #include <boost/function.hpp>
24 #include <boost/thread.hpp>
26 #include <dali/public-api/math/rect.h>
27 #include <dali/integration-api/events/touch-event-integ.h>
32 #include <livebox-client.h>
35 #include <public-api/adaptor-framework/livebox-plugin.h>
36 #include <internal/framework.h>
49 class CommandLineOptions;
52 typedef Dali::Rect<int> PositionSize;
60 * Implementation of the LiveboxPlugin class.
62 class LiveboxPlugin : public Framework::Observer
66 typedef Dali::LiveboxPlugin::LiveboxPluginSignalV2 LiveboxPluginSignalV2;
70 * @param[in] livebox The public instance of the LiveboxPlugin
71 * @param[in] argc A pointer to the number of arguments
72 * @param[in] argv A pointer to the argument list
73 * @param[in] name A name of livebox
74 * @param[in] baseLayout The base layout that the livebox has been written for
76 LiveboxPlugin(Dali::LiveboxPlugin& livebox, int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout);
81 virtual ~LiveboxPlugin();
86 * @copydoc Dali::LiveboxPlugin::SetTitle()
88 void SetTitle(const std::string& title) {mTitle = title; };
91 * @copydoc Dali::LiveboxPlugin::SetContent()
93 void SetContent(const std::string& content) {mContent = content; };
96 * @copydoc Dali::LiveboxPlugin::GetGlanceBarGeometry()
98 const PositionSize& GetGlanceBarGeometry() const { return mGlanceGeometry; };
101 * @copydoc Dali::LiveboxPlugin::GetGlanceBarEventInfo()
103 const GlanceBarEventInfo& GetGlanceBarEventInfo() const { return mGlanceBarEventInfo; };
106 * @copydoc Dali::LiveboxPlugin::GetLiveboxSizeType()
108 LiveboxSizeType GetLiveboxSizeType() const { return mBoxSizeType; };
111 * @copydoc Dali::LiveboxPlugin::Run()
116 * @copydoc Dali::LiveboxPlugin::Quit()
121 * @copydoc Dali::LiveboxPlugin::AddIdle()
123 bool AddIdle(boost::function<void(void)> callBack);
126 * @copydoc Dali::LiveboxPlugin::Get();
128 static Dali::LiveboxPlugin& Get();
131 public: // From Framework::Observer
134 * Called when the framework is initialised.
136 virtual void OnInit();
139 * Called when the framework is terminated.
141 virtual void OnTerminate();
144 * Called when the framework is paused.
146 virtual void OnPause();
149 * Called when the framework resumes from a paused state.
151 virtual void OnResume();
154 * Called when the framework informs the livebox that it should reset itself.
156 virtual void OnReset();
159 * Called when the framework informs the livebox that the language of the device has changed.
161 virtual void OnLanguageChanged();
169 * Notify the livebox was created.
171 * @param[in] pkgname package name
172 * @param[in] id livebox id string
173 * @param[in] content content string of livebox
174 * @param[in] width width of livebox
175 * @param[in] height height of livebox
177 void OnLiveboxCreated(const std::string& content, int width, int height, double period);
180 * Notify the livebox should be destroyed.
182 void OnLiveboxDestroyed();
185 * Notify the client should be resized.
187 * @param[in] resizedWidth new width of livebox
188 * @param[in] resizedHeight new height of livebox
190 void OnLiveboxResized(int resizedWidth, int resizedHeight);
193 * Send event to livebox.
195 * @param[in] point touch point
196 * @param[in] timeStamp time value of event
198 void OnLiveboxTouchEvent(TouchPoint& point, unsigned int timeStamp);
200 void OnPeriodUpdated(double period);
201 void OnUpdateRequested();
204 * Notify the glance was created.
206 * @param[in] pdWidth width of pd
207 * @param[in] pdHeight height of pd
208 * @param[in] arrowX x position of pd's arrow
209 * @param[in] arrowY y position of pd's arrow
211 void OnGlanceCreated(int width, int height, int arrowX, int arrowY);
214 * Notify the glance should be destroyed.
216 void OnGlanceDestroyed();
218 void OnGlanceTouchEvent();
219 void OnGlanceMoved(int arrowX, int arrowY, int width, int height);
220 void OnGlanceScriptEventCallback(std::string emission, std::string source, struct livebox_event_info *info);
223 * Notify the surface was damaged.
224 * When it was damager, this client should send update to master
231 * @copydoc Dali::LiveboxPlugin::InitializedSignal()
233 LiveboxPluginSignalV2& InitializedSignal() { return mInitializedSignalV2; }
236 * @copydoc Dali::LiveboxPlugin::TerminatedSignal()
238 LiveboxPluginSignalV2& TerminatedSignal() { return mTerminatedSignalV2; }
241 * @copydoc Dali::LiveboxPlugin::PausedSignal()
243 LiveboxPluginSignalV2& PausedSignal() { return mPausedSignalV2; }
246 * @copydoc Dali::LiveboxPlugin::ResumedSignal()
248 LiveboxPluginSignalV2& ResumedSignal() { return mResumedSignalV2; }
251 * @copydoc Dali::LiveboxPlugin::ResizedSignal()
253 LiveboxPluginSignalV2& ResizedSignal() { return mResizedSignalV2; }
256 * @copydoc Dali::LiveboxPlugin::GlanceCreatedSignal()
258 LiveboxPluginSignalV2& GlanceCreatedSignal() { return mGlanceCreatedSignalV2; }
261 * @copydoc Dali::LiveboxPlugin::GlanceDestroyedSignal()
263 LiveboxPluginSignalV2& GlanceDestroyedSignal() { return mGlanceDestroyedSignalV2; }
266 * @copydoc Dali::LiveboxPlugin::GlanceTouchedSignal()
268 LiveboxPluginSignalV2& GlanceTouchedSignal() { return mGlanceTouchedSignalV2; }
271 * @copydoc Dali::LiveboxPlugin::GlanceMovedSignal()
273 LiveboxPluginSignalV2& GlanceMovedSignal() { return mGlanceMovedSignalV2; }
276 * @copydoc Dali::LiveboxPlugin::GlanceScriptEventSignal()
278 LiveboxPluginSignalV2& GlanceScriptEventSignal() { return mGlanceScriptEventSignalV2; }
281 * @copydoc Dali::LiveboxPlugin::LanguageChangedSignal()
283 LiveboxPluginSignalV2& LanguageChangedSignal() { return mLanguageChangedSignalV2; }
288 LiveboxPlugin(const LiveboxPlugin&);
289 LiveboxPlugin& operator=(LiveboxPlugin&);
294 * Create pixmap surface for mSurface.
295 * If there is no mSurface, it will create mSurface with new display.
296 * If mSurface is existed already, then it uses existed display but overwrite mSurface by new one
297 * It make a callback for damage notify automatically
299 void CreateSurface(Ecore_X_Pixmap pixmap);
302 * Quits from the main loop
304 void QuitFromMainLoop();
308 LiveboxPluginSignalV2 mInitializedSignalV2;
309 LiveboxPluginSignalV2 mTerminatedSignalV2;
310 LiveboxPluginSignalV2 mPausedSignalV2;
311 LiveboxPluginSignalV2 mResumedSignalV2;
312 LiveboxPluginSignalV2 mResizedSignalV2;
313 LiveboxPluginSignalV2 mGlanceCreatedSignalV2;
314 LiveboxPluginSignalV2 mGlanceDestroyedSignalV2;
315 LiveboxPluginSignalV2 mGlanceTouchedSignalV2;
316 LiveboxPluginSignalV2 mGlanceMovedSignalV2;
317 LiveboxPluginSignalV2 mGlanceScriptEventSignalV2;
318 LiveboxPluginSignalV2 mLanguageChangedSignalV2;
320 Dali::LiveboxPlugin& mLiveboxPlugin;
322 Framework* mFramework;
324 CommandLineOptions* mCommandLineOptions;
326 Dali::Adaptor* mAdaptor;
330 DeviceLayout mBaseLayout;
333 livebox_h mLiveboxHandle;
335 std::string mContent;
338 PositionSize mGlanceGeometry;
339 GlanceBarEventInfo mGlanceBarEventInfo;
341 LiveboxSizeType mBoxSizeType;
344 /* for rendering control : these public members will be used in static function */
345 Ecore_Event_Handler* mDamageEventHandler;
346 Ecore_X_Damage mDamage;
347 ECoreX::RenderSurface* mSurface;
350 inline static LiveboxPlugin& GetImplementation(Dali::LiveboxPlugin& livebox) { return *livebox.mImpl; }
353 } // namespace Adaptor
355 } // namespace Internal
359 #endif // __DALI_INTERNAL_LIVEBOX_H__