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/character-spacing-glyph-run.h>
27 #include <dali-toolkit/internal/text/logical-model-impl.h>
28 #include <dali-toolkit/internal/text/text-model-interface.h>
29 #include <dali-toolkit/internal/text/visual-model-impl.h>
30 #include <dali-toolkit/public-api/text/text-enumerations.h>
38 // Forward declarations.
41 typedef IntrusivePtr<Model> ModelPtr;
44 * @brief Implementation class used to retrieve the text's model from the text-controller.
46 class Model : public RefObject, public ModelInterface
48 public: // Constructor.
50 * @brief Create a new instance of a text Model.
52 * @return A pointer to a new text Model.
54 static ModelPtr New();
58 * @copydoc ModelInterface::GetControlSize()
60 const Size& GetControlSize() const override;
63 * @copydoc ModelInterface::GetLayoutSize()
65 const Size& GetLayoutSize() const override;
68 * @copydoc ModelInterface::GetScrollPosition()
70 const Vector2& GetScrollPosition() const override;
73 * @copydoc ModelInterface::GetHorizontalAlignment()
75 HorizontalAlignment::Type GetHorizontalAlignment() const override;
78 * @copydoc ModelInterface::GetVerticalAlignment()
80 VerticalAlignment::Type GetVerticalAlignment() const override;
83 * @copydoc ModelInterface::GetVerticalLineAlignment()
85 DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const override;
88 * @copydoc ModelInterface::GetEllipsisPosition()
90 DevelText::EllipsisPosition::Type GetEllipsisPosition() const override;
93 * @copydoc ModelInterface::IsTextElideEnabled()
95 bool IsTextElideEnabled() const override;
98 * @copydoc ModelInterface::GetNumberOfLines()
100 Length GetNumberOfLines() const override;
103 * @copydoc ModelInterface::GetLines()
105 const LineRun* const GetLines() const override;
108 * @copydoc ModelInterface::GetNumberOfScripts()
110 Length GetNumberOfScripts() const override;
113 * @copydoc ModelInterface::GetScriptRuns()
115 const ScriptRun* const GetScriptRuns() const override;
118 * @copydoc ModelInterface::GetNumberOfGlyphs()
120 Length GetNumberOfGlyphs() const override;
123 * @copydoc ModelInterface::GetStartIndexOfElidedGlyphs()
125 GlyphIndex GetStartIndexOfElidedGlyphs() const override;
128 * @copydoc ModelInterface::GetEndIndexOfElidedGlyphs()
130 GlyphIndex GetEndIndexOfElidedGlyphs() const override;
133 * @copydoc ModelInterface::GetFirstMiddleIndexOfElidedGlyphs()
135 GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const override;
138 * @copydoc ModelInterface::GetSecondMiddleIndexOfElidedGlyphs()
140 GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const override;
143 * @copydoc ModelInterface::GetGlyphs()
145 const GlyphInfo* const GetGlyphs() const override;
148 * @copydoc ModelInterface::GetLayout()
150 const Vector2* const GetLayout() const override;
153 * @copydoc ModelInterface::GetColors()
155 const Vector4* const GetColors() const override;
158 * @copydoc ModelInterface::GetColorIndices()
160 const ColorIndex* const GetColorIndices() const override;
163 * @copydoc ModelInterface::GetBackgroundColors()
165 const Vector4* const GetBackgroundColors() const override;
168 * @copydoc ModelInterface::GetBackgroundColorIndices()
170 const ColorIndex* const GetBackgroundColorIndices() const override;
173 * @copydoc ModelInterface::IsMarkupBackgroundColorSet()
175 bool const IsMarkupBackgroundColorSet() const override;
178 * @copydoc ModelInterface::GetDefaultColor()
180 const Vector4& GetDefaultColor() const override;
183 * @copydoc ModelInterface::GetShadowOffset()
185 const Vector2& GetShadowOffset() const override;
188 * @copydoc ModelInterface::GetShadowColor()
190 const Vector4& GetShadowColor() const override;
193 * @copydoc ModelInterface::GetShadowBlurRadius()
195 const float& GetShadowBlurRadius() const override;
198 * @copydoc ModelInterface::GetUnderlineColor()
200 const Vector4& GetUnderlineColor() const override;
203 * @copydoc ModelInterface::IsUnderlineEnabled()
205 bool IsUnderlineEnabled() const override;
208 * @copydoc ModelInterface::IsMarkupUnderlineSet()
210 bool const IsMarkupUnderlineSet() const override;
213 * @copydoc ModelInterface::GetUnderlineHeight()
215 float GetUnderlineHeight() const override;
218 * @copydoc ModelInterface::GetUnderlineType()
220 Text::Underline::Type GetUnderlineType() const override;
223 * @copydoc ModelInterface::GetDashedUnderlineWidth()
225 float GetDashedUnderlineWidth() const override;
228 * @copydoc ModelInterface::GetDashedUnderlineGap()
230 float GetDashedUnderlineGap() const override;
233 * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
235 Length GetNumberOfUnderlineRuns() const override;
238 * @copydoc ModelInterface::GetUnderlineRuns()
240 void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const override;
243 * @copydoc ModelInterface::GetOutlineColor()
245 const Vector4& GetOutlineColor() const override;
248 * @copydoc ModelInterface::GetOutlineWidth()
250 uint16_t GetOutlineWidth() const override;
253 * @copydoc ModelInterface::GetBackgroundColor()
255 const Vector4& GetBackgroundColor() const override;
258 * @copydoc ModelInterface::IsBackgroundEnabled()
260 bool IsBackgroundEnabled() const override;
263 * @copydoc ModelInterface::IsMarkupProcessorEnabled()
265 bool IsMarkupProcessorEnabled() const override;
268 * @copydoc ModelInterface::GetHyphens()
270 const GlyphInfo* GetHyphens() const override;
273 * @copydoc ModelInterface::GetHyphens()
275 const Length* GetHyphenIndices() const override;
278 * @copydoc ModelInterface::GetHyphens()
280 Length GetHyphensCount() const override;
283 * @copydoc ModelInterface::GetStrikethroughHeight()
285 float GetStrikethroughHeight() const override;
288 * @copydoc ModelInterface::GetStrikethroughColor()
290 const Vector4& GetStrikethroughColor() const override;
293 * @copydoc ModelInterface::IsStrikethroughEnabled()
295 bool IsStrikethroughEnabled() const override;
298 * @copydoc ModelInterface::IsMarkupStrikethroughSet()
300 bool const IsMarkupStrikethroughSet() const override;
303 * @copydoc ModelInterface::GetCharacterSpacing()
305 const float GetCharacterSpacing() const override;
308 * @copydoc ModelInterface::GetTextBuffer()
310 const Character* GetTextBuffer() const override;
313 * @copydoc ModelInterface::GetGlyphsToCharacters()
315 const Vector<CharacterIndex>& GetGlyphsToCharacters() const override;
318 * @copydoc ModelInterface::GetNumberOfStrikethroughRuns()
320 Length GetNumberOfStrikethroughRuns() const override;
323 * @copydoc ModelInterface::GetStrikethroughRuns()
325 void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, StrikethroughRunIndex index, Length numberOfRuns) const override;
328 * @copydoc ModelInterface::GetNumberOfBoundedParagraphRuns()
330 virtual Length GetNumberOfBoundedParagraphRuns() const override;
333 * @copydoc ModelInterface::GetBoundedParagraphRuns()
335 virtual const Vector<BoundedParagraphRun>& GetBoundedParagraphRuns() const override;
338 * @copydoc ModelInterface::GetNumberOfCharacterSpacingGlyphRuns()
340 Length GetNumberOfCharacterSpacingGlyphRuns() const override;
343 * @copydoc ModelInterface::GetCharacterSpacingGlyphRuns()
345 const Vector<CharacterSpacingGlyphRun>& GetCharacterSpacingGlyphRuns() const override;
347 private: // Private contructors & copy operator.
349 * @brief Private constructor.
354 Model(const Model& handle);
357 Model& operator=(const Model& handle);
361 * @brief A reference counted object may only be deleted by calling Unreference().
366 LogicalModelPtr mLogicalModel; ///< Pointer to the logical model.
367 VisualModelPtr mVisualModel; ///< Pointer to the visual model.
369 * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
370 * Typically this will have a negative value with scrolling occurs.
372 Vector2 mScrollPosition; ///< The text is offset by this position when scrolling.
373 Vector2 mScrollPositionLast; ///< The last offset value of mScrollPosition
374 HorizontalAlignment::Type mHorizontalAlignment; ///< The layout's horizontal alignment.
375 VerticalAlignment::Type mVerticalAlignment; ///< The layout's vertical alignment.
376 DevelText::VerticalLineAlignment::Type mVerticalLineAlignment; ///< The layout's vertical line alignment.
377 Text::LineWrap::Mode mLineWrapMode; ///< The text wrap mode
378 float mAlignmentOffset; ///< The alignment offset.
379 bool mElideEnabled : 1; ///< Whether the text's elide is enabled.
380 bool mIgnoreSpacesAfterText : 1; ///< Whether ignoring spaces after text or not. Default is true.
381 DevelText::MatchLayoutDirection mMatchLayoutDirection; ///< Whether to match text alignment with layout direction or not.
382 DevelText::EllipsisPosition::Type mEllipsisPosition; ///< Where is the location the text elide
387 } // namespace Toolkit
391 #endif // DALI_TOOLKIT_TEXT_MODEL_H