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::IsTextElideEnabled()
91 bool IsTextElideEnabled() const override;
94 * @copydoc ModelInterface::GetNumberOfLines()
96 Length GetNumberOfLines() const override;
99 * @copydoc ModelInterface::GetLines()
101 const LineRun* const GetLines() const override;
104 * @copydoc ModelInterface::GetNumberOfScripts()
106 Length GetNumberOfScripts() const override;
109 * @copydoc ModelInterface::GetScriptRuns()
111 const ScriptRun* const GetScriptRuns() const override;
114 * @copydoc ModelInterface::GetNumberOfGlyphs()
116 Length GetNumberOfGlyphs() const override;
119 * @copydoc ModelInterface::GetGlyphs()
121 const GlyphInfo* const GetGlyphs() const override;
124 * @copydoc ModelInterface::GetLayout()
126 const Vector2* const GetLayout() const override;
129 * @copydoc ModelInterface::GetColors()
131 const Vector4* const GetColors() const override;
134 * @copydoc ModelInterface::GetColorIndices()
136 const ColorIndex* const GetColorIndices() const override;
139 * @copydoc ModelInterface::GetBackgroundColors()
141 const Vector4* const GetBackgroundColors() const override;
144 * @copydoc ModelInterface::GetBackgroundColorIndices()
146 const ColorIndex* const GetBackgroundColorIndices() const override;
149 * @copydoc ModelInterface::GetDefaultColor()
151 const Vector4& GetDefaultColor() const override;
154 * @copydoc ModelInterface::GetShadowOffset()
156 const Vector2& GetShadowOffset() const override;
159 * @copydoc ModelInterface::GetShadowColor()
161 const Vector4& GetShadowColor() const override;
164 * @copydoc ModelInterface::GetShadowBlurRadius()
166 const float& GetShadowBlurRadius() const override;
169 * @copydoc ModelInterface::GetUnderlineColor()
171 const Vector4& GetUnderlineColor() const override;
174 * @copydoc ModelInterface::IsUnderlineEnabled()
176 bool IsUnderlineEnabled() const override;
179 * @copydoc ModelInterface::GetUnderlineHeight()
181 float GetUnderlineHeight() const override;
184 * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
186 Length GetNumberOfUnderlineRuns() const override;
189 * @copydoc ModelInterface::GetUnderlineRuns()
191 void GetUnderlineRuns(GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const override;
194 * @copydoc ModelInterface::GetOutlineColor()
196 const Vector4& GetOutlineColor() const override;
199 * @copydoc ModelInterface::GetOutlineWidth()
201 uint16_t GetOutlineWidth() const override;
204 * @copydoc ModelInterface::GetBackgroundColor()
206 const Vector4& GetBackgroundColor() const override;
209 * @copydoc ModelInterface::IsBackgroundEnabled()
211 bool IsBackgroundEnabled() const override;
214 * @brief Does the text elide.
216 * It stores a copy of the visible glyphs and removes as many glyphs as needed
217 * from the last visible line to add the ellipsis glyph.
219 * It stores as well a copy of the positions for each visible glyph.
224 const ModelInterface* const mModel; ///< Pointer to the text's model.
225 Vector<GlyphInfo> mElidedGlyphs; ///< Stores the glyphs of the elided text.
226 Vector<Vector2> mElidedLayout; ///< Stores the positions of each glyph of the elided text.
227 bool mIsTextElided : 1; ///< Whether the text has been elided.
232 } // namespace Toolkit
236 #endif // DALI_TOOLKIT_TEXT_VIEW_MODEL_H