2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali-toolkit/internal/text/text-model.h>
22 #include <dali/devel-api/adaptor-framework/environment-variable.h>
32 const char* DALI_ENV_MATCH_SYSTEM_LANGUAGE_DIRECTION("DALI_MATCH_SYSTEM_LANGUAGE_DIRECTION");
37 return ModelPtr(new Model());
40 const Size& Model::GetControlSize() const
42 return mVisualModel->mControlSize;
45 const Size& Model::GetLayoutSize() const
47 return mVisualModel->GetLayoutSize();
50 const Vector2& Model::GetScrollPosition() const
52 return mScrollPosition;
55 HorizontalAlignment::Type Model::GetHorizontalAlignment() const
57 return mHorizontalAlignment;
60 VerticalAlignment::Type Model::GetVerticalAlignment() const
62 return mVerticalAlignment;
65 DevelText::VerticalLineAlignment::Type Model::GetVerticalLineAlignment() const
67 return mVerticalLineAlignment;
70 bool Model::IsTextElideEnabled() const
75 Length Model::GetNumberOfLines() const
77 return mVisualModel->mLines.Count();
80 const LineRun* const Model::GetLines() const
82 return mVisualModel->mLines.Begin();
85 Length Model::GetNumberOfScripts() const
87 return mLogicalModel->mScriptRuns.Count();
90 const ScriptRun* const Model::GetScriptRuns() const
92 return mLogicalModel->mScriptRuns.Begin();
95 Length Model::GetNumberOfGlyphs() const
97 return mVisualModel->mGlyphs.Count();
100 const GlyphInfo* const Model::GetGlyphs() const
102 return mVisualModel->mGlyphs.Begin();
105 const Vector2* const Model::GetLayout() const
107 return mVisualModel->mGlyphPositions.Begin();
110 const Vector4* const Model::GetColors() const
112 return mVisualModel->mColors.Begin();
115 const ColorIndex* const Model::GetColorIndices() const
117 return mVisualModel->mColorIndices.Begin();
120 const Vector4* const Model::GetBackgroundColors() const
122 return mVisualModel->mBackgroundColors.Begin();
125 const ColorIndex* const Model::GetBackgroundColorIndices() const
127 return mVisualModel->mBackgroundColorIndices.Begin();
130 bool const Model::IsMarkupBackgroundColorSet() const
132 return (mVisualModel->mBackgroundColorIndices.Count() > 0);
135 const Vector4& Model::GetDefaultColor() const
137 return mVisualModel->mTextColor;
140 const Vector2& Model::GetShadowOffset() const
142 return mVisualModel->mShadowOffset;
145 const Vector4& Model::GetShadowColor() const
147 return mVisualModel->mShadowColor;
150 const float& Model::GetShadowBlurRadius() const
152 return mVisualModel->mShadowBlurRadius;
155 const Vector4& Model::GetUnderlineColor() const
157 return mVisualModel->GetUnderlineColor();
160 bool Model::IsUnderlineEnabled() const
162 return mVisualModel->IsUnderlineEnabled();
165 float Model::GetUnderlineHeight() const
167 return mVisualModel->GetUnderlineHeight();
170 Length Model::GetNumberOfUnderlineRuns() const
172 return mVisualModel->GetNumberOfUnderlineRuns();
175 void Model::GetUnderlineRuns(GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const
177 mVisualModel->GetUnderlineRuns(underlineRuns, index, numberOfRuns);
180 const Vector4& Model::GetOutlineColor() const
182 return mVisualModel->GetOutlineColor();
185 uint16_t Model::GetOutlineWidth() const
187 return mVisualModel->GetOutlineWidth();
190 const Vector4& Model::GetBackgroundColor() const
192 return mVisualModel->GetBackgroundColor();
195 bool Model::IsBackgroundEnabled() const
197 return mVisualModel->IsBackgroundEnabled();
200 bool Model::IsMarkupProcessorEnabled() const
202 return mVisualModel->IsMarkupProcessorEnabled();
205 const GlyphInfo* Model::GetHyphens() const
207 return mVisualModel->mHyphen.glyph.Begin();
210 const Length* Model::GetHyphenIndices() const
212 return mVisualModel->mHyphen.index.Begin();
215 Length Model::GetHyphensCount() const
217 return mVisualModel->mHyphen.glyph.Size();
224 mScrollPositionLast(),
225 mHorizontalAlignment(Text::HorizontalAlignment::BEGIN),
226 mVerticalAlignment(Text::VerticalAlignment::TOP),
227 mVerticalLineAlignment(DevelText::VerticalLineAlignment::TOP),
228 mLineWrapMode(Text::LineWrap::WORD),
229 mAlignmentOffset(0.0f),
230 mElideEnabled(false),
231 mIgnoreSpacesAfterText(true),
232 mMatchSystemLanguageDirection(true)
234 mLogicalModel = LogicalModel::New();
235 mVisualModel = VisualModel::New();
237 // Check environment variable for DALI_MATCH_SYSTEM_LANGUAGE_DIRECTION
238 auto match = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_MATCH_SYSTEM_LANGUAGE_DIRECTION);
239 mMatchSystemLanguageDirection = match ? (std::atoi(match) == 0 ? false : true) : mMatchSystemLanguageDirection;
248 } // namespace Toolkit