1 #ifndef DALI_TOOLKIT_TEXT_VIEW_MODEL_H
2 #define DALI_TOOLKIT_TEXT_VIEW_MODEL_H
5 * Copyright (c) 2023 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* GetLines() const override;
110 * @copydoc ModelInterface::GetNumberOfScripts()
112 Length GetNumberOfScripts() const override;
115 * @copydoc ModelInterface::GetScriptRuns()
117 const ScriptRun* GetScriptRuns() const override;
120 * @copydoc ModelInterface::GetNumberOfCharacters()
122 Length GetNumberOfCharacters() const override;
125 * @copydoc ModelInterface::GetNumberOfGlyphs()
127 Length GetNumberOfGlyphs() const override;
130 * @copydoc ModelInterface::GetStartIndexOfElidedGlyphs()
132 GlyphIndex GetStartIndexOfElidedGlyphs() const override;
135 * @copydoc ModelInterface::GetEndIndexOfElidedGlyphs()
137 GlyphIndex GetEndIndexOfElidedGlyphs() const override;
140 * @copydoc ModelInterface::GetFirstMiddleIndexOfElidedGlyphs()
142 GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const override;
145 * @copydoc ModelInterface::GetSecondMiddleIndexOfElidedGlyphs()
147 GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const override;
150 * @copydoc ModelInterface::GetGlyphs()
152 const GlyphInfo* GetGlyphs() const override;
155 * @copydoc ModelInterface::GetLayout()
157 const Vector2* GetLayout() const override;
160 * @copydoc ModelInterface::GetColors()
162 const Vector4* GetColors() const override;
165 * @copydoc ModelInterface::GetColorIndices()
167 const ColorIndex* GetColorIndices() const override;
170 * @copydoc ModelInterface::GetBackgroundColors()
172 const Vector4* GetBackgroundColors() const override;
175 * @copydoc ModelInterface::GetBackgroundColorIndices()
177 const ColorIndex* GetBackgroundColorIndices() const override;
180 * @copydoc ModelInterface::IsMarkupBackgroundColorSet()
182 bool IsMarkupBackgroundColorSet() const override;
185 * @copydoc ModelInterface::GetDefaultColor()
187 const Vector4& GetDefaultColor() const override;
190 * @copydoc ModelInterface::GetShadowOffset()
192 const Vector2& GetShadowOffset() const override;
195 * @copydoc ModelInterface::GetShadowColor()
197 const Vector4& GetShadowColor() const override;
200 * @copydoc ModelInterface::GetShadowBlurRadius()
202 const float& GetShadowBlurRadius() const override;
205 * @copydoc ModelInterface::GetUnderlineColor()
207 const Vector4& GetUnderlineColor() const override;
210 * @copydoc ModelInterface::IsUnderlineEnabled()
212 bool IsUnderlineEnabled() const override;
215 * @copydoc ModelInterface::IsMarkupUnderlineSet()
217 bool IsMarkupUnderlineSet() const override;
220 * @copydoc ModelInterface::GetUnderlineHeight()
222 float GetUnderlineHeight() const override;
225 * @copydoc ModelInterface::GetUnderlineType()
227 Text::Underline::Type GetUnderlineType() const override;
230 * @copydoc ModelInterface::GetDashedUnderlineWidth()
232 float GetDashedUnderlineWidth() const override;
235 * @copydoc ModelInterface::GetDashedUnderlineGap()
237 float GetDashedUnderlineGap() const override;
240 * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
242 Length GetNumberOfUnderlineRuns() const override;
245 * @copydoc ModelInterface::GetUnderlineRuns()
247 void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const override;
250 * @copydoc ModelInterface::GetOutlineColor()
252 const Vector4& GetOutlineColor() const override;
255 * @copydoc ModelInterface::GetOutlineWidth()
257 uint16_t GetOutlineWidth() const override;
260 * @copydoc ModelInterface::GetBackgroundColor()
262 const Vector4& GetBackgroundColor() const override;
265 * @copydoc ModelInterface::IsBackgroundEnabled()
267 bool IsBackgroundEnabled() const override;
270 * @copydoc ModelInterface::IsMarkupProcessorEnabled()
272 bool IsMarkupProcessorEnabled() const override;
275 * @copydoc ModelInterface::IsSpannedTextPlaced()
277 bool IsSpannedTextPlaced() const override;
280 * @copydoc ModelInterface::GetHyphens()
282 const GlyphInfo* GetHyphens() const override;
285 * @copydoc ModelInterface::GetHyphens()
287 const Length* GetHyphenIndices() const override;
290 * @copydoc ModelInterface::GetHyphens()
292 Length GetHyphensCount() const override;
295 * @copydoc ModelInterface::GetCharacterSpacing()
297 float GetCharacterSpacing() const override;
300 * @copydoc ModelInterface::GetTextBuffer()
302 const Character* GetTextBuffer() const override;
305 * @copydoc ModelInterface::GetGlyphsToCharacters()
307 const Vector<CharacterIndex>& GetGlyphsToCharacters() const override;
310 * @brief Does the text elide at the end, start or middle of text according to ellipsis position
312 * It stores a copy of the visible glyphs and removes as many glyphs as needed
313 * from the last visible line to add the ellipsis glyph in END case,
314 * from the first visible line to add the ellipsis glyph in START case,
315 * between the first and last visible lines to add the ellipsis glyph.
317 * It stores as well a copy of the positions for each visible glyph.
322 * @copydoc ModelInterface::GetStrikethroughHeight()
324 float GetStrikethroughHeight() const override;
327 * @copydoc ModelInterface::GetStrikethroughColor()
329 const Vector4& GetStrikethroughColor() const override;
332 * @copydoc ModelInterface::IsStrikethroughEnabled()
334 bool IsStrikethroughEnabled() const override;
337 * @copydoc ModelInterface::IsMarkupStrikethroughSet()
339 bool IsMarkupStrikethroughSet() const override;
342 * @copydoc ModelInterface::GetNumberOfStrikethroughRuns()
344 Length GetNumberOfStrikethroughRuns() const override;
347 * @copydoc ModelInterface::GetNumberOfBoundedParagraphRuns()
349 virtual Length GetNumberOfBoundedParagraphRuns() const override;
352 * @copydoc ModelInterface::GetBoundedParagraphRuns()
354 virtual const Vector<BoundedParagraphRun>& GetBoundedParagraphRuns() const override;
357 * @copydoc ModelInterface::GetStrikethroughRuns()
359 void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, StrikethroughRunIndex index, Length numberOfRuns) const override;
362 * @copydoc ModelInterface::GetNumberOfCharacterSpacingGlyphRuns()
364 Length GetNumberOfCharacterSpacingGlyphRuns() const override;
367 * @copydoc ModelInterface::GetCharacterSpacingGlyphRuns()
369 const Vector<CharacterSpacingGlyphRun>& GetCharacterSpacingGlyphRuns() const override;
372 * @copydoc ModelInterface::GetFontRuns()
374 const Vector<FontRun>& GetFontRuns() const override;
377 * @copydoc ModelInterface::GetFontDescriptionRuns()
379 const Vector<FontDescriptionRun>& GetFontDescriptionRuns() const override;
382 const ModelInterface* const mModel; ///< Pointer to the text's model.
383 Vector<GlyphInfo> mElidedGlyphs; ///< Stores the glyphs of the elided text.
384 Vector<Vector2> mElidedLayout; ///< Stores the positions of each glyph of the elided text.
385 bool mIsTextElided : 1; ///< Whether the text has been elided.
386 GlyphIndex mStartIndexOfElidedGlyphs; ///< The start index of elided glyphs.
387 GlyphIndex mEndIndexOfElidedGlyphs; ///< The end index of elided glyphs.
388 GlyphIndex mFirstMiddleIndexOfElidedGlyphs; ///< The first end index of elided glyphs, index before ellipsis of middle.
389 GlyphIndex mSecondMiddleIndexOfElidedGlyphs; ///< The second end index of elided glyphs, index of ellipsis of middle.
394 } // namespace Toolkit
398 #endif // DALI_TOOLKIT_TEXT_VIEW_MODEL_H