Support Ellipsis Position Property
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-model.h
1 #ifndef DALI_TOOLKIT_TEXT_MODEL_H
2 #define DALI_TOOLKIT_TEXT_MODEL_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 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/ref-object.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/text/logical-model-impl.h>
26 #include <dali-toolkit/internal/text/text-model-interface.h>
27 #include <dali-toolkit/internal/text/visual-model-impl.h>
28 #include <dali-toolkit/public-api/text/text-enumerations.h>
29
30 namespace Dali
31 {
32 namespace Toolkit
33 {
34 namespace Text
35 {
36 // Forward declarations.
37 class Model;
38
39 typedef IntrusivePtr<Model> ModelPtr;
40
41 /**
42  * @brief Implementation class used to retrieve the text's model from the text-controller.
43  */
44 class Model : public RefObject, public ModelInterface
45 {
46 public: // Constructor.
47   /**
48    * @brief Create a new instance of a text Model.
49    *
50    * @return A pointer to a new text Model.
51    */
52   static ModelPtr New();
53
54 public:
55   /**
56    * @copydoc ModelInterface::GetControlSize()
57    */
58   const Size& GetControlSize() const override;
59
60   /**
61    * @copydoc ModelInterface::GetLayoutSize()
62    */
63   const Size& GetLayoutSize() const override;
64
65   /**
66    * @copydoc ModelInterface::GetScrollPosition()
67    */
68   const Vector2& GetScrollPosition() const override;
69
70   /**
71    * @copydoc ModelInterface::GetHorizontalAlignment()
72    */
73   HorizontalAlignment::Type GetHorizontalAlignment() const override;
74
75   /**
76    * @copydoc ModelInterface::GetVerticalAlignment()
77    */
78   VerticalAlignment::Type GetVerticalAlignment() const override;
79
80   /**
81    * @copydoc ModelInterface::GetVerticalLineAlignment()
82    */
83   DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const override;
84
85   /**
86    * @copydoc ModelInterface::GetEllipsisPosition()
87    */
88   DevelText::EllipsisPosition::Type GetEllipsisPosition() const override;
89
90   /**
91    * @copydoc ModelInterface::IsTextElideEnabled()
92    */
93   bool IsTextElideEnabled() const override;
94
95   /**
96    * @copydoc ModelInterface::GetNumberOfLines()
97    */
98   Length GetNumberOfLines() const override;
99
100   /**
101    * @copydoc ModelInterface::GetLines()
102    */
103   const LineRun* const GetLines() const override;
104
105   /**
106    * @copydoc ModelInterface::GetNumberOfScripts()
107    */
108   Length GetNumberOfScripts() const override;
109
110   /**
111    * @copydoc ModelInterface::GetScriptRuns()
112    */
113   const ScriptRun* const GetScriptRuns() const override;
114
115   /**
116    * @copydoc ModelInterface::GetNumberOfGlyphs()
117    */
118   Length GetNumberOfGlyphs() const override;
119
120   /**
121    * @copydoc ModelInterface::GetStartIndexOfElidedGlyphs()
122    */
123   GlyphIndex GetStartIndexOfElidedGlyphs() const override;
124
125   /**
126    * @copydoc ModelInterface::GetEndIndexOfElidedGlyphs()
127    */
128   GlyphIndex GetEndIndexOfElidedGlyphs() const override;
129
130   /**
131    * @copydoc ModelInterface::GetFirstMiddleIndexOfElidedGlyphs()
132    */
133   GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const override;
134
135   /**
136    * @copydoc ModelInterface::GetSecondMiddleIndexOfElidedGlyphs()
137    */
138   GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const override;
139
140   /**
141    * @copydoc ModelInterface::GetGlyphs()
142    */
143   const GlyphInfo* const GetGlyphs() const override;
144
145   /**
146    * @copydoc ModelInterface::GetLayout()
147    */
148   const Vector2* const GetLayout() const override;
149
150   /**
151    * @copydoc ModelInterface::GetColors()
152    */
153   const Vector4* const GetColors() const override;
154
155   /**
156    * @copydoc ModelInterface::GetColorIndices()
157    */
158   const ColorIndex* const GetColorIndices() const override;
159
160   /**
161    * @copydoc ModelInterface::GetBackgroundColors()
162    */
163   const Vector4* const GetBackgroundColors() const override;
164
165   /**
166    * @copydoc ModelInterface::GetBackgroundColorIndices()
167    */
168   const ColorIndex* const GetBackgroundColorIndices() const override;
169
170   /**
171    * @copydoc ModelInterface::IsMarkupBackgroundColorSet()
172    */
173   bool const IsMarkupBackgroundColorSet() const override;
174
175   /**
176    * @copydoc ModelInterface::GetDefaultColor()
177    */
178   const Vector4& GetDefaultColor() const override;
179
180   /**
181    * @copydoc ModelInterface::GetShadowOffset()
182    */
183   const Vector2& GetShadowOffset() const override;
184
185   /**
186    * @copydoc ModelInterface::GetShadowColor()
187    */
188   const Vector4& GetShadowColor() const override;
189
190   /**
191    * @copydoc ModelInterface::GetShadowBlurRadius()
192    */
193   const float& GetShadowBlurRadius() const override;
194
195   /**
196    * @copydoc ModelInterface::GetUnderlineColor()
197    */
198   const Vector4& GetUnderlineColor() const override;
199
200   /**
201    * @copydoc ModelInterface::IsUnderlineEnabled()
202    */
203   bool IsUnderlineEnabled() const override;
204
205   /**
206    * @copydoc ModelInterface::GetUnderlineHeight()
207    */
208   float GetUnderlineHeight() const override;
209
210   /**
211    * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
212    */
213   Length GetNumberOfUnderlineRuns() const override;
214
215   /**
216    * @copydoc ModelInterface::GetUnderlineRuns()
217    */
218   void GetUnderlineRuns(GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const override;
219
220   /**
221    * @copydoc ModelInterface::GetOutlineColor()
222    */
223   const Vector4& GetOutlineColor() const override;
224
225   /**
226    * @copydoc ModelInterface::GetOutlineWidth()
227    */
228   uint16_t GetOutlineWidth() const override;
229
230   /**
231    * @copydoc ModelInterface::GetBackgroundColor()
232    */
233   const Vector4& GetBackgroundColor() const override;
234
235   /**
236    * @copydoc ModelInterface::IsBackgroundEnabled()
237    */
238   bool IsBackgroundEnabled() const override;
239
240   /**
241    * @copydoc ModelInterface::IsMarkupProcessorEnabled()
242    */
243   bool IsMarkupProcessorEnabled() const override;
244
245   /**
246   * @copydoc ModelInterface::GetHyphens()
247   */
248   const GlyphInfo* GetHyphens() const override;
249
250   /**
251   * @copydoc ModelInterface::GetHyphens()
252   */
253   const Length* GetHyphenIndices() const override;
254
255   /**
256   * @copydoc ModelInterface::GetHyphens()
257   */
258   Length GetHyphensCount() const override;
259
260 private: // Private contructors & copy operator.
261   /**
262    * @brief Private constructor.
263    */
264   Model();
265
266   // Undefined.
267   Model(const Model& handle);
268
269   // Undefined.
270   Model& operator=(const Model& handle);
271
272 protected:
273   /**
274    * @brief A reference counted object may only be deleted by calling Unreference().
275    */
276   virtual ~Model();
277
278 public:
279   LogicalModelPtr mLogicalModel; ///< Pointer to the logical model.
280   VisualModelPtr  mVisualModel;  ///< Pointer to the visual model.
281   /**
282    * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
283    * Typically this will have a negative value with scrolling occurs.
284    */
285   Vector2                                mScrollPosition;            ///< The text is offset by this position when scrolling.
286   Vector2                                mScrollPositionLast;        ///< The last offset value of mScrollPosition
287   HorizontalAlignment::Type              mHorizontalAlignment;       ///< The layout's horizontal alignment.
288   VerticalAlignment::Type                mVerticalAlignment;         ///< The layout's vertical alignment.
289   DevelText::VerticalLineAlignment::Type mVerticalLineAlignment;     ///< The layout's vertical line alignment.
290   Text::LineWrap::Mode                   mLineWrapMode;              ///< The text wrap mode
291   float                                  mAlignmentOffset;           ///< The alignment offset.
292   bool                                   mElideEnabled : 1;          ///< Whether the text's elide is enabled.
293   bool                                   mIgnoreSpacesAfterText : 1; ///< Whether ignoring spaces after text or not. Default is true.
294   DevelText::MatchLayoutDirection        mMatchLayoutDirection;      ///< Whether to match text alignment with layout direction or not.
295   DevelText::EllipsisPosition::Type      mEllipsisPosition;          ///< Where is the location the text elide
296 };
297
298 } // namespace Text
299
300 } // namespace Toolkit
301
302 } // namespace Dali
303
304 #endif // DALI_TOOLKIT_TEXT_MODEL_H