Track ActiveTexture calls
[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) 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 INCLUDES
22 #include <boost/bind.hpp>
23 #include <boost/function.hpp>
24 #include <boost/thread.hpp>
25
26 #include <dali/public-api/math/rect.h>
27 #include <dali/public-api/object/base-object.h>
28
29 // INTERNAL INCLUDES
30 #include <application.h>
31 #include <singleton-service.h>
32
33 #include <framework.h>
34 #include <window-impl.h>
35
36 namespace Dali
37 {
38 class Adaptor;
39 class Window;
40
41 namespace Internal
42 {
43
44 namespace Adaptor
45 {
46 class CommandLineOptions;
47 class EventLoop;
48
49 typedef Dali::Rect<int> PositionSize;
50
51 class Application;
52 typedef IntrusivePtr<Application> ApplicationPtr;
53
54 /**
55  * Implementation of the Application class.
56  */
57 class Application : public BaseObject, public Framework::Observer
58 {
59 public:
60
61   typedef Dali::Application::AppSignalV2 AppSignalV2;
62
63   /**
64    * Constructor
65    * @param[in]  app         The public instance of the Application
66    * @param[in]  argc        A pointer to the number of arguments
67    * @param[in]  argv        A pointer to the argument list
68    * @param[in]  name        A name of application
69    * @param[in]  baseLayout  The base layout that the application has been written for
70    * @param[in]  windowMode  A member of Dali::Application::WINDOW_MODE
71    */
72   static ApplicationPtr New(int* argc, char **argv[], const std::string& name,
73                             const DeviceLayout& baseLayout,
74                             Dali::Application::WINDOW_MODE windowMode);
75
76   Application( int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout, Dali::Application::WINDOW_MODE windowMode );
77
78   /**
79    * Destructor
80    */
81   virtual ~Application();
82
83 public:
84
85   /**
86    * @copydoc Dali::Application::MainLoop()
87    */
88   void MainLoop(Dali::Configuration::ContextLoss configuration);
89
90   /**
91    * @copydoc Dali::Application::Lower()
92    */
93   void Lower();
94
95   /**
96    * @copydoc Dali::Application::Quit()
97    */
98   void Quit();
99
100   /**
101    * @copydoc Dali::Application::AddIdle()
102    */
103   bool AddIdle(boost::function<void(void)> callBack);
104
105   /**
106    * @copydoc Dali::Application::GetAdaptor();
107    */
108   Dali::Adaptor& GetAdaptor();
109
110   /**
111    * @copydoc Dali::Application::GetWindow();
112    */
113   Dali::Window GetWindow();
114
115   /**
116    * @copydoc Dali::Application::GetTheme();
117    */
118   const std::string& GetTheme();
119
120   /**
121    * @copydoc Dali::Application::SetTheme();
122    */
123   void SetTheme(const std::string& themeFilePath);
124
125   /**
126    * @copydoc Dali::Application::ReplaceWindow();
127    */
128   void ReplaceWindow(PositionSize windowPosition, const std::string& name);
129
130 public: // Stereoscopy
131
132   /**
133    * @copydoc Dali::Application::SetViewMode()
134    */
135   void SetViewMode( ViewMode viewMode );
136
137   /**
138    * @copydoc Dali::Application::GetViewMode()
139    */
140   ViewMode GetViewMode() const;
141
142   /**
143    * @copydoc Dali::Application::SetStereoBase()
144    */
145   void SetStereoBase( float stereoBase );
146
147   /**
148    * @copydoc Dali::Application::GetStereoBase()
149    */
150   float GetStereoBase() const;
151
152 public: // From Framework::Observer
153
154   /**
155    * Called when the framework is initialised.
156    */
157   virtual void OnInit();
158
159   /**
160    * Called when the framework is terminated.
161    */
162   virtual void OnTerminate();
163
164   /**
165    * Called when the framework is paused.
166    */
167   virtual void OnPause();
168
169   /**
170    * Called when the framework resumes from a paused state.
171    */
172   virtual void OnResume();
173
174   /**
175    * Called when the framework informs the application that it should reset itself.
176    */
177   virtual void OnReset();
178
179   /**
180    * Called when the framework informs the application that the language of the device has changed.
181    */
182   virtual void OnLanguageChanged();
183
184 public:
185
186   /**
187    * Signal handler when the adaptor's window resizes itself.
188    * @param[in]  adaptor  The adaptor
189    */
190   void OnResize(Dali::Adaptor& adaptor);
191
192 public:  // Signals
193
194   /**
195    * @copydoc Dali::Application::InitSignal()
196    */
197   Dali::Application::AppSignalV2& InitSignal() { return mInitSignalV2; }
198
199   /**
200    * @copydoc Dali::Application::TerminateSignal()
201    */
202   Dali::Application::AppSignalV2& TerminateSignal() { return mTerminateSignalV2; }
203
204   /**
205    * @copydoc Dali::Application::PauseSignal()
206    */
207   Dali::Application::AppSignalV2& PauseSignal() { return mPauseSignalV2; }
208
209   /**
210    * @copydoc Dali::Application::ResumeSignal()
211    */
212   Dali::Application::AppSignalV2& ResumeSignal() { return mResumeSignalV2; }
213
214   /**
215    * @copydoc Dali::Application::ResetSignal()
216    */
217   Dali::Application::AppSignalV2& ResetSignal() { return mResetSignalV2; }
218
219   /**
220    * @copydoc Dali::Application::ResizeSignal()
221    */
222   Dali::Application::AppSignalV2& ResizeSignal() { return mResizeSignalV2; }
223
224   /**
225    * @copydoc Dali::Application::LanguageChangedSignal()
226    */
227   Dali::Application::AppSignalV2& LanguageChangedSignal() { return mLanguageChangedSignalV2; }
228
229 private:
230
231   // Undefined
232   Application(const Application&);
233   Application& operator=(Application&);
234
235 private:
236   /**
237    * Creates the window
238    */
239   void CreateWindow();
240
241   /**
242    * Creates the adaptor
243    */
244   void CreateAdaptor();
245
246   /**
247    * Quits from the main loop
248    */
249   void QuitFromMainLoop();
250
251 private:
252
253   AppSignalV2                           mInitSignalV2;
254   AppSignalV2                           mTerminateSignalV2;
255   AppSignalV2                           mPauseSignalV2;
256   AppSignalV2                           mResumeSignalV2;
257   AppSignalV2                           mResetSignalV2;
258   AppSignalV2                           mResizeSignalV2;
259   AppSignalV2                           mLanguageChangedSignalV2;
260
261   EventLoop*                            mEventLoop;
262   Framework*                            mFramework;
263
264   Dali::Configuration::ContextLoss      mContextLossConfiguration;
265   CommandLineOptions*                   mCommandLineOptions;
266
267   Dali::SingletonService                mSingletonService;
268   Dali::Adaptor*                        mAdaptor;
269   Dali::Window                          mWindow;
270   Dali::Application::WINDOW_MODE        mWindowMode;
271   std::string                           mName;
272
273   bool                                  mInitialized;
274   DeviceLayout                          mBaseLayout;
275
276   SlotDelegate< Application >           mSlotDelegate;
277 };
278
279 inline Application& GetImplementation(Dali::Application& application)
280 {
281   DALI_ASSERT_ALWAYS(application && "application handle is empty");
282
283   BaseObject& handle = application.GetBaseObject();
284
285   return static_cast<Internal::Adaptor::Application&>(handle);
286 }
287
288 inline const Application& GetImplementation(const Dali::Application& application)
289 {
290   DALI_ASSERT_ALWAYS(application && "Timre handle is empty");
291
292   const BaseObject& handle = application.GetBaseObject();
293
294   return static_cast<const Internal::Adaptor::Application&>(handle);
295 }
296
297
298 } // namespace Adaptor
299
300 } // namespace Internal
301
302 } // namespace Dali
303
304 #endif // __DALI_INTERNAL_APPLICATION_H__