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