A layer acts like a transparent sheet upon which shapes can be placed, sub-layers within layers to any desired depth are supported. Layers provide a mechanism for overlaying groups of views on top of each other.
Layers can also clip their contents to exclude any content outside a user defined area.
Layers can be 2D or 3D, defined by their behaviour property.
When a layer is added to the stage, it is assigned a unique depth value. By default the stage has a root layer with a depth value of 0.
Layers are actors and inherit the position, orientation and scale of their parent actor.
Layers are drawn in an order determined by a layer depth value.
Layers work independently of the Actor hierarchy.
Layers can be positioned anywhere in the actor tree. The layer draw order is always defined by the depth value.
// C++ example of adding a actor to the root layer // using stage.add() will automatically add actor to the root layer Stage stage = Stage::GetCurrent(); stage.add( myActor ); // Or you can explicitly add an actor to the root layer. Layer rootLayer = stage.GetRootLayer(); rootLayer.add( myActor ); // adds an actor to the root layer
Layer::Property::BEHAVIOR: which can be
Clips the contents of the layer to a rectangle.
A range of functions are provided to change the draw order of the layers.
Dali::Layer::LAYER_UI, the draw order of the renderers is defined by both:
Set Layer behavior to
Opaque renderers are drawn first and written to the depth buffer.
Transparent renderers are drawn in order of distance from the camera ( painter’s algorithm ).
Inside a layer, it is possible to force tree views to be drawn on top of everything else in the layer.