1 #ifndef __DALI_INTERNAL_APPLICATION_H__
2 #define __DALI_INTERNAL_APPLICATION_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 <dali/public-api/math/rect.h>
23 #include <dali/public-api/object/base-object.h>
26 #include <application.h>
27 #include <singleton-service.h>
29 #include <framework.h>
30 #include <window-impl.h>
31 #include <base/environment-options.h>
43 class CommandLineOptions;
46 typedef Dali::Rect<int> PositionSize;
49 typedef IntrusivePtr<Application> ApplicationPtr;
52 * Implementation of the Application class.
54 class Application : public BaseObject, public Framework::Observer
58 typedef Dali::Application::AppSignalType AppSignalType;
59 typedef Dali::Application::AppControlSignalType AppControlSignalType;
60 typedef Dali::Application::WINDOW_MODE WINDOW_MODE;
63 * Create a new application
64 * @param[in] argc A pointer to the number of arguments
65 * @param[in] argv A pointer to the argument list
66 * @param[in] stylesheet The path to user defined theme file
67 * @param[in] windowMode A member of Dali::Application::WINDOW_MODE
69 static ApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
74 * @copydoc Dali::Application::MainLoop()
76 void MainLoop(Dali::Configuration::ContextLoss configuration);
79 * @copydoc Dali::Application::Lower()
84 * @copydoc Dali::Application::Quit()
89 * @copydoc Dali::Application::AddIdle()
91 bool AddIdle( CallbackBase* callback );
94 * @copydoc Dali::Application::GetAdaptor();
96 Dali::Adaptor& GetAdaptor();
99 * @copydoc Dali::Application::GetWindow();
101 Dali::Window GetWindow();
104 * @copydoc Dali::Application::ReplaceWindow();
106 void ReplaceWindow(PositionSize windowPosition, const std::string& name);
108 public: // Stereoscopy
111 * @copydoc Dali::Application::SetViewMode()
113 void SetViewMode( ViewMode viewMode );
116 * @copydoc Dali::Application::GetViewMode()
118 ViewMode GetViewMode() const;
121 * @copydoc Dali::Application::SetStereoBase()
123 void SetStereoBase( float stereoBase );
126 * @copydoc Dali::Application::GetStereoBase()
128 float GetStereoBase() const;
130 public: // From Framework::Observer
133 * Called when the framework is initialised.
135 virtual void OnInit();
138 * Called when the framework is terminated.
140 virtual void OnTerminate();
143 * Called when the framework is paused.
145 virtual void OnPause();
148 * Called when the framework resumes from a paused state.
150 virtual void OnResume();
153 * Called when the framework received AppControlSignal.
154 * @param[in] The bundle data of AppControl event.
156 virtual void OnAppControl(void *data);
159 * Called when the framework informs the application that it should reset itself.
161 virtual void OnReset();
164 * Called when the framework informs the application that the language of the device has changed.
166 virtual void OnLanguageChanged();
169 * Called when the framework informs the application that the region of the device has changed.
171 virtual void OnRegionChanged();
174 * Called when the framework informs the application that the battery level of the device is low.
176 virtual void OnBatteryLow();
179 * Called when the framework informs the application that the memory level of the device is low.
181 virtual void OnMemoryLow();
186 * Signal handler when the adaptor's window resizes itself.
187 * @param[in] adaptor The adaptor
189 void OnResize(Dali::Adaptor& adaptor);
194 * @copydoc Dali::Application::InitSignal()
196 Dali::Application::AppSignalType& InitSignal() { return mInitSignal; }
199 * @copydoc Dali::Application::TerminateSignal()
201 Dali::Application::AppSignalType& TerminateSignal() { return mTerminateSignal; }
204 * @copydoc Dali::Application::PauseSignal()
206 Dali::Application::AppSignalType& PauseSignal() { return mPauseSignal; }
209 * @copydoc Dali::Application::ResumeSignal()
211 Dali::Application::AppSignalType& ResumeSignal() { return mResumeSignal; }
214 * @copydoc Dali::Application::ResetSignal()
216 Dali::Application::AppSignalType& ResetSignal() { return mResetSignal; }
219 * @copydoc Dali::Application::AppControlSignal()
221 Dali::Application::AppControlSignalType& AppControlSignal() { return mAppControlSignal; }
224 * @copydoc Dali::Application::ResizeSignal()
226 Dali::Application::AppSignalType& ResizeSignal() { return mResizeSignal; }
229 * @copydoc Dali::Application::LanguageChangedSignal()
231 Dali::Application::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
234 * @copydoc Dali::Application::RegionChangedSignal()
236 Dali::Application::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
239 * @copydoc Dali::Application::BatteryLowSignal()
241 Dali::Application::AppSignalType& BatteryLowSignal() { return mBatteryLowSignal; }
244 * @copydoc Dali::Application::MemoryLowSignal()
246 Dali::Application::AppSignalType& MemoryLowSignal() { return mMemoryLowSignal; }
251 * Private Constructor
252 * @param[in] argc A pointer to the number of arguments
253 * @param[in] argv A pointer to the argument list
254 * @param[in] stylesheet The path to user defined theme file
255 * @param[in] windowMode A member of Dali::Application::WINDOW_MODE
257 Application( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
262 virtual ~Application();
265 Application(const Application&);
266 Application& operator=(Application&);
275 * Creates the adaptor
277 void CreateAdaptor();
280 * Quits from the main loop
282 void QuitFromMainLoop();
286 AppSignalType mInitSignal;
287 AppSignalType mTerminateSignal;
288 AppSignalType mPauseSignal;
289 AppSignalType mResumeSignal;
290 AppSignalType mResetSignal;
291 AppSignalType mResizeSignal;
292 AppControlSignalType mAppControlSignal;
293 AppSignalType mLanguageChangedSignal;
294 AppSignalType mRegionChangedSignal;
295 AppSignalType mBatteryLowSignal;
296 AppSignalType mMemoryLowSignal;
298 EventLoop* mEventLoop;
299 Framework* mFramework;
301 Dali::Configuration::ContextLoss mContextLossConfiguration;
302 CommandLineOptions* mCommandLineOptions;
304 Dali::SingletonService mSingletonService;
305 Dali::Adaptor* mAdaptor;
306 Dali::Window mWindow;
307 Dali::Application::WINDOW_MODE mWindowMode;
309 std::string mStylesheet;
310 EnvironmentOptions mEnvironmentOptions;
314 SlotDelegate< Application > mSlotDelegate;
317 inline Application& GetImplementation(Dali::Application& application)
319 DALI_ASSERT_ALWAYS(application && "application handle is empty");
321 BaseObject& handle = application.GetBaseObject();
323 return static_cast<Internal::Adaptor::Application&>(handle);
326 inline const Application& GetImplementation(const Dali::Application& application)
328 DALI_ASSERT_ALWAYS(application && "Timre handle is empty");
330 const BaseObject& handle = application.GetBaseObject();
332 return static_cast<const Internal::Adaptor::Application&>(handle);
336 } // namespace Adaptor
338 } // namespace Internal
342 #endif // __DALI_INTERNAL_APPLICATION_H__