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 Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/dali.h>
22 #include <dali-toolkit/public-api/markup-processor/markup-processor.h>
33 namespace TextViewProcessor
37 * Whether the direction is Right To Left or Left To Right.
41 LTR, ///< Left To Right direction.
42 RTL ///< Right To Left direction.
46 * Whether the text is a new line character, a white space or normal text.
48 enum TextSeparatorType
56 * Whether to clear the text of the text-actors when text is removed.
58 enum TextOperationOnRemove
66 * Stores text info indices.
68 struct TextInfoIndices
71 * Default constructor.
78 TextInfoIndices( std::size_t lineIndex,
79 std::size_t groupIndex,
80 std::size_t wordIndex,
81 std::size_t characterIndex );
85 * @param [in] indices The text-info indices to be compared.
87 * @return \e true if both indices are equal.
89 bool operator==( const TextInfoIndices& indices ) const;
91 std::size_t mLineIndex;
92 std::size_t mGroupIndex;
93 std::size_t mWordIndex;
94 std::size_t mCharacterIndex;
98 * Layout information for a character.
99 * It stores the position, size and ascender of its respective text-actor.
101 struct CharacterLayoutInfo
104 * Default constructor.
106 * Initializes all members to their default values.
108 CharacterLayoutInfo();
113 CharacterLayoutInfo( const CharacterLayoutInfo& character );
116 * Assignment operator.
118 CharacterLayoutInfo& operator=( const CharacterLayoutInfo& character );
120 // Natural size (metrics) of the glyph.
121 float mHeight; ///< Natural height of the character.
122 float mAdvance; ///< Natural horizontal distance from origin of current character and the next one.
123 float mBearing; ///< Natural vertical distance from the baseline to the top of the glyph's bbox.
125 // Size of the text-actor (may be modified by a scale factor).
126 Vector3 mPosition; ///< Position within the text-view
127 Vector2 mOffset; ///< Alignment and justification offset.
128 Size mSize; ///< Size of this character.
129 float mAscender; ///< Distance from the base line to the top of the line.
130 float mUnderlineThickness; ///< The underline's thickness.
131 float mUnderlinePosition; ///< The underline's position.
133 RenderableActor mGlyphActor; ///< Handle to a text-actor.
134 MarkupProcessor::StyledText mStyledText; ///< Stores the text and its style.
135 float mColorAlpha; ///< Alpha component for the initial text color when text is faded.
136 Vector4 mGradientColor; ///< Gradient color.
137 Vector2 mStartPoint; ///< Gradient start point.
138 Vector2 mEndPoint; ///< Gradient end point.
140 bool mIsVisible:1; ///< Whether the text-actor is visible.
141 bool mSetText:1; ///< Whether a new text needs to be set in the text-actor.
142 bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor.
143 bool mIsColorGlyph:1; ///< Whether this character is an emoticon.
145 typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;
148 * Layout information for a word.
150 struct WordLayoutInfo
153 * Default constructor.
155 * Initializes all members to their default values.
162 WordLayoutInfo( const WordLayoutInfo& word );
165 * Assignment operator.
167 WordLayoutInfo& operator=( const WordLayoutInfo& word );
169 Size mSize; ///< Size of the word.
170 float mAscender; ///< Max of all ascenders of all characters.
171 TextSeparatorType mType; ///< Whether this word is a word separator, a line separator or is not a separator.
172 CharacterLayoutInfoContainer mCharactersLayoutInfo; ///< Layout info for all characters.
174 typedef std::vector<WordLayoutInfo> WordLayoutInfoContainer;
177 * Layout information for a group of words.
179 struct WordGroupLayoutInfo
182 * Default constructor.
184 * Initializes all members to their default values.
186 WordGroupLayoutInfo();
191 WordGroupLayoutInfo( const WordGroupLayoutInfo& group );
194 * Assignment operator.
196 WordGroupLayoutInfo& operator=( const WordGroupLayoutInfo& group );
198 Size mSize; ///< Size of the group of words.
199 float mAscender; ///< Max of all ascenders of all words.
200 Direction mDirection; ///< Whether this group of words is Right To Left or Left To Right.
201 WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words.
202 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
204 typedef std::vector<WordGroupLayoutInfo> WordGroupLayoutInfoContainer;
207 * Layout information for a line.
209 struct LineLayoutInfo
212 * Default constructor.
214 * Initializes all members to their default values.
221 LineLayoutInfo( const LineLayoutInfo& line );
224 * Assignment operator.
226 LineLayoutInfo& operator=( const LineLayoutInfo& line );
228 Size mSize; ///< Size of the line.
229 float mAscender; ///< Max of all ascenders of all groups of words.
230 float mLineHeightOffset; ///< Line height offset.
231 WordGroupLayoutInfoContainer mWordGroupsLayoutInfo; ///< Layout info for all groups of words.
232 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
234 typedef std::vector<LineLayoutInfo> LineLayoutInfoContainer;
237 * Layout information for the whole text.
239 struct TextLayoutInfo
242 * Default constructor.
244 * Initializes all members to their default values.
251 TextLayoutInfo( const TextLayoutInfo& text );
254 * Assignment operator.
256 TextLayoutInfo& operator=( const TextLayoutInfo& text );
258 Size mWholeTextSize; ///< width and height of the whole text.
259 float mMaxWordWidth; ///< maximum width between all words.
260 LineLayoutInfoContainer mLinesLayoutInfo; ///< Layout information for all lines.
261 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
262 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.
263 WordLayoutInfo mEllipsizeLayoutInfo; ///< Layout information for the ellipsize text.
266 } // namespace TextViewProcessor
268 } // namespace Internal
270 } // namespace Toolkit
274 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__