1 #ifndef DALI_TOOLKIT_TEXT_MODEL_H
2 #define DALI_TOOLKIT_TEXT_MODEL_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/object/ref-object.h>
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>
36 // Forward declarations.
39 typedef IntrusivePtr<Model> ModelPtr;
42 * @brief Implementation class used to retrieve the text's model from the text-controller.
44 class Model : public RefObject, public ModelInterface
46 public: // Constructor.
48 * @brief Create a new instance of a text Model.
50 * @return A pointer to a new text Model.
52 static ModelPtr New();
56 * @copydoc ModelInterface::GetControlSize()
58 const Size& GetControlSize() const override;
61 * @copydoc ModelInterface::GetLayoutSize()
63 const Size& GetLayoutSize() const override;
66 * @copydoc ModelInterface::GetScrollPosition()
68 const Vector2& GetScrollPosition() const override;
71 * @copydoc ModelInterface::GetHorizontalAlignment()
73 HorizontalAlignment::Type GetHorizontalAlignment() const override;
76 * @copydoc ModelInterface::GetVerticalAlignment()
78 VerticalAlignment::Type GetVerticalAlignment() const override;
81 * @copydoc ModelInterface::GetVerticalLineAlignment()
83 DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const override;
86 * @copydoc ModelInterface::IsTextElideEnabled()
88 bool IsTextElideEnabled() const override;
91 * @copydoc ModelInterface::GetNumberOfLines()
93 Length GetNumberOfLines() const override;
96 * @copydoc ModelInterface::GetLines()
98 const LineRun* const GetLines() const override;
101 * @copydoc ModelInterface::GetNumberOfScripts()
103 Length GetNumberOfScripts() const override;
106 * @copydoc ModelInterface::GetScriptRuns()
108 const ScriptRun* const GetScriptRuns() const override;
111 * @copydoc ModelInterface::GetNumberOfGlyphs()
113 Length GetNumberOfGlyphs() const override;
116 * @copydoc ModelInterface::GetGlyphs()
118 const GlyphInfo* const GetGlyphs() const override;
121 * @copydoc ModelInterface::GetLayout()
123 const Vector2* const GetLayout() const override;
126 * @copydoc ModelInterface::GetColors()
128 const Vector4* const GetColors() const override;
131 * @copydoc ModelInterface::GetColorIndices()
133 const ColorIndex* const GetColorIndices() const override;
136 * @copydoc ModelInterface::GetBackgroundColors()
138 const Vector4* const GetBackgroundColors() const override;
141 * @copydoc ModelInterface::GetBackgroundColorIndices()
143 const ColorIndex* const GetBackgroundColorIndices() const override;
146 * @copydoc ModelInterface::GetDefaultColor()
148 const Vector4& GetDefaultColor() const override;
151 * @copydoc ModelInterface::GetShadowOffset()
153 const Vector2& GetShadowOffset() const override;
156 * @copydoc ModelInterface::GetShadowColor()
158 const Vector4& GetShadowColor() const override;
161 * @copydoc ModelInterface::GetShadowBlurRadius()
163 const float& GetShadowBlurRadius() const override;
166 * @copydoc ModelInterface::GetUnderlineColor()
168 const Vector4& GetUnderlineColor() const override;
171 * @copydoc ModelInterface::IsUnderlineEnabled()
173 bool IsUnderlineEnabled() const override;
176 * @copydoc ModelInterface::GetUnderlineHeight()
178 float GetUnderlineHeight() const override;
181 * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
183 Length GetNumberOfUnderlineRuns() const override;
186 * @copydoc ModelInterface::GetUnderlineRuns()
188 void GetUnderlineRuns(GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const override;
191 * @copydoc ModelInterface::GetOutlineColor()
193 const Vector4& GetOutlineColor() const override;
196 * @copydoc ModelInterface::GetOutlineWidth()
198 uint16_t GetOutlineWidth() const override;
201 * @copydoc ModelInterface::GetBackgroundColor()
203 const Vector4& GetBackgroundColor() const override;
206 * @copydoc ModelInterface::IsBackgroundEnabled()
208 bool IsBackgroundEnabled() const override;
211 * @copydoc ModelInterface::IsMarkupProcessorEnabled()
213 bool IsMarkupProcessorEnabled() const override;
215 private: // Private contructors & copy operator.
217 * @brief Private constructor.
222 Model(const Model& handle);
225 Model& operator=(const Model& handle);
229 * @brief A reference counted object may only be deleted by calling Unreference().
234 LogicalModelPtr mLogicalModel; ///< Pointer to the logical model.
235 VisualModelPtr mVisualModel; ///< Pointer to the visual model.
237 * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
238 * Typically this will have a negative value with scrolling occurs.
240 Vector2 mScrollPosition; ///< The text is offset by this position when scrolling.
241 Vector2 mScrollPositionLast; ///< The last offset value of mScrollPosition
242 HorizontalAlignment::Type mHorizontalAlignment; ///< The layout's horizontal alignment.
243 VerticalAlignment::Type mVerticalAlignment; ///< The layout's vertical alignment.
244 DevelText::VerticalLineAlignment::Type mVerticalLineAlignment; ///< The layout's vertical line alignment.
245 Text::LineWrap::Mode mLineWrapMode; ///< The text wrap mode
246 float mAlignmentOffset; ///< The alignment offset.
247 bool mElideEnabled : 1; ///< Whether the text's elide is enabled.
248 bool mIgnoreSpacesAfterText : 1; ///< Whether ignoring spaces after text or not. Default is true.
249 bool mMatchSystemLanguageDirection : 1; ///< Whether match align for system language direction or not. Default is false.
254 } // namespace Toolkit
258 #endif // DALI_TOOLKIT_TEXT_MODEL_H