1 #ifndef DALI_TOOLKIT_VISUAL_BASE_H
2 #define DALI_TOOLKIT_VISUAL_BASE_H
4 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 #include <dali/public-api/object/base-handle.h>
22 #include <dali/public-api/actors/actor.h>
30 namespace Internal DALI_INTERNAL
41 * @brief Visual provides a renderer for rendering the controls. A control may have multiple visuals.
43 * Visuals reuses geometry, shader etc. across controls and manages the renderer and texture sets to exist only when control is on-stage.
44 * It also responds to actor size and color change, and provides the clipping at the renderer level.
45 * Note: The visual responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
47 class DALI_IMPORT_API Base : public BaseHandle
52 * @brief Create an empty Visual Handle
59 * This is non-virtual since derived Handle types must not contain data or virtual methods.
64 * @brief This copy constructor is required for (smart) pointer semantics.
66 * @param[in] handle A reference to the copied handle.
68 Base( const Base& handle );
71 * @brief This assignment operator is required for (smart) pointer semantics.
73 * @param [in] handle A reference to the copied handle.
74 * @return A reference to this.
76 Base& operator=( const Base& handle );
79 * @brief Set the size of the painting area.
81 * @param[in] size The size of the painting area.
83 void SetSize( const Vector2& size );
86 * @brief Get the size of the painting area.
88 * @return The size of the visual's painting area.
90 const Vector2& GetSize() const;
93 * @brief Returns the height for a given width.
95 * @param[in] width Width to use.
97 * @return The height based on the width.
99 float GetHeightForWidth( float width ) const;
102 * @brief Return the natural size of the visual.
104 * Deriving classes stipulate the natural size and by default a visual has a ZERO natural size.
106 * @param[out] naturalSize The visual's natural size
108 void GetNaturalSize( Vector2& naturalSize ) const;
111 * @brief Set the depth index of this visual.
113 * Depth-index controls draw-order for overlapping visuals.
114 * Visuals with higher depth indices are rendered in front of other visual with smaller values
116 * @param[in] index The depth index of this visual.
118 void SetDepthIndex( float index );
121 * @brief Get the depth index of this visual
123 * @return The depth index of this visual.
125 float GetDepthIndex() const;
128 * @brief Visual needs to know when the control is put on to the stage to add the renderer.
130 * This function should be called when the control is put on to the stage.
132 * @param[in] actor The actor using this visual.
133 * @post SetOffStage should be called with the same actor when the control is put off stage otherwise memory will be leaked
135 void SetOnStage( Actor& actor );
138 * @brief Visual needs to know when the control is removed from the stage to remove the renderer.
140 * This function should be called when the control is removed from the stage
142 * @param[in] actor The actor using this visual.
144 void SetOffStage( Actor& actor );
147 * @brief Remove the renderer from the actor and reset the visual self.
149 * This function can be called with an empty handle. If the visual is empty, this is a no-op.
151 * @param[in] actor The actor to be set off stage.
153 void RemoveAndReset( Actor& actor );
156 * @brief Create the property map representing this visual.
158 * @param[out] map The visual property map.
160 void CreatePropertyMap( Dali::Property::Map& map ) const;
163 * @brief Sets the value of an existing property.
165 * @param [in] index The index of the property.
166 * @param [in] propertyValue The new value of the property.
168 void SetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
171 * @brief Retrieves a property value.
173 * @param [in] index The index of the property.
175 * @return The property value.
177 Dali::Property::Value GetProperty( Dali::Property::Index index );
179 public: // Not intended for application developers
181 explicit DALI_INTERNAL Base(Internal::Visual::Base *impl);
185 } // namespace Visual
187 } // namespace Toolkit
191 #endif /*DALI_TOOLKIT_VISUAL_BASE_H*/