1 #ifndef DALI_TOOLKIT_TEXT_VIEW_MODEL_H
2 #define DALI_TOOLKIT_TEXT_VIEW_MODEL_H
5 * Copyright (c) 2018 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/public-api/text/text-enumerations.h>
26 #include <dali-toolkit/internal/text/text-model-interface.h>
27 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
39 * @brief Responsible of creating and store temporary modifications of the text model.
40 * i.e. The elide of text.
42 class ViewModel : public ModelInterface
48 * Keeps the pointer to the text's model. It initializes all the members of the class to their defaults.
50 * @param[in] model Pointer to the text's model interface.
52 ViewModel( const ModelInterface* const model );
55 * @brief Virtual destructor.
57 * It's a default destructor.
62 * @copydoc ModelInterface::GetControlSize()
64 virtual const Size& GetControlSize() const;
67 * @copydoc ModelInterface::GetLayoutSize()
69 virtual const Size& GetLayoutSize() const;
72 * @copydoc ModelInterface::GetScrollPosition()
74 virtual const Vector2& GetScrollPosition() const;
77 * @copydoc ModelInterface::GetHorizontalAlignment()
79 virtual Text::HorizontalAlignment::Type GetHorizontalAlignment() const;
82 * @copydoc ModelInterface::GetVerticalAlignment()
84 virtual Text::VerticalAlignment::Type GetVerticalAlignment() const;
87 * @copydoc ModelInterface::GetVerticalLineAlignment()
89 virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const;
92 * @copydoc ModelInterface::IsTextElideEnabled()
94 virtual bool IsTextElideEnabled() const;
97 * @copydoc ModelInterface::GetNumberOfLines()
99 virtual Length GetNumberOfLines() const;
102 * @copydoc ModelInterface::GetLines()
104 virtual const LineRun* const GetLines() const;
107 * @copydoc ModelInterface::GetNumberOfScripts()
109 virtual Length GetNumberOfScripts() const;
112 * @copydoc ModelInterface::GetScriptRuns()
114 virtual const ScriptRun* const GetScriptRuns() const;
117 * @copydoc ModelInterface::GetNumberOfGlyphs()
119 virtual Length GetNumberOfGlyphs() const;
122 * @copydoc ModelInterface::GetGlyphs()
124 virtual const GlyphInfo* const GetGlyphs() const;
127 * @copydoc ModelInterface::GetLayout()
129 virtual const Vector2* const GetLayout() const;
132 * @copydoc ModelInterface::GetColors()
134 virtual const Vector4* const GetColors() const;
137 * @copydoc ModelInterface::GetColorIndices()
139 virtual const ColorIndex* const GetColorIndices() const;
142 * @copydoc ModelInterface::GetDefaultColor()
144 virtual const Vector4& GetDefaultColor() const;
147 * @copydoc ModelInterface::GetShadowOffset()
149 virtual const Vector2& GetShadowOffset() const;
152 * @copydoc ModelInterface::GetShadowColor()
154 virtual const Vector4& GetShadowColor() const;
157 * @copydoc ModelInterface::GetShadowBlurRadius()
159 virtual const float& GetShadowBlurRadius() const;
162 * @copydoc ModelInterface::GetUnderlineColor()
164 virtual const Vector4& GetUnderlineColor() const;
167 * @copydoc ModelInterface::IsUnderlineEnabled()
169 virtual bool IsUnderlineEnabled() const;
172 * @copydoc ModelInterface::GetUnderlineHeight()
174 virtual float GetUnderlineHeight() const;
177 * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
179 virtual Length GetNumberOfUnderlineRuns() const;
182 * @copydoc ModelInterface::GetUnderlineRuns()
184 virtual void GetUnderlineRuns( GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns ) const;
187 * @copydoc ModelInterface::GetOutlineColor()
189 virtual const Vector4& GetOutlineColor() const;
192 * @copydoc ModelInterface::GetOutlineWidth()
194 virtual float GetOutlineWidth() const;
197 * @copydoc ModelInterface::GetBackgroundColor()
199 virtual const Vector4& GetBackgroundColor() const;
202 * @copydoc ModelInterface::IsBackgroundEnabled()
204 virtual bool IsBackgroundEnabled() const;
207 * @brief Does the text elide.
209 * It stores a copy of the visible glyphs and removes as many glyphs as needed
210 * from the last visible line to add the ellipsis glyph.
212 * It stores as well a copy of the positions for each visible glyph.
217 const ModelInterface* const mModel; ///< Pointer to the text's model.
218 Vector<GlyphInfo> mElidedGlyphs; ///< Stores the glyphs of the elided text.
219 Vector<Vector2> mElidedLayout; ///< Stores the positions of each glyph of the elided text.
220 bool mIsTextElided : 1; ///< Whether the text has been elided.
225 } // namespace Toolkit
229 #endif // DALI_TOOLKIT_TEXT_VIEW_MODEL_H