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 * Layout information for a character.
91 * It stores the position, size and ascender of its respective text-actor.
93 struct CharacterLayoutInfo
96 * Default constructor.
98 * Initializes all members to their default values.
100 CharacterLayoutInfo();
103 * Default destructor.
105 * Deletes the gradient info.
107 ~CharacterLayoutInfo();
112 CharacterLayoutInfo( const CharacterLayoutInfo& character );
115 * Assignment operator.
117 CharacterLayoutInfo& operator=( const CharacterLayoutInfo& character );
119 // Natural size (metrics) of the glyph.
120 float mHeight; ///< Natural height of the character.
121 float mAdvance; ///< Natural horizontal distance from origin of current character and the next one.
122 float mBearing; ///< Natural vertical distance from the baseline to the top of the glyph's bbox.
124 // Size of the text-actor (may be modified by a scale factor).
125 Vector3 mPosition; ///< Position within the text-view
126 Vector2 mOffset; ///< Alignment and justification offset.
127 Size mSize; ///< Size of this character.
128 float mAscender; ///< Distance from the base line to the top of the line.
129 float mUnderlineThickness; ///< The underline's thickness.
130 float mUnderlinePosition; ///< The underline's position.
132 RenderableActor mGlyphActor; ///< Handle to a text-actor.
133 MarkupProcessor::StyledText mStyledText; ///< Stores the text and its style.
134 float mColorAlpha; ///< Alpha component for the initial text color when text is faded.
135 Vector4 mGradientColor; ///< Gradient color.
136 Vector2 mStartPoint; ///< Gradient start point.
137 Vector2 mEndPoint; ///< Gradient end point.
139 bool mIsVisible:1; ///< Whether the text-actor is visible.
140 bool mSetText:1; ///< Whether a new text needs to be set in the text-actor.
141 bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor.
142 bool mIsColorGlyph:1; ///< Whether this character is an emoticon.
144 typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;
147 * Layout information for a word.
149 struct WordLayoutInfo
152 * Default constructor.
154 * Initializes all members to their default values.
159 * Default destructor.
161 * Clears all characters.
168 WordLayoutInfo( const WordLayoutInfo& word );
171 * Assignment operator.
173 WordLayoutInfo& operator=( const WordLayoutInfo& word );
175 Size mSize; ///< Size of the word.
176 float mAscender; ///< Max of all ascenders of all characters.
177 TextSeparatorType mType; ///< Whether this word is a word separator, a line separator or is not a separator.
178 CharacterLayoutInfoContainer mCharactersLayoutInfo; ///< Layout info for all characters.
180 typedef std::vector<WordLayoutInfo> WordLayoutInfoContainer;
183 * Layout information for a paragraph.
185 struct ParagraphLayoutInfo
188 * Default constructor.
190 * Initializes all members to their default values.
192 ParagraphLayoutInfo();
195 * Default destructor.
197 * Clears all words and deletes all text styles.
199 ~ParagraphLayoutInfo();
204 ParagraphLayoutInfo( const ParagraphLayoutInfo& paragraph );
207 * Assignment operator.
209 ParagraphLayoutInfo& operator=( const ParagraphLayoutInfo& paragraph );
211 Size mSize; ///< Size of the paragraph.
212 float mAscender; ///< Max of all ascenders of all words.
213 float mLineHeightOffset; ///< Line height offset.
214 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
215 WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words.
217 typedef std::vector<ParagraphLayoutInfo> ParagraphLayoutInfoContainer;
220 * Layout information for the whole text.
222 struct TextLayoutInfo
225 * Default constructor.
227 * Initializes all members to their default values.
234 TextLayoutInfo( const TextLayoutInfo& text );
237 * Assignment operator.
239 TextLayoutInfo& operator=( const TextLayoutInfo& text );
241 Size mWholeTextSize; ///< width and height of the whole text.
242 float mMaxWordWidth; ///< maximum width between all words.
243 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.
244 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
245 ParagraphLayoutInfoContainer mParagraphsLayoutInfo; ///< Layout information for all paragraphs.
246 WordLayoutInfo mEllipsizeLayoutInfo; ///< Layout information for the ellipsize text.
249 } // namespace TextViewProcessor
251 } // namespace Internal
253 } // namespace Toolkit
257 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__