1 #ifndef DALI_TOOLKIT_TEXT_VIEW_MODEL_H
2 #define DALI_TOOLKIT_TEXT_VIEW_MODEL_H
5 * Copyright (c) 2017 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>
38 * @brief Responsible of creating and store temporary modifications of the text model.
39 * i.e. The elide of text.
41 class ViewModel : public ModelInterface
47 * Keeps the pointer to the text's model. It initializes all the members of the class to their defaults.
49 * @param[in] model Pointer to the text's model interface.
51 ViewModel( const ModelInterface* const model );
54 * @brief Virtual destructor.
56 * It's a default destructor.
61 * @copydoc ModelInterface::GetControlSize()
63 virtual const Size& GetControlSize() const;
66 * @copydoc ModelInterface::GetLayoutSize()
68 virtual const Size& GetLayoutSize() const;
71 * @copydoc ModelInterface::GetScrollPosition()
73 virtual const Vector2& GetScrollPosition() const;
76 * @copydoc ModelInterface::GetHorizontalAlignment()
78 virtual Text::HorizontalAlignment::Type GetHorizontalAlignment() const;
81 * @copydoc ModelInterface::GetVerticalAlignment()
83 virtual Text::VerticalAlignment::Type GetVerticalAlignment() const;
86 * @copydoc ModelInterface::IsTextElideEnabled()
88 virtual bool IsTextElideEnabled() const;
91 * @copydoc ModelInterface::GetNumberOfLines()
93 virtual Length GetNumberOfLines() const;
96 * @copydoc ModelInterface::GetLines()
98 virtual const LineRun* const GetLines() const;
101 * @copydoc ModelInterface::GetNumberOfScripts()
103 virtual Length GetNumberOfScripts() const;
106 * @copydoc ModelInterface::GetScriptRuns()
108 virtual const ScriptRun* const GetScriptRuns() const;
111 * @copydoc ModelInterface::GetNumberOfGlyphs()
113 virtual Length GetNumberOfGlyphs() const;
116 * @copydoc ModelInterface::GetGlyphs()
118 virtual const GlyphInfo* const GetGlyphs() const;
121 * @copydoc ModelInterface::GetLayout()
123 virtual const Vector2* const GetLayout() const;
126 * @copydoc ModelInterface::GetColors()
128 virtual const Vector4* const GetColors() const;
131 * @copydoc ModelInterface::GetColorIndices()
133 virtual const ColorIndex* const GetColorIndices() const;
136 * @copydoc ModelInterface::GetDefaultColor()
138 virtual const Vector4& GetDefaultColor() const;
141 * @copydoc ModelInterface::GetShadowOffset()
143 virtual const Vector2& GetShadowOffset() const;
146 * @copydoc ModelInterface::GetShadowColor()
148 virtual const Vector4& GetShadowColor() const;
151 * @copydoc ModelInterface::GetShadowBlurRadius()
153 virtual const float& GetShadowBlurRadius() const;
156 * @copydoc ModelInterface::GetUnderlineColor()
158 virtual const Vector4& GetUnderlineColor() const;
161 * @copydoc ModelInterface::IsUnderlineEnabled()
163 virtual bool IsUnderlineEnabled() const;
166 * @copydoc ModelInterface::GetUnderlineHeight()
168 virtual float GetUnderlineHeight() const;
171 * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
173 virtual Length GetNumberOfUnderlineRuns() const;
176 * @copydoc ModelInterface::GetUnderlineRuns()
178 virtual void GetUnderlineRuns( GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns ) const;
181 * @copydoc ModelInterface::GetOutlineColor()
183 virtual const Vector4& GetOutlineColor() const;
186 * @copydoc ModelInterface::GetOutlineWidth()
188 virtual float GetOutlineWidth() const;
191 * @brief Does the text elide.
193 * It stores a copy of the visible glyphs and removes as many glyphs as needed
194 * from the last visible line to add the ellipsis glyph.
196 * It stores as well a copy of the positions for each visible glyph.
201 const ModelInterface* const mModel; ///< Pointer to the text's model.
202 Vector<GlyphInfo> mElidedGlyphs; ///< Stores the glyphs of the elided text.
203 Vector<Vector2> mElidedLayout; ///< Stores the positions of each glyph of the elided text.
204 bool mIsTextElided : 1; ///< Whether the text has been elided.
209 } // namespace Toolkit
213 #endif // DALI_TOOLKIT_TEXT_VIEW_MODEL_H