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