(Text Controller) Remove meaningless check to see if an unsigned int is positive...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-model.h
1 #ifndef DALI_TOOLKIT_TEXT_MODEL_H
2 #define DALI_TOOLKIT_TEXT_MODEL_H
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/ref-object.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/text/layouts/layout-alignment.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>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Text
37 {
38
39 // Forward declarations.
40 class Model;
41
42 typedef IntrusivePtr<Model> ModelPtr;
43
44 /**
45  * @brief Implementation class used to retrieve the text's model from the text-controller.
46  */
47 class Model : public RefObject, public ModelInterface
48 {
49
50 public: // Constructor.
51
52   /**
53    * @brief Create a new instance of a text Model.
54    *
55    * @return A pointer to a new text Model.
56    */
57   static ModelPtr New();
58
59 public:
60
61   /**
62    * @copydoc ModelInterface::GetControlSize()
63    */
64   virtual const Size& GetControlSize() const;
65
66   /**
67    * @copydoc ModelInterface::GetLayoutSize()
68    */
69   virtual const Size& GetLayoutSize() const;
70
71   /**
72    * @copydoc ModelInterface::GetScrollPosition()
73    */
74   virtual const Vector2& GetScrollPosition() const;
75
76   /**
77    * @copydoc ModelInterface::GetHorizontalAlignment()
78    */
79   virtual Layout::HorizontalAlignment GetHorizontalAlignment() const;
80
81   /**
82    * @copydoc ModelInterface::GetVerticalAlignment()
83    */
84   virtual Layout::VerticalAlignment GetVerticalAlignment() const;
85
86   /**
87    * @copydoc ModelInterface::IsTextElideEnabled()
88    */
89   virtual bool IsTextElideEnabled() const;
90
91   /**
92    * @copydoc ModelInterface::GetNumberOfLines()
93    */
94   virtual Length GetNumberOfLines() const;
95
96   /**
97    * @copydoc ModelInterface::GetLines()
98    */
99   virtual const LineRun* const GetLines() const;
100
101   /**
102    * @copydoc ModelInterface::GetNumberOfGlyphs()
103    */
104   virtual Length GetNumberOfGlyphs() const;
105
106   /**
107    * @copydoc ModelInterface::GetGlyphs()
108    */
109   virtual const GlyphInfo* const GetGlyphs() const;
110
111   /**
112    * @copydoc ModelInterface::GetLayout()
113    */
114   virtual const Vector2* const GetLayout() const;
115
116   /**
117    * @copydoc ModelInterface::GetColors()
118    */
119   virtual const Vector4* const GetColors() const;
120
121   /**
122    * @copydoc ModelInterface::GetColorIndices()
123    */
124   virtual const ColorIndex* const GetColorIndices() const;
125
126   /**
127    * @copydoc ModelInterface::GetDefaultColor()
128    */
129   virtual const Vector4& GetDefaultColor() const;
130
131 private: // Private contructors & copy operator.
132
133   /**
134    * @brief Private constructor.
135    */
136   Model();
137
138   // Undefined.
139   Model( const Model& handle );
140
141   // Undefined.
142   Model& operator=( const Model& handle );
143
144 protected:
145
146   /**
147    * @brief A reference counted object may only be deleted by calling Unreference().
148    */
149   virtual ~Model();
150
151 public:
152   LogicalModelPtr             mLogicalModel;        ///< Pointer to the logical model.
153   VisualModelPtr              mVisualModel;         ///< Pointer to the visual model.
154   /**
155    * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
156    * Typically this will have a negative value with scrolling occurs.
157    */
158   Vector2                     mScrollPosition;      ///< The text is offset by this position when scrolling.
159   Vector2                     mScrollPositionLast;  ///< The last offset value of mScrollPosition
160   Layout::HorizontalAlignment mHorizontalAlignment; ///< The layout's horizontal alignment.
161   Layout::VerticalAlignment   mVerticalAlignment;   ///< The layout's vertical alignment.
162   float                       mAlignmentOffset;     ///< The alignment offset.
163   bool                        mElideEnabled:1;      ///< Whether the text's elide is enabled.
164 };
165
166 } // namespace Text
167
168 } // namespace Toolkit
169
170 } // namespace Dali
171
172 #endif // DALI_TOOLKIT_TEXT_MODEL_H