1 #ifndef DALI_TOOLKIT_TEXT_MODEL_H
2 #define DALI_TOOLKIT_TEXT_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/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;
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 HorizontalAlignment::Type GetHorizontalAlignment() const;
82 * @copydoc ModelInterface::GetVerticalAlignment()
84 virtual VerticalAlignment::Type GetVerticalAlignment() const;
87 * @copydoc ModelInterface::IsTextElideEnabled()
89 virtual bool IsTextElideEnabled() const;
92 * @copydoc ModelInterface::GetNumberOfLines()
94 virtual Length GetNumberOfLines() const;
97 * @copydoc ModelInterface::GetLines()
99 virtual const LineRun* const GetLines() const;
102 * @copydoc ModelInterface::GetNumberOfScripts()
104 virtual Length GetNumberOfScripts() const;
107 * @copydoc ModelInterface::GetScriptRuns()
109 virtual const ScriptRun* const GetScriptRuns() const;
112 * @copydoc ModelInterface::GetNumberOfGlyphs()
114 virtual Length GetNumberOfGlyphs() const;
117 * @copydoc ModelInterface::GetGlyphs()
119 virtual const GlyphInfo* const GetGlyphs() const;
122 * @copydoc ModelInterface::GetLayout()
124 virtual const Vector2* const GetLayout() const;
127 * @copydoc ModelInterface::GetColors()
129 virtual const Vector4* const GetColors() const;
132 * @copydoc ModelInterface::GetColorIndices()
134 virtual const ColorIndex* const GetColorIndices() const;
137 * @copydoc ModelInterface::GetDefaultColor()
139 virtual const Vector4& GetDefaultColor() const;
142 * @copydoc ModelInterface::GetShadowOffset()
144 virtual const Vector2& GetShadowOffset() const;
147 * @copydoc ModelInterface::GetShadowColor()
149 virtual const Vector4& GetShadowColor() const;
152 * @copydoc ModelInterface::GetShadowBlurRadius()
154 virtual const float& GetShadowBlurRadius() const;
157 * @copydoc ModelInterface::GetUnderlineColor()
159 virtual const Vector4& GetUnderlineColor() const;
162 * @copydoc ModelInterface::IsUnderlineEnabled()
164 virtual bool IsUnderlineEnabled() const;
167 * @copydoc ModelInterface::GetUnderlineHeight()
169 virtual float GetUnderlineHeight() const;
172 * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
174 virtual Length GetNumberOfUnderlineRuns() const;
177 * @copydoc ModelInterface::GetUnderlineRuns()
179 virtual void GetUnderlineRuns( GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns ) const;
182 * @copydoc ModelInterface::GetOutlineColor()
184 virtual const Vector4& GetOutlineColor() const;
187 * @copydoc ModelInterface::GetOutlineWidth()
189 virtual float GetOutlineWidth() const;
191 private: // Private contructors & copy operator.
194 * @brief Private constructor.
199 Model( const Model& handle );
202 Model& operator=( const Model& handle );
207 * @brief A reference counted object may only be deleted by calling Unreference().
212 LogicalModelPtr mLogicalModel; ///< Pointer to the logical model.
213 VisualModelPtr mVisualModel; ///< Pointer to the visual model.
215 * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
216 * Typically this will have a negative value with scrolling occurs.
218 Vector2 mScrollPosition; ///< The text is offset by this position when scrolling.
219 Vector2 mScrollPositionLast; ///< The last offset value of mScrollPosition
220 HorizontalAlignment::Type mHorizontalAlignment; ///< The layout's horizontal alignment.
221 VerticalAlignment::Type mVerticalAlignment; ///< The layout's vertical alignment.
222 Text::LineWrap::Mode mLineWrapMode; ///< The text wrap mode
223 float mAlignmentOffset; ///< The alignment offset.
224 bool mElideEnabled:1; ///< Whether the text's elide is enabled.
229 } // namespace Toolkit
233 #endif // DALI_TOOLKIT_TEXT_MODEL_H