Merge "Spannable: Add BoldSpan" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-view.h
1 #ifndef DALI_TOOLKIT_TEXT_VIEW_H
2 #define DALI_TOOLKIT_TEXT_VIEW_H
3
4 /*
5  * Copyright (c) 2022 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/bounded-paragraph-run.h>
23 #include <dali-toolkit/internal/text/logical-model-impl.h>
24 #include <dali-toolkit/internal/text/text-view-interface.h>
25 #include <dali-toolkit/internal/text/visual-model-impl.h>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace Text
32 {
33 /**
34  * @brief View provides an interface between the Text layout engine and rendering back-end.
35  */
36 class View : public ViewInterface
37 {
38 public:
39   /**
40    * @brief Create a new instance of a View.
41    */
42   View();
43
44   /**
45    * @brief Virtual destructor.
46    */
47   virtual ~View();
48
49   /**
50    * @brief Set the visual model.
51    *
52    * @param[in] visualModel The visual model used by the View.
53    */
54   void SetVisualModel(VisualModelPtr visualModel);
55
56   /**
57    * @brief Set the logical model.
58    *
59    * @param[in] logicalModel The logical model used by the View.
60    */
61   void SetLogicalModel(LogicalModelPtr logicalModel);
62
63   /**
64    * @copydoc Dali::Toolkit::Text::ViewInterface::GetControlSize()
65    */
66   const Vector2& GetControlSize() const override;
67
68   /**
69    * @copydoc Dali::Toolkit::Text::ViewInterface::GetLayoutSize()
70    */
71   const Vector2& GetLayoutSize() const override;
72
73   /**
74    * @copydoc Dali::Toolkit::Text::ViewInterface::GetNumberOfGlyphs()
75    */
76   Length GetNumberOfGlyphs() const override;
77
78   /**
79    * @copydoc Dali::Toolkit::Text::ViewInterface::GetGlyphs()
80    */
81   virtual Length GetGlyphs(GlyphInfo* glyphs,
82                            Vector2*   glyphPositions,
83                            float&     minLineOffset,
84                            GlyphIndex glyphIndex,
85                            Length     numberOfGlyphs) const;
86
87   /**
88    * @copydoc Dali::Toolkit::Text::ViewInterface::GetColors()
89    */
90   const Vector4* GetColors() const override;
91
92   /**
93    * @copydoc Dali::Toolkit::Text::ViewInterface::GetColorIndices()
94    */
95   const ColorIndex* GetColorIndices() const override;
96
97   /**
98    * @copydoc Dali::Toolkit::Text::ViewInterface::GetBackgroundColors()
99    */
100   const Vector4* GetBackgroundColors() const override;
101
102   /**
103    * @copydoc Dali::Toolkit::Text::ViewInterface::GetBackgroundColorIndices()
104    */
105   const ColorIndex* GetBackgroundColorIndices() const override;
106
107   /**
108    * @copydoc Dali::Toolkit::Text::ViewInterface::IsMarkupBackgroundColorSet()
109    */
110   bool IsMarkupBackgroundColorSet() const;
111
112   /**
113    * @copydoc Dali::Toolkit::Text::ViewInterface::GetTextColor()
114    */
115   const Vector4& GetTextColor() const override;
116
117   /**
118    * @copydoc Dali::Toolkit::Text::ViewInterface::GetShadowOffset()
119    */
120   const Vector2& GetShadowOffset() const override;
121
122   /**
123    * @copydoc Dali::Toolkit::Text::ViewInterface::GetShadowColor()
124    */
125   const Vector4& GetShadowColor() const override;
126
127   /**
128    * @copydoc Dali::Toolkit::Text::ViewInterface::GetUnderlineColor()
129    */
130   const Vector4& GetUnderlineColor() const override;
131
132   /**
133    * @copydoc Dali::Toolkit::Text::ViewInterface::IsUnderlineEnabled()
134    */
135   bool IsUnderlineEnabled() const override;
136
137   /**
138    * @copydoc Dali::Toolkit::Text::ViewInterface::IsMarkupUnderlineSet()
139    */
140   bool IsMarkupUnderlineSet() const;
141
142   /**
143   * @copydoc Dali::Toolkit::Text::ViewInterface::GetHyphens()
144   */
145   const GlyphInfo* GetHyphens() const override;
146
147   /**
148   * @copydoc Dali::Toolkit::Text::ViewInterface::GetHyphens()
149   */
150   const Length* GetHyphenIndices() const override;
151
152   /**
153   * @copydoc Dali::Toolkit::Text::ViewInterface::GetHyphens()
154   */
155   Length GetHyphensCount() const override;
156
157   /**
158    * @copydoc Dali::Toolkit::Text::ViewInterface::GetUnderlineHeight()
159    */
160   float GetUnderlineHeight() const override;
161
162   /**
163    * @copydoc Dali::Toolkit::Text::ViewInterface::GetUnderlineType()
164    */
165   Text::Underline::Type GetUnderlineType() const override;
166
167   /**
168    * @copydoc Dali::Toolkit::Text::ViewInterface::GetDashedUnderlineWidth()
169    */
170   float GetDashedUnderlineWidth() const override;
171
172   /**
173    * @copydoc Dali::Toolkit::Text::ViewInterface::GetDashedUnderlineGap()
174    */
175   float GetDashedUnderlineGap() const override;
176
177   /**
178    * @copydoc Dali::Toolkit::Text::ViewInterface::GetNumberOfUnderlineRuns()
179    */
180   Length GetNumberOfUnderlineRuns() const override;
181
182   /**
183    * @copydoc Dali::Toolkit::Text::ViewInterface::GetUnderlineRuns()
184    */
185   virtual void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns,
186                                 UnderlineRunIndex   index,
187                                 Length              numberOfRuns) const;
188
189   /**
190    * @copydoc Dali::Toolkit::Text::ViewInterface::GetOutlineColor()
191    */
192   const Vector4& GetOutlineColor() const override;
193
194   /**
195    * @copydoc Dali::Toolkit::Text::ViewInterface::GetOutlineWidth()
196    */
197   uint16_t GetOutlineWidth() const override;
198
199   /**
200   * @copydoc Dali::Toolkit::Text::ViewInterface::GetEllipsisPosition()
201   */
202   DevelText::EllipsisPosition::Type GetEllipsisPosition() const override;
203
204   /**
205    * @copydoc Dali::Toolkit::Text::ViewInterface::IsTextElideEnabled()
206    */
207   bool IsTextElideEnabled() const override;
208
209   /**
210    * @copydoc Dali::Toolkit::Text::ViewInterface::GetStartIndexOfElidedGlyphs()
211    */
212   GlyphIndex GetStartIndexOfElidedGlyphs() const override;
213
214   /**
215    * @copydoc Dali::Toolkit::Text::ViewInterface::GetEndIndexOfElidedGlyphs()
216    */
217   GlyphIndex GetEndIndexOfElidedGlyphs() const override;
218
219   /**
220    * @copydoc Dali::Toolkit::Text::ViewInterface::GetFirstMiddleIndexOfElidedGlyphs()
221    */
222   GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const override;
223
224   /**
225    * @copydoc Dali::Toolkit::Text::ViewInterface::GetSecondMiddleIndexOfElidedGlyphs()
226    */
227   GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const override;
228
229   /**
230    * @copydoc Dali::Toolkit::Text::ViewInterface::GetStrikethroughColor()
231    */
232   const Vector4& GetStrikethroughColor() const override;
233
234   /**
235    * @copydoc Dali::Toolkit::Text::ViewInterface::IsStrikethroughEnabled()
236    */
237   bool IsStrikethroughEnabled() const override;
238
239   /**
240    * @copydoc Dali::Toolkit::Text::ViewInterface::IsMarkupStrikethroughSet()
241    */
242   bool IsMarkupStrikethroughSet() const;
243
244   /**
245    * @copydoc Dali::Toolkit::Text::ViewInterface::GetStrikethroughHeight()
246    */
247   float GetStrikethroughHeight() const override;
248
249   /**
250    * @copydoc Dali::Toolkit::Text::ViewInterface::GetNumberOfStrikethroughRuns()
251    */
252   Length GetNumberOfStrikethroughRuns() const;
253
254   /**
255    * @copydoc Dali::Toolkit::Text::ViewInterface::GetStrikethroughRuns()
256    */
257   void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns,
258                             StrikethroughRunIndex  index,
259                             Length                 numberOfRuns) const;
260
261   /**
262    * @copydoc Dali::Toolkit::Text::ViewInterface::GetNumberOfBoundedParagraphRuns()
263    */
264   virtual Length GetNumberOfBoundedParagraphRuns() const;
265
266   /**
267    * @copydoc Dali::Toolkit::Text::ViewInterface::GetBoundedParagraphRuns()
268    */
269   virtual const Vector<BoundedParagraphRun>& GetBoundedParagraphRuns() const;
270
271   /**
272    * @copydoc Dali::Toolkit::Text::ViewInterface::GetNumberOfCharacterSpacingGlyphRuns()
273    */
274   Length GetNumberOfCharacterSpacingGlyphRuns() const override;
275
276   /**
277    * @copydoc Dali::Toolkit::Text::ViewInterface::GetCharacterSpacingGlyphRuns()
278    */
279   const Vector<CharacterSpacingGlyphRun>& GetCharacterSpacingGlyphRuns() const override;
280
281   /**
282    * @copydoc Dali::Toolkit::Text::ViewInterface::GetCharacterSpacing()
283    */
284   float GetCharacterSpacing() const override;
285
286   /**
287    * @copydoc Dali::Toolkit::Text::ViewInterface::GetTextBuffer()
288    */
289   const Character* GetTextBuffer() const override;
290
291   /**
292    * @copydoc Dali::Toolkit::Text::ViewInterface::GetGlyphsToCharacters()
293    */
294   const Vector<CharacterIndex>& GetGlyphsToCharacters() const override;
295
296 private:
297   // Undefined
298   View(const View& handle);
299
300   // Undefined
301   View& operator=(const View& handle);
302
303 private:
304   struct Impl;
305   Impl* mImpl;
306 };
307 } // namespace Text
308
309 } // namespace Toolkit
310
311 } // namespace Dali
312
313 #endif // DALI_TOOLKIT_TEXT_VIEW_H