392128463ac93180fdca13ed037b66900eff2612
[platform/core/uifw/dali-toolkit.git] / docs / content / programming-guide / dali-application.h
1 /*! \page dali-application DALi Application
2  *
3 <h2 class="pg">Creating an Application</h2>
4
5 The Adaptor framework provides provides a Dali::Application class which initialises and sets up Dali appropriately so that the application writer does not have to.
6 This provides many platform related services.
7
8 Several signals can be connected to so that the application writer is informed when certain platform related activities occur.
9 It also ensures that, upon system events, DALi is called in a thread-safe manner.
10
11 The following example shows how to create a Dali::Application instance and connect to its initialise signal (which is where a Dali::Actor hierarchy should be created).
12
13 @code
14 void CreateProgram(Application& app)
15 {
16   // Create Dali components...
17   Dali::Actor actor = Actor::New();
18   ...
19 }
20
21 int main (int argc, char **argv)
22 {
23   Dali::Application app = Application::New(&argc, &argv);
24   app.InitSignal().Connect(&CreateProgram);
25   app.MainLoop();
26 }
27 @endcode
28
29 Please see the Dali::Application class for other signals to which the application can connect.
30
31 <h2 class="pg">Window</h2>
32 DALi provides a Window class to manage drawing to a default surface. It is also responsible for drawing the Indicator bar if required. The Application class automatically creates a Window which the application author can access after the SignalInit has fired.
33
34 @code
35 void CreateProgram(Application& app)
36 {
37   app.GetWindow().ShowIndicator(Dali::Window::VISIBLE);
38 }
39
40 int main (int argc, char **argv)
41 {
42   Dali::Application app = Application::New(argc, argv);
43   app.SignalInit().Connect(&CreateProgram);
44   app.MainLoop();
45 }
46 @endcode
47
48 <h2 class="pg">Timers</h2>
49
50 Timers are also provided by the Adaptor Framework so that the application writer can execute a portion of their code periodically or just once, after a delay.  The example below shows how a Dali::Timer can be created and used:
51
52 @code
53 bool Tick()
54 {
55   ...
56   return true; // Timer continues, i.e. this function will be called again after the specified time has elapsed.
57 }
58
59 ...
60
61 // Elsewhere
62 Dali::Timer timer = Dali::Timer::New(2000); // 2 second timeout
63 timer.SignalTick().Connect(&Tick);
64 ...
65 @endcode
66
67  */