488cb8b6bf3f25e706979be7ef4cc34972e9c6d0
[platform/core/uifw/dali-toolkit.git] / docs / content / shared-javascript-and-cpp-documentation / script-hello.md
1 /**
2  *
3  # Hello World - JSON layout{#script-hello}
4
5  The following JSON code is the minimum required to put the sentence "Hello World" on the screen.
6
7 ~~~{.json}
8 {
9  // a tree of actors
10  "stage": [{
11    "name": "text-label",
12    "type": "TextLabel",
13    "text": "Hello World",
14    "parent-origin": "CENTER"
15  }]
16 }
17 ~~~
18
19  The following code loads the JSON file
20
21 ~~~{.cpp}
22  // C++
23  Builder builder = Builder::New();
24
25  std::string json_data(ReadFile("layout.json"));
26
27  builder.LoadFromString(json_data);
28
29  builder.AddActors( Stage::GetCurrent().GetRootLayer() );
30
31  ~~~
32
33  ~~~{.js}
34  // JavaScript
35
36  var builder = new dali.Builder();
37
38  builder.loadFromFile("layout.json");
39
40  builder.addActors( dali.stage.getRootLayer )
41
42 ~~~
43  ## Hello World - Javascript
44
45  The Dali script application is needed to run the Javascript which provides a Javascript runtime and an interface to Dali.
46
47 ~~~
48  scripting.example hello-world.js
49 ~~~
50
51  The TextLabel control to display Hello World can be constructed using Javascript dot notation accessing Dali Actor Properties.
52
53 ~~~{.js}
54 // JavaScript
55
56  var textLabel = new dali.TextLabel();
57
58  textLabel.text         = "Hello World";
59  textLabel.fontFamily   = "FreeSans";
60  textLabel.fontStyle    = "Regular";
61  textLabel.parentOrigin = dali.CENTER;
62
63  dali.stage.add( textLabel );
64 ~~~
65
66 @class _Guide_Script_Hello_World
67  */