[Tizen] Add deprecated logs to Adaptor and Application
[platform/core/uifw/dali-adaptor-legacy.git] / dali / public-api / adaptor-framework / application.h
1 #ifndef DALI_APPLICATION_H
2 #define DALI_APPLICATION_H
3
4 /*
5  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/view-mode.h>
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/signals/callback.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/adaptor-framework/application-configuration.h>
28 #include <dali/public-api/adaptor-framework/device-status.h>
29 #include <dali/public-api/adaptor-framework/window.h>
30
31 namespace Dali
32 {
33 /**
34  * @addtogroup dali_adaptor_framework
35  * @{
36  */
37
38 namespace Internal DALI_INTERNAL
39 {
40 namespace Adaptor
41 {
42 class Application;
43 }
44 }
45 /**
46  * @DEPRECATED_1_5.19
47  *
48  * @brief An Application class object should be created by every application
49  * that wishes to use Dali.
50  *
51  * It provides a means for initializing the
52  * resources required by the Dali::Core.
53  *
54  * The Application class emits several signals which the user can
55  * connect to.  The user should not create any Dali objects in the main
56  * function and instead should connect to the Init signal of the
57  * Application and create the Dali objects in the connected callback.
58  *
59  * Applications should follow the example below:
60  *
61  * @code
62  * class ExampleController: public ConnectionTracker
63  * {
64  * public:
65  *   ExampleController( Application& application )
66  *   : mApplication( application )
67  *   {
68  *     mApplication.InitSignal().Connect( this, &ExampleController::Create );
69  *   }
70  *
71  *   void Create( Application& application )
72  *   {
73  *     // Create Dali components...
74  *   }
75  *  ...
76  * private:
77  *   Application& mApplication;
78  * };
79  *
80  * int main (int argc, char **argv)
81  * {
82  *   Application app = Application::New(&argc, &argv);
83  *   ExampleController example( app );
84  *   app.MainLoop();
85  * }
86  * @endcode
87  *
88  * If required, you can also connect class member functions to a signal:
89  *
90  * @code
91  * MyApplication app;
92  * app.ResumeSignal().Connect(&app, &MyApplication::Resume);
93  * @endcode
94  *
95  * This class accepts command line arguments as well. The following options are supported:
96  *
97  * @code
98  *  -w|--width          Stage Width
99  *  -h|--height         Stage Height
100  *  -d|--dpi            Emulated DPI
101  *     --help           Help
102  * @endcode
103  *
104  * When the above options are found, they are stripped from argv, and argc is updated appropriately.
105  * @SINCE_1_0.0
106  */
107 class DALI_ADAPTOR_API Application : public BaseHandle
108 {
109 public:
110
111   typedef Signal< void (DeviceStatus::Battery::Status) > LowBatterySignalType; ///< Application device signal type @SINCE_1_2.62
112   typedef Signal< void (DeviceStatus::Memory::Status) > LowMemorySignalType;   ///< Application device signal type @SINCE_1_2.62
113   typedef Signal< void (Application&) > AppSignalType;  ///< Application lifecycle signal and system signal callback type @SINCE_1_0.0
114   typedef Signal< void (Application&, void *) > AppControlSignalType; ///< Application control signal callback type @SINCE_1_0.0
115
116   /**
117    * @brief Enumeration for deciding whether a Dali application window is opaque or transparent.
118    * @SINCE_1_0.0
119    */
120   enum WINDOW_MODE
121   {
122     OPAQUE = 0,       ///< The window will be opaque @SINCE_1_0.0
123     TRANSPARENT = 1   ///< The window transparency will match the alpha value set in Dali::Stage::SetBackgroundcolor() @SINCE_1_0.0
124   };
125
126 public:
127
128   /**
129    * @DEPRECATED_1_5.19
130    *
131    * @brief This is the constructor for applications without an argument list.
132    * @SINCE_1_0.0
133    * @PRIVLEVEL_PUBLIC
134    * @PRIVILEGE_DISPLAY
135    * @return A handle to the Application
136    */
137   static Application New();
138
139   /**
140    * @DEPRECATED_1_5.19
141    *
142    * @brief This is the constructor for applications.
143    *
144    * @SINCE_1_0.0
145    * @PRIVLEVEL_PUBLIC
146    * @PRIVILEGE_DISPLAY
147    * @param[in,out]  argc        A pointer to the number of arguments
148    * @param[in,out]  argv        A pointer to the argument list
149    * @return A handle to the Application
150    */
151   static Application New( int* argc, char **argv[] );
152
153   /**
154    * @DEPRECATED_1_5.19
155    *
156    * @brief This is the constructor for applications with a name.
157    *
158    * @SINCE_1_0.0
159    * @PRIVLEVEL_PUBLIC
160    * @PRIVILEGE_DISPLAY
161    * @param[in,out]  argc        A pointer to the number of arguments
162    * @param[in,out]  argv        A pointer to the argument list
163    * @param[in]      stylesheet  The path to user defined theme file
164    * @return A handle to the Application
165    * @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.
166    */
167   static Application New( int* argc, char **argv[], const std::string& stylesheet );
168
169   /**
170    * @DEPRECATED_1_5.19
171    *
172    * @brief This is the constructor for applications with a name.
173    *
174    * @SINCE_1_0.0
175    * @PRIVLEVEL_PUBLIC
176    * @PRIVILEGE_DISPLAY
177    * @param[in,out]  argc        A pointer to the number of arguments
178    * @param[in,out]  argv        A pointer to the argument list
179    * @param[in]      stylesheet  The path to user defined theme file
180    * @param[in]      windowMode  A member of WINDOW_MODE
181    * @return A handle to the Application
182    * @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.
183    */
184   static Application New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
185
186   /**
187    * @DEPRECATED_1_5.19
188    *
189    * @brief This is the constructor for applications.
190    *
191    * @SINCE_1_2.60
192    * @PRIVLEVEL_PUBLIC
193    * @PRIVILEGE_DISPLAY
194    * @param[in,out]  argc         A pointer to the number of arguments
195    * @param[in,out]  argv         A pointer to the argument list
196    * @param[in]      stylesheet   The path to user defined theme file
197    * @param[in]      windowMode   A member of WINDOW_MODE
198    * @param[in]      positionSize A position and a size of the window
199    * @return A handle to the Application
200    * @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.
201    */
202   static Application New( int* argc, char **argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize );
203
204   /**
205    * @brief Constructs an empty handle.
206    * @SINCE_1_0.0
207    */
208   Application();
209
210   /**
211    * @brief Copy Constructor.
212    * @SINCE_1_0.0
213    * @param[in] application Handle to an object
214    */
215   Application( const Application& application );
216
217   /**
218    * @brief Assignment operator.
219    * @SINCE_1_0.0
220    * @param[in] application Handle to an object
221    * @return A reference to this
222    */
223   Application& operator=( const Application& application );
224
225   /**
226    * @brief Destructor.
227    *
228    * This is non-virtual since derived Handle types must not contain data or virtual methods.
229    * @SINCE_1_0.0
230    */
231   ~Application();
232
233 public:
234   /**
235    * @brief This starts the application.
236    *
237    * Choosing this form of main loop indicates that the default
238    * application configuration of APPLICATION_HANDLES_CONTEXT_LOSS is used. On platforms where
239    * context loss can occur, the application is responsible for tearing down and re-loading UI.
240    * The application should listen to Stage::ContextLostSignal and Stage::ContextRegainedSignal.
241    * @SINCE_1_0.0
242    */
243   void MainLoop();
244
245   /**
246    * @brief This starts the application, and allows the app to choose a different configuration.
247    *
248    * If the application plans on using the ReplaceSurface or ReplaceWindow API, then this will
249    * trigger context loss & regain.
250    * The application should listen to Stage::ContextLostSignal and Stage::ContextRegainedSignal.
251    * @SINCE_1_0.0
252    * @param[in] configuration The context loss configuration
253    */
254   void MainLoop(Configuration::ContextLoss configuration);
255
256   /**
257    * @brief This lowers the application to bottom without actually quitting it.
258    * @SINCE_1_0.0
259    */
260   void Lower();
261
262   /**
263    * @brief This quits the application.  Tizen applications should use Lower to improve re-start performance unless they need to Quit completely.
264    * @SINCE_1_0.0
265    */
266   void Quit();
267
268   /**
269    * @brief Ensures that the function passed in is called from the main loop when it is idle.
270    * @SINCE_1_0.0
271    * @param[in] callback The function to call
272    * @return @c true if added successfully, @c false otherwise
273    *
274    * @note Function must be called from main event thread only
275    *
276    * A callback of the following type may be used:
277    * @code
278    *   void MyFunction();
279    * @endcode
280    * This callback will be deleted once it is called.
281    *
282    * @note Ownership of the callback is passed onto this class.
283    */
284   bool AddIdle( CallbackBase* callback );
285
286   /**
287    * @brief Retrieves the main window used by the Application class.
288    *
289    * The application writer can use the window to change indicator and orientation
290    * properties.
291    * @SINCE_1_0.0
292    * @return A handle to the window
293    */
294   Window GetWindow();
295
296   /**
297    * @DEPRECATED_1_4.12
298    * @brief Replaces the current window.
299    *
300    * This will force context loss.
301    * If you plan on using this API in your application, then you should configure
302    * it to prevent discard behavior when handling the Init signal.
303    * @SINCE_1_0.0
304    * @param[in] windowPosition The position and size parameters of the new window
305    * @param[in] name The name of the new window
306    */
307   void ReplaceWindow(PositionSize windowPosition, const std::string& name)  DALI_DEPRECATED_API;
308
309   /**
310    * @brief Get path application resources are stored at
311    *
312    * @SINCE_1_2.2
313    * @return the full path of the resources
314    */
315   static std::string GetResourcePath();
316
317   /**
318    * @brief This is used to get region information from device.
319    *
320    * @SINCE_1_2.62
321    * @return Region information
322    */
323   std::string GetRegion() const;
324
325   /**
326    * @brief This is used to get language information from device.
327    *
328    * @SINCE_1_2.62
329    * @return Language information
330    */
331   std::string GetLanguage() const;
332
333 public: // Stereoscopy
334
335   /**
336    * @DEPRECATED_1_3_51
337    * @brief Sets the viewing mode for the application.
338    * @SINCE_1_0.0
339    * @param[in] viewMode The new viewing mode
340    */
341   void SetViewMode( ViewMode viewMode );
342
343   /**
344    * @DEPRECATED_1_3_51
345    * @brief Gets the current viewing mode.
346    * @SINCE_1_0.0
347    * @return The current viewing mode
348    */
349   ViewMode GetViewMode() const;
350
351   /**
352    * @DEPRECATED_1_3_51
353    * @brief Sets the stereo base (eye separation) for Stereoscopic 3D.
354    *
355    * The stereo base is the distance in millimetres between the eyes. Typical values are
356    * between 50mm and 70mm. The default value is 65mm.
357    * @SINCE_1_0.0
358    * @param[in] stereoBase The stereo base (eye separation) for Stereoscopic 3D
359    */
360   void SetStereoBase( float stereoBase );
361
362   /**
363    * @DEPRECATED_1_3_51
364    * @brief Gets the stereo base (eye separation) for Stereoscopic 3D.
365    *
366    * @SINCE_1_0.0
367    * @return The stereo base (eye separation) for Stereoscopic 3D
368    */
369   float GetStereoBase() const;
370
371 public:  // Signals
372
373   /**
374    * @brief The user should connect to this signal to determine when they should initialize
375    * their application.
376    * @SINCE_1_0.0
377    * @return The signal to connect to
378    */
379   AppSignalType& InitSignal();
380
381   /**
382    * @brief The user should connect to this signal to determine when they should terminate
383    * their application.
384    * @SINCE_1_0.0
385    * @return The signal to connect to
386    */
387   AppSignalType& TerminateSignal();
388
389   /**
390    * @brief The user should connect to this signal if they need to perform any special
391    * activities when the application is about to be paused.
392    * @SINCE_1_0.0
393    * @return The signal to connect to
394    */
395   AppSignalType& PauseSignal();
396
397   /**
398    * @brief The user should connect to this signal if they need to perform any special
399    * activities when the application has resumed.
400    * @SINCE_1_0.0
401    * @return The signal to connect to
402    */
403   AppSignalType& ResumeSignal();
404
405   /**
406    * @brief This signal is sent when the system requires the user to reinitialize itself.
407    * @SINCE_1_0.0
408    * @return The signal to connect to
409    */
410   AppSignalType& ResetSignal();
411
412   /**
413    * @DEPRECATED_1_2.62 Use Window::ResizedSignal() instead.
414    * @brief This signal is emitted when the window application rendering on is resized.
415    * @SINCE_1_0.0
416    * @return The signal to connect to
417    */
418   AppSignalType& ResizeSignal() DALI_DEPRECATED_API;
419
420   /**
421   * @brief This signal is emitted when another application sends a launch request to the application.
422   *
423   * When the application is launched, this signal is emitted after the main loop of the application starts up.
424   * The passed parameter describes the launch request and contains the information about why the application is launched.
425   * @SINCE_1_0.0
426   * @return The signal to connect to
427   */
428   AppControlSignalType& AppControlSignal();
429
430   /**
431    * @brief This signal is emitted when the language is changed on the device.
432    * @SINCE_1_0.0
433    * @return The signal to connect to
434    */
435   AppSignalType& LanguageChangedSignal();
436
437   /**
438   * @brief This signal is emitted when the region of the device is changed.
439   * @SINCE_1_0.0
440   * @return The signal to connect to
441   */
442   AppSignalType& RegionChangedSignal();
443
444   /**
445   * @DEPRECATED_1_2.62 Use LowBatterySignal() instead.
446   * @brief This signal is emitted when the battery level of the device is low.
447   * @SINCE_1_0.0
448   * @return The signal to connect to
449   */
450   AppSignalType& BatteryLowSignal() DALI_DEPRECATED_API;
451
452   /**
453   * @DEPRECATED_1_2.62 Use LowMemorySignal() instead.
454   * @brief This signal is emitted when the memory level of the device is low.
455   * @SINCE_1_0.0
456   * @return The signal to connect to
457   */
458   AppSignalType& MemoryLowSignal() DALI_DEPRECATED_API;
459
460   /**
461    * @brief This signal is emitted when the battery level of the device is low.
462    * @SINCE_1_2.62
463    * @return The signal to connect to
464    */
465   LowBatterySignalType& LowBatterySignal();
466
467   /**
468    * @brief This signal is emitted when the memory level of the device is low.
469    * @SINCE_1_2.62
470    * @return The signal to connect to
471    */
472   LowMemorySignalType& LowMemorySignal();
473
474 public: // Not intended for application developers
475   /// @cond internal
476   /**
477    * @brief Internal constructor.
478    * @SINCE_1_0.0
479    */
480   explicit DALI_INTERNAL Application(Internal::Adaptor::Application* application);
481   /// @endcond
482 };
483
484 /**
485  * @}
486  */
487 } // namespace Dali
488
489 #endif // DALI_APPLICATION_H