2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/rendering/geometry.h>
22 #include <dali/public-api/rendering/sampler.h>
23 #include <dali/public-api/rendering/shader.h>
24 #include <dali/public-api/rendering/texture-set.h>
25 #include <dali/public-api/rendering/renderer.h>
26 #include <dali/devel-api/scripting/scripting.h>
27 #include <dali/devel-api/events/hit-test-algorithm.h>
28 #include <dali/devel-api/images/texture-set-image.h>
29 #include "emscripten/emscripten.h"
30 #include "emscripten/bind.h"
31 #include "emscripten/val.h"
34 #include "platform-abstractions/emscripten/emscripten-callbacks.h"
35 #include "platform-abstractions/emscripten/emscripten-platform-abstraction.h"
36 #include "sdl-application.h"
37 #include "actor-wrapper.h"
38 #include "animation-wrapper.h"
39 #include "emscripten-utils.h"
40 #include "geometry-wrapper.h"
41 #include "handle-wrapper.h"
42 #include "image-wrapper.h"
43 #include "property-buffer-wrapper.h"
44 #include "property-value-wrapper.h"
45 #include "render-task-wrapper.h"
46 #include "signal-holder.h"
47 #include "type-info-wrapper.h"
49 ////////////////////////////////////////////////////////////////////////////////
51 // The browser javascript wrapper consists of this cpp file and a counterpart
54 // They work in tandem to help make the interface natural and convenient
55 // for a Javascript programmer.
57 // Unfortunately there is no finalize/destruction in javascript so any cpp
58 // objects created must be explicitly deleted. Sometimes this wrapper can
59 // hide the details and simple types can be immediately marshalled to and
60 // from javascript values. More often objects created must have
61 // object.delete() called at the correct time.
63 ////////////////////////////////////////////////////////////////////////////////
65 extern void EmscriptenMouseEvent(double x, double y, int mouseIsDown);
66 extern void EmscriptenUpdateOnce();
67 extern void EmscriptenRenderOnce();
76 // Javascript callbacks. These are set in the Javascript wrapper source and called
77 // from the c++ wrapper source
78 extern emscripten::val JSGetGlyphImage;
79 extern emscripten::val JSGetImage;
80 extern emscripten::val JSGetImageMetaData;
81 extern emscripten::val JSRenderFinished;
83 using namespace emscripten;
86 * Dali Vector access for Emscripten wrapping of Dali::Vector
88 template<typename DaliVectorType>
89 struct DaliVectorAccess
91 static emscripten::val Get( const DaliVectorType& v, typename DaliVectorType::SizeType index )
95 return emscripten::val(v[index]);
99 return emscripten::val::undefined();
103 static bool Set( DaliVectorType& v, typename DaliVectorType::SizeType index, const typename DaliVectorType::ItemType& value)
109 static size_t Size( DaliVectorType& v)
116 * Registering a Dali Vector with Emscripten to wrap for JavaScript
119 class_<Dali::Vector<T>> register_dali_vector(const char* name)
121 typedef Dali::Vector<T> DaliVecType;
123 void (DaliVecType::*PushBack)(const T&) = &DaliVecType::PushBack;
124 void (DaliVecType::*Resize)(const size_t, const T&) = &DaliVecType::Resize;
125 return class_<DaliVecType>(name)
126 .template constructor<>()
127 .function("push_back", PushBack)
128 .function("resize", Resize)
129 .function("size", &DaliVectorAccess<DaliVecType>::Size)
130 .function("get", &DaliVectorAccess<DaliVecType>::Get)
131 .function("set", &DaliVectorAccess<DaliVecType>::Set)
139 std::string VersionString()
141 std::stringstream versionString;
142 versionString << "DALi Core: " << Dali::CORE_MAJOR_VERSION << "." << Dali::CORE_MINOR_VERSION << "." << Dali::CORE_MICRO_VERSION << " (" << Dali::CORE_BUILD_DATE << ")" << std::endl;
143 return versionString.str();
147 * Creates an Actor previously registered with the TypeRegistry by name
148 * Actors are currently differentiated in the dali-wrapper.js and have accessor functions
149 * to support 'property.name=' access in the Javascript side object
151 Dali::Actor CreateActor(const std::string& name)
155 Dali::TypeRegistry registry = Dali::TypeRegistry::Get();
157 Dali::TypeInfo typeInfo = registry.GetTypeInfo( name );
161 EM_ASM( throw "Invalid type name" );
165 Dali::BaseHandle handle = typeInfo.CreateInstance();
169 EM_ASM( throw "Invalid handle. Cannot downcast (not an actor)" );
172 if( Dali::Actor actor = Dali::Actor::DownCast(handle) )
182 * Creates any Handle from the TypeRegistry by name
184 Dali::Handle CreateHandle(const std::string& name)
188 Dali::TypeRegistry registry = Dali::TypeRegistry::Get();
190 Dali::TypeInfo typeInfo = registry.GetTypeInfo( name );
194 EM_ASM( throw "Invalid type name" );
198 Dali::BaseHandle base = typeInfo.CreateInstance();
201 EM_ASM( throw "Cannot create instance (not a handle)" );
203 Dali::Handle handle = Dali::Handle::DownCast(base);
207 EM_ASM( throw "Invalid handle. Cannot downcast" );
217 * The functor to be used in the hit-test algorithm to check whether the actor is hittable.
219 bool IsActorHittableFunction(Dali::Actor actor, Dali::HitTestAlgorithm::TraverseType type)
221 const std::string& name = actor.GetName();
222 // by convention if not visible, or with a * starting the name or if the root layer
223 return actor.IsVisible() && (name.size() ? name[0] != '*' : true);
230 Dali::Actor HitTest(float x, float y)
232 Dali::HitTestAlgorithm::Results results;
233 Dali::HitTestAlgorithm::HitTest( Dali::Stage::GetCurrent(), Dali::Vector2(x,y), results, IsActorHittableFunction );
234 return results.actor;
238 * Creates a solid colour actor
240 Dali::Actor CreateSolidColorActor( const Dali::Vector4& color, bool border, const Dali::Vector4& borderColor, const unsigned int borderSize )
242 static const unsigned int MAX_BORDER_SIZE( 9 );
245 if( borderSize > MAX_BORDER_SIZE )
250 const unsigned int bitmapWidth = borderSize * 2 + 2;
252 // Using a (2 + border) x (2 + border) image gives a better blend with the GL implementation
253 // than a (1 + border) x (1 + border) image
254 const unsigned int bitmapSize = bitmapWidth * bitmapWidth;
255 const unsigned int topLeft = bitmapWidth * borderSize + borderSize;
256 const unsigned int topRight = topLeft + 1;
257 const unsigned int bottomLeft = bitmapWidth * (borderSize + 1) + borderSize;
258 const unsigned int bottomRight = bottomLeft + 1;
260 Dali::BufferImage imageData;
261 if(color.a != 1.0 || borderColor.a != 1.0)
263 imageData = Dali::BufferImage::New( bitmapWidth, bitmapWidth, Dali::Pixel::RGBA8888 );
266 Dali::PixelBuffer* pixbuf = imageData.GetBuffer();
267 Dali::Vector4 outerColor = color;
270 outerColor = borderColor;
273 for( size_t i = 0; i < bitmapSize; ++i )
280 pixbuf[i*4+0] = 0xFF * color.r;
281 pixbuf[i*4+1] = 0xFF * color.g;
282 pixbuf[i*4+2] = 0xFF * color.b;
283 pixbuf[i*4+3] = 0xFF * color.a;
287 pixbuf[i*4+0] = 0xFF * outerColor.r;
288 pixbuf[i*4+1] = 0xFF * outerColor.g;
289 pixbuf[i*4+2] = 0xFF * outerColor.b;
290 pixbuf[i*4+3] = 0xFF * outerColor.a;
296 imageData = Dali::BufferImage::New( bitmapWidth, bitmapWidth, Dali::Pixel::RGB888 );
299 Dali::PixelBuffer* pixbuf = imageData.GetBuffer();
300 Dali::Vector4 outerColor = color;
303 outerColor = borderColor;
306 for( size_t i = 0; i < bitmapSize; ++i )
313 pixbuf[i*3+0] = 0xFF * color.r;
314 pixbuf[i*3+1] = 0xFF * color.g;
315 pixbuf[i*3+2] = 0xFF * color.b;
319 pixbuf[i*3+0] = 0xFF * outerColor.r;
320 pixbuf[i*3+1] = 0xFF * outerColor.g;
321 pixbuf[i*3+2] = 0xFF * outerColor.b;
327 image = Dali::Actor::New();
328 image.SetAnchorPoint( Dali::AnchorPoint::CENTER );
329 image.SetParentOrigin( Dali::ParentOrigin::CENTER );
331 std::string vertexShader(
332 "attribute mediump vec2 aPosition;\n"
333 "varying mediump vec2 vTexCoord;\n"
334 "uniform mediump mat4 uMvpMatrix;\n"
335 "uniform mediump vec3 uSize;\n"
336 "uniform mediump vec4 sTextureRect;\n"
339 " gl_Position = uMvpMatrix * vec4(aPosition * uSize.xy, 0.0, 1.0);\n"
340 " vTexCoord = aPosition + vec2(0.5);\n"
343 std::string fragmentShader(
344 "varying mediump vec2 vTexCoord;\n"
345 "uniform sampler2D sTexture;\n"
346 "uniform lowp vec4 uColor;\n"
349 " gl_FragColor = texture2D( sTexture, vTexCoord )*uColor;\n"
352 Dali::Shader shader = Dali::Shader::New( vertexShader, fragmentShader );
354 // Create Quad geometry
355 Dali::Property::Map quadVertexFormat;
356 quadVertexFormat["aPosition"] = Dali::Property::VECTOR2;
357 Dali::PropertyBuffer vertexData = Dali::PropertyBuffer::New( quadVertexFormat );
358 const float halfQuadSize = .5f;
359 struct QuadVertex { Dali::Vector2 position; };
360 QuadVertex quadVertexData[4] = {
361 { Dali::Vector2(-halfQuadSize, -halfQuadSize) },
362 { Dali::Vector2(-halfQuadSize, halfQuadSize) },
363 { Dali::Vector2( halfQuadSize, -halfQuadSize) },
364 { Dali::Vector2( halfQuadSize, halfQuadSize) } };
365 vertexData.SetData(quadVertexData, 4);
367 Dali::Geometry quad = Dali::Geometry::New();
368 quad.AddVertexBuffer( vertexData );
369 quad.SetType( Dali::Geometry::TRIANGLE_STRIP );
371 Dali::Renderer renderer = Dali::Renderer::New( quad, shader );
372 Dali::TextureSet textureSet = Dali::TextureSet::New();
373 TextureSetImage( textureSet, 0u, imageData );
374 renderer.SetTextures( textureSet );
376 image.AddRenderer( renderer );
384 * Sets the callback to getting a glyph (from dali-wrapper.js/browser)
386 void SetCallbackGetGlyphImage(const emscripten::val& callback)
388 JSGetGlyphImage = callback;
392 * Sets the callback to get an image (from dali-wrapper.js/browser)
394 void SetCallbackGetImage(const emscripten::val& callback)
396 JSGetImage = callback;
400 * Sets the callback to get image meta data (from dali-wrapper.js/browser)
402 void SetCallbackGetImageMetadata(const emscripten::val& callback)
404 JSGetImageMetaData = callback;
408 * Sets the callback to signal render finished to dali-wrapper.js/browser
410 void SetCallbackRenderFinished(const emscripten::val& callback)
412 JSRenderFinished = callback;
416 * Generates control points for a Path
418 void GenerateControlPoints(Dali::Handle& handle, float curvature)
422 Dali::Path path = Dali::Path::DownCast(handle);
425 path.GenerateControlPoints(curvature);
429 EM_ASM( throw "Handle is not a path object" );
434 EM_ASM( throw "Handle is empty" );
440 * Creating property Value Objects
441 * javascript can't select on type so we have renamed constructors
443 * Emscripten can convert some basic types and ones we've declared as value_array(s)
444 * (These are given member access offsets/functions and are for simple structs etc)
446 * The composite types need converting.
448 Dali::Property::Value PropertyValueBoolean(bool v)
450 return Dali::Property::Value(v);
453 Dali::Property::Value PropertyValueFloat(float v)
455 return Dali::Property::Value(v);
458 Dali::Property::Value PropertyValueInteger(int v)
460 return Dali::Property::Value(v);
463 Dali::Property::Value PropertyValueVector2( const Dali::Vector2& v )
465 return Dali::Property::Value(v);
468 Dali::Property::Value PropertyValueVector3( const Dali::Vector3& v )
470 return Dali::Property::Value(v);
473 Dali::Property::Value PropertyValueVector4( const Dali::Vector4& v )
475 return Dali::Property::Value(v);
478 Dali::Property::Value PropertyValueIntRect( int a, int b, int c, int d )
480 return Dali::Property::Value(Dali::Rect<int>( a, b, c, d));
483 Dali::Property::Value PropertyValueMatrix( const Dali::Matrix& v )
485 return Dali::Property::Value(v);
488 Dali::Property::Value PropertyValueMatrix3( const Dali::Matrix3& v )
490 return Dali::Property::Value(v);
493 Dali::Property::Value PropertyValueEuler( const Dali::Vector3& v )
495 return Dali::Property::Value( Dali::Quaternion(
496 Dali::Radian(Dali::Degree(v.x)),
497 Dali::Radian(Dali::Degree(v.y)),
498 Dali::Radian(Dali::Degree(v.z)) ) );
501 Dali::Property::Value PropertyValueAxisAngle( const Dali::Vector4& v )
503 return Dali::Quaternion( Dali::Radian(Dali::Degree(v[3])), Dali::Vector3(v) );
506 Dali::Property::Value PropertyValueString( const std::string& v )
508 return Dali::Property::Value(v);
511 Dali::Property::Value PropertyValueContainer( const emscripten::val& v )
513 Dali::Property::Value ret;
514 RecursiveSetProperty( ret, v );
519 * Property value accessors from Dali Property Value
521 bool PropertyGetBoolean(const Dali::Property::Value& v)
523 return v.Get<bool>();
526 float PropertyGetFloat(const Dali::Property::Value& v)
528 return v.Get<float>();
531 int PropertyGetInteger(const Dali::Property::Value& v)
536 Dali::Vector2 PropertyGetVector2(const Dali::Property::Value& v)
538 return v.Get<Dali::Vector2>();
541 Dali::Vector3 PropertyGetVector3(const Dali::Property::Value& v)
543 return v.Get<Dali::Vector3>();
546 Dali::Vector4 PropertyGetVector4(const Dali::Property::Value& v)
548 return v.Get<Dali::Vector4>();
551 emscripten::val PropertyGetIntRect(const Dali::Property::Value& v)
553 return JavascriptValue(v);
556 std::string PropertyGetString(const Dali::Property::Value& v)
558 return v.Get<std::string>();
561 emscripten::val PropertyGetMap(const Dali::Property::Value& v)
563 return JavascriptValue(v);
566 emscripten::val PropertyGetArray(const Dali::Property::Value& v)
568 return JavascriptValue(v);
571 emscripten::val PropertyGetMatrix(const Dali::Property::Value& v)
573 return JavascriptValue(v);
576 emscripten::val PropertyGetMatrix3(const Dali::Property::Value& v)
578 return JavascriptValue(v);
581 emscripten::val PropertyGetEuler(const Dali::Property::Value& v)
583 return JavascriptValue(v);
586 emscripten::val PropertyGetRotation(const Dali::Property::Value& v)
588 return JavascriptValue(v);
591 int PropertyGetType(Dali::Property::Value& v)
593 return (int)v.GetType();
596 std::string PropertyGetTypeName(Dali::Property::Value& v)
598 return Dali::PropertyTypes::GetName(v.GetType());
601 template <typename T>
602 float MatrixGetter(T &v, int n)
604 return *(v.AsFloat() + n);
607 template <typename T>
608 void MatrixSetter(T &v, float f, int n)
610 *(v.AsFloat() + n) = f;
613 float MatrixGetter0(const Dali::Matrix &v) { return MatrixGetter(v, 0); }
614 float MatrixGetter1(const Dali::Matrix &v) { return MatrixGetter(v, 1); }
615 float MatrixGetter2(const Dali::Matrix &v) { return MatrixGetter(v, 2); }
616 float MatrixGetter3(const Dali::Matrix &v) { return MatrixGetter(v, 3); }
617 float MatrixGetter4(const Dali::Matrix &v) { return MatrixGetter(v, 4); }
618 float MatrixGetter5(const Dali::Matrix &v) { return MatrixGetter(v, 5); }
619 float MatrixGetter6(const Dali::Matrix &v) { return MatrixGetter(v, 6); }
620 float MatrixGetter7(const Dali::Matrix &v) { return MatrixGetter(v, 7); }
621 float MatrixGetter8(const Dali::Matrix &v) { return MatrixGetter(v, 8); }
622 float MatrixGetter9(const Dali::Matrix &v) { return MatrixGetter(v, 9); }
623 float MatrixGetter10(const Dali::Matrix &v) { return MatrixGetter(v,10); }
624 float MatrixGetter11(const Dali::Matrix &v) { return MatrixGetter(v,11); }
625 float MatrixGetter12(const Dali::Matrix &v) { return MatrixGetter(v,12); }
626 float MatrixGetter13(const Dali::Matrix &v) { return MatrixGetter(v,13); }
627 float MatrixGetter14(const Dali::Matrix &v) { return MatrixGetter(v,14); }
628 float MatrixGetter15(const Dali::Matrix &v) { return MatrixGetter(v,15); }
629 float MatrixGetter16(const Dali::Matrix &v) { return MatrixGetter(v,16); }
631 void MatrixSetter0(Dali::Matrix &v, float f) { MatrixSetter(v, f, 0); }
632 void MatrixSetter1(Dali::Matrix &v, float f) { MatrixSetter(v, f, 1); }
633 void MatrixSetter2(Dali::Matrix &v, float f) { MatrixSetter(v, f, 2); }
634 void MatrixSetter3(Dali::Matrix &v, float f) { MatrixSetter(v, f, 3); }
635 void MatrixSetter4(Dali::Matrix &v, float f) { MatrixSetter(v, f, 4); }
636 void MatrixSetter5(Dali::Matrix &v, float f) { MatrixSetter(v, f, 5); }
637 void MatrixSetter6(Dali::Matrix &v, float f) { MatrixSetter(v, f, 6); }
638 void MatrixSetter7(Dali::Matrix &v, float f) { MatrixSetter(v, f, 7); }
639 void MatrixSetter8(Dali::Matrix &v, float f) { MatrixSetter(v, f, 8); }
640 void MatrixSetter9(Dali::Matrix &v, float f) { MatrixSetter(v, f, 9); }
641 void MatrixSetter10(Dali::Matrix &v, float f) { MatrixSetter(v, f,10); }
642 void MatrixSetter11(Dali::Matrix &v, float f) { MatrixSetter(v, f,11); }
643 void MatrixSetter12(Dali::Matrix &v, float f) { MatrixSetter(v, f,12); }
644 void MatrixSetter13(Dali::Matrix &v, float f) { MatrixSetter(v, f,13); }
645 void MatrixSetter14(Dali::Matrix &v, float f) { MatrixSetter(v, f,14); }
646 void MatrixSetter15(Dali::Matrix &v, float f) { MatrixSetter(v, f,15); }
647 void MatrixSetter16(Dali::Matrix &v, float f) { MatrixSetter(v, f,16); }
649 float Matrix3Getter0(const Dali::Matrix3 &v) { return MatrixGetter(v, 0); }
650 float Matrix3Getter1(const Dali::Matrix3 &v) { return MatrixGetter(v, 1); }
651 float Matrix3Getter2(const Dali::Matrix3 &v) { return MatrixGetter(v, 2); }
652 float Matrix3Getter3(const Dali::Matrix3 &v) { return MatrixGetter(v, 3); }
653 float Matrix3Getter4(const Dali::Matrix3 &v) { return MatrixGetter(v, 4); }
654 float Matrix3Getter5(const Dali::Matrix3 &v) { return MatrixGetter(v, 5); }
655 float Matrix3Getter6(const Dali::Matrix3 &v) { return MatrixGetter(v, 6); }
656 float Matrix3Getter7(const Dali::Matrix3 &v) { return MatrixGetter(v, 7); }
657 float Matrix3Getter8(const Dali::Matrix3 &v) { return MatrixGetter(v, 8); }
659 void Matrix3Setter0(Dali::Matrix3 &v, float f) { MatrixSetter(v, f, 0); }
660 void Matrix3Setter1(Dali::Matrix3 &v, float f) { MatrixSetter(v, f, 1); }
661 void Matrix3Setter2(Dali::Matrix3 &v, float f) { MatrixSetter(v, f, 2); }
662 void Matrix3Setter3(Dali::Matrix3 &v, float f) { MatrixSetter(v, f, 3); }
663 void Matrix3Setter4(Dali::Matrix3 &v, float f) { MatrixSetter(v, f, 4); }
664 void Matrix3Setter5(Dali::Matrix3 &v, float f) { MatrixSetter(v, f, 5); }
665 void Matrix3Setter6(Dali::Matrix3 &v, float f) { MatrixSetter(v, f, 6); }
666 void Matrix3Setter7(Dali::Matrix3 &v, float f) { MatrixSetter(v, f, 7); }
667 void Matrix3Setter8(Dali::Matrix3 &v, float f) { MatrixSetter(v, f, 8); }
669 val JavascriptUpdateCallback( val::undefined() );
670 bool JavascriptUpdateCallbackSet = false;
672 void JavascriptUpdate(int dt)
674 if( JavascriptUpdateCallbackSet )
676 JavascriptUpdateCallback( val(dt) );
680 void SetUpdateFunction( const emscripten::val& function )
682 JavascriptUpdateCallback = function;
683 JavascriptUpdateCallbackSet = true;
686 const emscripten::val& GetUpdateFunction()
688 return JavascriptUpdateCallback;
692 * Emscripten Bindings
694 * This uses Emscripten 'bind' (similar in design to Boost's python wrapper library).
695 * It provides a simplified way to wrap C++ classes and wraps Emscriptens type
698 * A convention below is that where there is a function or method name prepended
699 * with '__' there is a corresponding Javascript helper function to help with
700 * marshalling parameters and return values.
703 EMSCRIPTEN_BINDINGS(dali_wrapper)
705 // With a little help embind knows about vectors so we tell it which ones to instantiate
706 register_dali_vector<int>("DaliVectorInt");
707 register_vector<std::string>("VectorString");
708 register_vector<int>("VectorInt");
709 register_vector<float>("VectorFloat");
710 register_vector<Dali::Actor>("VectorActor");
713 // Creation functions.
715 emscripten::function("VersionString", &VersionString);
716 emscripten::function("__createActor", &CreateActor);
717 emscripten::function("__createHandle", &CreateHandle);
718 emscripten::function("__createSolidColorActor", &CreateSolidColorActor);
723 emscripten::function("javascriptValue", &JavascriptValue);
724 emscripten::function("__hitTest", &HitTest);
725 emscripten::function("sendMouseEvent", &EmscriptenMouseEvent);
726 emscripten::function("__updateOnce", &EmscriptenUpdateOnce);
727 emscripten::function("__renderOnce", &EmscriptenRenderOnce);
728 emscripten::function("generateControlPoints", &GenerateControlPoints);
731 // Global callback functions
733 emscripten::function("setCallbackGetGlyphImage", &SetCallbackGetGlyphImage);
734 emscripten::function("setCallbackGetImage", &SetCallbackGetImage);
735 emscripten::function("setCallbackGetImageMetadata", &SetCallbackGetImageMetadata);
736 emscripten::function("setCallbackRenderFinished", &SetCallbackRenderFinished);
737 emscripten::function("setUpdateFunction", &SetUpdateFunction);
738 emscripten::function("getUpdateFunction", &GetUpdateFunction);
741 // Property value creation (Javascript can't select on type)
743 emscripten::function("PropertyValueBoolean", &PropertyValueBoolean);
744 emscripten::function("PropertyValueFloat", &PropertyValueFloat);
745 emscripten::function("PropertyValueInteger", &PropertyValueInteger);
746 emscripten::function("PropertyValueString", &PropertyValueString);
747 emscripten::function("PropertyValueVector2", &PropertyValueVector2);
748 emscripten::function("PropertyValueVector3", &PropertyValueVector3);
749 emscripten::function("PropertyValueVector4", &PropertyValueVector4);
750 emscripten::function("PropertyValueMatrix", &PropertyValueMatrix);
751 emscripten::function("PropertyValueMatrix3", &PropertyValueMatrix3);
752 emscripten::function("PropertyValueMap", &PropertyValueContainer);
753 emscripten::function("PropertyValueArray", &PropertyValueContainer);
754 emscripten::function("PropertyValueEuler", &PropertyValueEuler);
755 emscripten::function("PropertyValueAxisAngle", &PropertyValueAxisAngle);
756 emscripten::function("PropertyValueString", &PropertyValueString);
757 emscripten::function("PropertyValueIntRect", &PropertyValueIntRect);
760 // One unfortunate aspect of wrapping for the browser is that we get no notification
761 // of object deletion so all JS wrapper objects must be wrapper.delete() correctly.
763 // Embind has a mechanism around this for simple c style structs decared as value_arrays.
764 // These are immediately transformed to Javascript arrays and don't need explicit
765 // destruction, however the API needs a member offset.
767 value_array<Dali::Internal::Emscripten::Statistics>("Statistics")
768 .element(&Dali::Internal::Emscripten::Statistics::on)
769 .element(&Dali::Internal::Emscripten::Statistics::frameCount)
770 .element(&Dali::Internal::Emscripten::Statistics::lastFrameDeltaSeconds)
771 .element(&Dali::Internal::Emscripten::Statistics::lastSyncTimeMilliseconds)
772 .element(&Dali::Internal::Emscripten::Statistics::nextSyncTimeMilliseconds)
773 .element(&Dali::Internal::Emscripten::Statistics::keepUpdating)
774 .element(&Dali::Internal::Emscripten::Statistics::needsNotification)
775 .element(&Dali::Internal::Emscripten::Statistics::secondsFromLastFrame)
778 value_array<Dali::Vector2>("Vector2")
779 .element(&Dali::Vector2::x)
780 .element(&Dali::Vector2::y)
783 value_array<Dali::Vector3>("Vector3")
784 .element(&Dali::Vector3::x)
785 .element(&Dali::Vector3::y)
786 .element(&Dali::Vector3::z)
789 value_array<Dali::Vector4>("Vector4")
790 .element(&Dali::Vector4::x)
791 .element(&Dali::Vector4::y)
792 .element(&Dali::Vector4::z)
793 .element(&Dali::Vector4::w)
796 value_array<Dali::Matrix>("Matrix")
797 .element(&MatrixGetter0, &MatrixSetter0)
798 .element(&MatrixGetter1, &MatrixSetter1)
799 .element(&MatrixGetter2, &MatrixSetter2)
800 .element(&MatrixGetter3, &MatrixSetter3)
801 .element(&MatrixGetter4, &MatrixSetter4)
802 .element(&MatrixGetter5, &MatrixSetter5)
803 .element(&MatrixGetter6, &MatrixSetter6)
804 .element(&MatrixGetter7, &MatrixSetter7)
805 .element(&MatrixGetter8, &MatrixSetter8)
806 .element(&MatrixGetter9, &MatrixSetter9)
807 .element(&MatrixGetter10, &MatrixSetter10)
808 .element(&MatrixGetter11, &MatrixSetter11)
809 .element(&MatrixGetter12, &MatrixSetter12)
810 .element(&MatrixGetter13, &MatrixSetter13)
811 .element(&MatrixGetter14, &MatrixSetter14)
812 .element(&MatrixGetter15, &MatrixSetter15)
815 value_array<Dali::Matrix3>("Matrix3")
816 .element(&Matrix3Getter0, &Matrix3Setter0)
817 .element(&Matrix3Getter1, &Matrix3Setter1)
818 .element(&Matrix3Getter2, &Matrix3Setter2)
819 .element(&Matrix3Getter3, &Matrix3Setter3)
820 .element(&Matrix3Getter4, &Matrix3Setter4)
821 .element(&Matrix3Getter5, &Matrix3Setter5)
822 .element(&Matrix3Getter6, &Matrix3Setter6)
823 .element(&Matrix3Getter7, &Matrix3Setter7)
824 .element(&Matrix3Getter8, &Matrix3Setter8)
830 enum_<Dali::Property::Type>("PropertyType")
831 .value("NONE", Dali::Property::NONE)
832 .value("BOOLEAN", Dali::Property::BOOLEAN)
833 .value("FLOAT", Dali::Property::FLOAT)
834 .value("INTEGER", Dali::Property::INTEGER)
835 .value("VECTOR2", Dali::Property::VECTOR2)
836 .value("VECTOR3", Dali::Property::VECTOR3)
837 .value("VECTOR4", Dali::Property::VECTOR4)
838 .value("MATRIX3", Dali::Property::MATRIX3)
839 .value("MATRIX", Dali::Property::MATRIX)
840 .value("RECTANGLE", Dali::Property::RECTANGLE)
841 .value("ROTATION", Dali::Property::ROTATION)
842 .value("STRING", Dali::Property::STRING)
843 .value("ARRAY", Dali::Property::ARRAY)
844 .value("MAP", Dali::Property::MAP)
847 enum_<Dali::Shader::Hint::Value>("ShaderHints")
848 .value("NONE", Dali::Shader::Hint::NONE)
849 .value("OUTPUT_IS_TRANSPARENT", Dali::Shader::Hint::OUTPUT_IS_TRANSPARENT)
850 .value("MODIFIES_GEOMETRY", Dali::Shader::Hint::MODIFIES_GEOMETRY)
853 enum_<Dali::Animation::EndAction>("EndAction")
854 .value("Bake", Dali::Animation::Bake)
855 .value("Discard", Dali::Animation::Discard)
856 .value("BakeFinal", Dali::Animation::BakeFinal)
859 enum_<Dali::Animation::Interpolation>("Interpolation")
860 .value("Linear", Dali::Animation::Interpolation::Linear)
861 .value("Cubic", Dali::Animation::Interpolation::Cubic)
864 enum_<Dali::Geometry::Type>("Type")
865 .value("POINTS", Dali::Geometry::POINTS)
866 .value("LINES", Dali::Geometry::LINES)
867 .value("LINE_LOOP", Dali::Geometry::LINE_LOOP)
868 .value("LINE_STRIP", Dali::Geometry::LINE_STRIP)
869 .value("TRIANGLES", Dali::Geometry::TRIANGLES)
870 .value("TRIANGLE_FAN", Dali::Geometry::TRIANGLE_FAN)
871 .value("TRIANGLE_STRIP", Dali::Geometry::TRIANGLE_STRIP)
874 enum_<Dali::Pixel::Format>("PixelFormat")
875 .value("A8", Dali::Pixel::Format::A8)
876 .value("L8", Dali::Pixel::Format::L8)
877 .value("LA88", Dali::Pixel::Format::LA88)
878 .value("RGB565", Dali::Pixel::Format::RGB565)
879 .value("BGR565", Dali::Pixel::Format::BGR565)
880 .value("RGBA4444", Dali::Pixel::Format::RGBA4444)
881 .value("BGRA4444", Dali::Pixel::Format::BGRA4444)
882 .value("RGBA5551", Dali::Pixel::Format::RGBA5551)
883 .value("BGRA5551", Dali::Pixel::Format::BGRA5551)
884 .value("RGB888", Dali::Pixel::Format::RGB888)
885 .value("RGB8888", Dali::Pixel::Format::RGB8888)
886 .value("BGR8888", Dali::Pixel::Format::BGR8888)
887 .value("RGBA8888", Dali::Pixel::Format::RGBA8888)
888 .value("BGRA8888", Dali::Pixel::Format::BGRA8888)
889 // GLES 3 Standard compressed formats:
890 .value("COMPRESSED_R11_EAC", Dali::Pixel::Format::COMPRESSED_R11_EAC)
891 .value("COMPRESSED_SIGNED_R11_EAC", Dali::Pixel::Format::COMPRESSED_SIGNED_R11_EAC)
892 .value("COMPRESSED_RG11_EAC", Dali::Pixel::Format::COMPRESSED_RG11_EAC)
893 .value("COMPRESSED_SIGNED_RG11_EAC", Dali::Pixel::Format::COMPRESSED_SIGNED_RG11_EAC)
894 .value("COMPRESSED_RGB8_ETC2", Dali::Pixel::Format::COMPRESSED_RGB8_ETC2)
895 .value("COMPRESSED_SRGB8_ETC2", Dali::Pixel::Format::COMPRESSED_SRGB8_ETC2)
896 .value("COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", Dali::Pixel::Format::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2)
897 .value("COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", Dali::Pixel::Format::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2)
898 .value("COMPRESSED_RGBA8_ETC2_EAC", Dali::Pixel::Format::COMPRESSED_RGBA8_ETC2_EAC)
899 .value("COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", Dali::Pixel::Format::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC)
900 // GLES 2 extension compressed formats:
901 .value("COMPRESSED_RGB8_ETC1", Dali::Pixel::Format::COMPRESSED_RGB8_ETC1)
902 .value("COMPRESSED_RGB_PVRTC_4BPPV1", Dali::Pixel::Format::COMPRESSED_RGB_PVRTC_4BPPV1)
905 enum_<Dali::FaceCullingMode::Type>("FaceCullingMode")
906 .value("NONE", Dali::FaceCullingMode::NONE)
907 .value("FRONT", Dali::FaceCullingMode::FRONT)
908 .value("BACK", Dali::FaceCullingMode::BACK)
909 .value("FRONT_AND_BACK", Dali::FaceCullingMode::FRONT_AND_BACK)
912 enum_<Dali::DepthWriteMode::Type>("DepthWriteMode")
913 .value("OFF", Dali::DepthWriteMode::OFF)
914 .value("AUTO", Dali::DepthWriteMode::AUTO)
915 .value("ON", Dali::DepthWriteMode::ON)
918 enum_<Dali::BlendMode::Type>("BlendMode")
919 .value("OFF", Dali::BlendMode::OFF)
920 .value("AUTO", Dali::BlendMode::AUTO)
921 .value("ON", Dali::BlendMode::ON)
924 enum_<Dali::AlphaFunction::BuiltinFunction>("AlphaFunction")
925 .value("DEFAULT", Dali::AlphaFunction::BuiltinFunction::DEFAULT)
926 .value("LINEAR", Dali::AlphaFunction::BuiltinFunction::LINEAR)
927 .value("REVERSE", Dali::AlphaFunction::BuiltinFunction::REVERSE)
928 .value("EASE_IN_SQUARE", Dali::AlphaFunction::BuiltinFunction::EASE_IN_SQUARE)
929 .value("EASE_OUT_SQUARE", Dali::AlphaFunction::BuiltinFunction::EASE_OUT_SQUARE)
930 .value("EASE_IN", Dali::AlphaFunction::BuiltinFunction::EASE_IN)
931 .value("EASE_OUT", Dali::AlphaFunction::BuiltinFunction::EASE_OUT)
932 .value("EASE_IN_OUT", Dali::AlphaFunction::BuiltinFunction::EASE_IN_OUT)
933 .value("EASE_IN_SINE", Dali::AlphaFunction::BuiltinFunction::EASE_IN_SINE)
934 .value("EASE_OUT_SINE", Dali::AlphaFunction::BuiltinFunction::EASE_OUT_SINE)
935 .value("EASE_IN_OUT_SINE", Dali::AlphaFunction::BuiltinFunction::EASE_IN_OUT_SINE)
936 .value("BOUNCE", Dali::AlphaFunction::BuiltinFunction::BOUNCE)
937 .value("SIN", Dali::AlphaFunction::BuiltinFunction::SIN)
938 .value("EASE_OUT_BACK", Dali::AlphaFunction::BuiltinFunction::EASE_OUT_BACK)
945 // we need property map as an object rather than straight conversion to javascript 'object'
946 // because its ordered. And PropertyBuffer needs an order.
947 class_<Dali::Property::Map>("PropertyMap")
949 .function("count", &Dali::Property::Map::Count)
950 .function("empty", &Dali::Property::Map::Empty)
951 .function("__insert", select_overload< void(const std::string&, const Dali::Property::Value&) > (&Dali::Property::Map::Insert))
952 .function("__get", &PropertyMapGet)
953 .function("__getValue", &Dali::Property::Map::GetValue)
954 .function("getKey", &Dali::Property::Map::GetKey)
955 .function("clear", &Dali::Property::Map::Clear)
956 .function("merge", &Dali::Property::Map::Merge)
959 class_<Dali::Property::Value>("PropertyValue")
961 .function("getType", &PropertyGetType)
962 .function("getTypeName", &PropertyGetTypeName)
963 .function("getBoolean", &PropertyGetBoolean)
964 .function("getFloat", &PropertyGetFloat)
965 .function("getInteger", &PropertyGetInteger)
966 .function("getVector2", &PropertyGetVector2)
967 .function("getVector3", &PropertyGetVector3)
968 .function("getVector4", &PropertyGetVector4)
969 .function("getString", &PropertyGetString)
970 .function("getMap", &PropertyGetMap)
971 .function("getArray", &PropertyGetArray)
972 .function("getMatrix", &PropertyGetMatrix)
973 .function("getMatrix3", &PropertyGetMatrix3)
974 .function("getEuler", &PropertyGetEuler)
975 .function("getRotation", &PropertyGetRotation)
976 .function("getIntRect", &PropertyGetIntRect)
979 class_<Dali::BaseHandle>("BaseHandle")
980 .function("ok", &BaseHandleOk)
981 .function("getTypeName", &BaseHandle::GetTypeName)
984 class_<Dali::TypeInfo, base<Dali::BaseHandle>>("TypeInfo")
985 .function("getName", &Dali::TypeInfo::GetName)
986 .function("getBaseName", &Dali::TypeInfo::GetBaseName)
987 .function("getProperties", &GetAllProperties)
988 .function("getActions", &GetActions)
989 .function("getSignals", &GetSignals)
990 .function("getPropertyIndices", &Dali::TypeInfo::GetPropertyIndices)
993 class_<Dali::TypeRegistry>("TypeRegistry")
994 .constructor<>(&Dali::TypeRegistry::Get)
995 .function("getTypeNameCount", &Dali::TypeRegistry::GetTypeNameCount)
996 .function("getTypeName", &Dali::TypeRegistry::GetTypeName)
997 .function("getTypeInfo", select_overload< Dali::TypeInfo(const std::string&) > (&Dali::TypeRegistry::GetTypeInfo))
1000 class_<SignalHolder>("SignalHolder")
1004 class_<Dali::Handle, base<Dali::BaseHandle>>("Handle")
1005 .function("__registerProperty", &RegisterProperty)
1006 .function("__registerAnimatedProperty", &RegisterAnimatedProperty)
1007 .function("setSelf", &SetSelf)
1008 .function("setProperty", &SetProperty)
1009 .function("getProperty", &GetProperty)
1010 .function("getPropertyIndex", &GetPropertyIndex)
1011 .function("getProperties", &GetProperties)
1012 .function("getPropertyIndices", &Handle::GetPropertyIndices)
1013 .function("getPropertyTypeFromName", &GetPropertyTypeFromName)
1014 .function("getPropertyTypeName", &GetPropertyTypeName)
1015 .function("registerProperty", &RegisterProperty)
1016 .function("registerAnimatedProperty", &RegisterAnimatedProperty)
1017 .function("getTypeInfo", &GetTypeInfo)
1018 .function("isPropertyWritable", &Handle::IsPropertyWritable)
1019 .function("isPropertyAnimatable", &Handle::IsPropertyAnimatable)
1020 .function("isPropertyAConstraintInput", &Handle::IsPropertyAConstraintInput)
1023 class_<Dali::Path, base<Dali::Handle>>("Path")
1024 .constructor<>(&Dali::Path::New)
1025 .function("addPoint", &Dali::Path::AddPoint)
1026 .function("addControlPoint", &Dali::Path::AddControlPoint)
1027 .function("generateControlPoints", &Dali::Path::GenerateControlPoints)
1028 .function("sample", &Dali::Path::Sample)
1029 .function("getPoint", &Dali::Path::GetPoint)
1030 .function("getControlPoint", &Dali::Path::GetControlPoint)
1031 .function("getPointCount", &Dali::Path::GetPointCount)
1034 class_<Dali::KeyFrames>("KeyFrames")
1035 .constructor<>(&Dali::KeyFrames::New)
1036 .function("add", select_overload<void (float progress, Property::Value value)>(&Dali::KeyFrames::Add))
1037 .function("addWithAlpha", &KeyFramesAddWithAlpha)
1040 class_<Dali::Animation>("Animation")
1041 .constructor<float>(&Dali::Animation::New)
1042 .function("__animateTo", &AnimateTo)
1043 .function("__animateBy", &AnimateBy)
1044 .function("__animateBetween", &AnimateBetween)
1045 .function("__animatePath", &AnimatePath)
1046 .function("setDuration", &Dali::Animation::SetDuration)
1047 .function("getDuration", &Dali::Animation::GetDuration)
1048 .function("setLooping", &Dali::Animation::SetLooping)
1049 .function("isLooping", &Dali::Animation::IsLooping)
1050 .function("setEndAction", &Dali::Animation::SetEndAction)
1051 .function("getEndAction", &Dali::Animation::GetEndAction)
1052 .function("setDisconnectAction", &Dali::Animation::SetDisconnectAction)
1053 .function("getDisconnectAction", &Dali::Animation::GetDisconnectAction)
1054 .function("setCurrentProgress", &Dali::Animation::SetCurrentProgress)
1055 .function("getCurrentProgress", &Dali::Animation::GetCurrentProgress)
1056 .function("setSpeedFactor", &Dali::Animation::SetSpeedFactor)
1057 .function("getSpeedFactor", &Dali::Animation::GetSpeedFactor)
1058 .function("setPlayRange", &Dali::Animation::SetPlayRange)
1059 .function("getPlayRange", &Dali::Animation::GetPlayRange)
1060 .function("play", &Dali::Animation::Play)
1061 .function("playFrom", &Dali::Animation::PlayFrom)
1062 .function("pause", &Dali::Animation::Pause)
1063 .function("stop", &Dali::Animation::Stop)
1064 .function("clear", &Dali::Animation::Clear)
1067 class_<Dali::PropertyBuffer>("PropertyBuffer")
1068 .constructor<Dali::Property::Map&>(Dali::PropertyBuffer::New)
1069 .function("setData", &SetPropertyBufferDataRaw)
1072 class_<Dali::Geometry>("Geometry")
1073 .constructor<>(&Dali::Geometry::New)
1074 .function("addVertexBuffer", &Dali::Geometry::AddVertexBuffer)
1075 .function("getNumberOfVertexBuffers", &Dali::Geometry::GetNumberOfVertexBuffers)
1076 .function("setIndexBuffer", &SetIndexBufferDataRaw)
1077 .function("setType", &Dali::Geometry::SetType)
1078 .function("getType", &Dali::Geometry::GetType)
1081 class_<Dali::Image>("Image")
1084 class_<Dali::BufferImage, base<Dali::Image> >("BufferImage")
1085 .constructor<const std::string&, unsigned int, unsigned int, Dali::Pixel::Format>(&BufferImageNew)
1088 class_<Dali::EncodedBufferImage, base<Dali::Image> >("EncodedBufferImage")
1089 .constructor<const std::string&>(&EncodedBufferImageNew)
1092 class_<Dali::Sampler>("Sampler")
1093 .constructor<>(&Dali::Sampler::New)
1096 class_<Dali::Shader, base<Dali::Handle>>("Shader")
1097 .constructor<>(&Dali::Shader::New)
1100 class_<Dali::TextureSet>("TextureSet")
1101 .constructor<>(&Dali::TextureSet::New)
1102 .function("setTexture", &Dali::TextureSet::SetTexture)
1103 .function("setSampler", &Dali::TextureSet::SetSampler)
1104 .function("getTexture", &Dali::TextureSet::GetTexture)
1105 .function("getSampler", &Dali::TextureSet::GetSampler)
1106 .function("getTextureCount", &Dali::TextureSet::GetTextureCount)
1109 class_<Dali::Renderer, base<Dali::Handle>>("Renderer")
1110 .constructor<>(&Dali::Renderer::New)
1111 .function("setGeometry", &Dali::Renderer::SetGeometry)
1112 .function("getGeometry", &Dali::Renderer::GetGeometry)
1113 .function("SetTextures", &Dali::Renderer::SetTextures)
1114 .function("SetTextures", &Dali::Renderer::SetTextures)
1117 class_<Dali::Actor, base<Dali::Handle>>("Actor")
1118 .constructor<>(&Dali::Actor::New)
1119 .function("add", &Dali::Actor::Add)
1120 .function("remove", &Dali::Actor::Remove)
1121 .function("getId", &Dali::Actor::GetId)
1122 .function("__getParent", &Dali::Actor::GetParent)
1123 .function("__findChildById", &Dali::Actor::FindChildById)
1124 .function("__findChildByName", &Dali::Actor::FindChildByName)
1125 .function("__getChildAt", &Dali::Actor::GetChildAt)
1126 .function("getChildCount", &Dali::Actor::GetChildCount)
1127 .function("__screenToLocal",
1128 select_overload<std::vector<float> (Dali::Actor, float, float)>(&ScreenToLocal))
1129 .function("addressOf", &AddressOf)
1130 .function("__connect", &ConnectSignal)
1131 .function("__setPropertyNotification", &SetPropertyNotification)
1132 .function("addRenderer", &Dali::Actor::AddRenderer)
1133 .function("getRendererCount", &Dali::Actor::GetRendererCount)
1134 .function("removeRenderer",
1135 select_overload<void(unsigned int)>(&Dali::Actor::RemoveRenderer))
1136 .function("__getRendererAt", &Dali::Actor::GetRendererAt)
1139 class_<Dali::CameraActor, base<Dali::Actor>>("CameraActor")
1140 .constructor<>( select_overload<Dali::CameraActor()>(&Dali::CameraActor::New))
1143 class_<Dali::Layer, base<Dali::Actor>>("Layer")
1144 .constructor<>(&Dali::Layer::New)
1145 .function("raise", &Dali::Layer::Raise)
1146 .function("lower", &Dali::Layer::Lower)
1149 class_<Dali::Stage>("Stage")
1150 .constructor<>(&Dali::Stage::GetCurrent)
1151 .function("add", &Dali::Stage::Add)
1152 .function("remove", &Dali::Stage::Remove)
1153 .function("__getRootLayer", &Dali::Stage::GetRootLayer)
1154 .function("getLayer", &Dali::Stage::GetLayer)
1155 .function("getRenderTaskList", &Dali::Stage::GetRenderTaskList)
1156 .function("setBackgroundColor", &Dali::Stage::SetBackgroundColor)
1159 class_<Dali::RenderTaskList>("RenderTaskList")
1160 .function("createTask", &Dali::RenderTaskList::CreateTask)
1161 .function("removeTask", &Dali::RenderTaskList::RemoveTask)
1162 .function("getTaskCount", &Dali::RenderTaskList::GetTaskCount)
1163 .function("getTask", &Dali::RenderTaskList::GetTask)
1166 class_<Dali::RenderTask>("RenderTask")
1167 .function("__getCameraActor", &Dali::RenderTask::GetCameraActor)
1168 .function("setCameraActor", &Dali::RenderTask::SetCameraActor)
1169 .function("setSourceActor", &Dali::RenderTask::SetSourceActor)
1170 .function("setExclusive", &Dali::RenderTask::SetExclusive)
1171 .function("setInputEnabled", &Dali::RenderTask::SetInputEnabled)
1172 .function("setViewportPosition", &Dali::RenderTask::SetViewportPosition)
1173 .function("setViewportSize", &Dali::RenderTask::SetViewportSize)
1174 .function("getCurrentViewportPosition", &Dali::RenderTask::GetCurrentViewportPosition)
1175 .function("getCurrentViewportSize", &Dali::RenderTask::GetCurrentViewportSize)
1176 .function("setClearColor", &Dali::RenderTask::SetClearColor)
1177 .function("getClearColor", &Dali::RenderTask::GetClearColor)
1178 .function("setClearEnabled", &Dali::RenderTask::SetClearEnabled)
1179 .function("getClearEnabled", &Dali::RenderTask::GetClearEnabled)
1180 .function("screenToLocal",
1181 select_overload<Dali::Vector2(Dali::RenderTask, Dali::Actor, float, float)>(&ScreenToLocal))
1182 .function("worldToScreen", &WorldToScreen)
1187 }; // namespace Emscripten
1188 }; // namespace Internal
1189 }; // namespace Dali