Merge "Makes the LTR/RTL alignment of text follow the system language by default...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-view-interface.h
1 #ifndef DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H
2 #define DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H
3
4 /*
5  * Copyright (c) 2021 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-toolkit/internal/text/text-definitions.h>
23
24 namespace Dali
25 {
26 struct Vector2;
27 struct Vector4;
28
29 namespace Toolkit
30 {
31 namespace Text
32 {
33 struct GlyphRun;
34
35 /**
36  * @brief Abstract interface to provide the information necessary to display text.
37  *
38  * This includes:
39  * - The font & glyph IDs needed to get bitmaps etc. from TextAbstraction
40  * - The visual position of each glyph within the layout
41  * - A window into the text layout e.g. which page of a document to view
42  */
43 class ViewInterface
44 {
45 public:
46   /**
47    * @brief Constructor.
48    */
49   ViewInterface();
50
51   /**
52    * @brief Virtual destructor
53    */
54   virtual ~ViewInterface();
55
56   /**
57    * @brief Retrieves the target size of the UI control.
58    *
59    * @return The control's size.
60    */
61   virtual const Vector2& GetControlSize() const = 0;
62
63   /**
64    * @brief Retrieves the text's layout size.
65    *
66    * @return The text's size. Note that this may be larger than the control size,
67    * in the case where text is scrolling/clipped.
68    */
69   virtual const Vector2& GetLayoutSize() const = 0;
70
71   /**
72    * Retrieves the number of glyphs.
73    *
74    * @return The number of glyphs.
75    */
76   virtual Length GetNumberOfGlyphs() const = 0;
77
78   /**
79    * @brief Retrieves glyphs and positions in the given buffers.
80    *
81    * @note The size of the @p glyphs and @p glyphPositions buffers need to be big enough to copy the @p numberOfGlyphs glyphs and positions.
82    * @note The returned number of glyphs may be less than @p numberOfGlyphs if a line has ellipsis.
83    *
84    * @param[out] glyphs Pointer to a buffer where the glyphs are copied.
85    * @param[out] glyphPositions Pointer to a buffer where the glyph's positions are copied.
86    * @param[out] minLineOffset The minimum line offset.
87    * @param[in] glyphIndex Index to the first glyph.
88    * @param[in] numberOfGlyphs Number of glyphs to be copied.
89    *
90    * @return The number of glyphs.
91    */
92   virtual Length GetGlyphs(GlyphInfo* glyphs,
93                            Vector2*   glyphPositions,
94                            float&     minLineOffset,
95                            GlyphIndex glyphIndex,
96                            Length     numberOfGlyphs) const = 0;
97
98   /**
99    * @brief Retrieves the vector of colors.
100    *
101    * @return Pointer to the vector of colors.
102    */
103   virtual const Vector4* const GetColors() const = 0;
104
105   /**
106    * @brief Retrieves the vector of indices to the vector of colors.
107    *
108    * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
109    */
110   virtual const ColorIndex* const GetColorIndices() const = 0;
111
112   /**
113    * @brief Retrieves the vector of background colors.
114    *
115    * @return Pointer to the vector of background colors.
116    */
117   virtual const Vector4* const GetBackgroundColors() const = 0;
118
119   /**
120    * @brief Retrieves the vector of indices to the vector of background colors.
121    *
122    * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
123    */
124   virtual const ColorIndex* const GetBackgroundColorIndices() const = 0;
125
126   /**
127    * @brief checks if there is background colors set using markup.
128    *
129    * @return boolean if there is background colors set using markup .
130    */
131   virtual bool const IsMarkupBackgroundColorSet() const = 0;
132
133   /**
134    * @brief Retrieves the text color
135    *
136    * @return The text color
137    */
138   virtual const Vector4& GetTextColor() const = 0;
139
140   /**
141    * @brief Retrieves the shadow offset, 0 indicates no shadow.
142    *
143    * @return The shadow offset.
144    */
145   virtual const Vector2& GetShadowOffset() const = 0;
146
147   /**
148    * @brief Retrieves the shadow color.
149    *
150    * @return The shadow color.
151    */
152   virtual const Vector4& GetShadowColor() const = 0;
153
154   /**
155    * @brief Retrieves the underline color.
156    *
157    * @return The underline color.
158    */
159   virtual const Vector4& GetUnderlineColor() const = 0;
160
161   /**
162    * @brief Returns whether underline is enabled or not.
163    *
164    * @return The underline state.
165    */
166   virtual bool IsUnderlineEnabled() const = 0;
167
168   /**
169    * @brief Returns the hyphens glyph info.
170    *
171    * @return hyphens glyph info.
172    */
173   virtual const GlyphInfo* GetHyphens() const = 0;
174
175   /**
176    * @brief Returns the indices of the hyphen in the text.
177    *
178    * @return the hyphen indices.
179    */
180   virtual const Length* GetHyphenIndices() const = 0;
181
182   /**
183    * @brief Returns number of hyphens to add in text.
184    *
185    * @return number of hyphens.
186    */
187   virtual Length GetHyphensCount() const = 0;
188   /**
189    * @brief Retrieves the underline height override
190    *
191    * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
192    */
193   virtual float GetUnderlineHeight() const = 0;
194
195   /**
196    * @brief Retrieves the number of underline runs.
197    *
198    * @return The number of underline runs.
199    */
200   virtual Length GetNumberOfUnderlineRuns() const = 0;
201
202   /**
203    * @brief Retrieves the underline runs.
204    *
205    * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
206    * @param[in] index Index of the first underline run to be copied.
207    * @param[in] numberOfRuns Number of underline runs to be copied.
208    */
209   virtual void GetUnderlineRuns(GlyphRun*         underlineRuns,
210                                 UnderlineRunIndex index,
211                                 Length            numberOfRuns) const = 0;
212
213   /**
214    * @brief Retrieve the outline color.
215    *
216    * @return The outline color.
217    */
218   virtual const Vector4& GetOutlineColor() const = 0;
219
220   /**
221    * @brief Retrieves the width of an outline
222    *
223    * @return The width of the outline.
224    */
225   virtual uint16_t GetOutlineWidth() const = 0;
226 };
227
228 } // namespace Text
229
230 } // namespace Toolkit
231
232 } // namespace Dali
233
234 #endif // DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H