1 #ifndef __INTERNAL_TEXT_PARAMETERS_H__
2 #define __INTERNAL_TEXT_PARAMETERS_H__
5 * Copyright (c) 2014 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/public-api/math/vector2.h>
23 #include <dali/public-api/math/vector4.h>
24 #include <dali/public-api/common/dali-vector.h>
33 // Number of bits for an index mask - increase if more attributes are added...
34 const unsigned int TEXT_PARAMETER_BITS = 2u;
36 // Set mask for this number of bits
37 const unsigned int TEXT_PARAMETER_MASK = ~( -1 << TEXT_PARAMETER_BITS );
39 // Shift values for attribute indices
40 const unsigned int OUTLINE_INDEX_SHIFT = 0u;
41 const unsigned int GLOW_INDEX_SHIFT = OUTLINE_INDEX_SHIFT + TEXT_PARAMETER_BITS;
42 const unsigned int DROP_SHADOW_INDEX_SHIFT = GLOW_INDEX_SHIFT + TEXT_PARAMETER_BITS;
43 const unsigned int GRADIENT_INDEX_SHIFT = DROP_SHADOW_INDEX_SHIFT + TEXT_PARAMETER_BITS;
44 const unsigned int TEXT_PARAMETER_FLAGS = GRADIENT_INDEX_SHIFT + TEXT_PARAMETER_BITS;
46 // Position in flags for attribute index
47 const unsigned int OUTLINE_INDEX = 0u; // bits 0,1
48 const unsigned int GLOW_INDEX = TEXT_PARAMETER_MASK << GLOW_INDEX_SHIFT; // bits 2,3
49 const unsigned int DROP_SHADOW_INDEX = TEXT_PARAMETER_MASK << DROP_SHADOW_INDEX_SHIFT; // bits 4,5
50 const unsigned int GRADIENT_INDEX = TEXT_PARAMETER_MASK << GRADIENT_INDEX_SHIFT; // bits 6,7
52 // Flag positions for attributes ( gradient has two as parameters can be set independently )
53 const unsigned int OUTLINE_EXISTS = 1u << TEXT_PARAMETER_FLAGS; // bit 8
54 const unsigned int OUTLINE_ENABLED = 1u << ( TEXT_PARAMETER_FLAGS + 1u ); // bit 9
55 const unsigned int GLOW_EXISTS = 1u << ( TEXT_PARAMETER_FLAGS + 2u ); // bit 10
56 const unsigned int GLOW_ENABLED = 1u << ( TEXT_PARAMETER_FLAGS + 3u ); // bit 11
57 const unsigned int DROP_SHADOW_EXISTS = 1u << ( TEXT_PARAMETER_FLAGS + 4u ); // bit 12
58 const unsigned int DROP_SHADOW_ENABLED = 1u << ( TEXT_PARAMETER_FLAGS + 5u ); // bit 13
59 const unsigned int GRADIENT_EXISTS = 1u << ( TEXT_PARAMETER_FLAGS + 6u ); // bit 14
60 const unsigned int GRADIENT_ENABLED = 1u << ( TEXT_PARAMETER_FLAGS + 7u ); // bit 15
61 const unsigned int ATTRIBUTE_END = GRADIENT_ENABLED;
64 * class TextParameters internal class to encapsulate (and allow on demand allocation) of
65 * text effect parameters like, outline, glow and shadow
72 * @brief Outline attributes
74 struct OutlineAttributes
76 Vector4 mOutlineColor;
77 Vector2 mOutlineThickness;
81 * @brief Glow attributes
90 * @brief Drop Shadow attributes
92 struct DropShadowAttributes
94 Vector4 mDropShadowColor;
95 Vector2 mDropShadowOffset;
96 float mDropShadowSize;
100 * @brief Gradient attributes
102 struct GradientAttributes
104 Vector4 mGradientColor;
105 Vector2 mGradientStartPoint;
106 Vector2 mGradientEndPoint;
119 /// @copydoc Dali::TextActor::SetOutline
120 void SetOutline( bool enable, const Vector4& color, const Vector2& thickness );
122 /// @copydoc Dali::TextActor::SetGlow
123 void SetGlow( bool enable, const Vector4& color, float intensity );
125 /// @copydoc Dali::TextActor::SetShadow
126 void SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size );
129 * @brief Set Gradient parameters.
130 * @param[in] color The gradient color (end-point color)
131 * @param[in] start The relative position of the gradient start point.
132 * @param[in] end The relative position of the gradient end point.
134 void SetGradient( const Vector4& color, const Vector2& start, const Vector2& end );
137 * @brief Get the Gradient Color
139 * @return Gradient Color
141 const Vector4& GetOutlineColor() const;
144 * @brief Get Outline Thickness
146 * @return Outline Thickness
148 const Vector2& GetOutlineThickness() const;
151 * @brief Get Glow Color
155 const Vector4& GetGlowColor() const;
158 * @brief Get Glow Intensity
160 * @return Glow Intensity
162 float GetGlowIntensity() const;
165 * @brief Get Drop Shadow Color
167 * @return Drop Shadow Color
169 const Vector4& GetDropShadowColor() const;
172 * @brief Get Drop Shadow Offset
174 * @return Drop Shadow Offset
176 const Vector2& GetDropShadowOffset() const;
179 * @brief Get Drop Shadow Size
181 * @return Drop Shadow Size
183 float GetDropShadowSize() const;
186 * @brief Get Gradient Color
188 * @return Gradient Color
190 const Vector4& GetGradientColor() const;
193 * @brief Get Gradient Start Point
195 * @return Position of Gradient Start Point
197 const Vector2& GetGradientStartPoint() const;
200 * @brief Get Gradient End Point
202 * @return Position of Gradient End Point
204 const Vector2& GetGradientEndPoint() const;
207 * @brief Get if Outline is enabled
209 * @return true if enabled, false if not
211 bool IsOutlineEnabled() const
213 return ( ( mFlags & OUTLINE_ENABLED ) != 0 );
217 * @brief Get if Glow is enabled
219 * @return true if enabled, false if not
221 bool IsGlowEnabled() const
223 return ( ( mFlags & GLOW_ENABLED ) != 0 );
227 * @brief Get if Drop Shadow is enabled
229 * @return true if enabled, false if not
231 bool IsDropShadowEnabled() const
233 return ( ( mFlags & DROP_SHADOW_ENABLED ) != 0 );
237 * @brief Get if Gradient is enabled
239 * @return true if enabled, false if not
241 bool IsGradientEnabled() const
243 return ( ( mFlags & GRADIENT_ENABLED ) != 0 );
246 private: // unimplemented copy constructor and assignment operator
247 TextParameters( const TextParameters& copy );
248 TextParameters& operator=(const TextParameters& rhs);
250 Vector<char*> mParameters; // container for any used attributes
252 #if ( ATTRIBUTE_END > 0x8000 )
253 unsigned int mFlags; // flags for used attributes, packed with position in container
255 unsigned short mFlags; // might be rendered irrelevant by alignment / packing
258 }; // class TextParameters
260 } // namespace Internal
264 #endif // __INTERNAL_TEXT_PARAMETERS_H__