Dali 3D User Interface Engine
script-hello

Hello World - JSON layout

The following JSON code is the minimum required to put the sentence "Hello World" on the screen.

{
// a tree of actors
"stage": [{
"name": "text-label",
"type": "TextLabel",
"text": "Hello World",
"parentOrigin": "CENTER"
}]
}

The following code loads the JSON file

// C++
Builder builder = Builder::New();
std::string json_data(ReadFile("layout.json"));
builder.LoadFromString(json_data);
builder.AddActors( Stage::GetCurrent().GetRootLayer() );
// JavaScript
var builder = new dali.Builder();
builder.loadFromFile("layout.json");
builder.addActors( dali.stage.getRootLayer )

Hello World - Javascript

The DALi script application is needed to run the Javascript which provides a Javascript runtime and an interface to Dali.

scripting.example hello-world.js

The TextLabel control to display Hello World can be constructed using Javascript dot notation accessing DALi Actor Properties.

// JavaScript
var textLabel = new dali.TextLabel();
textLabel.text = "Hello World";
textLabel.fontFamily = "FreeSans";
textLabel.fontStyle = "Regular";
textLabel.parentOrigin = dali.CENTER;
dali.stage.add( textLabel );
Dali Docs Home
Read more about Dali