1 #ifndef DALI_TOOLKIT_TEXT_MODEL_H
2 #define DALI_TOOLKIT_TEXT_MODEL_H
5 * Copyright (c) 2022 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/bounded-paragraph-run.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 #include <dali-toolkit/public-api/text/text-enumerations.h>
37 // Forward declarations.
40 typedef IntrusivePtr<Model> ModelPtr;
43 * @brief Implementation class used to retrieve the text's model from the text-controller.
45 class Model : public RefObject, public ModelInterface
47 public: // Constructor.
49 * @brief Create a new instance of a text Model.
51 * @return A pointer to a new text Model.
53 static ModelPtr New();
57 * @copydoc ModelInterface::GetControlSize()
59 const Size& GetControlSize() const override;
62 * @copydoc ModelInterface::GetLayoutSize()
64 const Size& GetLayoutSize() const override;
67 * @copydoc ModelInterface::GetScrollPosition()
69 const Vector2& GetScrollPosition() const override;
72 * @copydoc ModelInterface::GetHorizontalAlignment()
74 HorizontalAlignment::Type GetHorizontalAlignment() const override;
77 * @copydoc ModelInterface::GetVerticalAlignment()
79 VerticalAlignment::Type GetVerticalAlignment() const override;
82 * @copydoc ModelInterface::GetVerticalLineAlignment()
84 DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const override;
87 * @copydoc ModelInterface::GetEllipsisPosition()
89 DevelText::EllipsisPosition::Type GetEllipsisPosition() const override;
92 * @copydoc ModelInterface::IsTextElideEnabled()
94 bool IsTextElideEnabled() const override;
97 * @copydoc ModelInterface::GetNumberOfLines()
99 Length GetNumberOfLines() const override;
102 * @copydoc ModelInterface::GetLines()
104 const LineRun* const GetLines() const override;
107 * @copydoc ModelInterface::GetNumberOfScripts()
109 Length GetNumberOfScripts() const override;
112 * @copydoc ModelInterface::GetScriptRuns()
114 const ScriptRun* const GetScriptRuns() const override;
117 * @copydoc ModelInterface::GetNumberOfGlyphs()
119 Length GetNumberOfGlyphs() const override;
122 * @copydoc ModelInterface::GetStartIndexOfElidedGlyphs()
124 GlyphIndex GetStartIndexOfElidedGlyphs() const override;
127 * @copydoc ModelInterface::GetEndIndexOfElidedGlyphs()
129 GlyphIndex GetEndIndexOfElidedGlyphs() const override;
132 * @copydoc ModelInterface::GetFirstMiddleIndexOfElidedGlyphs()
134 GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const override;
137 * @copydoc ModelInterface::GetSecondMiddleIndexOfElidedGlyphs()
139 GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const override;
142 * @copydoc ModelInterface::GetGlyphs()
144 const GlyphInfo* const GetGlyphs() const override;
147 * @copydoc ModelInterface::GetLayout()
149 const Vector2* const GetLayout() const override;
152 * @copydoc ModelInterface::GetColors()
154 const Vector4* const GetColors() const override;
157 * @copydoc ModelInterface::GetColorIndices()
159 const ColorIndex* const GetColorIndices() const override;
162 * @copydoc ModelInterface::GetBackgroundColors()
164 const Vector4* const GetBackgroundColors() const override;
167 * @copydoc ModelInterface::GetBackgroundColorIndices()
169 const ColorIndex* const GetBackgroundColorIndices() const override;
172 * @copydoc ModelInterface::IsMarkupBackgroundColorSet()
174 bool const IsMarkupBackgroundColorSet() const override;
177 * @copydoc ModelInterface::GetDefaultColor()
179 const Vector4& GetDefaultColor() const override;
182 * @copydoc ModelInterface::GetShadowOffset()
184 const Vector2& GetShadowOffset() const override;
187 * @copydoc ModelInterface::GetShadowColor()
189 const Vector4& GetShadowColor() const override;
192 * @copydoc ModelInterface::GetShadowBlurRadius()
194 const float& GetShadowBlurRadius() const override;
197 * @copydoc ModelInterface::GetUnderlineColor()
199 const Vector4& GetUnderlineColor() const override;
202 * @copydoc ModelInterface::IsUnderlineEnabled()
204 bool IsUnderlineEnabled() const override;
207 * @copydoc ModelInterface::GetUnderlineHeight()
209 float GetUnderlineHeight() const override;
212 * @copydoc ModelInterface::GetUnderlineType()
214 Text::Underline::Type GetUnderlineType() const override;
217 * @copydoc ModelInterface::GetDashedUnderlineWidth()
219 float GetDashedUnderlineWidth() const override;
222 * @copydoc ModelInterface::GetDashedUnderlineGap()
224 float GetDashedUnderlineGap() const override;
227 * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
229 Length GetNumberOfUnderlineRuns() const override;
232 * @copydoc ModelInterface::GetUnderlineRuns()
234 void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const override;
237 * @copydoc ModelInterface::GetOutlineColor()
239 const Vector4& GetOutlineColor() const override;
242 * @copydoc ModelInterface::GetOutlineWidth()
244 uint16_t GetOutlineWidth() const override;
247 * @copydoc ModelInterface::GetBackgroundColor()
249 const Vector4& GetBackgroundColor() const override;
252 * @copydoc ModelInterface::IsBackgroundEnabled()
254 bool IsBackgroundEnabled() const override;
257 * @copydoc ModelInterface::IsMarkupProcessorEnabled()
259 bool IsMarkupProcessorEnabled() const override;
262 * @copydoc ModelInterface::GetHyphens()
264 const GlyphInfo* GetHyphens() const override;
267 * @copydoc ModelInterface::GetHyphens()
269 const Length* GetHyphenIndices() const override;
272 * @copydoc ModelInterface::GetHyphens()
274 Length GetHyphensCount() const override;
276 float GetStrikethroughHeight() const override;
278 const Vector4& GetStrikethroughColor() const override;
280 bool IsStrikethroughEnabled() const override;
282 * @copydoc ModelInterface::GetCharacterSpacing()
284 const float GetCharacterSpacing() const override;
287 * @copydoc ModelInterface::GetTextBuffer()
289 const Character* GetTextBuffer() const override;
292 * @copydoc ModelInterface::GetGlyphsToCharacters()
294 const Vector<CharacterIndex>& GetGlyphsToCharacters() const override;
297 * @copydoc ModelInterface::GetNumberOfStrikethroughRuns()
299 Length GetNumberOfStrikethroughRuns() const override;
302 * @copydoc ModelInterface::GetStrikethroughRuns()
304 void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, StrikethroughRunIndex index, Length numberOfRuns) const override;
307 * @copydoc ModelInterface::GetNumberOfBoundedParagraphRuns()
309 virtual Length GetNumberOfBoundedParagraphRuns() const override;
312 * @copydoc ModelInterface::GetBoundedParagraphRuns()
314 virtual const Vector<BoundedParagraphRun>& GetBoundedParagraphRuns() const override;
316 private: // Private contructors & copy operator.
318 * @brief Private constructor.
323 Model(const Model& handle);
326 Model& operator=(const Model& handle);
330 * @brief A reference counted object may only be deleted by calling Unreference().
335 LogicalModelPtr mLogicalModel; ///< Pointer to the logical model.
336 VisualModelPtr mVisualModel; ///< Pointer to the visual model.
338 * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
339 * Typically this will have a negative value with scrolling occurs.
341 Vector2 mScrollPosition; ///< The text is offset by this position when scrolling.
342 Vector2 mScrollPositionLast; ///< The last offset value of mScrollPosition
343 HorizontalAlignment::Type mHorizontalAlignment; ///< The layout's horizontal alignment.
344 VerticalAlignment::Type mVerticalAlignment; ///< The layout's vertical alignment.
345 DevelText::VerticalLineAlignment::Type mVerticalLineAlignment; ///< The layout's vertical line alignment.
346 Text::LineWrap::Mode mLineWrapMode; ///< The text wrap mode
347 float mAlignmentOffset; ///< The alignment offset.
348 bool mElideEnabled : 1; ///< Whether the text's elide is enabled.
349 bool mIgnoreSpacesAfterText : 1; ///< Whether ignoring spaces after text or not. Default is true.
350 DevelText::MatchLayoutDirection mMatchLayoutDirection; ///< Whether to match text alignment with layout direction or not.
351 DevelText::EllipsisPosition::Type mEllipsisPosition; ///< Where is the location the text elide
356 } // namespace Toolkit
360 #endif // DALI_TOOLKIT_TEXT_MODEL_H