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>
42 class CommandLineOptions;
45 typedef Dali::Rect<int> PositionSize;
48 typedef IntrusivePtr<Application> ApplicationPtr;
51 * Implementation of the Application class.
53 class Application : public BaseObject, public Framework::Observer
57 typedef Dali::Application::AppSignalType AppSignalType;
58 typedef Dali::Application::AppControlSignalType AppControlSignalType;
62 * @param[in] app The public instance of the 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] name A name of application
66 * @param[in] baseLayout The base layout that the application has been written for
67 * @param[in] windowMode A member of Dali::Application::WINDOW_MODE
69 static ApplicationPtr New(int* argc, char **argv[], const std::string& name,
70 const DeviceLayout& baseLayout,
71 Dali::Application::WINDOW_MODE windowMode);
73 Application( int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout, Dali::Application::WINDOW_MODE windowMode );
78 virtual ~Application();
83 * @copydoc Dali::Application::MainLoop()
85 void MainLoop(Dali::Configuration::ContextLoss configuration);
88 * @copydoc Dali::Application::Lower()
93 * @copydoc Dali::Application::Quit()
98 * @copydoc Dali::Application::AddIdle()
100 bool AddIdle( CallbackBase* callback );
103 * @copydoc Dali::Application::GetAdaptor();
105 Dali::Adaptor& GetAdaptor();
108 * @copydoc Dali::Application::GetWindow();
110 Dali::Window GetWindow();
113 * @copydoc Dali::Application::GetTheme();
115 const std::string& GetTheme();
118 * @copydoc Dali::Application::SetTheme();
120 void SetTheme(const std::string& themeFilePath);
123 * @copydoc Dali::Application::ReplaceWindow();
125 void ReplaceWindow(PositionSize windowPosition, const std::string& name);
127 public: // Stereoscopy
130 * @copydoc Dali::Application::SetViewMode()
132 void SetViewMode( ViewMode viewMode );
135 * @copydoc Dali::Application::GetViewMode()
137 ViewMode GetViewMode() const;
140 * @copydoc Dali::Application::SetStereoBase()
142 void SetStereoBase( float stereoBase );
145 * @copydoc Dali::Application::GetStereoBase()
147 float GetStereoBase() const;
149 public: // From Framework::Observer
152 * Called when the framework is initialised.
154 virtual void OnInit();
157 * Called when the framework is terminated.
159 virtual void OnTerminate();
162 * Called when the framework is paused.
164 virtual void OnPause();
167 * Called when the framework resumes from a paused state.
169 virtual void OnResume();
172 * Called when the framework received AppControlSignal.
173 * @param[in] The bundle data of AppControl event.
175 virtual void OnAppControl(void *data);
178 * Called when the framework informs the application that it should reset itself.
180 virtual void OnReset();
183 * Called when the framework informs the application that the language of the device has changed.
185 virtual void OnLanguageChanged();
188 * Called when the framework informs the application that the region of the device has changed.
190 virtual void OnRegionChanged();
193 * Called when the framework informs the application that the battery level of the device is low.
195 virtual void OnBatteryLow();
198 * Called when the framework informs the application that the memory level of the device is low.
200 virtual void OnMemoryLow();
205 * Signal handler when the adaptor's window resizes itself.
206 * @param[in] adaptor The adaptor
208 void OnResize(Dali::Adaptor& adaptor);
213 * @copydoc Dali::Application::InitSignal()
215 Dali::Application::AppSignalType& InitSignal() { return mInitSignal; }
218 * @copydoc Dali::Application::TerminateSignal()
220 Dali::Application::AppSignalType& TerminateSignal() { return mTerminateSignal; }
223 * @copydoc Dali::Application::PauseSignal()
225 Dali::Application::AppSignalType& PauseSignal() { return mPauseSignal; }
228 * @copydoc Dali::Application::ResumeSignal()
230 Dali::Application::AppSignalType& ResumeSignal() { return mResumeSignal; }
233 * @copydoc Dali::Application::ResetSignal()
235 Dali::Application::AppSignalType& ResetSignal() { return mResetSignal; }
238 * @copydoc Dali::Application::AppControlSignal()
240 Dali::Application::AppControlSignalType& AppControlSignal() { return mAppControlSignal; }
243 * @copydoc Dali::Application::ResizeSignal()
245 Dali::Application::AppSignalType& ResizeSignal() { return mResizeSignal; }
248 * @copydoc Dali::Application::LanguageChangedSignal()
250 Dali::Application::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
253 * @copydoc Dali::Application::RegionChangedSignal()
255 Dali::Application::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
258 * @copydoc Dali::Application::BatteryLowSignal()
260 Dali::Application::AppSignalType& BatteryLowSignal() { return mBatteryLowSignal; }
263 * @copydoc Dali::Application::MemoryLowSignal()
265 Dali::Application::AppSignalType& MemoryLowSignal() { return mMemoryLowSignal; }
270 Application(const Application&);
271 Application& operator=(Application&);
280 * Creates the adaptor
282 void CreateAdaptor();
285 * Quits from the main loop
287 void QuitFromMainLoop();
291 AppSignalType mInitSignal;
292 AppSignalType mTerminateSignal;
293 AppSignalType mPauseSignal;
294 AppSignalType mResumeSignal;
295 AppSignalType mResetSignal;
296 AppSignalType mResizeSignal;
297 AppControlSignalType mAppControlSignal;
298 AppSignalType mLanguageChangedSignal;
299 AppSignalType mRegionChangedSignal;
300 AppSignalType mBatteryLowSignal;
301 AppSignalType mMemoryLowSignal;
304 EventLoop* mEventLoop;
305 Framework* mFramework;
307 Dali::Configuration::ContextLoss mContextLossConfiguration;
308 CommandLineOptions* mCommandLineOptions;
310 Dali::SingletonService mSingletonService;
311 Dali::Adaptor* mAdaptor;
312 Dali::Window mWindow;
313 Dali::Application::WINDOW_MODE mWindowMode;
317 DeviceLayout mBaseLayout;
319 SlotDelegate< Application > mSlotDelegate;
322 inline Application& GetImplementation(Dali::Application& application)
324 DALI_ASSERT_ALWAYS(application && "application handle is empty");
326 BaseObject& handle = application.GetBaseObject();
328 return static_cast<Internal::Adaptor::Application&>(handle);
331 inline const Application& GetImplementation(const Dali::Application& application)
333 DALI_ASSERT_ALWAYS(application && "Timre handle is empty");
335 const BaseObject& handle = application.GetBaseObject();
337 return static_cast<const Internal::Adaptor::Application&>(handle);
341 } // namespace Adaptor
343 } // namespace Internal
347 #endif // __DALI_INTERNAL_APPLICATION_H__