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.
182 bool mIsRightToLeft:1; ///< Whether this character is right to left.
184 typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;
187 * Layout information for a word.
189 struct WordLayoutInfo
192 * Default constructor.
194 * Initializes all members to their default values.
199 * Default destructor.
201 * Clears all characters.
208 WordLayoutInfo( const WordLayoutInfo& word );
211 * Assignment operator.
213 WordLayoutInfo& operator=( const WordLayoutInfo& word );
215 Size mSize; ///< Size of the word.
216 float mAscender; ///< Max of all ascenders of all characters.
217 TextSeparatorType mType; ///< Whether this word is a word separator, a line separator or is not a separator.
218 std::size_t mFirstCharacter; ///< Index to the first character of the word within the paragraph.
219 CharacterLayoutInfoContainer mCharactersLayoutInfo; ///< Layout info for all characters.
221 typedef std::vector<WordLayoutInfo> WordLayoutInfoContainer;
224 * Stores the reordered layout for right to left text.
226 struct RightToLeftParagraphLayout
228 RightToLeftParagraphLayout()
229 : mWordsLayoutInfo(),
232 mPreviousLayoutCleared( false )
236 WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words.
237 Text mText; ///< Stores the text.
238 Vector<TextStyle*> mTextStyles; ///< Stores the style per each character.
239 bool mPreviousLayoutCleared:1; ///< Whether the previous right to left layout has been cleared.
242 * Clears the word layout vector, the text and the vector of styles.
248 * Layout information for a paragraph.
250 struct ParagraphLayoutInfo
253 * Default constructor.
255 * Initializes all members to their default values.
257 ParagraphLayoutInfo();
260 * Default destructor.
262 * Clears all words, deletes all text styles, the paragraph bidirectional info and all bidirectional infor for each line.
264 ~ParagraphLayoutInfo();
269 ParagraphLayoutInfo( const ParagraphLayoutInfo& paragraph );
272 * Assignment operator.
274 ParagraphLayoutInfo& operator=( const ParagraphLayoutInfo& paragraph );
277 * Deletes the bidirectional info for each line.
279 void ClearBidirectionalInfo();
284 * Deletes all text styles.
289 Size mSize; ///< Size of the paragraph.
290 float mAscender; ///< Max of all ascenders of all words.
291 float mLineHeightOffset; ///< Line height offset.
292 std::size_t mFirstCharacter; ///< Index to the first character of the paragraph.
293 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
294 WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words.
295 Text mText; ///< Stores the text.
296 Vector<TextStyle*> mTextStyles; ///< Stores the style per each character.
297 RightToLeftParagraphLayout* mRightToLeftLayout; ///< Stores the reordered layout for the paragraph.
298 TextProcessor::BidirectionalParagraphInfo* mBidirectionalParagraphInfo; ///< Contains bidirectional info for the whole paragraph. Set to NULL if the paragraph has left to right characters only.
299 Vector<TextProcessor::BidirectionalLineInfo*> mBidirectionalLinesInfo; ///< Contains bidirectional info for each laid-out line.
301 typedef std::vector<ParagraphLayoutInfo> ParagraphLayoutInfoContainer;
304 * Layout information for the whole text.
306 struct TextLayoutInfo
309 * Default constructor.
311 * Initializes all members to their default values.
316 * Defualt destructor.
318 * Clears the paragraph vector, the ellipsis text and deletes all ellipsis styles.
325 TextLayoutInfo( const TextLayoutInfo& text );
328 * Assignment operator.
330 TextLayoutInfo& operator=( const TextLayoutInfo& text );
334 * Deletes all the ellipsis text styles.
339 Size mWholeTextSize; ///< width and height of the whole text.
340 float mMaxWordWidth; ///< maximum width between all words.
341 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.
342 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
343 ParagraphLayoutInfoContainer mParagraphsLayoutInfo; ///< Layout information for all paragraphs.
344 WordLayoutInfo mEllipsizeLayoutInfo; ///< Layout information for the ellipsize text.
345 Dali::Text mEllipsisText; ///< The ellipsis text.
346 Vector<TextStyle*> mEllipsisTextStyles; ///< Stores the style per each character of the ellipsis text.
349 } // namespace TextViewProcessor
351 } // namespace Internal
353 } // namespace Toolkit
357 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__