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/public-api/text/text.h>
36 namespace TextProcessor
38 // Forward declarations.
39 struct BidirectionalParagraphInfo;
40 struct BidirectionalLineInfo;
41 } // namespace TextProcessor
43 namespace TextViewProcessor
47 * Whether the text is a new paragraph character '\n', a white space or normal text.
49 enum TextSeparatorType
57 * Whether to clear the text of the text-actors when text is removed.
59 enum TextOperationOnRemove
67 * Stores text info indices.
69 struct TextInfoIndices
72 * Default constructor.
74 * Initializes all members to their default values.
81 TextInfoIndices( std::size_t paragraphIndex,
82 std::size_t wordIndex,
83 std::size_t characterIndex );
87 * @param [in] indices The text-info indices to be compared.
89 * @return \e true if both indices are equal.
91 bool operator==( const TextInfoIndices& indices ) const;
93 std::size_t mParagraphIndex; ///< The paragraph index within the text.
94 std::size_t mWordIndex; ///< The word index within the paragraph.
95 std::size_t mCharacterIndex; ///< The character index within the word.
96 std::size_t mCharacterParagraphIndex; ///< The character index within the paragraph.
100 * Stores gradient info.
102 * Used to fade in/out text-actors.
107 * Default constructor.
109 * Initializes all members to their default values.
114 * Default destructor.
121 GradientInfo( const GradientInfo& info );
124 * Assignment operator.
126 GradientInfo& operator=( const GradientInfo& info );
128 Vector4 mGradientColor; ///< Gradient color.
129 Vector2 mStartPoint; ///< Gradient start point.
130 Vector2 mEndPoint; ///< Gradient end point.
134 * Layout information for a character.
135 * It stores the position, size and ascender of its respective text-actor.
137 struct CharacterLayoutInfo
140 * Default constructor.
142 * Initializes all members to their default values.
144 CharacterLayoutInfo();
147 * Default destructor.
149 * Deletes the gradient info.
151 ~CharacterLayoutInfo();
156 CharacterLayoutInfo( const CharacterLayoutInfo& character );
159 * Assignment operator.
161 CharacterLayoutInfo& operator=( const CharacterLayoutInfo& character );
163 // Metrics of the glyph.
164 Size mSize; ///< Height of the font and advance (the horizontal distance from the origin of the current character and the next one).
165 float mBearing; ///< Vertical distance from the baseline to the top of the glyph's boundary box.
166 float mAscender; ///< Distance from the base line to the top of the line.
167 float mUnderlineThickness; ///< The underline's thickness.
168 float mUnderlinePosition; ///< The underline's position.
170 // Position and alignment offset. It depends on the lay-out.
171 Vector3 mPosition; ///< Position within the text-view
172 Vector2 mOffset; ///< Alignment and justification offset.
174 RenderableActor mGlyphActor; ///< Handle to a text-actor.
175 float mColorAlpha; ///< Alpha component for the initial text color when text is faded.
176 GradientInfo* mGradientInfo; ///< Stores gradient info.
178 bool mIsVisible:1; ///< Whether the text-actor is visible.
179 bool mSetText:1; ///< Whether a new text needs to be set in the text-actor.
180 bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor.
181 bool mIsColorGlyph:1; ///< Whether this character is an emoticon.
183 typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;
186 * Layout information for a word.
188 struct WordLayoutInfo
191 * Default constructor.
193 * Initializes all members to their default values.
198 * Default destructor.
200 * Clears all characters.
207 WordLayoutInfo( const WordLayoutInfo& word );
210 * Assignment operator.
212 WordLayoutInfo& operator=( const WordLayoutInfo& word );
214 Size mSize; ///< Size of the word.
215 float mAscender; ///< Max of all ascenders of all characters.
216 TextSeparatorType mType; ///< Whether this word is a word separator, a line separator or is not a separator.
217 std::size_t mFirstCharacter; ///< Index to the first character of the word within the paragraph.
218 CharacterLayoutInfoContainer mCharactersLayoutInfo; ///< Layout info for all characters.
220 typedef std::vector<WordLayoutInfo> WordLayoutInfoContainer;
223 * Stores the reordered layout for right to left text.
225 struct RightToLeftParagraphLayout
227 RightToLeftParagraphLayout()
228 : mWordsLayoutInfo(),
231 mPreviousLayoutCleared( false )
235 WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words.
236 Text mText; ///< Stores the text.
237 Vector<TextStyle*> mTextStyles; ///< Stores the style per each character.
238 bool mPreviousLayoutCleared:1; ///< Whether the previous right to left layout has been cleared.
241 * Clears the word layout vector, the text and the vector of styles.
247 * Layout information for a paragraph.
249 struct ParagraphLayoutInfo
252 * Default constructor.
254 * Initializes all members to their default values.
256 ParagraphLayoutInfo();
259 * Default destructor.
261 * Clears all words, deletes all text styles, the paragraph bidirectional info and all bidirectional infor for each line.
263 ~ParagraphLayoutInfo();
268 ParagraphLayoutInfo( const ParagraphLayoutInfo& paragraph );
271 * Assignment operator.
273 ParagraphLayoutInfo& operator=( const ParagraphLayoutInfo& paragraph );
276 * Deletes the bidirectional info for each line.
278 void ClearBidirectionalInfo();
283 * Deletes all text styles.
288 Size mSize; ///< Size of the paragraph.
289 float mAscender; ///< Max of all ascenders of all words.
290 float mLineHeightOffset; ///< Line height offset.
291 std::size_t mFirstCharacter; ///< Index to the first character of the paragraph.
292 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
293 WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words.
294 Text mText; ///< Stores the text.
295 Vector<TextStyle*> mTextStyles; ///< Stores the style per each character.
296 RightToLeftParagraphLayout* mRightToLeftLayout; ///< Stores the reordered layout for the paragraph.
297 TextProcessor::BidirectionalParagraphInfo* mBidirectionalParagraphInfo; ///< Contains bidirectional info for the whole paragraph. Set to NULL if the paragraph has left to right characters only.
298 Vector<TextProcessor::BidirectionalLineInfo*> mBidirectionalLinesInfo; ///< Contains bidirectional info for each laid-out line.
300 typedef std::vector<ParagraphLayoutInfo> ParagraphLayoutInfoContainer;
303 * Layout information for the whole text.
305 struct TextLayoutInfo
308 * Default constructor.
310 * Initializes all members to their default values.
315 * Defualt destructor.
317 * Clears the paragraph vector, the ellipsis text and deletes all ellipsis styles.
324 TextLayoutInfo( const TextLayoutInfo& text );
327 * Assignment operator.
329 TextLayoutInfo& operator=( const TextLayoutInfo& text );
333 * Deletes all the ellipsis text styles.
338 Size mWholeTextSize; ///< width and height of the whole text.
339 float mMaxWordWidth; ///< maximum width between all words.
340 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.
341 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
342 ParagraphLayoutInfoContainer mParagraphsLayoutInfo; ///< Layout information for all paragraphs.
343 WordLayoutInfo mEllipsizeLayoutInfo; ///< Layout information for the ellipsize text.
344 Dali::Text mEllipsisText; ///< The ellipsis text.
345 Vector<TextStyle*> mEllipsisTextStyles; ///< Stores the style per each character of the ellipsis text.
348 } // namespace TextViewProcessor
350 } // namespace Internal
352 } // namespace Toolkit
356 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__