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/internal/text/layouts/layout-alignment.h>
26 #include <dali-toolkit/internal/text/layouts/layout-wrap-mode.h>
27 #include <dali-toolkit/internal/text/logical-model-impl.h>
28 #include <dali-toolkit/internal/text/text-model-interface.h>
29 #include <dali-toolkit/internal/text/visual-model-impl.h>
40 // Forward declarations.
43 typedef IntrusivePtr<Model> ModelPtr;
46 * @brief Implementation class used to retrieve the text's model from the text-controller.
48 class Model : public RefObject, public ModelInterface
51 public: // Constructor.
54 * @brief Create a new instance of a text Model.
56 * @return A pointer to a new text Model.
58 static ModelPtr New();
63 * @copydoc ModelInterface::GetControlSize()
65 virtual const Size& GetControlSize() const;
68 * @copydoc ModelInterface::GetLayoutSize()
70 virtual const Size& GetLayoutSize() const;
73 * @copydoc ModelInterface::GetScrollPosition()
75 virtual const Vector2& GetScrollPosition() const;
78 * @copydoc ModelInterface::GetHorizontalAlignment()
80 virtual Layout::HorizontalAlignment GetHorizontalAlignment() const;
83 * @copydoc ModelInterface::GetVerticalAlignment()
85 virtual Layout::VerticalAlignment GetVerticalAlignment() const;
88 * @copydoc ModelInterface::IsTextElideEnabled()
90 virtual bool IsTextElideEnabled() const;
93 * @copydoc ModelInterface::GetNumberOfLines()
95 virtual Length GetNumberOfLines() const;
98 * @copydoc ModelInterface::GetLines()
100 virtual const LineRun* const GetLines() const;
103 * @copydoc ModelInterface::GetNumberOfGlyphs()
105 virtual Length GetNumberOfGlyphs() const;
108 * @copydoc ModelInterface::GetGlyphs()
110 virtual const GlyphInfo* const GetGlyphs() const;
113 * @copydoc ModelInterface::GetLayout()
115 virtual const Vector2* const GetLayout() const;
118 * @copydoc ModelInterface::GetColors()
120 virtual const Vector4* const GetColors() const;
123 * @copydoc ModelInterface::GetColorIndices()
125 virtual const ColorIndex* const GetColorIndices() const;
128 * @copydoc ModelInterface::GetDefaultColor()
130 virtual const Vector4& GetDefaultColor() const;
132 private: // Private contructors & copy operator.
135 * @brief Private constructor.
140 Model( const Model& handle );
143 Model& operator=( const Model& handle );
148 * @brief A reference counted object may only be deleted by calling Unreference().
153 LogicalModelPtr mLogicalModel; ///< Pointer to the logical model.
154 VisualModelPtr mVisualModel; ///< Pointer to the visual model.
156 * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
157 * Typically this will have a negative value with scrolling occurs.
159 Vector2 mScrollPosition; ///< The text is offset by this position when scrolling.
160 Vector2 mScrollPositionLast; ///< The last offset value of mScrollPosition
161 Layout::HorizontalAlignment mHorizontalAlignment; ///< The layout's horizontal alignment.
162 Layout::VerticalAlignment mVerticalAlignment; ///< The layout's vertical alignment.
163 Layout::LineWrap::Mode mLineWrapMode; ///< The text wrap mode
164 float mAlignmentOffset; ///< The alignment offset.
165 bool mElideEnabled:1; ///< Whether the text's elide is enabled.
170 } // namespace Toolkit
174 #endif // DALI_TOOLKIT_TEXT_MODEL_H