1 #ifndef DALI_TOOLKIT_TEXT_VIEW_MODEL_H
2 #define DALI_TOOLKIT_TEXT_VIEW_MODEL_H
5 * Copyright (c) 2021 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::GetNumberOfUnderlineRuns()
216 Length GetNumberOfUnderlineRuns() const override;
219 * @copydoc ModelInterface::GetUnderlineRuns()
221 void GetUnderlineRuns(GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const override;
224 * @copydoc ModelInterface::GetOutlineColor()
226 const Vector4& GetOutlineColor() const override;
229 * @copydoc ModelInterface::GetOutlineWidth()
231 uint16_t GetOutlineWidth() const override;
234 * @copydoc ModelInterface::GetBackgroundColor()
236 const Vector4& GetBackgroundColor() const override;
239 * @copydoc ModelInterface::IsBackgroundEnabled()
241 bool IsBackgroundEnabled() const override;
244 * @copydoc ModelInterface::IsMarkupProcessorEnabled()
246 bool IsMarkupProcessorEnabled() const override;
249 * @copydoc ModelInterface::GetHyphens()
251 const GlyphInfo* GetHyphens() const override;
254 * @copydoc ModelInterface::GetHyphens()
256 const Length* GetHyphenIndices() const override;
259 * @copydoc ModelInterface::GetHyphens()
261 Length GetHyphensCount() const override;
264 * @brief Does the text elide at the end, start or middle of text according to ellipsis position
266 * It stores a copy of the visible glyphs and removes as many glyphs as needed
267 * from the last visible line to add the ellipsis glyph in END case,
268 * from the first visible line to add the ellipsis glyph in START case,
269 * between the first and last visible lines to add the ellipsis glyph.
271 * It stores as well a copy of the positions for each visible glyph.
275 float GetStrikethroughHeight() const override;
277 const Vector4& GetStrikethroughColor() const override;
279 bool IsStrikethroughEnabled() const override;
282 const ModelInterface* const mModel; ///< Pointer to the text's model.
283 Vector<GlyphInfo> mElidedGlyphs; ///< Stores the glyphs of the elided text.
284 Vector<Vector2> mElidedLayout; ///< Stores the positions of each glyph of the elided text.
285 bool mIsTextElided : 1; ///< Whether the text has been elided.
286 GlyphIndex mStartIndexOfElidedGlyphs; ///< The start index of elided glyphs.
287 GlyphIndex mEndIndexOfElidedGlyphs; ///< The end index of elided glyphs.
288 GlyphIndex mFirstMiddleIndexOfElidedGlyphs; ///< The first end index of elided glyphs, index before ellipsis of middle.
289 GlyphIndex mSecondMiddleIndexOfElidedGlyphs; ///< The second end index of elided glyphs, index of ellipsis of middle.
294 } // namespace Toolkit
298 #endif // DALI_TOOLKIT_TEXT_VIEW_MODEL_H