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::GetEllipsisPosition()
88 DevelText::EllipsisPosition::Type GetEllipsisPosition() const override;
91 * @copydoc ModelInterface::IsTextElideEnabled()
93 bool IsTextElideEnabled() const override;
96 * @copydoc ModelInterface::GetNumberOfLines()
98 Length GetNumberOfLines() const override;
101 * @copydoc ModelInterface::GetLines()
103 const LineRun* const GetLines() const override;
106 * @copydoc ModelInterface::GetNumberOfScripts()
108 Length GetNumberOfScripts() const override;
111 * @copydoc ModelInterface::GetScriptRuns()
113 const ScriptRun* const GetScriptRuns() const override;
116 * @copydoc ModelInterface::GetNumberOfGlyphs()
118 Length GetNumberOfGlyphs() const override;
121 * @copydoc ModelInterface::GetStartIndexOfElidedGlyphs()
123 GlyphIndex GetStartIndexOfElidedGlyphs() const override;
126 * @copydoc ModelInterface::GetEndIndexOfElidedGlyphs()
128 GlyphIndex GetEndIndexOfElidedGlyphs() const override;
131 * @copydoc ModelInterface::GetFirstMiddleIndexOfElidedGlyphs()
133 GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const override;
136 * @copydoc ModelInterface::GetSecondMiddleIndexOfElidedGlyphs()
138 GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const override;
141 * @copydoc ModelInterface::GetGlyphs()
143 const GlyphInfo* const GetGlyphs() const override;
146 * @copydoc ModelInterface::GetLayout()
148 const Vector2* const GetLayout() const override;
151 * @copydoc ModelInterface::GetColors()
153 const Vector4* const GetColors() const override;
156 * @copydoc ModelInterface::GetColorIndices()
158 const ColorIndex* const GetColorIndices() const override;
161 * @copydoc ModelInterface::GetBackgroundColors()
163 const Vector4* const GetBackgroundColors() const override;
166 * @copydoc ModelInterface::GetBackgroundColorIndices()
168 const ColorIndex* const GetBackgroundColorIndices() const override;
171 * @copydoc ModelInterface::IsMarkupBackgroundColorSet()
173 bool const IsMarkupBackgroundColorSet() const override;
176 * @copydoc ModelInterface::GetDefaultColor()
178 const Vector4& GetDefaultColor() const override;
181 * @copydoc ModelInterface::GetShadowOffset()
183 const Vector2& GetShadowOffset() const override;
186 * @copydoc ModelInterface::GetShadowColor()
188 const Vector4& GetShadowColor() const override;
191 * @copydoc ModelInterface::GetShadowBlurRadius()
193 const float& GetShadowBlurRadius() const override;
196 * @copydoc ModelInterface::GetUnderlineColor()
198 const Vector4& GetUnderlineColor() const override;
201 * @copydoc ModelInterface::IsUnderlineEnabled()
203 bool IsUnderlineEnabled() const override;
206 * @copydoc ModelInterface::GetUnderlineHeight()
208 float GetUnderlineHeight() const override;
211 * @copydoc ModelInterface::GetUnderlineType()
213 Text::Underline::Type GetUnderlineType() const override;
216 * @copydoc ModelInterface::GetDashedUnderlineWidth()
218 float GetDashedUnderlineWidth() const override;
221 * @copydoc ModelInterface::GetDashedUnderlineGap()
223 float GetDashedUnderlineGap() const override;
226 * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
228 Length GetNumberOfUnderlineRuns() const override;
231 * @copydoc ModelInterface::GetUnderlineRuns()
233 void GetUnderlineRuns(GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const override;
236 * @copydoc ModelInterface::GetOutlineColor()
238 const Vector4& GetOutlineColor() const override;
241 * @copydoc ModelInterface::GetOutlineWidth()
243 uint16_t GetOutlineWidth() const override;
246 * @copydoc ModelInterface::GetBackgroundColor()
248 const Vector4& GetBackgroundColor() const override;
251 * @copydoc ModelInterface::IsBackgroundEnabled()
253 bool IsBackgroundEnabled() const override;
256 * @copydoc ModelInterface::IsMarkupProcessorEnabled()
258 bool IsMarkupProcessorEnabled() const override;
261 * @copydoc ModelInterface::GetHyphens()
263 const GlyphInfo* GetHyphens() const override;
266 * @copydoc ModelInterface::GetHyphens()
268 const Length* GetHyphenIndices() const override;
271 * @copydoc ModelInterface::GetHyphens()
273 Length GetHyphensCount() const override;
275 float GetStrikethroughHeight() const override;
277 const Vector4& GetStrikethroughColor() const override;
279 bool IsStrikethroughEnabled() const override;
281 private: // Private contructors & copy operator.
283 * @brief Private constructor.
288 Model(const Model& handle);
291 Model& operator=(const Model& handle);
295 * @brief A reference counted object may only be deleted by calling Unreference().
300 LogicalModelPtr mLogicalModel; ///< Pointer to the logical model.
301 VisualModelPtr mVisualModel; ///< Pointer to the visual model.
303 * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
304 * Typically this will have a negative value with scrolling occurs.
306 Vector2 mScrollPosition; ///< The text is offset by this position when scrolling.
307 Vector2 mScrollPositionLast; ///< The last offset value of mScrollPosition
308 HorizontalAlignment::Type mHorizontalAlignment; ///< The layout's horizontal alignment.
309 VerticalAlignment::Type mVerticalAlignment; ///< The layout's vertical alignment.
310 DevelText::VerticalLineAlignment::Type mVerticalLineAlignment; ///< The layout's vertical line alignment.
311 Text::LineWrap::Mode mLineWrapMode; ///< The text wrap mode
312 float mAlignmentOffset; ///< The alignment offset.
313 bool mElideEnabled : 1; ///< Whether the text's elide is enabled.
314 bool mIgnoreSpacesAfterText : 1; ///< Whether ignoring spaces after text or not. Default is true.
315 DevelText::MatchLayoutDirection mMatchLayoutDirection; ///< Whether to match text alignment with layout direction or not.
316 DevelText::EllipsisPosition::Type mEllipsisPosition; ///< Where is the location the text elide
321 } // namespace Toolkit
325 #endif // DALI_TOOLKIT_TEXT_MODEL_H