[dali_2.3.19] Merge branch 'devel/master'
[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::IsTextElideEnabled()
87    */
88   bool IsTextElideEnabled() const override;
89
90   /**
91    * @copydoc ModelInterface::GetNumberOfLines()
92    */
93   Length GetNumberOfLines() const override;
94
95   /**
96    * @copydoc ModelInterface::GetLines()
97    */
98   const LineRun* const GetLines() const override;
99
100   /**
101    * @copydoc ModelInterface::GetNumberOfScripts()
102    */
103   Length GetNumberOfScripts() const override;
104
105   /**
106    * @copydoc ModelInterface::GetScriptRuns()
107    */
108   const ScriptRun* const GetScriptRuns() const override;
109
110   /**
111    * @copydoc ModelInterface::GetNumberOfGlyphs()
112    */
113   Length GetNumberOfGlyphs() const override;
114
115   /**
116    * @copydoc ModelInterface::GetGlyphs()
117    */
118   const GlyphInfo* const GetGlyphs() const override;
119
120   /**
121    * @copydoc ModelInterface::GetLayout()
122    */
123   const Vector2* const GetLayout() const override;
124
125   /**
126    * @copydoc ModelInterface::GetColors()
127    */
128   const Vector4* const GetColors() const override;
129
130   /**
131    * @copydoc ModelInterface::GetColorIndices()
132    */
133   const ColorIndex* const GetColorIndices() const override;
134
135   /**
136    * @copydoc ModelInterface::GetBackgroundColors()
137    */
138   const Vector4* const GetBackgroundColors() const override;
139
140   /**
141    * @copydoc ModelInterface::GetBackgroundColorIndices()
142    */
143   const ColorIndex* const GetBackgroundColorIndices() const override;
144
145   /**
146    * @copydoc ModelInterface::GetDefaultColor()
147    */
148   const Vector4& GetDefaultColor() const override;
149
150   /**
151    * @copydoc ModelInterface::GetShadowOffset()
152    */
153   const Vector2& GetShadowOffset() const override;
154
155   /**
156    * @copydoc ModelInterface::GetShadowColor()
157    */
158   const Vector4& GetShadowColor() const override;
159
160   /**
161    * @copydoc ModelInterface::GetShadowBlurRadius()
162    */
163   const float& GetShadowBlurRadius() const override;
164
165   /**
166    * @copydoc ModelInterface::GetUnderlineColor()
167    */
168   const Vector4& GetUnderlineColor() const override;
169
170   /**
171    * @copydoc ModelInterface::IsUnderlineEnabled()
172    */
173   bool IsUnderlineEnabled() const override;
174
175   /**
176    * @copydoc ModelInterface::GetUnderlineHeight()
177    */
178   float GetUnderlineHeight() const override;
179
180   /**
181    * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
182    */
183   Length GetNumberOfUnderlineRuns() const override;
184
185   /**
186    * @copydoc ModelInterface::GetUnderlineRuns()
187    */
188   void GetUnderlineRuns(GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const override;
189
190   /**
191    * @copydoc ModelInterface::GetOutlineColor()
192    */
193   const Vector4& GetOutlineColor() const override;
194
195   /**
196    * @copydoc ModelInterface::GetOutlineWidth()
197    */
198   uint16_t GetOutlineWidth() const override;
199
200   /**
201    * @copydoc ModelInterface::GetBackgroundColor()
202    */
203   const Vector4& GetBackgroundColor() const override;
204
205   /**
206    * @copydoc ModelInterface::IsBackgroundEnabled()
207    */
208   bool IsBackgroundEnabled() const override;
209
210 private: // Private contructors & copy operator.
211   /**
212    * @brief Private constructor.
213    */
214   Model();
215
216   // Undefined.
217   Model(const Model& handle);
218
219   // Undefined.
220   Model& operator=(const Model& handle);
221
222 protected:
223   /**
224    * @brief A reference counted object may only be deleted by calling Unreference().
225    */
226   virtual ~Model();
227
228 public:
229   LogicalModelPtr mLogicalModel; ///< Pointer to the logical model.
230   VisualModelPtr  mVisualModel;  ///< Pointer to the visual model.
231   /**
232    * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
233    * Typically this will have a negative value with scrolling occurs.
234    */
235   Vector2                                mScrollPosition;                   ///< The text is offset by this position when scrolling.
236   Vector2                                mScrollPositionLast;               ///< The last offset value of mScrollPosition
237   HorizontalAlignment::Type              mHorizontalAlignment;              ///< The layout's horizontal alignment.
238   VerticalAlignment::Type                mVerticalAlignment;                ///< The layout's vertical alignment.
239   DevelText::VerticalLineAlignment::Type mVerticalLineAlignment;            ///< The layout's vertical line alignment.
240   Text::LineWrap::Mode                   mLineWrapMode;                     ///< The text wrap mode
241   float                                  mAlignmentOffset;                  ///< The alignment offset.
242   bool                                   mElideEnabled : 1;                 ///< Whether the text's elide is enabled.
243   bool                                   mIgnoreSpacesAfterText : 1;        ///< Whether ignoring spaces after text or not. Default is true.
244   bool                                   mMatchSystemLanguageDirection : 1; ///< Whether match align for system language direction or not. Default is false.
245 };
246
247 } // namespace Text
248
249 } // namespace Toolkit
250
251 } // namespace Dali
252
253 #endif // DALI_TOOLKIT_TEXT_MODEL_H