1 #ifndef DALI_TOOLKIT_TEXT_MODEL_H
2 #define DALI_TOOLKIT_TEXT_MODEL_H
5 * Copyright (c) 2019 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/object/ref-object.h>
25 #include <dali-toolkit/public-api/text/text-enumerations.h>
26 #include <dali-toolkit/internal/text/logical-model-impl.h>
27 #include <dali-toolkit/internal/text/text-model-interface.h>
28 #include <dali-toolkit/internal/text/visual-model-impl.h>
39 // Forward declarations.
42 typedef IntrusivePtr<Model> ModelPtr;
45 * @brief Implementation class used to retrieve the text's model from the text-controller.
47 class Model : public RefObject, public ModelInterface
50 public: // Constructor.
53 * @brief Create a new instance of a text Model.
55 * @return A pointer to a new text Model.
57 static ModelPtr New();
62 * @copydoc ModelInterface::GetControlSize()
64 virtual const Size& GetControlSize() const override;
67 * @copydoc ModelInterface::GetLayoutSize()
69 virtual const Size& GetLayoutSize() const override;
72 * @copydoc ModelInterface::GetScrollPosition()
74 virtual const Vector2& GetScrollPosition() const override;
77 * @copydoc ModelInterface::GetHorizontalAlignment()
79 virtual HorizontalAlignment::Type GetHorizontalAlignment() const override;
82 * @copydoc ModelInterface::GetVerticalAlignment()
84 virtual VerticalAlignment::Type GetVerticalAlignment() const override;
87 * @copydoc ModelInterface::GetVerticalLineAlignment()
89 virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const override;
92 * @copydoc ModelInterface::IsTextElideEnabled()
94 virtual bool IsTextElideEnabled() const override;
97 * @copydoc ModelInterface::GetNumberOfLines()
99 virtual Length GetNumberOfLines() const override;
102 * @copydoc ModelInterface::GetLines()
104 virtual const LineRun* const GetLines() const override;
107 * @copydoc ModelInterface::GetNumberOfScripts()
109 virtual Length GetNumberOfScripts() const override;
112 * @copydoc ModelInterface::GetScriptRuns()
114 virtual const ScriptRun* const GetScriptRuns() const override;
117 * @copydoc ModelInterface::GetNumberOfGlyphs()
119 virtual Length GetNumberOfGlyphs() const override;
122 * @copydoc ModelInterface::GetGlyphs()
124 virtual const GlyphInfo* const GetGlyphs() const override;
127 * @copydoc ModelInterface::GetLayout()
129 virtual const Vector2* const GetLayout() const override;
132 * @copydoc ModelInterface::GetColors()
134 virtual const Vector4* const GetColors() const override;
137 * @copydoc ModelInterface::GetColorIndices()
139 virtual const ColorIndex* const GetColorIndices() const override;
142 * @copydoc ModelInterface::GetBackgroundColors()
144 virtual const Vector4* const GetBackgroundColors() const override;
147 * @copydoc ModelInterface::GetBackgroundColorIndices()
149 virtual const ColorIndex* const GetBackgroundColorIndices() const override;
152 * @copydoc ModelInterface::GetDefaultColor()
154 virtual const Vector4& GetDefaultColor() const override;
157 * @copydoc ModelInterface::GetShadowOffset()
159 virtual const Vector2& GetShadowOffset() const override;
162 * @copydoc ModelInterface::GetShadowColor()
164 virtual const Vector4& GetShadowColor() const override;
167 * @copydoc ModelInterface::GetShadowBlurRadius()
169 virtual const float& GetShadowBlurRadius() const override;
172 * @copydoc ModelInterface::GetUnderlineColor()
174 virtual const Vector4& GetUnderlineColor() const override;
177 * @copydoc ModelInterface::IsUnderlineEnabled()
179 virtual bool IsUnderlineEnabled() const override;
182 * @copydoc ModelInterface::GetUnderlineHeight()
184 virtual float GetUnderlineHeight() const override;
187 * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
189 virtual Length GetNumberOfUnderlineRuns() const override;
192 * @copydoc ModelInterface::GetUnderlineRuns()
194 virtual void GetUnderlineRuns( GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns ) const override;
197 * @copydoc ModelInterface::GetOutlineColor()
199 virtual const Vector4& GetOutlineColor() const override;
202 * @copydoc ModelInterface::GetOutlineWidth()
204 virtual uint16_t GetOutlineWidth() const override;
207 * @copydoc ModelInterface::GetBackgroundColor()
209 virtual const Vector4& GetBackgroundColor() const override;
212 * @copydoc ModelInterface::IsBackgroundEnabled()
214 virtual bool IsBackgroundEnabled() const override;
216 private: // Private contructors & copy operator.
219 * @brief Private constructor.
224 Model( const Model& handle );
227 Model& operator=( const Model& handle );
232 * @brief A reference counted object may only be deleted by calling Unreference().
237 LogicalModelPtr mLogicalModel; ///< Pointer to the logical model.
238 VisualModelPtr mVisualModel; ///< Pointer to the visual model.
240 * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
241 * Typically this will have a negative value with scrolling occurs.
243 Vector2 mScrollPosition; ///< The text is offset by this position when scrolling.
244 Vector2 mScrollPositionLast; ///< The last offset value of mScrollPosition
245 HorizontalAlignment::Type mHorizontalAlignment; ///< The layout's horizontal alignment.
246 VerticalAlignment::Type mVerticalAlignment; ///< The layout's vertical alignment.
247 DevelText::VerticalLineAlignment::Type mVerticalLineAlignment; ///< The layout's vertical line alignment.
248 Text::LineWrap::Mode mLineWrapMode; ///< The text wrap mode
249 float mAlignmentOffset; ///< The alignment offset.
250 bool mElideEnabled:1; ///< Whether the text's elide is enabled.
251 bool mIgnoreSpacesAfterText:1; ///< Whether ignoring spaces after text or not. Default is true.
252 bool mMatchSystemLanguageDirection:1; ///< Whether match align for system language direction or not. Default is false.
257 } // namespace Toolkit
261 #endif // DALI_TOOLKIT_TEXT_MODEL_H