1 #ifndef DALI_TOOLKIT_TEXT_VIEW_MODEL_H
2 #define DALI_TOOLKIT_TEXT_VIEW_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/common/dali-vector.h>
25 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
26 #include <dali-toolkit/internal/text/bounded-paragraph-run.h>
27 #include <dali-toolkit/internal/text/text-model-interface.h>
28 #include <dali-toolkit/public-api/text/text-enumerations.h>
37 * @brief Responsible of creating and store temporary modifications of the text model.
38 * i.e. The elide of text.
40 class ViewModel : public ModelInterface
46 * Keeps the pointer to the text's model. It initializes all the members of the class to their defaults.
48 * @param[in] model Pointer to the text's model interface.
50 ViewModel(const ModelInterface* const model);
53 * @brief Virtual destructor.
55 * It's a default destructor.
60 * @copydoc ModelInterface::GetControlSize()
62 const Size& GetControlSize() const override;
65 * @copydoc ModelInterface::GetLayoutSize()
67 const Size& GetLayoutSize() const override;
70 * @copydoc ModelInterface::GetScrollPosition()
72 const Vector2& GetScrollPosition() const override;
75 * @copydoc ModelInterface::GetHorizontalAlignment()
77 Text::HorizontalAlignment::Type GetHorizontalAlignment() const override;
80 * @copydoc ModelInterface::GetVerticalAlignment()
82 Text::VerticalAlignment::Type GetVerticalAlignment() const override;
85 * @copydoc ModelInterface::GetVerticalLineAlignment()
87 DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const override;
90 * @copydoc ModelInterface::GetEllipsisPosition()
92 DevelText::EllipsisPosition::Type GetEllipsisPosition() const override;
95 * @copydoc ModelInterface::IsTextElideEnabled()
97 bool IsTextElideEnabled() const override;
100 * @copydoc ModelInterface::GetNumberOfLines()
102 Length GetNumberOfLines() const override;
105 * @copydoc ModelInterface::GetLines()
107 const LineRun* const GetLines() const override;
110 * @copydoc ModelInterface::GetNumberOfScripts()
112 Length GetNumberOfScripts() const override;
115 * @copydoc ModelInterface::GetScriptRuns()
117 const ScriptRun* const GetScriptRuns() const override;
120 * @copydoc ModelInterface::GetNumberOfGlyphs()
122 Length GetNumberOfGlyphs() const override;
125 * @copydoc ModelInterface::GetStartIndexOfElidedGlyphs()
127 GlyphIndex GetStartIndexOfElidedGlyphs() const override;
130 * @copydoc ModelInterface::GetEndIndexOfElidedGlyphs()
132 GlyphIndex GetEndIndexOfElidedGlyphs() const override;
135 * @copydoc ModelInterface::GetFirstMiddleIndexOfElidedGlyphs()
137 GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const override;
140 * @copydoc ModelInterface::GetSecondMiddleIndexOfElidedGlyphs()
142 GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const override;
145 * @copydoc ModelInterface::GetGlyphs()
147 const GlyphInfo* const GetGlyphs() const override;
150 * @copydoc ModelInterface::GetLayout()
152 const Vector2* const GetLayout() const override;
155 * @copydoc ModelInterface::GetColors()
157 const Vector4* const GetColors() const override;
160 * @copydoc ModelInterface::GetColorIndices()
162 const ColorIndex* const GetColorIndices() const override;
165 * @copydoc ModelInterface::GetBackgroundColors()
167 const Vector4* const GetBackgroundColors() const override;
170 * @copydoc ModelInterface::GetBackgroundColorIndices()
172 const ColorIndex* const GetBackgroundColorIndices() const override;
175 * @copydoc ModelInterface::IsMarkupBackgroundColorSet()
177 bool const IsMarkupBackgroundColorSet() const override;
180 * @copydoc ModelInterface::GetDefaultColor()
182 const Vector4& GetDefaultColor() const override;
185 * @copydoc ModelInterface::GetShadowOffset()
187 const Vector2& GetShadowOffset() const override;
190 * @copydoc ModelInterface::GetShadowColor()
192 const Vector4& GetShadowColor() const override;
195 * @copydoc ModelInterface::GetShadowBlurRadius()
197 const float& GetShadowBlurRadius() const override;
200 * @copydoc ModelInterface::GetUnderlineColor()
202 const Vector4& GetUnderlineColor() const override;
205 * @copydoc ModelInterface::IsUnderlineEnabled()
207 bool IsUnderlineEnabled() const override;
210 * @copydoc ModelInterface::IsMarkupUnderlineSet()
212 bool const IsMarkupUnderlineSet() const override;
215 * @copydoc ModelInterface::GetUnderlineHeight()
217 float GetUnderlineHeight() const override;
220 * @copydoc ModelInterface::GetUnderlineType()
222 Text::Underline::Type GetUnderlineType() const override;
225 * @copydoc ModelInterface::GetDashedUnderlineWidth()
227 float GetDashedUnderlineWidth() const override;
230 * @copydoc ModelInterface::GetDashedUnderlineGap()
232 float GetDashedUnderlineGap() const override;
235 * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
237 Length GetNumberOfUnderlineRuns() const override;
240 * @copydoc ModelInterface::GetUnderlineRuns()
242 void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const override;
245 * @copydoc ModelInterface::GetOutlineColor()
247 const Vector4& GetOutlineColor() const override;
250 * @copydoc ModelInterface::GetOutlineWidth()
252 uint16_t GetOutlineWidth() const override;
255 * @copydoc ModelInterface::GetBackgroundColor()
257 const Vector4& GetBackgroundColor() const override;
260 * @copydoc ModelInterface::IsBackgroundEnabled()
262 bool IsBackgroundEnabled() const override;
265 * @copydoc ModelInterface::IsMarkupProcessorEnabled()
267 bool IsMarkupProcessorEnabled() const override;
270 * @copydoc ModelInterface::IsSpannedTextPlaced()
272 bool IsSpannedTextPlaced() const override;
275 * @copydoc ModelInterface::GetHyphens()
277 const GlyphInfo* GetHyphens() const override;
280 * @copydoc ModelInterface::GetHyphens()
282 const Length* GetHyphenIndices() const override;
285 * @copydoc ModelInterface::GetHyphens()
287 Length GetHyphensCount() const override;
290 * @copydoc ModelInterface::GetCharacterSpacing()
292 const float GetCharacterSpacing() const override;
295 * @copydoc ModelInterface::GetTextBuffer()
297 const Character* GetTextBuffer() const override;
300 * @copydoc ModelInterface::GetGlyphsToCharacters()
302 const Vector<CharacterIndex>& GetGlyphsToCharacters() const override;
305 * @brief Does the text elide at the end, start or middle of text according to ellipsis position
307 * It stores a copy of the visible glyphs and removes as many glyphs as needed
308 * from the last visible line to add the ellipsis glyph in END case,
309 * from the first visible line to add the ellipsis glyph in START case,
310 * between the first and last visible lines to add the ellipsis glyph.
312 * It stores as well a copy of the positions for each visible glyph.
317 * @copydoc ModelInterface::GetStrikethroughHeight()
319 float GetStrikethroughHeight() const override;
322 * @copydoc ModelInterface::GetStrikethroughColor()
324 const Vector4& GetStrikethroughColor() const override;
327 * @copydoc ModelInterface::IsStrikethroughEnabled()
329 bool IsStrikethroughEnabled() const override;
332 * @copydoc ModelInterface::IsMarkupStrikethroughSet()
334 bool const IsMarkupStrikethroughSet() const override;
337 * @copydoc ModelInterface::GetNumberOfStrikethroughRuns()
339 Length GetNumberOfStrikethroughRuns() const override;
342 * @copydoc ModelInterface::GetNumberOfBoundedParagraphRuns()
344 virtual Length GetNumberOfBoundedParagraphRuns() const override;
347 * @copydoc ModelInterface::GetBoundedParagraphRuns()
349 virtual const Vector<BoundedParagraphRun>& GetBoundedParagraphRuns() const override;
352 * @copydoc ModelInterface::GetStrikethroughRuns()
354 void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, StrikethroughRunIndex index, Length numberOfRuns) const override;
357 * @copydoc ModelInterface::GetNumberOfCharacterSpacingGlyphRuns()
359 Length GetNumberOfCharacterSpacingGlyphRuns() const override;
362 * @copydoc ModelInterface::GetCharacterSpacingGlyphRuns()
364 const Vector<CharacterSpacingGlyphRun>& GetCharacterSpacingGlyphRuns() const override;
367 * @copydoc ModelInterface::GetFontRuns()
369 const Vector<FontRun>& GetFontRuns() const override;
372 * @copydoc ModelInterface::GetFontDescriptionRuns()
374 const Vector<FontDescriptionRun>& GetFontDescriptionRuns() const override;
377 const ModelInterface* const mModel; ///< Pointer to the text's model.
378 Vector<GlyphInfo> mElidedGlyphs; ///< Stores the glyphs of the elided text.
379 Vector<Vector2> mElidedLayout; ///< Stores the positions of each glyph of the elided text.
380 bool mIsTextElided : 1; ///< Whether the text has been elided.
381 GlyphIndex mStartIndexOfElidedGlyphs; ///< The start index of elided glyphs.
382 GlyphIndex mEndIndexOfElidedGlyphs; ///< The end index of elided glyphs.
383 GlyphIndex mFirstMiddleIndexOfElidedGlyphs; ///< The first end index of elided glyphs, index before ellipsis of middle.
384 GlyphIndex mSecondMiddleIndexOfElidedGlyphs; ///< The second end index of elided glyphs, index of ellipsis of middle.
389 } // namespace Toolkit
393 #endif // DALI_TOOLKIT_TEXT_VIEW_MODEL_H