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 TextActor mTextActor; ///< 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.
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.
161 WordLayoutInfo( const WordLayoutInfo& word );
164 * Assignment operator.
166 WordLayoutInfo& operator=( const WordLayoutInfo& word );
168 Size mSize; ///< Size of the word.
169 float mAscender; ///< Max of all ascenders of all characters.
170 TextSeparatorType mType; ///< Whether this word is a word separator, a line separator or is not a separator.
171 CharacterLayoutInfoContainer mCharactersLayoutInfo; ///< Layout info for all characters.
173 typedef std::vector<WordLayoutInfo> WordLayoutInfoContainer;
176 * Layout information for a group of words.
178 struct WordGroupLayoutInfo
181 * Default constructor.
183 * Initializes all members to their default values.
185 WordGroupLayoutInfo();
190 WordGroupLayoutInfo( const WordGroupLayoutInfo& group );
193 * Assignment operator.
195 WordGroupLayoutInfo& operator=( const WordGroupLayoutInfo& group );
197 Size mSize; ///< Size of the group of words.
198 float mAscender; ///< Max of all ascenders of all words.
199 Direction mDirection; ///< Whether this group of words is Right To Left or Left To Right.
200 WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words.
201 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
203 typedef std::vector<WordGroupLayoutInfo> WordGroupLayoutInfoContainer;
206 * Layout information for a line.
208 struct LineLayoutInfo
211 * Default constructor.
213 * Initializes all members to their default values.
220 LineLayoutInfo( const LineLayoutInfo& line );
223 * Assignment operator.
225 LineLayoutInfo& operator=( const LineLayoutInfo& line );
227 Size mSize; ///< Size of the line.
228 float mAscender; ///< Max of all ascenders of all groups of words.
229 float mLineHeightOffset; ///< Line height offset.
230 WordGroupLayoutInfoContainer mWordGroupsLayoutInfo; ///< Layout info for all groups of words.
231 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
233 typedef std::vector<LineLayoutInfo> LineLayoutInfoContainer;
236 * Layout information for the whole text.
238 struct TextLayoutInfo
241 * Default constructor.
243 * Initializes all members to their default values.
250 TextLayoutInfo( const TextLayoutInfo& text );
253 * Assignment operator.
255 TextLayoutInfo& operator=( const TextLayoutInfo& text );
257 Size mWholeTextSize; ///< width and height of the whole text.
258 float mMaxWordWidth; ///< maximum width between all words.
259 LineLayoutInfoContainer mLinesLayoutInfo; ///< Layout information for all lines.
260 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
261 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.
262 WordLayoutInfo mEllipsizeLayoutInfo; ///< Layout information for the ellipsize text.
265 } // namespace TextViewProcessor
267 } // namespace Internal
269 } // namespace Toolkit
273 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__