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/dali.h>
23 #include <dali-toolkit/public-api/markup-processor/markup-processor.h>
34 namespace TextViewProcessor
38 * Whether the direction is Right To Left or Left To Right.
42 LTR, ///< Left To Right direction.
43 RTL ///< Right To Left direction.
47 * Whether the text is a new line character, 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.
79 TextInfoIndices( std::size_t lineIndex,
80 std::size_t groupIndex,
81 std::size_t wordIndex,
82 std::size_t characterIndex );
86 * @param [in] indices The text-info indices to be compared.
88 * @return \e true if both indices are equal.
90 bool operator==( const TextInfoIndices& indices ) const;
92 std::size_t mLineIndex;
93 std::size_t mGroupIndex;
94 std::size_t mWordIndex;
95 std::size_t mCharacterIndex;
99 * Layout information for a character.
100 * It stores the position, size and ascender of its respective text-actor.
102 struct CharacterLayoutInfo
105 * Default constructor.
107 * Initializes all members to their default values.
109 CharacterLayoutInfo();
114 CharacterLayoutInfo( const CharacterLayoutInfo& character );
117 * Assignment operator.
119 CharacterLayoutInfo& operator=( const CharacterLayoutInfo& character );
121 // Natural size (metrics) of the glyph.
122 float mHeight; ///< Natural height of the character.
123 float mAdvance; ///< Natural horizontal distance from origin of current character and the next one.
124 float mBearing; ///< Natural vertical distance from the baseline to the top of the glyph's bbox.
126 // Size of the text-actor (may be modified by a scale factor).
127 Vector3 mPosition; ///< Position within the text-view
128 Vector2 mOffset; ///< Alignment and justification offset.
129 Size mSize; ///< Size of this character.
130 float mAscender; ///< Distance from the base line to the top of the line.
131 float mUnderlineThickness; ///< The underline's thickness.
132 float mUnderlinePosition; ///< The underline's position.
134 RenderableActor mGlyphActor; ///< Handle to a text-actor.
135 MarkupProcessor::StyledText mStyledText; ///< Stores the text and its style.
136 float mColorAlpha; ///< Alpha component for the initial text color when text is faded.
137 Vector4 mGradientColor; ///< Gradient color.
138 Vector2 mStartPoint; ///< Gradient start point.
139 Vector2 mEndPoint; ///< Gradient end point.
141 bool mIsVisible:1; ///< Whether the text-actor is visible.
142 bool mSetText:1; ///< Whether a new text needs to be set in the text-actor.
143 bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor.
144 bool mIsColorGlyph:1; ///< Whether this character is an emoticon.
146 typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;
149 * Layout information for a word.
151 struct WordLayoutInfo
154 * Default constructor.
156 * Initializes all members to their default values.
163 WordLayoutInfo( const WordLayoutInfo& word );
166 * Assignment operator.
168 WordLayoutInfo& operator=( const WordLayoutInfo& word );
170 Size mSize; ///< Size of the word.
171 float mAscender; ///< Max of all ascenders of all characters.
172 TextSeparatorType mType; ///< Whether this word is a word separator, a line separator or is not a separator.
173 CharacterLayoutInfoContainer mCharactersLayoutInfo; ///< Layout info for all characters.
175 typedef std::vector<WordLayoutInfo> WordLayoutInfoContainer;
178 * Layout information for a group of words.
180 struct WordGroupLayoutInfo
183 * Default constructor.
185 * Initializes all members to their default values.
187 WordGroupLayoutInfo();
192 WordGroupLayoutInfo( const WordGroupLayoutInfo& group );
195 * Assignment operator.
197 WordGroupLayoutInfo& operator=( const WordGroupLayoutInfo& group );
199 Size mSize; ///< Size of the group of words.
200 float mAscender; ///< Max of all ascenders of all words.
201 Direction mDirection; ///< Whether this group of words is Right To Left or Left To Right.
202 WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words.
203 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
205 typedef std::vector<WordGroupLayoutInfo> WordGroupLayoutInfoContainer;
208 * Layout information for a line.
210 struct LineLayoutInfo
213 * Default constructor.
215 * Initializes all members to their default values.
222 LineLayoutInfo( const LineLayoutInfo& line );
225 * Assignment operator.
227 LineLayoutInfo& operator=( const LineLayoutInfo& line );
229 Size mSize; ///< Size of the line.
230 float mAscender; ///< Max of all ascenders of all groups of words.
231 float mLineHeightOffset; ///< Line height offset.
232 WordGroupLayoutInfoContainer mWordGroupsLayoutInfo; ///< Layout info for all groups of words.
233 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
235 typedef std::vector<LineLayoutInfo> LineLayoutInfoContainer;
238 * Layout information for the whole text.
240 struct TextLayoutInfo
243 * Default constructor.
245 * Initializes all members to their default values.
252 TextLayoutInfo( const TextLayoutInfo& text );
255 * Assignment operator.
257 TextLayoutInfo& operator=( const TextLayoutInfo& text );
259 Size mWholeTextSize; ///< width and height of the whole text.
260 float mMaxWordWidth; ///< maximum width between all words.
261 LineLayoutInfoContainer mLinesLayoutInfo; ///< Layout information for all lines.
262 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
263 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.
264 WordLayoutInfo mEllipsizeLayoutInfo; ///< Layout information for the ellipsize text.
267 } // namespace TextViewProcessor
269 } // namespace Internal
271 } // namespace Toolkit
275 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__