1 #ifndef __DALI_INTERNAL_APPLICATION_H__
2 #define __DALI_INTERNAL_APPLICATION_H__
5 * Copyright (c) 2016 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
57 typedef Dali::Application::AppSignalType AppSignalType;
58 typedef Dali::Application::AppControlSignalType AppControlSignalType;
59 typedef Dali::Application::WINDOW_MODE WINDOW_MODE;
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
69 static ApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet,
70 WINDOW_MODE windowMode, Framework::Type applicationType );
75 * @copydoc Dali::Application::MainLoop()
77 void MainLoop(Dali::Configuration::ContextLoss configuration);
80 * @copydoc Dali::Application::Lower()
85 * @copydoc Dali::Application::Quit()
90 * @copydoc Dali::Application::AddIdle()
92 bool AddIdle( CallbackBase* callback );
95 * @copydoc Dali::Application::GetAdaptor();
97 Dali::Adaptor& GetAdaptor();
100 * @copydoc Dali::Application::GetWindow();
102 Dali::Window GetWindow();
105 * @copydoc Dali::Application::ReplaceWindow();
107 void ReplaceWindow(PositionSize windowPosition, const std::string& name);
110 * @copydoc Dali::Application::GetResourcePath();
112 static std::string GetResourcePath();
114 public: // Stereoscopy
117 * @copydoc Dali::Application::SetViewMode()
119 void SetViewMode( ViewMode viewMode );
122 * @copydoc Dali::Application::GetViewMode()
124 ViewMode GetViewMode() const;
127 * @copydoc Dali::Application::SetStereoBase()
129 void SetStereoBase( float stereoBase );
132 * @copydoc Dali::Application::GetStereoBase()
134 float GetStereoBase() const;
136 public: // Lifecycle functionality
139 * Called when OnInit is called or the framework is initialised.
144 * Called when OnTerminate is called or the framework is terminated.
149 * Called when OnPause is called or the framework is paused.
154 * Called when OnResume is called or the framework resumes from a paused state.
159 * Called when OnLanguageChanged is called or the framework informs the application that the language of the device has changed.
161 void DoLanguageChange();
163 public: // From Framework::Observer
166 * Called when the framework is initialised.
168 virtual void OnInit();
171 * Called when the framework is terminated.
173 virtual void OnTerminate();
176 * Called when the framework is paused.
178 virtual void OnPause();
181 * Called when the framework resumes from a paused state.
183 virtual void OnResume();
186 * Called when the framework received AppControlSignal.
187 * @param[in] The bundle data of AppControl event.
189 virtual void OnAppControl(void *data);
192 * Called when the framework informs the application that it should reset itself.
194 virtual void OnReset();
197 * Called when the framework informs the application that the language of the device has changed.
199 virtual void OnLanguageChanged();
202 * Called when the framework informs the application that the region of the device has changed.
204 virtual void OnRegionChanged();
207 * Called when the framework informs the application that the battery level of the device is low.
209 virtual void OnBatteryLow();
212 * Called when the framework informs the application that the memory level of the device is low.
214 virtual void OnMemoryLow();
219 * Signal handler when the adaptor's window resizes itself.
220 * @param[in] adaptor The adaptor
222 void OnResize(Dali::Adaptor& adaptor);
227 * @copydoc Dali::Application::InitSignal()
229 Dali::Application::AppSignalType& InitSignal() { return mInitSignal; }
232 * @copydoc Dali::Application::TerminateSignal()
234 Dali::Application::AppSignalType& TerminateSignal() { return mTerminateSignal; }
237 * @copydoc Dali::Application::PauseSignal()
239 Dali::Application::AppSignalType& PauseSignal() { return mPauseSignal; }
242 * @copydoc Dali::Application::ResumeSignal()
244 Dali::Application::AppSignalType& ResumeSignal() { return mResumeSignal; }
247 * @copydoc Dali::Application::ResetSignal()
249 Dali::Application::AppSignalType& ResetSignal() { return mResetSignal; }
252 * @copydoc Dali::Application::AppControlSignal()
254 Dali::Application::AppControlSignalType& AppControlSignal() { return mAppControlSignal; }
257 * @copydoc Dali::Application::ResizeSignal()
259 Dali::Application::AppSignalType& ResizeSignal() { return mResizeSignal; }
262 * @copydoc Dali::Application::LanguageChangedSignal()
264 Dali::Application::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
267 * @copydoc Dali::Application::RegionChangedSignal()
269 Dali::Application::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
272 * @copydoc Dali::Application::BatteryLowSignal()
274 Dali::Application::AppSignalType& BatteryLowSignal() { return mBatteryLowSignal; }
277 * @copydoc Dali::Application::MemoryLowSignal()
279 Dali::Application::AppSignalType& MemoryLowSignal() { return mMemoryLowSignal; }
284 * Private Constructor
285 * @param[in] argc A pointer to the number of arguments
286 * @param[in] argv A pointer to the argument list
287 * @param[in] stylesheet The path to user defined theme file
288 * @param[in] windowMode A member of Dali::Application::WINDOW_MODE
290 Application( int* argc, char **argv[], const std::string& stylesheet,
291 WINDOW_MODE windowMode, Framework::Type applicationType );
296 virtual ~Application();
299 Application(const Application&);
300 Application& operator=(Application&);
308 * Creates the adaptor
310 void CreateAdaptor();
313 * Quits from the main loop
315 void QuitFromMainLoop();
319 AppSignalType mInitSignal;
320 AppSignalType mTerminateSignal;
321 AppSignalType mPauseSignal;
322 AppSignalType mResumeSignal;
323 AppSignalType mResetSignal;
324 AppSignalType mResizeSignal;
325 AppControlSignalType mAppControlSignal;
326 AppSignalType mLanguageChangedSignal;
327 AppSignalType mRegionChangedSignal;
328 AppSignalType mBatteryLowSignal;
329 AppSignalType mMemoryLowSignal;
331 EventLoop* mEventLoop;
332 Framework* mFramework;
334 Dali::Configuration::ContextLoss mContextLossConfiguration;
335 CommandLineOptions* mCommandLineOptions;
337 Dali::SingletonService mSingletonService;
338 Dali::Adaptor* mAdaptor;
339 Dali::Window mWindow;
340 Dali::Application::WINDOW_MODE mWindowMode;
342 std::string mStylesheet;
343 EnvironmentOptions mEnvironmentOptions;
344 bool mUseRemoteSurface;
346 SlotDelegate< Application > mSlotDelegate;
349 inline Application& GetImplementation(Dali::Application& application)
351 DALI_ASSERT_ALWAYS(application && "application handle is empty");
353 BaseObject& handle = application.GetBaseObject();
355 return static_cast<Internal::Adaptor::Application&>(handle);
358 inline const Application& GetImplementation(const Dali::Application& application)
360 DALI_ASSERT_ALWAYS(application && "Timre handle is empty");
362 const BaseObject& handle = application.GetBaseObject();
364 return static_cast<const Internal::Adaptor::Application&>(handle);
368 } // namespace Adaptor
370 } // namespace Internal
374 #endif // __DALI_INTERNAL_APPLICATION_H__