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