TextView - Remove groups of words.
[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 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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
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
21 // INTERNAL INCLUDES
22 #include <dali/public-api/actors/renderable-actor.h>
23 #include <dali-toolkit/public-api/markup-processor/markup-processor.h>
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Internal
32 {
33
34 namespace TextViewProcessor
35 {
36
37 /**
38  * Whether the text is a new line character, a white space or normal text.
39  */
40 enum TextSeparatorType
41 {
42   LineSeparator,
43   WordSeparator,
44   NoSeparator
45 };
46
47 /**
48  * Whether to clear the text of the text-actors when text is removed.
49  */
50 enum TextOperationOnRemove
51 {
52   CLEAR_TEXT,
53   KEEP_TEXT
54 };
55
56
57 /**
58  * Stores text info indices.
59  */
60 struct TextInfoIndices
61 {
62   /**
63    * Default constructor.
64    */
65   TextInfoIndices();
66
67   /**
68    * Constructor.
69    */
70   TextInfoIndices( std::size_t lineIndex,
71                    std::size_t wordIndex,
72                    std::size_t characterIndex );
73
74   /**
75    * Equality operator.
76    * @param [in] indices The text-info indices to be compared.
77    *
78    * @return \e true if both indices are equal.
79    */
80   bool operator==( const TextInfoIndices& indices ) const;
81
82   std::size_t mLineIndex;
83   std::size_t mWordIndex;
84   std::size_t mCharacterIndex;
85 };
86
87 /**
88  * Layout information for a character.
89  * It stores the position, size and ascender of its respective text-actor.
90  */
91 struct CharacterLayoutInfo
92 {
93   /**
94    * Default constructor.
95    *
96    * Initializes all members to their default values.
97    */
98   CharacterLayoutInfo();
99
100   /**
101    * Copy constructor.
102    */
103   CharacterLayoutInfo( const CharacterLayoutInfo& character );
104
105   /**
106    * Assignment operator.
107    */
108   CharacterLayoutInfo& operator=( const CharacterLayoutInfo& character );
109
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.
114
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.
122
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.
129
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.
134 };
135 typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;
136
137 /**
138  * Layout information for a word.
139  */
140 struct WordLayoutInfo
141 {
142   /**
143    * Default constructor.
144    *
145    * Initializes all members to their default values.
146    */
147   WordLayoutInfo();
148
149   /**
150    * Copy constructor.
151    */
152   WordLayoutInfo( const WordLayoutInfo& word );
153
154   /**
155    * Assignment operator.
156    */
157   WordLayoutInfo& operator=( const WordLayoutInfo& word );
158
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.
163 };
164 typedef std::vector<WordLayoutInfo> WordLayoutInfoContainer;
165
166 /**
167  * Layout information for a line.
168  */
169 struct LineLayoutInfo
170 {
171   /**
172    * Default constructor.
173    *
174    * Initializes all members to their default values.
175    */
176   LineLayoutInfo();
177
178   /**
179    * Copy constructor.
180    */
181   LineLayoutInfo( const LineLayoutInfo& line );
182
183   /**
184    * Assignment operator.
185    */
186   LineLayoutInfo& operator=( const LineLayoutInfo& line );
187
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.
193 };
194 typedef std::vector<LineLayoutInfo> LineLayoutInfoContainer;
195
196 /**
197  * Layout information for the whole text.
198  */
199 struct TextLayoutInfo
200 {
201   /**
202    * Default constructor.
203    *
204    * Initializes all members to their default values.
205    */
206   TextLayoutInfo();
207
208   /**
209    * Copy constructor.
210    */
211   TextLayoutInfo( const TextLayoutInfo& text );
212
213   /**
214    * Assignment operator.
215    */
216   TextLayoutInfo& operator=( const TextLayoutInfo& text );
217
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.
224 };
225
226 } // namespace TextViewProcessor
227
228 } // namespace Internal
229
230 } // namespace Toolkit
231
232 } // namespace Dali
233
234 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__