1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_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/actors/renderable-actor.h>
23 #include <dali-toolkit/public-api/markup-processor/markup-processor.h>
34 namespace TextViewProcessor
38 * Whether the text is a new paragraph character '\n', a white space or normal text.
40 enum TextSeparatorType
48 * Whether to clear the text of the text-actors when text is removed.
50 enum TextOperationOnRemove
58 * Stores text info indices.
60 struct TextInfoIndices
63 * Default constructor.
65 * Initializes all members to their default values.
72 TextInfoIndices( std::size_t paragraphIndex,
73 std::size_t wordIndex,
74 std::size_t characterIndex );
78 * @param [in] indices The text-info indices to be compared.
80 * @return \e true if both indices are equal.
82 bool operator==( const TextInfoIndices& indices ) const;
84 std::size_t mParagraphIndex; ///< The paragraph index within the text.
85 std::size_t mWordIndex; ///< The word index within the paragraph.
86 std::size_t mCharacterIndex; ///< The character index within the word.
90 * Stores gradient info.
92 * Used to fade in/out text-actors.
97 * Default constructor.
99 * Initializes all members to their default values.
104 * Default destructor.
111 GradientInfo( const GradientInfo& info );
114 * Assignment operator.
116 GradientInfo& operator=( const GradientInfo& info );
118 Vector4 mGradientColor; ///< Gradient color.
119 Vector2 mStartPoint; ///< Gradient start point.
120 Vector2 mEndPoint; ///< Gradient end point.
124 * Layout information for a character.
125 * It stores the position, size and ascender of its respective text-actor.
127 struct CharacterLayoutInfo
130 * Default constructor.
132 * Initializes all members to their default values.
134 CharacterLayoutInfo();
137 * Default destructor.
139 * Deletes the gradient info.
141 ~CharacterLayoutInfo();
146 CharacterLayoutInfo( const CharacterLayoutInfo& character );
149 * Assignment operator.
151 CharacterLayoutInfo& operator=( const CharacterLayoutInfo& character );
153 // Metrics of the glyph.
154 Size mSize; ///< Height of the font and advance (the horizontal distance from the origin of the current character and the next one).
155 float mBearing; ///< Vertical distance from the baseline to the top of the glyph's boundary box.
156 float mAscender; ///< Distance from the base line to the top of the line.
157 float mUnderlineThickness; ///< The underline's thickness.
158 float mUnderlinePosition; ///< The underline's position.
160 // Position and alignment offset. It depends on the lay-out.
161 Vector3 mPosition; ///< Position within the text-view
162 Vector2 mOffset; ///< Alignment and justification offset.
164 RenderableActor mGlyphActor; ///< Handle to a text-actor.
165 MarkupProcessor::StyledText mStyledText; ///< Stores the text and its style.
166 float mColorAlpha; ///< Alpha component for the initial text color when text is faded.
167 GradientInfo* mGradientInfo; ///< Stores gradient info.
169 bool mIsVisible:1; ///< Whether the text-actor is visible.
170 bool mSetText:1; ///< Whether a new text needs to be set in the text-actor.
171 bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor.
172 bool mIsColorGlyph:1; ///< Whether this character is an emoticon.
174 typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;
177 * Layout information for a word.
179 struct WordLayoutInfo
182 * Default constructor.
184 * Initializes all members to their default values.
189 * Default destructor.
191 * Clears all characters.
198 WordLayoutInfo( const WordLayoutInfo& word );
201 * Assignment operator.
203 WordLayoutInfo& operator=( const WordLayoutInfo& word );
205 Size mSize; ///< Size of the word.
206 float mAscender; ///< Max of all ascenders of all characters.
207 TextSeparatorType mType; ///< Whether this word is a word separator, a line separator or is not a separator.
208 CharacterLayoutInfoContainer mCharactersLayoutInfo; ///< Layout info for all characters.
210 typedef std::vector<WordLayoutInfo> WordLayoutInfoContainer;
213 * Layout information for a paragraph.
215 struct ParagraphLayoutInfo
218 * Default constructor.
220 * Initializes all members to their default values.
222 ParagraphLayoutInfo();
225 * Default destructor.
229 ~ParagraphLayoutInfo();
234 ParagraphLayoutInfo( const ParagraphLayoutInfo& paragraph );
237 * Assignment operator.
239 ParagraphLayoutInfo& operator=( const ParagraphLayoutInfo& paragraph );
241 Size mSize; ///< Size of the paragraph.
242 float mAscender; ///< Max of all ascenders of all words.
243 float mLineHeightOffset; ///< Line height offset.
244 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
245 WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words.
247 typedef std::vector<ParagraphLayoutInfo> ParagraphLayoutInfoContainer;
250 * Layout information for the whole text.
252 struct TextLayoutInfo
255 * Default constructor.
257 * Initializes all members to their default values.
264 TextLayoutInfo( const TextLayoutInfo& text );
267 * Assignment operator.
269 TextLayoutInfo& operator=( const TextLayoutInfo& text );
271 Size mWholeTextSize; ///< width and height of the whole text.
272 float mMaxWordWidth; ///< maximum width between all words.
273 float mMaxItalicsOffset; ///< When rendering text-view in offscreen an extra width offset is needed to prevent italic characters to be cut if they are in the right edge.
274 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
275 ParagraphLayoutInfoContainer mParagraphsLayoutInfo; ///< Layout information for all paragraphs.
276 WordLayoutInfo mEllipsizeLayoutInfo; ///< Layout information for the ellipsize text.
279 } // namespace TextViewProcessor
281 } // namespace Internal
283 } // namespace Toolkit
287 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__