1 #ifndef __DALI_TOOLKIT_INTERNAL_GRADIENT_RENDERER_H__
2 #define __DALI_TOOLKIT_INTERNAL_GRADIENT_RENDERER_H__
5 * Copyright (c) 2015 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 <dali-toolkit/internal/controls/renderers/control-renderer-impl.h>
23 #include <dali-toolkit/internal/controls/renderers/gradient/gradient.h>
38 * The renderer which renders smooth transition of colors to the control's quad.
39 * It supports two types of gradients: linear and radial.
41 * The following properties are essential for create a LINEAR GradientRender
43 * | %Property Name | Type |
44 * |-------------------------|------------------|
45 * | startPosition | VECTOR2 |
46 * | endPosition | VECTOR2 |
47 * | stopColor | ARRAY of VECTOR4 |
49 * The following properties are essential for create a RADIAL GradientRender
51 * | %Property Name | Type |
52 * |-------------------------|------------------|
53 * | center | VECTOR2 |
55 * | stopColor | ARRAY of VECTOR4 |
57 * The following properties are optional for both LINEAR and RADIAL GradientRender.
59 * | %Property Name | Type |
60 * |-------------------------|------------------|
61 * | stopOffset | ARRAY of FLOAT |
63 * | spreadMethod | STRING |
65 * Valid values for units are 'userSpace' and 'objectBoundingBox'.
66 * Valid values for spreadMethod are 'pad', 'repeat' and 'reflect.'
67 * If not provided, 'objectBoundingBox' is used as default gradient units, and 'pad' is used as default spread method.
69 class GradientRenderer: public ControlRenderer
74 * Types of the gradient
85 * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
87 GradientRenderer( RendererFactoryCache& factoryCache );
90 * @brief A reference counted object may only be deleted by calling Unreference().
94 public: // from ControlRenderer
97 * @copydoc ControlRenderer::SetSize
99 virtual void SetSize( const Vector2& size );
102 * @copydoc ControlRenderer::SetClipRect
104 virtual void SetClipRect( const Rect<int>& clipRect );
107 * @copydoc ControlRenderer::SetOffset
109 virtual void SetOffset( const Vector2& offset );
112 * @copydoc ControlRenderer::CreatePropertyMap
114 virtual void DoCreatePropertyMap( Property::Map& map ) const;
118 * @copydoc ControlRenderer::DoInitialize
120 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
123 * @copydoc ControlRenderer::DoSetOnStage
125 virtual void DoSetOnStage( Actor& actor );
130 * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
132 void InitializeRenderer();
135 * New a gradient object with the given property map.
137 * @return True if the property map provides valid properties to create a gradient. Otherwise, returns false.
139 bool NewGradient(Type gradientType, const Property::Map& propertyMap);
142 * Get the stop-offsets from the property.
143 * The valid property type are ARRAY, VECTOR2, VECTOR3, VECTOR4.
145 * @param[in] value The property value of stop-offsets
146 * @param[out] stopOffsets The vector contains the stop offset values.
148 static void GetStopOffsets(const Property::Value* value, Vector<float>& stopOffsets);
151 GradientRenderer( const GradientRenderer& gradientRenderer );
154 GradientRenderer& operator=( const GradientRenderer& gradientRenderer );
158 Matrix3 mGradientTransform;
159 IntrusivePtr<Gradient> mGradient;
163 } // namespace Internal
165 } // namespace Toolkit
169 #endif /* __DALI_TOOLKIT_INTERNAL_GRADIENT_RENDERER_H__ */