Update contents of programming guide
[platform/core/uifw/dali-toolkit.git] / docs / content / shared-javascript-and-cpp-documentation / programming-languages.md
1 /**
2  *
3 # Programming Languages {#programming-languages}
4
5 DALi applications can be written in several different programming languages.
6
7 ## C++ {#c-plus-plus}
8
9 ~~~{.cpp}
10 Dali::Actor actor = Dali::Actor::New();
11 actor.SetParentOrigin( Dali::ParentOrigin::CENTER );
12 actor.SetAnchorPoint( Dali::AnchorPoint::CENTER );
13 Dali::Stage::GetCurrent().Add( actor );
14 ...
15 bool OnPressed( Dali::Actor, const TouchEvent& event )
16 {
17   Dali::Animation anim = Dali::Animation::New( 1.5f );
18   anim.AnimateTo( Property( actor, Actor::Property::POSITION ), Vector3( 200,-100,0), AlphaFunctions::Bounce );
19   anim.play();
20   return true; // consume the touch event
21 }
22 ...
23 actor.TouchedSignal().Connect( &OnPressed );
24 ~~~
25
26 */
27
28 ## JavaScript {#java-script-support}
29
30 ~~~{.js}
31 var actor = new dali.Actor();
32 actor.parentOrigin = dali.CENTER;
33 actor.anchorPoint = dali.CENTER;
34 dali.stage.add( actor );
35 ...
36 function onPressed( actor, touchEvent )
37 {
38   var animOptions = { alpha: "bounce", delay: 0, duration: 15 };
39   var anim = new dali.Animation();
40   anim.animateTo( actor, "position", [ 200,-100,0], animOptions );
41   anim.play();
42   return true; // consume the touch event
43 }
44 ...
45 actor.connect( "touched", onPressed );
46
47 ~~~
48
49 ## JSON {#json-support}
50
51 ~~~{.json}
52 {
53  "animations":
54   {
55     "move":
56     {
57       "duration": 1.5,
58       "properties":
59       [
60         {
61           "actor":"image",
62           "property":"position",
63           "value":[200,-100,0],
64           "alpha-function": "BOUNCE"
65         }
66       ]
67     }
68   },
69   "stage":
70   [
71     {
72       "name":"image",
73       "type":"Actor",
74       "anchor-point": "CENTER",
75       "parent-origin": "CENTER",
76       "signals" :
77       [
78         { "name" : "touched", "action": "play", "animation": "move" }
79       ]
80     }
81   ]
82 }
83 ~~~