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);
109 public: // Stereoscopy
112 * @copydoc Dali::Application::SetViewMode()
114 void SetViewMode( ViewMode viewMode );
117 * @copydoc Dali::Application::GetViewMode()
119 ViewMode GetViewMode() const;
122 * @copydoc Dali::Application::SetStereoBase()
124 void SetStereoBase( float stereoBase );
127 * @copydoc Dali::Application::GetStereoBase()
129 float GetStereoBase() const;
131 public: // From Framework::Observer
134 * Called when the framework is initialised.
136 virtual void OnInit();
139 * Called when the framework is terminated.
141 virtual void OnTerminate();
144 * Called when the framework is paused.
146 virtual void OnPause();
149 * Called when the framework resumes from a paused state.
151 virtual void OnResume();
154 * Called when the framework received AppControlSignal.
155 * @param[in] The bundle data of AppControl event.
157 virtual void OnAppControl(void *data);
160 * Called when the framework informs the application that it should reset itself.
162 virtual void OnReset();
165 * Called when the framework informs the application that the language of the device has changed.
167 virtual void OnLanguageChanged();
170 * Called when the framework informs the application that the region of the device has changed.
172 virtual void OnRegionChanged();
175 * Called when the framework informs the application that the battery level of the device is low.
177 virtual void OnBatteryLow();
180 * Called when the framework informs the application that the memory level of the device is low.
182 virtual void OnMemoryLow();
187 * Signal handler when the adaptor's window resizes itself.
188 * @param[in] adaptor The adaptor
190 void OnResize(Dali::Adaptor& adaptor);
195 * @copydoc Dali::Application::InitSignal()
197 Dali::Application::AppSignalType& InitSignal() { return mInitSignal; }
200 * @copydoc Dali::Application::TerminateSignal()
202 Dali::Application::AppSignalType& TerminateSignal() { return mTerminateSignal; }
205 * @copydoc Dali::Application::PauseSignal()
207 Dali::Application::AppSignalType& PauseSignal() { return mPauseSignal; }
210 * @copydoc Dali::Application::ResumeSignal()
212 Dali::Application::AppSignalType& ResumeSignal() { return mResumeSignal; }
215 * @copydoc Dali::Application::ResetSignal()
217 Dali::Application::AppSignalType& ResetSignal() { return mResetSignal; }
220 * @copydoc Dali::Application::AppControlSignal()
222 Dali::Application::AppControlSignalType& AppControlSignal() { return mAppControlSignal; }
225 * @copydoc Dali::Application::ResizeSignal()
227 Dali::Application::AppSignalType& ResizeSignal() { return mResizeSignal; }
230 * @copydoc Dali::Application::LanguageChangedSignal()
232 Dali::Application::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
235 * @copydoc Dali::Application::RegionChangedSignal()
237 Dali::Application::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
240 * @copydoc Dali::Application::BatteryLowSignal()
242 Dali::Application::AppSignalType& BatteryLowSignal() { return mBatteryLowSignal; }
245 * @copydoc Dali::Application::MemoryLowSignal()
247 Dali::Application::AppSignalType& MemoryLowSignal() { return mMemoryLowSignal; }
252 * Private Constructor
253 * @param[in] argc A pointer to the number of arguments
254 * @param[in] argv A pointer to the argument list
255 * @param[in] stylesheet The path to user defined theme file
256 * @param[in] windowMode A member of Dali::Application::WINDOW_MODE
258 Application( int* argc, char **argv[], const std::string& stylesheet,
259 WINDOW_MODE windowMode, Framework::Type applicationType );
264 virtual ~Application();
267 Application(const Application&);
268 Application& operator=(Application&);
276 * Creates the adaptor
278 void CreateAdaptor();
281 * Quits from the main loop
283 void QuitFromMainLoop();
287 AppSignalType mInitSignal;
288 AppSignalType mTerminateSignal;
289 AppSignalType mPauseSignal;
290 AppSignalType mResumeSignal;
291 AppSignalType mResetSignal;
292 AppSignalType mResizeSignal;
293 AppControlSignalType mAppControlSignal;
294 AppSignalType mLanguageChangedSignal;
295 AppSignalType mRegionChangedSignal;
296 AppSignalType mBatteryLowSignal;
297 AppSignalType mMemoryLowSignal;
299 EventLoop* mEventLoop;
300 Framework* mFramework;
302 Dali::Configuration::ContextLoss mContextLossConfiguration;
303 CommandLineOptions* mCommandLineOptions;
305 Dali::SingletonService mSingletonService;
306 Dali::Adaptor* mAdaptor;
307 Dali::Window mWindow;
308 Dali::Application::WINDOW_MODE mWindowMode;
310 std::string mStylesheet;
311 EnvironmentOptions mEnvironmentOptions;
312 bool mUseRemoteSurface;
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__