Revert "[Tizen] Fix build errors in adaptor-uv by ecore wayland"
[platform/core/uifw/dali-adaptor.git] / adaptors / common / application-impl.h
1 #ifndef __DALI_INTERNAL_APPLICATION_H__
2 #define __DALI_INTERNAL_APPLICATION_H__
3
4 /*
5  * Copyright (c) 2016 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 INCLUDES
22 #include <dali/public-api/math/rect.h>
23 #include <dali/public-api/object/base-object.h>
24
25 // INTERNAL INCLUDES
26 #include <application.h>
27 #include <singleton-service.h>
28
29 #include <framework.h>
30 #include <window-impl.h>
31 #include <base/environment-options.h>
32
33 namespace Dali
34 {
35 class Adaptor;
36 class Window;
37
38 namespace Internal
39 {
40
41 namespace Adaptor
42 {
43 class CommandLineOptions;
44 class EventLoop;
45
46 typedef Dali::Rect<int> PositionSize;
47
48 class Application;
49 typedef IntrusivePtr<Application> ApplicationPtr;
50
51 /**
52  * Implementation of the Application class.
53  */
54 class Application : public BaseObject, public Framework::Observer
55 {
56 public:
57   typedef Dali::Application::AppSignalType AppSignalType;
58   typedef Dali::Application::AppControlSignalType AppControlSignalType;
59   typedef Dali::Application::WINDOW_MODE WINDOW_MODE;
60
61   /**
62    * Create a new application
63    * @param[in]  argc        A pointer to the number of arguments
64    * @param[in]  argv        A pointer to the argument list
65    * @param[in]  stylesheet  The path to user defined theme file
66    * @param[in]  windowMode  A member of Dali::Application::WINDOW_MODE
67    * @param[in]  applicationType  A member of Dali::Framework::Type
68    */
69   static ApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet,
70     WINDOW_MODE windowMode, Framework::Type applicationType );
71
72 public:
73
74   /**
75    * @copydoc Dali::Application::MainLoop()
76    */
77   void MainLoop(Dali::Configuration::ContextLoss configuration);
78
79   /**
80    * @copydoc Dali::Application::Lower()
81    */
82   void Lower();
83
84   /**
85    * @copydoc Dali::Application::Quit()
86    */
87   void Quit();
88
89   /**
90    * @copydoc Dali::Application::AddIdle()
91    */
92   bool AddIdle( CallbackBase* callback );
93
94   /**
95    * @copydoc Dali::Application::GetAdaptor();
96    */
97   Dali::Adaptor& GetAdaptor();
98
99   /**
100    * @copydoc Dali::Application::GetWindow();
101    */
102   Dali::Window GetWindow();
103
104   /**
105    * @copydoc Dali::Application::ReplaceWindow();
106    */
107   void ReplaceWindow(PositionSize windowPosition, const std::string& name);
108
109   /**
110    * @copydoc Dali::Application::GetResourcePath();
111    */
112   static std::string GetResourcePath();
113
114 public: // Stereoscopy
115
116   /**
117    * @copydoc Dali::Application::SetViewMode()
118    */
119   void SetViewMode( ViewMode viewMode );
120
121   /**
122    * @copydoc Dali::Application::GetViewMode()
123    */
124   ViewMode GetViewMode() const;
125
126   /**
127    * @copydoc Dali::Application::SetStereoBase()
128    */
129   void SetStereoBase( float stereoBase );
130
131   /**
132    * @copydoc Dali::Application::GetStereoBase()
133    */
134   float GetStereoBase() const;
135
136 public: // Lifecycle functionality
137
138   /**
139    * Called when OnInit is called or the framework is initialised.
140    */
141   void DoInit();
142
143   /**
144    * Called after OnInit is called or the framework is started.
145    */
146   void DoStart();
147
148   /**
149    * Called when OnTerminate is called or the framework is terminated.
150    */
151   void DoTerminate();
152
153   /**
154    * Called when OnPause is called or the framework is paused.
155    */
156   void DoPause();
157
158   /**
159    * Called when OnResume is called or the framework resumes from a paused state.
160    */
161   void DoResume();
162
163   /**
164    * Called when OnLanguageChanged is called or the framework informs the application that the language of the device has changed.
165    */
166   void DoLanguageChange();
167
168 public: // From Framework::Observer
169
170   /**
171    * Called when the framework is initialised.
172    */
173   virtual void OnInit();
174
175   /**
176    * Called when the framework is terminated.
177    */
178   virtual void OnTerminate();
179
180   /**
181    * Called when the framework is paused.
182    */
183   virtual void OnPause();
184
185   /**
186    * Called when the framework resumes from a paused state.
187    */
188   virtual void OnResume();
189
190   /**
191   * Called when the framework received AppControlSignal.
192   * @param[in] The bundle data of AppControl event.
193   */
194   virtual void OnAppControl(void *data);
195
196   /**
197    * Called when the framework informs the application that it should reset itself.
198    */
199   virtual void OnReset();
200
201   /**
202    * Called when the framework informs the application that the language of the device has changed.
203    */
204   virtual void OnLanguageChanged();
205
206   /**
207   * Called when the framework informs the application that the region of the device has changed.
208   */
209   virtual void OnRegionChanged();
210
211   /**
212   * Called when the framework informs the application that the battery level of the device is low.
213   */
214   virtual void OnBatteryLow();
215
216   /**
217   * Called when the framework informs the application that the memory level of the device is low.
218   */
219   virtual void OnMemoryLow();
220
221 public:
222
223   /**
224    * Signal handler when the adaptor's window resizes itself.
225    * @param[in]  adaptor  The adaptor
226    */
227   void OnResize(Dali::Adaptor& adaptor);
228
229 public:  // Signals
230
231   /**
232    * @copydoc Dali::Application::InitSignal()
233    */
234   Dali::Application::AppSignalType& InitSignal() { return mInitSignal; }
235
236   /**
237    * @copydoc Dali::Application::TerminateSignal()
238    */
239   Dali::Application::AppSignalType& TerminateSignal() { return mTerminateSignal; }
240
241   /**
242    * @copydoc Dali::Application::PauseSignal()
243    */
244   Dali::Application::AppSignalType& PauseSignal() { return mPauseSignal; }
245
246   /**
247    * @copydoc Dali::Application::ResumeSignal()
248    */
249   Dali::Application::AppSignalType& ResumeSignal() { return mResumeSignal; }
250
251   /**
252    * @copydoc Dali::Application::ResetSignal()
253    */
254   Dali::Application::AppSignalType& ResetSignal() { return mResetSignal; }
255
256   /**
257   * @copydoc Dali::Application::AppControlSignal()
258   */
259   Dali::Application::AppControlSignalType& AppControlSignal() { return mAppControlSignal; }
260
261   /**
262    * @copydoc Dali::Application::ResizeSignal()
263    */
264   Dali::Application::AppSignalType& ResizeSignal() { return mResizeSignal; }
265
266   /**
267    * @copydoc Dali::Application::LanguageChangedSignal()
268    */
269   Dali::Application::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
270
271   /**
272   * @copydoc Dali::Application::RegionChangedSignal()
273   */
274   Dali::Application::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
275
276   /**
277   * @copydoc Dali::Application::BatteryLowSignal()
278   */
279   Dali::Application::AppSignalType& BatteryLowSignal() { return mBatteryLowSignal; }
280
281   /**
282   * @copydoc Dali::Application::MemoryLowSignal()
283   */
284   Dali::Application::AppSignalType& MemoryLowSignal() { return mMemoryLowSignal; }
285
286 protected:
287
288   /**
289    * Private Constructor
290    * @param[in]  argc        A pointer to the number of arguments
291    * @param[in]  argv        A pointer to the argument list
292    * @param[in]  stylesheet  The path to user defined theme file
293    * @param[in]  windowMode  A member of Dali::Application::WINDOW_MODE
294    */
295   Application( int* argc, char **argv[], const std::string& stylesheet,
296       WINDOW_MODE windowMode, Framework::Type applicationType );
297
298   /**
299    * Destructor
300    */
301   virtual ~Application();
302
303   // Undefined
304   Application(const Application&);
305   Application& operator=(Application&);
306
307   /**
308    * Creates the window
309    */
310   void CreateWindow();
311
312   /**
313    * Creates the adaptor
314    */
315   void CreateAdaptor();
316
317   /**
318    * Quits from the main loop
319    */
320   void QuitFromMainLoop();
321
322 private:
323
324   AppSignalType                           mInitSignal;
325   AppSignalType                           mTerminateSignal;
326   AppSignalType                           mPauseSignal;
327   AppSignalType                           mResumeSignal;
328   AppSignalType                           mResetSignal;
329   AppSignalType                           mResizeSignal;
330   AppControlSignalType                    mAppControlSignal;
331   AppSignalType                           mLanguageChangedSignal;
332   AppSignalType                           mRegionChangedSignal;
333   AppSignalType                           mBatteryLowSignal;
334   AppSignalType                           mMemoryLowSignal;
335
336   EventLoop*                            mEventLoop;
337   Framework*                            mFramework;
338
339   Dali::Configuration::ContextLoss      mContextLossConfiguration;
340   CommandLineOptions*                   mCommandLineOptions;
341
342   Dali::SingletonService                mSingletonService;
343   Dali::Adaptor*                        mAdaptor;
344   Dali::Window                          mWindow;
345   Dali::Application::WINDOW_MODE        mWindowMode;
346   std::string                           mName;
347   std::string                           mStylesheet;
348   EnvironmentOptions                    mEnvironmentOptions;
349   bool                                  mUseRemoteSurface;
350
351   SlotDelegate< Application >           mSlotDelegate;
352 };
353
354 inline Application& GetImplementation(Dali::Application& application)
355 {
356   DALI_ASSERT_ALWAYS(application && "application handle is empty");
357
358   BaseObject& handle = application.GetBaseObject();
359
360   return static_cast<Internal::Adaptor::Application&>(handle);
361 }
362
363 inline const Application& GetImplementation(const Dali::Application& application)
364 {
365   DALI_ASSERT_ALWAYS(application && "Timre handle is empty");
366
367   const BaseObject& handle = application.GetBaseObject();
368
369   return static_cast<const Internal::Adaptor::Application&>(handle);
370 }
371
372
373 } // namespace Adaptor
374
375 } // namespace Internal
376
377 } // namespace Dali
378
379 #endif // __DALI_INTERNAL_APPLICATION_H__