1 /*! \page script-overview Scripting Overview
3 * Dali has scripting support to
6 * <li>Provide a mechanism to allow custom controls in scripting.
7 * <li>Support layouts using JSON.
8 * <li>Support a dynamic Javascript runtime.
11 * This is accessed via the Dali script external application which wraps Dali with a scripting engine. For example
14 * daliscript hello-world.js
17 * <h1 class="pg">A Mechanism To Allow Custom Controls in Scripting</h1>
19 * <h2 class="pg">The TypeRegistry</h2>
21 * The TypeRegistry allows class 'types' to register themselves as creatable from a scripting environment.
23 * Custom controls can register a creation function using class run time type information (RTTI).
25 * The RTTI typeid provides Dali with a unique name to register the type. In this registration the creation function is responsible for creating new instances of the custom class.
27 * Signals can be added to this type registration with a signal connection function.
29 * Actions can be similarly added with an action function.
32 * <h2 class="pg">Non Animatable Properies</h2>
34 * The property system has non animatable properties that can be used by the scripting runtime to set actor attributes.
36 * Custom controls can register properties for scripting access.
39 * <h2 class="pg">A Javascript example</h2>
41 * A Javascript runtime wrapping Dali and the V8 Javacript engine is being developed to allow the creation of pure Javascript applications.
43 * ie 'daliscript helloworld.js'.
45 * This example shows how a Javacript file relates to the TypeRegistry and Property system.
49 * // This line looks for a type registered as "MyActor" and calls its creation function
50 * var custom = new MyActor();
53 * // This line finds a property called "alpha" and Sets with SetProperty(index, Property::Value(2.0))
56 * // NB: non animatable properties can be strings
57 * custom.text = "a label";
60 * // This line finds the action function registered as "SelectPage" and calls its with a list of arguments
61 * // (NB: arguments are currently limited to non aggregate types ie no list, maps or objects)
62 * custom.SelectPage("one");
65 * // This line finds the signal registered as "touched" and sets the "OnTouch" callback function
66 * custom.signals.touched = OnTouch;
68 * // OnTouch could have been previously defined as
69 * function OnTouch(name)
75 * <h1 class="pg">Supporting Layouts Using JSON</h1>
77 * The builder in Dali Toolkit provides a means to define layouts using the JSON file format.
79 * This format defines a text representation for key value pairs and lists of data. Lists and Maps can hold the fundamental Javascript data types of string, number(float/int), true, false, nil.
83 * Currently the builder supports internal Toolkit and Dali controls.
87 * The builder will be improved to make use of the TypeRegistry and non animatable properties and allow Custom Controls to be added into Scripting.
89 * This means the current JSON format will alter slightly (for example; properties will not be defined as a tree but as one level below the actor definition)
91 * An actor tree defined in JSON will be retrievable as a "Buildable" class instance.
93 * This buildable class allows the creation of the actor tree. It will also aid resource managment as a buildable can store the layout representation and unload resources when off stage (reconstructing the object when its added back onto the stage).
95 * <h1 class="pg">Supporting A Javascript Runtime</h1>
97 * As a separate project an application will be available that can execute Javascript.
99 * This application will provide a wrapping layer between V8 and Dali and allow a natural interface to the Javascript developer.