Resolve incorrect position for Ellipsis when mixed LTR & RTL languages and set layout...
[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* const GetColors() const override;
91
92   /**
93    * @copydoc Dali::Toolkit::Text::ViewInterface::GetColorIndices()
94    */
95   const ColorIndex* const GetColorIndices() const override;
96
97   /**
98    * @copydoc Dali::Toolkit::Text::ViewInterface::GetBackgroundColors()
99    */
100   const Vector4* const GetBackgroundColors() const override;
101
102   /**
103    * @copydoc Dali::Toolkit::Text::ViewInterface::GetBackgroundColorIndices()
104    */
105   const ColorIndex* const GetBackgroundColorIndices() const override;
106
107   /**
108    * @copydoc Dali::Toolkit::Text::ViewInterface::IsMarkupBackgroundColorSet()
109    */
110   bool const 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::GetHyphens()
139   */
140   const GlyphInfo* GetHyphens() const override;
141
142   /**
143   * @copydoc Dali::Toolkit::Text::ViewInterface::GetHyphens()
144   */
145   const Length* GetHyphenIndices() const override;
146
147   /**
148   * @copydoc Dali::Toolkit::Text::ViewInterface::GetHyphens()
149   */
150   Length GetHyphensCount() const override;
151
152   /**
153    * @copydoc Dali::Toolkit::Text::ViewInterface::GetUnderlineHeight()
154    */
155   float GetUnderlineHeight() const override;
156
157   /**
158    * @copydoc Dali::Toolkit::Text::ViewInterface::GetUnderlineType()
159    */
160   Text::Underline::Type GetUnderlineType() const override;
161
162   /**
163    * @copydoc Dali::Toolkit::Text::ViewInterface::GetDashedUnderlineWidth()
164    */
165   float GetDashedUnderlineWidth() const override;
166
167   /**
168    * @copydoc Dali::Toolkit::Text::ViewInterface::GetDashedUnderlineGap()
169    */
170   float GetDashedUnderlineGap() const override;
171
172   /**
173    * @copydoc Dali::Toolkit::Text::ViewInterface::GetNumberOfUnderlineRuns()
174    */
175   Length GetNumberOfUnderlineRuns() const override;
176
177   /**
178    * @copydoc Dali::Toolkit::Text::ViewInterface::GetUnderlineRuns()
179    */
180   virtual void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns,
181                                 UnderlineRunIndex   index,
182                                 Length              numberOfRuns) const;
183
184   /**
185    * @copydoc Dali::Toolkit::Text::ViewInterface::GetOutlineColor()
186    */
187   const Vector4& GetOutlineColor() const override;
188
189   /**
190    * @copydoc Dali::Toolkit::Text::ViewInterface::GetOutlineWidth()
191    */
192   uint16_t GetOutlineWidth() const override;
193
194   /**
195   * @copydoc Dali::Toolkit::Text::ViewInterface::GetEllipsisPosition()
196   */
197   DevelText::EllipsisPosition::Type GetEllipsisPosition() const override;
198
199   /**
200    * @copydoc Dali::Toolkit::Text::ViewInterface::IsTextElideEnabled()
201    */
202   bool IsTextElideEnabled() const override;
203
204   /**
205    * @copydoc Dali::Toolkit::Text::ViewInterface::GetStartIndexOfElidedGlyphs()
206    */
207   GlyphIndex GetStartIndexOfElidedGlyphs() const override;
208
209   /**
210    * @copydoc Dali::Toolkit::Text::ViewInterface::GetEndIndexOfElidedGlyphs()
211    */
212   GlyphIndex GetEndIndexOfElidedGlyphs() const override;
213
214   /**
215    * @copydoc Dali::Toolkit::Text::ViewInterface::GetFirstMiddleIndexOfElidedGlyphs()
216    */
217   GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const override;
218
219   /**
220    * @copydoc Dali::Toolkit::Text::ViewInterface::GetSecondMiddleIndexOfElidedGlyphs()
221    */
222   GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const override;
223
224   /**
225    * @copydoc Dali::Toolkit::Text::ViewInterface::GetStrikethroughColor()
226    */
227   const Vector4& GetStrikethroughColor() const override;
228
229   /**
230    * @copydoc Dali::Toolkit::Text::ViewInterface::IsStrikethroughEnabled()
231    */
232   bool IsStrikethroughEnabled() const override;
233
234   /**
235    * @copydoc Dali::Toolkit::Text::ViewInterface::GetStrikethroughHeight()
236    */
237   float GetStrikethroughHeight() const override;
238
239   /**
240    * @copydoc Dali::Toolkit::Text::ViewInterface::GetNumberOfStrikethroughRuns()
241    */
242   Length GetNumberOfStrikethroughRuns() const;
243
244   /**
245    * @copydoc Dali::Toolkit::Text::ViewInterface::GetStrikethroughRuns()
246    */
247   void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns,
248                             StrikethroughRunIndex  index,
249                             Length                 numberOfRuns) const;
250
251   /**
252    * @copydoc Dali::Toolkit::Text::ViewInterface::GetNumberOfBoundedParagraphRuns()
253    */
254   virtual Length GetNumberOfBoundedParagraphRuns() const;
255
256   /**
257    * @copydoc Dali::Toolkit::Text::ViewInterface::GetBoundedParagraphRuns()
258    */
259   virtual const Vector<BoundedParagraphRun>& GetBoundedParagraphRuns() const;
260
261   /**
262    * @copydoc Dali::Toolkit::Text::ViewInterface::GetNumberOfCharacterSpacingGlyphRuns()
263    */
264   Length GetNumberOfCharacterSpacingGlyphRuns() const override;
265
266   /**
267    * @copydoc Dali::Toolkit::Text::ViewInterface::GetCharacterSpacingGlyphRuns()
268    */
269   const Vector<CharacterSpacingGlyphRun>& GetCharacterSpacingGlyphRuns() const override;
270
271   /**
272    * @copydoc Dali::Toolkit::Text::ViewInterface::GetCharacterSpacing()
273    */
274   const float GetCharacterSpacing() const override;
275
276   /**
277    * @copydoc Dali::Toolkit::Text::ViewInterface::GetTextBuffer()
278    */
279   const Character* GetTextBuffer() const override;
280
281   /**
282    * @copydoc Dali::Toolkit::Text::ViewInterface::GetGlyphsToCharacters()
283    */
284   const Vector<CharacterIndex>& GetGlyphsToCharacters() const override;
285
286 private:
287   // Undefined
288   View(const View& handle);
289
290   // Undefined
291   View& operator=(const View& handle);
292
293 private:
294   struct Impl;
295   Impl* mImpl;
296 };
297 } // namespace Text
298
299 } // namespace Toolkit
300
301 } // namespace Dali
302
303 #endif // DALI_TOOLKIT_TEXT_VIEW_H