1 #ifndef __DALI_INTERNAL_APPLICATION_H__
2 #define __DALI_INTERNAL_APPLICATION_H__
5 * Copyright (c) 2017 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] positionSize A position and a size of the window
68 * @param[in] applicationType A member of Dali::Framework::Type
70 static ApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet,
71 WINDOW_MODE windowMode, const PositionSize& positionSize, Framework::Type applicationType );
76 * @copydoc Dali::Application::MainLoop()
78 void MainLoop(Dali::Configuration::ContextLoss configuration);
81 * @copydoc Dali::Application::Lower()
86 * @copydoc Dali::Application::Quit()
91 * @copydoc Dali::Application::AddIdle()
93 bool AddIdle( CallbackBase* callback );
96 * @copydoc Dali::Application::GetAdaptor();
98 Dali::Adaptor& GetAdaptor();
101 * @copydoc Dali::Application::GetWindow();
103 Dali::Window GetWindow();
106 * @copydoc Dali::Application::ReplaceWindow();
108 void ReplaceWindow( const PositionSize& positionSize, const std::string& name);
111 * @copydoc Dali::Application::GetResourcePath();
113 static std::string GetResourcePath();
115 public: // Stereoscopy
118 * @copydoc Dali::Application::SetViewMode()
120 void SetViewMode( ViewMode viewMode );
123 * @copydoc Dali::Application::GetViewMode()
125 ViewMode GetViewMode() const;
128 * @copydoc Dali::Application::SetStereoBase()
130 void SetStereoBase( float stereoBase );
133 * @copydoc Dali::Application::GetStereoBase()
135 float GetStereoBase() const;
137 public: // Lifecycle functionality
140 * Called when OnInit is called or the framework is initialised.
145 * Called after OnInit is called or the framework is started.
150 * Called when OnTerminate is called or the framework is terminated.
155 * Called when OnPause is called or the framework is paused.
160 * Called when OnResume is called or the framework resumes from a paused state.
165 * Called when OnLanguageChanged is called or the framework informs the application that the language of the device has changed.
167 void DoLanguageChange();
169 public: // From Framework::Observer
172 * Called when the framework is initialised.
174 virtual void OnInit();
177 * Called when the framework is terminated.
179 virtual void OnTerminate();
182 * Called when the framework is paused.
184 virtual void OnPause();
187 * Called when the framework resumes from a paused state.
189 virtual void OnResume();
192 * Called when the framework received AppControlSignal.
193 * @param[in] The bundle data of AppControl event.
195 virtual void OnAppControl(void *data);
198 * Called when the framework informs the application that it should reset itself.
200 virtual void OnReset();
203 * Called when the framework informs the application that the language of the device has changed.
205 virtual void OnLanguageChanged();
208 * Called when the framework informs the application that the region of the device has changed.
210 virtual void OnRegionChanged();
213 * Called when the framework informs the application that the battery level of the device is low.
215 virtual void OnBatteryLow();
218 * Called when the framework informs the application that the memory level of the device is low.
220 virtual void OnMemoryLow();
225 * Signal handler when the adaptor's window resizes itself.
226 * @param[in] adaptor The adaptor
228 void OnResize(Dali::Adaptor& adaptor);
233 * @copydoc Dali::Application::InitSignal()
235 Dali::Application::AppSignalType& InitSignal() { return mInitSignal; }
238 * @copydoc Dali::Application::TerminateSignal()
240 Dali::Application::AppSignalType& TerminateSignal() { return mTerminateSignal; }
243 * @copydoc Dali::Application::PauseSignal()
245 Dali::Application::AppSignalType& PauseSignal() { return mPauseSignal; }
248 * @copydoc Dali::Application::ResumeSignal()
250 Dali::Application::AppSignalType& ResumeSignal() { return mResumeSignal; }
253 * @copydoc Dali::Application::ResetSignal()
255 Dali::Application::AppSignalType& ResetSignal() { return mResetSignal; }
258 * @copydoc Dali::Application::AppControlSignal()
260 Dali::Application::AppControlSignalType& AppControlSignal() { return mAppControlSignal; }
263 * @copydoc Dali::Application::ResizeSignal()
265 Dali::Application::AppSignalType& ResizeSignal() { return mResizeSignal; }
268 * @copydoc Dali::Application::LanguageChangedSignal()
270 Dali::Application::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
273 * @copydoc Dali::Application::RegionChangedSignal()
275 Dali::Application::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
278 * @copydoc Dali::Application::BatteryLowSignal()
280 Dali::Application::AppSignalType& BatteryLowSignal() { return mBatteryLowSignal; }
283 * @copydoc Dali::Application::MemoryLowSignal()
285 Dali::Application::AppSignalType& MemoryLowSignal() { return mMemoryLowSignal; }
290 * Private Constructor
291 * @param[in] argc A pointer to the number of arguments
292 * @param[in] argv A pointer to the argument list
293 * @param[in] stylesheet The path to user defined theme file
294 * @param[in] windowMode A member of Dali::Application::WINDOW_MODE
295 * @param[in] positionSize A position and a size of the window
296 * @param[in] applicationType A member of Dali::Framework::Type
298 Application( int* argc, char **argv[], const std::string& stylesheet,
299 WINDOW_MODE windowMode, const PositionSize& positionSize, Framework::Type applicationType );
304 virtual ~Application();
307 Application(const Application&);
308 Application& operator=(Application&);
316 * Creates the adaptor
318 void CreateAdaptor();
321 * Quits from the main loop
323 void QuitFromMainLoop();
327 AppSignalType mInitSignal;
328 AppSignalType mTerminateSignal;
329 AppSignalType mPauseSignal;
330 AppSignalType mResumeSignal;
331 AppSignalType mResetSignal;
332 AppSignalType mResizeSignal;
333 AppControlSignalType mAppControlSignal;
334 AppSignalType mLanguageChangedSignal;
335 AppSignalType mRegionChangedSignal;
336 AppSignalType mBatteryLowSignal;
337 AppSignalType mMemoryLowSignal;
339 EventLoop* mEventLoop;
340 Framework* mFramework;
342 Dali::Configuration::ContextLoss mContextLossConfiguration;
343 CommandLineOptions* mCommandLineOptions;
345 Dali::SingletonService mSingletonService;
346 Dali::Adaptor* mAdaptor;
347 Dali::Window mWindow;
348 Dali::Application::WINDOW_MODE mWindowMode;
350 std::string mStylesheet;
351 EnvironmentOptions mEnvironmentOptions;
352 PositionSize mWindowPositionSize;
353 bool mUseRemoteSurface;
355 SlotDelegate< Application > mSlotDelegate;
358 inline Application& GetImplementation(Dali::Application& application)
360 DALI_ASSERT_ALWAYS(application && "application handle is empty");
362 BaseObject& handle = application.GetBaseObject();
364 return static_cast<Internal::Adaptor::Application&>(handle);
367 inline const Application& GetImplementation(const Dali::Application& application)
369 DALI_ASSERT_ALWAYS(application && "Timre handle is empty");
371 const BaseObject& handle = application.GetBaseObject();
373 return static_cast<const Internal::Adaptor::Application&>(handle);
377 } // namespace Adaptor
379 } // namespace Internal
383 #endif // __DALI_INTERNAL_APPLICATION_H__