2d60854e0fc65416de16519d30d5f04f0d9f01af
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-model.cpp
1 /*
2  * Copyright (c) 2021 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 namespace Toolkit
24 {
25 namespace Text
26 {
27 ModelPtr Model::New()
28 {
29   return ModelPtr(new Model());
30 }
31
32 const Size& Model::GetControlSize() const
33 {
34   return mVisualModel->mControlSize;
35 }
36
37 const Size& Model::GetLayoutSize() const
38 {
39   return mVisualModel->GetLayoutSize();
40 }
41
42 const Vector2& Model::GetScrollPosition() const
43 {
44   return mScrollPosition;
45 }
46
47 HorizontalAlignment::Type Model::GetHorizontalAlignment() const
48 {
49   return mHorizontalAlignment;
50 }
51
52 VerticalAlignment::Type Model::GetVerticalAlignment() const
53 {
54   return mVerticalAlignment;
55 }
56
57 DevelText::VerticalLineAlignment::Type Model::GetVerticalLineAlignment() const
58 {
59   return mVerticalLineAlignment;
60 }
61
62 bool Model::IsTextElideEnabled() const
63 {
64   return mElideEnabled;
65 }
66
67 Length Model::GetNumberOfLines() const
68 {
69   return mVisualModel->mLines.Count();
70 }
71
72 const LineRun* const Model::GetLines() const
73 {
74   return mVisualModel->mLines.Begin();
75 }
76
77 Length Model::GetNumberOfScripts() const
78 {
79   return mLogicalModel->mScriptRuns.Count();
80 }
81
82 const ScriptRun* const Model::GetScriptRuns() const
83 {
84   return mLogicalModel->mScriptRuns.Begin();
85 }
86
87 Length Model::GetNumberOfGlyphs() const
88 {
89   return mVisualModel->mGlyphs.Count();
90 }
91
92 const GlyphInfo* const Model::GetGlyphs() const
93 {
94   return mVisualModel->mGlyphs.Begin();
95 }
96
97 const Vector2* const Model::GetLayout() const
98 {
99   return mVisualModel->mGlyphPositions.Begin();
100 }
101
102 const Vector4* const Model::GetColors() const
103 {
104   return mVisualModel->mColors.Begin();
105 }
106
107 const ColorIndex* const Model::GetColorIndices() const
108 {
109   return mVisualModel->mColorIndices.Begin();
110 }
111
112 const Vector4* const Model::GetBackgroundColors() const
113 {
114   return mVisualModel->mBackgroundColors.Begin();
115 }
116
117 const ColorIndex* const Model::GetBackgroundColorIndices() const
118 {
119   return mVisualModel->mBackgroundColorIndices.Begin();
120 }
121
122 const Vector4& Model::GetDefaultColor() const
123 {
124   return mVisualModel->mTextColor;
125 }
126
127 const Vector2& Model::GetShadowOffset() const
128 {
129   return mVisualModel->mShadowOffset;
130 }
131
132 const Vector4& Model::GetShadowColor() const
133 {
134   return mVisualModel->mShadowColor;
135 }
136
137 const float& Model::GetShadowBlurRadius() const
138 {
139   return mVisualModel->mShadowBlurRadius;
140 }
141
142 const Vector4& Model::GetUnderlineColor() const
143 {
144   return mVisualModel->GetUnderlineColor();
145 }
146
147 bool Model::IsUnderlineEnabled() const
148 {
149   return mVisualModel->IsUnderlineEnabled();
150 }
151
152 float Model::GetUnderlineHeight() const
153 {
154   return mVisualModel->GetUnderlineHeight();
155 }
156
157 Length Model::GetNumberOfUnderlineRuns() const
158 {
159   return mVisualModel->GetNumberOfUnderlineRuns();
160 }
161
162 void Model::GetUnderlineRuns(GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const
163 {
164   mVisualModel->GetUnderlineRuns(underlineRuns, index, numberOfRuns);
165 }
166
167 const Vector4& Model::GetOutlineColor() const
168 {
169   return mVisualModel->GetOutlineColor();
170 }
171
172 uint16_t Model::GetOutlineWidth() const
173 {
174   return mVisualModel->GetOutlineWidth();
175 }
176
177 const Vector4& Model::GetBackgroundColor() const
178 {
179   return mVisualModel->GetBackgroundColor();
180 }
181
182 bool Model::IsBackgroundEnabled() const
183 {
184   return mVisualModel->IsBackgroundEnabled();
185 }
186
187 Model::Model()
188 : mLogicalModel(),
189   mVisualModel(),
190   mScrollPosition(),
191   mScrollPositionLast(),
192   mHorizontalAlignment(Text::HorizontalAlignment::BEGIN),
193   mVerticalAlignment(Text::VerticalAlignment::TOP),
194   mVerticalLineAlignment(DevelText::VerticalLineAlignment::TOP),
195   mLineWrapMode(Text::LineWrap::WORD),
196   mAlignmentOffset(0.0f),
197   mElideEnabled(false),
198   mIgnoreSpacesAfterText(true),
199   mMatchSystemLanguageDirection(false)
200 {
201   mLogicalModel = LogicalModel::New();
202   mVisualModel  = VisualModel::New();
203 }
204
205 Model::~Model()
206 {
207 }
208
209 } // namespace Text
210
211 } // namespace Toolkit
212
213 } // namespace Dali