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 line character, 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.
70 TextInfoIndices( std::size_t lineIndex,
71 std::size_t wordIndex,
72 std::size_t characterIndex );
76 * @param [in] indices The text-info indices to be compared.
78 * @return \e true if both indices are equal.
80 bool operator==( const TextInfoIndices& indices ) const;
82 std::size_t mLineIndex;
83 std::size_t mWordIndex;
84 std::size_t mCharacterIndex;
88 * Layout information for a character.
89 * It stores the position, size and ascender of its respective text-actor.
91 struct CharacterLayoutInfo
94 * Default constructor.
96 * Initializes all members to their default values.
98 CharacterLayoutInfo();
103 CharacterLayoutInfo( const CharacterLayoutInfo& character );
106 * Assignment operator.
108 CharacterLayoutInfo& operator=( const CharacterLayoutInfo& character );
110 // Natural size (metrics) of the glyph.
111 float mHeight; ///< Natural height of the character.
112 float mAdvance; ///< Natural horizontal distance from origin of current character and the next one.
113 float mBearing; ///< Natural vertical distance from the baseline to the top of the glyph's bbox.
115 // Size of the text-actor (may be modified by a scale factor).
116 Vector3 mPosition; ///< Position within the text-view
117 Vector2 mOffset; ///< Alignment and justification offset.
118 Size mSize; ///< Size of this character.
119 float mAscender; ///< Distance from the base line to the top of the line.
120 float mUnderlineThickness; ///< The underline's thickness.
121 float mUnderlinePosition; ///< The underline's position.
123 RenderableActor mGlyphActor; ///< Handle to a text-actor.
124 MarkupProcessor::StyledText mStyledText; ///< Stores the text and its style.
125 float mColorAlpha; ///< Alpha component for the initial text color when text is faded.
126 Vector4 mGradientColor; ///< Gradient color.
127 Vector2 mStartPoint; ///< Gradient start point.
128 Vector2 mEndPoint; ///< Gradient end point.
130 bool mIsVisible:1; ///< Whether the text-actor is visible.
131 bool mSetText:1; ///< Whether a new text needs to be set in the text-actor.
132 bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor.
133 bool mIsColorGlyph:1; ///< Whether this character is an emoticon.
135 typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;
138 * Layout information for a word.
140 struct WordLayoutInfo
143 * Default constructor.
145 * Initializes all members to their default values.
152 WordLayoutInfo( const WordLayoutInfo& word );
155 * Assignment operator.
157 WordLayoutInfo& operator=( const WordLayoutInfo& word );
159 Size mSize; ///< Size of the word.
160 float mAscender; ///< Max of all ascenders of all characters.
161 TextSeparatorType mType; ///< Whether this word is a word separator, a line separator or is not a separator.
162 CharacterLayoutInfoContainer mCharactersLayoutInfo; ///< Layout info for all characters.
164 typedef std::vector<WordLayoutInfo> WordLayoutInfoContainer;
167 * Layout information for a line.
169 struct LineLayoutInfo
172 * Default constructor.
174 * Initializes all members to their default values.
181 LineLayoutInfo( const LineLayoutInfo& line );
184 * Assignment operator.
186 LineLayoutInfo& operator=( const LineLayoutInfo& line );
188 Size mSize; ///< Size of the line.
189 float mAscender; ///< Max of all ascenders of all words.
190 float mLineHeightOffset; ///< Line height offset.
191 WordLayoutInfoContainer mWordsLayoutInfo; ///< Layout info for all words.
192 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
194 typedef std::vector<LineLayoutInfo> LineLayoutInfoContainer;
197 * Layout information for the whole text.
199 struct TextLayoutInfo
202 * Default constructor.
204 * Initializes all members to their default values.
211 TextLayoutInfo( const TextLayoutInfo& text );
214 * Assignment operator.
216 TextLayoutInfo& operator=( const TextLayoutInfo& text );
218 Size mWholeTextSize; ///< width and height of the whole text.
219 float mMaxWordWidth; ///< maximum width between all words.
220 LineLayoutInfoContainer mLinesLayoutInfo; ///< Layout information for all lines.
221 std::size_t mNumberOfCharacters; ///< Stores the number of characters.
222 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.
223 WordLayoutInfo mEllipsizeLayoutInfo; ///< Layout information for the ellipsize text.
226 } // namespace TextViewProcessor
228 } // namespace Internal
230 } // namespace Toolkit
234 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__