1 #ifndef DALI_INTERNAL_LAYER_LIST_H
2 #define DALI_INTERNAL_LAYER_LIST_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <cstdint> // uint32_t
25 #include <dali/public-api/common/vector-wrapper.h>
39 * An ordered list of layers.
40 * Layers are not owned by the LayerList; each layer is responsible for registering & unregistering.
41 * This is used by the Stage, to keep track of layer depths.
47 * Create a new list of layers.
48 * @param[in] updateManager A reference to the update manager.
50 static LayerList* New(SceneGraph::UpdateManager& updateManager);
53 * Non-virtual destructor; not suitable as a base class.
58 * Query the number of layers.
59 * @return The number of layers.
61 uint32_t GetLayerCount() const;
64 * Retrieve the layer at a specified depth.
65 * @pre depth is less than layer count; see GetLayerCount().
66 * @param[in] depth The depth.
67 * @return The layer found at the given depth.
69 Layer* GetLayer(uint32_t depth) const;
72 * Gets the depth of a given layer
73 * @param layer which depth to check
75 uint32_t GetDepth(const Layer* layer) const;
78 * Register a layer with the stage.
79 * The stage determines the relative depth of each layer.
81 void RegisterLayer(Layer& layer);
84 * Unregister a layer from the stage
86 void UnregisterLayer(Layer& layer);
89 * Increment the depth of the layer inside the stage
90 * @pre layer is on stage
92 void RaiseLayer(Layer& layer);
95 * Decrement the depth of the layer inside the stage
96 * @pre layer is on stage
98 void LowerLayer(Layer& layer);
101 * Raises the layer to the top of the stage
102 * @pre layer is on stage
103 * @param layer to move
105 void RaiseLayerToTop(const Layer& layer);
108 * Lowers the layer to the bottom of the stage
109 * @pre layer is on stage
110 * @param layer to move
112 void LowerLayerToBottom(const Layer& layer);
115 * Moves the layer above the target layer on the stage
116 * @pre layer is on stage
117 * @pre target is on stage
118 * @param layer to move
119 * @param target to move above of
121 void MoveLayerAbove(const Layer& layer, const Layer& target);
124 * Moves the layer below the target layer on the stage
125 * @pre layer is on stage
126 * @pre target is on stage
127 * @param layer to move
128 * @param target to move below of
130 void MoveLayerBelow(const Layer& layer, const Layer& target);
133 * Sets the root layer that this layer list belongs to
134 * @pre the root layer is created
135 * @param rootLayer The root layer
137 void SetRootLayer(Layer* rootLayer);
141 * Protected constructor; see also LayerList::New().
142 * @param[in] updateManager to send messages.
144 LayerList(SceneGraph::UpdateManager& updateManager);
147 * A private helper method to set the depth for each layer.
148 * Layers have depth which is the same as their ordinal number in the stage container
149 * This method propagates any changes in the layer depths onto the scene graph side
151 void SetLayerDepths();
154 SceneGraph::UpdateManager& mUpdateManager;
156 Layer* mRoot; ///< The root layer that this ordered list of layers belong to
158 using LayerContainer = std::vector<Layer*>;
160 // Layers are not owned by the LayerList.
161 // Each layer is responsible for registering & unregistering before the end of its life-time.
162 LayerContainer mLayers;
165 } // namespace Internal
169 #endif // DALI_INTERNAL_LAYER_LIST_H