TextView - Split width exceed policy and EllipsizeEnd height exceed policy combinatio...
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-view / text-view-processor-types.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
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
10 //
11 //     http://floralicense.org/license/
12 //
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.
18 //
19
20 // INTERNAL INCLUDES
21 #include <dali/dali.h>
22 #include <dali-toolkit/public-api/markup-processor/markup-processor.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal
31 {
32
33 namespace TextViewProcessor
34 {
35
36 /**
37  * Whether the direction is Right To Left or Left To Right.
38  */
39 enum Direction
40 {
41   LTR, ///< Left To Right direction.
42   RTL  ///< Right To Left direction.
43 };
44
45 /**
46  * Whether the text is a new line character, a white space or normal text.
47  */
48 enum TextSeparatorType
49 {
50   LineSeparator,
51   WordSeparator,
52   NoSeparator
53 };
54
55 /**
56  * Whether to clear the text of the text-actors when text is removed.
57  */
58 enum TextOperationOnRemove
59 {
60   CLEAR_TEXT,
61   KEEP_TEXT
62 };
63
64
65 /**
66  * Stores text info indices.
67  */
68 struct TextInfoIndices
69 {
70   /**
71    * Default constructor.
72    */
73   TextInfoIndices();
74
75   /**
76    * Constructor.
77    */
78   TextInfoIndices( std::size_t lineIndex,
79                    std::size_t groupIndex,
80                    std::size_t wordIndex,
81                    std::size_t characterIndex );
82
83   /**
84    * Equality operator.
85    * @param [in] indices The text-info indices to be compared.
86    *
87    * @return \e true if both indices are equal.
88    */
89   bool operator==( const TextInfoIndices& indices ) const;
90
91   std::size_t mLineIndex;
92   std::size_t mGroupIndex;
93   std::size_t mWordIndex;
94   std::size_t mCharacterIndex;
95 };
96
97 /**
98  * Layout information for a character.
99  * It stores the position, size and ascender of its respective text-actor.
100  */
101 struct CharacterLayoutInfo
102 {
103   /**
104    * Default constructor.
105    *
106    * Initializes all members to their default values.
107    */
108   CharacterLayoutInfo();
109
110   /**
111    * Copy constructor.
112    */
113   CharacterLayoutInfo( const CharacterLayoutInfo& character );
114
115   /**
116    * Assignment operator.
117    */
118   CharacterLayoutInfo& operator=( const CharacterLayoutInfo& character );
119
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.
124
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.
132
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.
139
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.
144 };
145 typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;
146
147 /**
148  * Layout information for a word.
149  */
150 struct WordLayoutInfo
151 {
152   /**
153    * Default constructor.
154    *
155    * Initializes all members to their default values.
156    */
157   WordLayoutInfo();
158
159   /**
160    * Copy constructor.
161    */
162   WordLayoutInfo( const WordLayoutInfo& word );
163
164   /**
165    * Assignment operator.
166    */
167   WordLayoutInfo& operator=( const WordLayoutInfo& word );
168
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.
173 };
174 typedef std::vector<WordLayoutInfo> WordLayoutInfoContainer;
175
176 /**
177  * Layout information for a group of words.
178  */
179 struct WordGroupLayoutInfo
180 {
181   /**
182    * Default constructor.
183    *
184    * Initializes all members to their default values.
185    */
186   WordGroupLayoutInfo();
187
188   /**
189    * Copy constructor.
190    */
191   WordGroupLayoutInfo( const WordGroupLayoutInfo& group );
192
193   /**
194    * Assignment operator.
195    */
196   WordGroupLayoutInfo& operator=( const WordGroupLayoutInfo& group );
197
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.
203 };
204 typedef std::vector<WordGroupLayoutInfo> WordGroupLayoutInfoContainer;
205
206 /**
207  * Layout information for a line.
208  */
209 struct LineLayoutInfo
210 {
211   /**
212    * Default constructor.
213    *
214    * Initializes all members to their default values.
215    */
216   LineLayoutInfo();
217
218   /**
219    * Copy constructor.
220    */
221   LineLayoutInfo( const LineLayoutInfo& line );
222
223   /**
224    * Assignment operator.
225    */
226   LineLayoutInfo& operator=( const LineLayoutInfo& line );
227
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.
233 };
234 typedef std::vector<LineLayoutInfo> LineLayoutInfoContainer;
235
236 /**
237  * Layout information for the whole text.
238  */
239 struct TextLayoutInfo
240 {
241   /**
242    * Default constructor.
243    *
244    * Initializes all members to their default values.
245    */
246   TextLayoutInfo();
247
248   /**
249    * Copy constructor.
250    */
251   TextLayoutInfo( const TextLayoutInfo& text );
252
253   /**
254    * Assignment operator.
255    */
256   TextLayoutInfo& operator=( const TextLayoutInfo& text );
257
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.
264 };
265
266 } // namespace TextViewProcessor
267
268 } // namespace Internal
269
270 } // namespace Toolkit
271
272 } // namespace Dali
273
274 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__