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 <boost/bind.hpp>
23 #include <boost/function.hpp>
24 #include <boost/thread.hpp>
26 #include <dali/public-api/math/rect.h>
27 #include <dali/public-api/object/base-object.h>
30 #include <application.h>
31 #include <singleton-service.h>
33 #include <framework.h>
34 #include <window-impl.h>
46 class CommandLineOptions;
49 typedef Dali::Rect<int> PositionSize;
52 typedef IntrusivePtr<Application> ApplicationPtr;
55 * Implementation of the Application class.
57 class Application : public BaseObject, public Framework::Observer
61 typedef Dali::Application::AppSignalType AppSignalType;
65 * @param[in] app The public instance of the Application
66 * @param[in] argc A pointer to the number of arguments
67 * @param[in] argv A pointer to the argument list
68 * @param[in] name A name of application
69 * @param[in] baseLayout The base layout that the application has been written for
70 * @param[in] windowMode A member of Dali::Application::WINDOW_MODE
72 static ApplicationPtr New(int* argc, char **argv[], const std::string& name,
73 const DeviceLayout& baseLayout,
74 Dali::Application::WINDOW_MODE windowMode);
76 Application( int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout, Dali::Application::WINDOW_MODE windowMode );
81 virtual ~Application();
86 * @copydoc Dali::Application::MainLoop()
88 void MainLoop(Dali::Configuration::ContextLoss configuration);
91 * @copydoc Dali::Application::Lower()
96 * @copydoc Dali::Application::Quit()
101 * @copydoc Dali::Application::AddIdle()
103 bool AddIdle(boost::function<void(void)> callBack);
106 * @copydoc Dali::Application::GetAdaptor();
108 Dali::Adaptor& GetAdaptor();
111 * @copydoc Dali::Application::GetWindow();
113 Dali::Window GetWindow();
116 * @copydoc Dali::Application::GetTheme();
118 const std::string& GetTheme();
121 * @copydoc Dali::Application::SetTheme();
123 void SetTheme(const std::string& themeFilePath);
126 * @copydoc Dali::Application::ReplaceWindow();
128 void ReplaceWindow(PositionSize windowPosition, const std::string& name);
130 public: // Stereoscopy
133 * @copydoc Dali::Application::SetViewMode()
135 void SetViewMode( ViewMode viewMode );
138 * @copydoc Dali::Application::GetViewMode()
140 ViewMode GetViewMode() const;
143 * @copydoc Dali::Application::SetStereoBase()
145 void SetStereoBase( float stereoBase );
148 * @copydoc Dali::Application::GetStereoBase()
150 float GetStereoBase() const;
152 public: // From Framework::Observer
155 * Called when the framework is initialised.
157 virtual void OnInit();
160 * Called when the framework is terminated.
162 virtual void OnTerminate();
165 * Called when the framework is paused.
167 virtual void OnPause();
170 * Called when the framework resumes from a paused state.
172 virtual void OnResume();
175 * Called when the framework informs the application that it should reset itself.
177 virtual void OnReset();
180 * Called when the framework informs the application that the language of the device has changed.
182 virtual void OnLanguageChanged();
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::ResizeSignal()
222 Dali::Application::AppSignalType& ResizeSignal() { return mResizeSignal; }
225 * @copydoc Dali::Application::LanguageChangedSignal()
227 Dali::Application::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
232 Application(const Application&);
233 Application& operator=(Application&);
242 * Creates the adaptor
244 void CreateAdaptor();
247 * Quits from the main loop
249 void QuitFromMainLoop();
253 AppSignalType mInitSignal;
254 AppSignalType mTerminateSignal;
255 AppSignalType mPauseSignal;
256 AppSignalType mResumeSignal;
257 AppSignalType mResetSignal;
258 AppSignalType mResizeSignal;
259 AppSignalType mLanguageChangedSignal;
261 EventLoop* mEventLoop;
262 Framework* mFramework;
264 Dali::Configuration::ContextLoss mContextLossConfiguration;
265 CommandLineOptions* mCommandLineOptions;
267 Dali::SingletonService mSingletonService;
268 Dali::Adaptor* mAdaptor;
269 Dali::Window mWindow;
270 Dali::Application::WINDOW_MODE mWindowMode;
274 DeviceLayout mBaseLayout;
276 SlotDelegate< Application > mSlotDelegate;
279 inline Application& GetImplementation(Dali::Application& application)
281 DALI_ASSERT_ALWAYS(application && "application handle is empty");
283 BaseObject& handle = application.GetBaseObject();
285 return static_cast<Internal::Adaptor::Application&>(handle);
288 inline const Application& GetImplementation(const Dali::Application& application)
290 DALI_ASSERT_ALWAYS(application && "Timre handle is empty");
292 const BaseObject& handle = application.GetBaseObject();
294 return static_cast<const Internal::Adaptor::Application&>(handle);
298 } // namespace Adaptor
300 } // namespace Internal
304 #endif // __DALI_INTERNAL_APPLICATION_H__