Merge "GetLineCount() after GetTextDirection() returns wrong value." into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-model.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-toolkit/internal/text/text-model.h>
20
21 namespace Dali
22 {
23
24 namespace Toolkit
25 {
26
27 namespace Text
28 {
29
30 ModelPtr Model::New()
31 {
32   return ModelPtr( new Model() );
33 }
34
35 const Size& Model::GetControlSize() const
36 {
37   return mVisualModel->mControlSize;
38 }
39
40 const Size& Model::GetLayoutSize() const
41 {
42   return mVisualModel->GetLayoutSize();
43 }
44
45 const Vector2& Model::GetScrollPosition() const
46 {
47   return mScrollPosition;
48 }
49
50 HorizontalAlignment::Type Model::GetHorizontalAlignment() const
51 {
52   return mHorizontalAlignment;
53 }
54
55 VerticalAlignment::Type Model::GetVerticalAlignment() const
56 {
57   return mVerticalAlignment;
58 }
59
60 DevelText::VerticalLineAlignment::Type Model::GetVerticalLineAlignment() const
61 {
62   return mVerticalLineAlignment;
63 }
64
65 bool Model::IsTextElideEnabled() const
66 {
67   return mElideEnabled;
68 }
69
70 Length Model::GetNumberOfLines() const
71 {
72   return mVisualModel->mLines.Count();
73 }
74
75 const LineRun* const Model::GetLines() const
76 {
77   return mVisualModel->mLines.Begin();
78 }
79
80 Length Model::GetNumberOfScripts() const
81 {
82   return mLogicalModel->mScriptRuns.Count();
83 }
84
85 const ScriptRun* const Model::GetScriptRuns() const
86 {
87   return mLogicalModel->mScriptRuns.Begin();
88 }
89
90 Length Model::GetNumberOfGlyphs() const
91 {
92   return mVisualModel->mGlyphs.Count();
93 }
94
95 const GlyphInfo* const Model::GetGlyphs() const
96 {
97   return mVisualModel->mGlyphs.Begin();
98 }
99
100 const Vector2* const Model::GetLayout() const
101 {
102   return mVisualModel->mGlyphPositions.Begin();
103 }
104
105 const Vector4* const Model::GetColors() const
106 {
107   return mVisualModel->mColors.Begin();
108 }
109
110 const ColorIndex* const Model::GetColorIndices() const
111 {
112   return mVisualModel->mColorIndices.Begin();
113 }
114
115 const Vector4* const Model::GetBackgroundColors() const
116 {
117   return mVisualModel->mBackgroundColors.Begin();
118 }
119
120 const ColorIndex* const Model::GetBackgroundColorIndices() const
121 {
122   return mVisualModel->mBackgroundColorIndices.Begin();
123 }
124
125 const Vector4& Model::GetDefaultColor() const
126 {
127   return mVisualModel->mTextColor;
128 }
129
130 const Vector2& Model::GetShadowOffset() const
131 {
132   return mVisualModel->mShadowOffset;
133 }
134
135 const Vector4& Model::GetShadowColor() const
136 {
137   return mVisualModel->mShadowColor;
138 }
139
140 const float& Model::GetShadowBlurRadius() const
141 {
142   return mVisualModel->mShadowBlurRadius;
143 }
144
145 const Vector4& Model::GetUnderlineColor() const
146 {
147   return mVisualModel->GetUnderlineColor();
148 }
149
150 bool Model::IsUnderlineEnabled() const
151 {
152   return mVisualModel->IsUnderlineEnabled();
153 }
154
155 float Model::GetUnderlineHeight() const
156 {
157   return mVisualModel->GetUnderlineHeight();
158 }
159
160 Length Model::GetNumberOfUnderlineRuns() const
161 {
162   return mVisualModel->GetNumberOfUnderlineRuns();
163 }
164
165 void Model::GetUnderlineRuns( GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns ) const
166 {
167   mVisualModel->GetUnderlineRuns( underlineRuns, index, numberOfRuns );
168 }
169
170 const Vector4& Model::GetOutlineColor() const
171 {
172   return mVisualModel->GetOutlineColor();
173 }
174
175 uint16_t Model::GetOutlineWidth() const
176 {
177   return mVisualModel->GetOutlineWidth();
178 }
179
180 const Vector4& Model::GetBackgroundColor() const
181 {
182   return mVisualModel->GetBackgroundColor();
183 }
184
185 bool Model::IsBackgroundEnabled() const
186 {
187   return mVisualModel->IsBackgroundEnabled();
188 }
189
190 Model::Model()
191 : mLogicalModel(),
192   mVisualModel(),
193   mScrollPosition(),
194   mScrollPositionLast(),
195   mHorizontalAlignment( Text::HorizontalAlignment::BEGIN ),
196   mVerticalAlignment( Text::VerticalAlignment::TOP ),
197   mVerticalLineAlignment( DevelText::VerticalLineAlignment::TOP ),
198   mLineWrapMode( Text::LineWrap::WORD ),
199   mAlignmentOffset( 0.0f ),
200   mElideEnabled( false ),
201   mIgnoreSpacesAfterText( true ),
202   mMatchSystemLanguageDirection( false )
203 {
204   mLogicalModel = LogicalModel::New();
205   mVisualModel = VisualModel::New();
206 }
207
208 Model::~Model()
209 {
210 }
211
212 } // namespace Text
213
214 } // namespace Toolkit
215
216 } // namespace Dali