Fix issues related with cameras.
[platform/core/uifw/dali-toolkit.git] / 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   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.
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 };
144 typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;
145
146 /**
147  * Layout information for a word.
148  */
149 struct WordLayoutInfo
150 {
151   /**
152    * Default constructor.
153    *
154    * Initializes all members to their default values.
155    */
156   WordLayoutInfo();
157
158   /**
159    * Copy constructor.
160    */
161   WordLayoutInfo( const WordLayoutInfo& word );
162
163   /**
164    * Assignment operator.
165    */
166   WordLayoutInfo& operator=( const WordLayoutInfo& word );
167
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.
172 };
173 typedef std::vector<WordLayoutInfo> WordLayoutInfoContainer;
174
175 /**
176  * Layout information for a group of words.
177  */
178 struct WordGroupLayoutInfo
179 {
180   /**
181    * Default constructor.
182    *
183    * Initializes all members to their default values.
184    */
185   WordGroupLayoutInfo();
186
187   /**
188    * Copy constructor.
189    */
190   WordGroupLayoutInfo( const WordGroupLayoutInfo& group );
191
192   /**
193    * Assignment operator.
194    */
195   WordGroupLayoutInfo& operator=( const WordGroupLayoutInfo& group );
196
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.
202 };
203 typedef std::vector<WordGroupLayoutInfo> WordGroupLayoutInfoContainer;
204
205 /**
206  * Layout information for a line.
207  */
208 struct LineLayoutInfo
209 {
210   /**
211    * Default constructor.
212    *
213    * Initializes all members to their default values.
214    */
215   LineLayoutInfo();
216
217   /**
218    * Copy constructor.
219    */
220   LineLayoutInfo( const LineLayoutInfo& line );
221
222   /**
223    * Assignment operator.
224    */
225   LineLayoutInfo& operator=( const LineLayoutInfo& line );
226
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.
232 };
233 typedef std::vector<LineLayoutInfo> LineLayoutInfoContainer;
234
235 /**
236  * Layout information for the whole text.
237  */
238 struct TextLayoutInfo
239 {
240   /**
241    * Default constructor.
242    *
243    * Initializes all members to their default values.
244    */
245   TextLayoutInfo();
246
247   /**
248    * Copy constructor.
249    */
250   TextLayoutInfo( const TextLayoutInfo& text );
251
252   /**
253    * Assignment operator.
254    */
255   TextLayoutInfo& operator=( const TextLayoutInfo& text );
256
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.
263 };
264
265 } // namespace TextViewProcessor
266
267 } // namespace Internal
268
269 } // namespace Toolkit
270
271 } // namespace Dali
272
273 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_TYPES_H__