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/text-model-interface.h>
27 #include <dali-toolkit/public-api/text/text-enumerations.h>
36 * @brief Responsible of creating and store temporary modifications of the text model.
37 * i.e. The elide of text.
39 class ViewModel : public ModelInterface
45 * Keeps the pointer to the text's model. It initializes all the members of the class to their defaults.
47 * @param[in] model Pointer to the text's model interface.
49 ViewModel(const ModelInterface* const model);
52 * @brief Virtual destructor.
54 * It's a default destructor.
59 * @copydoc ModelInterface::GetControlSize()
61 const Size& GetControlSize() const override;
64 * @copydoc ModelInterface::GetLayoutSize()
66 const Size& GetLayoutSize() const override;
69 * @copydoc ModelInterface::GetScrollPosition()
71 const Vector2& GetScrollPosition() const override;
74 * @copydoc ModelInterface::GetHorizontalAlignment()
76 Text::HorizontalAlignment::Type GetHorizontalAlignment() const override;
79 * @copydoc ModelInterface::GetVerticalAlignment()
81 Text::VerticalAlignment::Type GetVerticalAlignment() const override;
84 * @copydoc ModelInterface::GetVerticalLineAlignment()
86 DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const override;
89 * @copydoc ModelInterface::GetEllipsisPosition()
91 DevelText::EllipsisPosition::Type GetEllipsisPosition() const override;
94 * @copydoc ModelInterface::IsTextElideEnabled()
96 bool IsTextElideEnabled() const override;
99 * @copydoc ModelInterface::GetNumberOfLines()
101 Length GetNumberOfLines() const override;
104 * @copydoc ModelInterface::GetLines()
106 const LineRun* const GetLines() const override;
109 * @copydoc ModelInterface::GetNumberOfScripts()
111 Length GetNumberOfScripts() const override;
114 * @copydoc ModelInterface::GetScriptRuns()
116 const ScriptRun* const GetScriptRuns() const override;
119 * @copydoc ModelInterface::GetNumberOfGlyphs()
121 Length GetNumberOfGlyphs() const override;
124 * @copydoc ModelInterface::GetStartIndexOfElidedGlyphs()
126 GlyphIndex GetStartIndexOfElidedGlyphs() const override;
129 * @copydoc ModelInterface::GetEndIndexOfElidedGlyphs()
131 GlyphIndex GetEndIndexOfElidedGlyphs() const override;
134 * @copydoc ModelInterface::GetFirstMiddleIndexOfElidedGlyphs()
136 GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const override;
139 * @copydoc ModelInterface::GetSecondMiddleIndexOfElidedGlyphs()
141 GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const override;
144 * @copydoc ModelInterface::GetGlyphs()
146 const GlyphInfo* const GetGlyphs() const override;
149 * @copydoc ModelInterface::GetLayout()
151 const Vector2* const GetLayout() const override;
154 * @copydoc ModelInterface::GetColors()
156 const Vector4* const GetColors() const override;
159 * @copydoc ModelInterface::GetColorIndices()
161 const ColorIndex* const GetColorIndices() const override;
164 * @copydoc ModelInterface::GetBackgroundColors()
166 const Vector4* const GetBackgroundColors() const override;
169 * @copydoc ModelInterface::GetBackgroundColorIndices()
171 const ColorIndex* const GetBackgroundColorIndices() const override;
174 * @copydoc ModelInterface::IsMarkupBackgroundColorSet()
176 bool const IsMarkupBackgroundColorSet() const override;
179 * @copydoc ModelInterface::GetDefaultColor()
181 const Vector4& GetDefaultColor() const override;
184 * @copydoc ModelInterface::GetShadowOffset()
186 const Vector2& GetShadowOffset() const override;
189 * @copydoc ModelInterface::GetShadowColor()
191 const Vector4& GetShadowColor() const override;
194 * @copydoc ModelInterface::GetShadowBlurRadius()
196 const float& GetShadowBlurRadius() const override;
199 * @copydoc ModelInterface::GetUnderlineColor()
201 const Vector4& GetUnderlineColor() const override;
204 * @copydoc ModelInterface::IsUnderlineEnabled()
206 bool IsUnderlineEnabled() const override;
209 * @copydoc ModelInterface::GetUnderlineHeight()
211 float GetUnderlineHeight() const override;
214 * @copydoc ModelInterface::GetUnderlineType()
216 Text::Underline::Type GetUnderlineType() const override;
219 * @copydoc ModelInterface::GetDashedUnderlineWidth()
221 float GetDashedUnderlineWidth() const override;
224 * @copydoc ModelInterface::GetDashedUnderlineGap()
226 float GetDashedUnderlineGap() const override;
229 * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
231 Length GetNumberOfUnderlineRuns() const override;
234 * @copydoc ModelInterface::GetUnderlineRuns()
236 void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const override;
239 * @copydoc ModelInterface::GetOutlineColor()
241 const Vector4& GetOutlineColor() const override;
244 * @copydoc ModelInterface::GetOutlineWidth()
246 uint16_t GetOutlineWidth() const override;
249 * @copydoc ModelInterface::GetBackgroundColor()
251 const Vector4& GetBackgroundColor() const override;
254 * @copydoc ModelInterface::IsBackgroundEnabled()
256 bool IsBackgroundEnabled() const override;
259 * @copydoc ModelInterface::IsMarkupProcessorEnabled()
261 bool IsMarkupProcessorEnabled() const override;
264 * @copydoc ModelInterface::GetHyphens()
266 const GlyphInfo* GetHyphens() const override;
269 * @copydoc ModelInterface::GetHyphens()
271 const Length* GetHyphenIndices() const override;
274 * @copydoc ModelInterface::GetHyphens()
276 Length GetHyphensCount() const override;
279 * @copydoc ModelInterface::GetCharacterSpacing()
281 const float GetCharacterSpacing() const override;
284 * @copydoc ModelInterface::GetTextBuffer()
286 const Character* GetTextBuffer() const override;
289 * @copydoc ModelInterface::GetGlyphsToCharacters()
291 const Vector<CharacterIndex>& GetGlyphsToCharacters() const override;
294 * @brief Does the text elide at the end, start or middle of text according to ellipsis position
296 * It stores a copy of the visible glyphs and removes as many glyphs as needed
297 * from the last visible line to add the ellipsis glyph in END case,
298 * from the first visible line to add the ellipsis glyph in START case,
299 * between the first and last visible lines to add the ellipsis glyph.
301 * It stores as well a copy of the positions for each visible glyph.
305 float GetStrikethroughHeight() const override;
307 const Vector4& GetStrikethroughColor() const override;
309 bool IsStrikethroughEnabled() const override;
312 * @copydoc ModelInterface::GetNumberOfStrikethroughRuns()
314 Length GetNumberOfStrikethroughRuns() const override;
317 * @copydoc ModelInterface::GetStrikethroughRuns()
319 void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, StrikethroughRunIndex index, Length numberOfRuns) const override;
322 const ModelInterface* const mModel; ///< Pointer to the text's model.
323 Vector<GlyphInfo> mElidedGlyphs; ///< Stores the glyphs of the elided text.
324 Vector<Vector2> mElidedLayout; ///< Stores the positions of each glyph of the elided text.
325 bool mIsTextElided : 1; ///< Whether the text has been elided.
326 GlyphIndex mStartIndexOfElidedGlyphs; ///< The start index of elided glyphs.
327 GlyphIndex mEndIndexOfElidedGlyphs; ///< The end index of elided glyphs.
328 GlyphIndex mFirstMiddleIndexOfElidedGlyphs; ///< The first end index of elided glyphs, index before ellipsis of middle.
329 GlyphIndex mSecondMiddleIndexOfElidedGlyphs; ///< The second end index of elided glyphs, index of ellipsis of middle.
334 } // namespace Toolkit
338 #endif // DALI_TOOLKIT_TEXT_VIEW_MODEL_H