1 #ifndef __DALI_APPLICATION_H__
2 #define __DALI_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/function.hpp>
24 #include <dali/public-api/object/base-handle.h>
25 #include <dali/public-api/common/view-mode.h>
27 #include "style-monitor.h"
28 #include "device-layout.h"
31 namespace Dali DALI_IMPORT_API
34 namespace Internal DALI_INTERNAL
43 * An Application class object should be created by every application
44 * that wishes to use Dali. It provides a means for initialising the
45 * resources required by the Dali::Core.
47 * The Application class emits several signals which the user can
48 * connect to. The user should not create any Dali objects in the main
49 * function and instead should connect to the Init signal of the
50 * Application and create the Dali objects in the connected callback.
52 * Applications should follow the example below:
55 * void CreateProgram(Application app)
57 * // Create Dali components...
58 * // Can instantiate here, if required
61 * int main (int argc, char **argv)
63 * Application app = Application::New(&argc, &argv);
64 * app.InitSignal().Connect(&CreateProgram);
69 * If required, you can also connect class member functions to a signal:
73 * app.ResumeSignal().Connect(&app, &MyApplication::Resume);
76 * This class accepts command line arguments as well. The following options are supported:
79 * --no-vsync Disable VSync on Render
80 * -w|--width Stage Width
81 * -h|--height Stage Height
82 * -d|--dpi Emulated DPI
86 * When the above options are found, they are stripped from argv, and argc is updated appropriately.
88 class Application : public BaseHandle
92 typedef SignalV2< void (Application&) > AppSignalV2;
95 * Decides whether a Dali application window is opaque or transparent.
99 OPAQUE = 0, ///< The window will be opaque
100 TRANSPARENT = 1 ///< The window transparency will match the alpha value set in Dali::Stage::SetBackgroundcolor()
106 * This is the constructor for applications without an argument list.
108 * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
110 static Application New();
113 * This is the constructor for applications.
115 * @param[in,out] argc A pointer to the number of arguments
116 * @param[in,out] argv A pointer the the argument list
118 * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
119 * @note Supported options are stripped from argv, and argc is updated appropriately.
121 static Application New( int* argc, char **argv[] );
124 * This is the constructor for applications with a name
126 * @param[in,out] argc A pointer to the number of arguments
127 * @param[in,out] argv A pointer the the argument list
128 * @param[in] name A name of application
130 * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
131 * @note Supported options are stripped from argv, and argc is updated appropriately.
133 static Application New( int* argc, char **argv[], const std::string& name );
136 * This is the constructor for applications with a name, and also require a
137 * transparent top-level window
139 * @param[in,out] argc A pointer to the number of arguments
140 * @param[in,out] argv A pointer the the argument list
141 * @param[in] name A name of application
142 * @param[in] windowMode A member of WINDOW_MODE
144 * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
145 * @note Supported options are stripped from argv, and argc is updated appropriately.
147 static Application New( int* argc, char **argv[], const std::string& name, WINDOW_MODE windowMode );
150 * This is the constructor for applications when a layout for the application is specified.
152 * @param[in,out] argc A pointer to the number of arguments
153 * @param[in,out] argv A pointer the the argument list
154 * @param[in] baseLayout The base layout that the application has been written for
156 * @note Supported options are stripped from argv, and argc is updated appropriately.
158 static Application New( int* argc, char **argv[], const DeviceLayout& baseLayout );
161 * This is the constructor for applications with a name and when a layout for the application is specified.
163 * @param[in,out] argc A pointer to the number of arguments
164 * @param[in,out] argv A pointer the the argument list
165 * @param[in] name A name of application
166 * @param[in] baseLayout The base layout that the application has been written for
168 * @note Supported options are stripped from argv, and argc is updated appropriately.
170 static Application New( int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout );
173 * Construct an empty handle
180 Application( const Application& application );
183 * Assignment operator
185 Application& operator=( const Application& applicaton );
190 * This is non-virtual since derived Handle types must not contain data or virtual methods.
196 * This starts the application.
201 * This lowers the application to bottom without actually quitting it
206 * This quits the application. Tizen applications should use Lower to improve re-start performance unless they need to Quit completely.
211 * This returns a handle to the Orientation object used by Application which allows
212 * the user to determine the orientation of the device and connect to a
213 * signal emitted whenever the orientation changes.
214 * @return A handle to the Orientation object used by the Application
216 Orientation GetOrientation();
219 * Ensures that the function passed in is called from the main loop when it is idle.
221 * A callback of the following type may be used:
226 * @param[in] callBack The function to call.
227 * @return true if added successfully, false otherwise
229 bool AddIdle(boost::function<void(void)> callBack);
232 * Retrieves the window used by the Application class.
233 * The application writer can use the window to change indicator and orientation
235 * @return A handle to the window
239 public: // Stereoscopy
242 * Set the viewing mode for the application.
243 * @param[in] viewMode The new viewing mode.
245 void SetViewMode( ViewMode viewMode );
248 * Get the current viewing mode.
249 * @return The current viewing mode.
251 ViewMode GetViewMode() const;
254 * Set the stereo base (eye seperation) for stereoscopic 3D
255 * @param[in] stereoBase The stereo base (eye seperation) for stereoscopic 3D
257 void SetStereoBase( float stereoBase );
260 * Get the stereo base (eye seperation) for stereoscopic 3D
261 * @return The stereo base (eye seperation) for stereoscopic 3D
263 float GetStereoBase() const;
268 * The user should connect to this signal to determine when they should initialise
271 AppSignalV2& InitSignal();
274 * The user should connect to this signal to determine when they should terminate
277 AppSignalV2& TerminateSignal();
280 * The user should connect to this signal if they need to perform any special
281 * activities when the application is about to be paused.
283 AppSignalV2& PauseSignal();
286 * The user should connect to this signal if they need to perform any special
287 * activities when the application has resumed.
289 AppSignalV2& ResumeSignal();
292 * This signal is sent when the system requires the user to reinitialise itself.
294 AppSignalV2& ResetSignal();
297 * This signal is emitted when the window the application is rendering on is resized.
299 AppSignalV2& ResizeSignal();
302 * This signal is emitted when the language is changed on the device.
304 AppSignalV2& LanguageChangedSignal();
306 public: // Not intended for application developers
308 * Internal constructor
310 explicit DALI_INTERNAL Application(Internal::Adaptor::Application* application);
315 #endif // __DALI_APPLICATION_H__