2 * Copyright (c) 2022 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/spannable/spans/strikethrough-span-impl.h>
22 #include <dali-toolkit/internal/text/color-run.h>
23 #include <dali-toolkit/internal/text/markup-tags-and-attributes.h>
33 struct StrikethroughSpan::Impl
35 StrikethroughStyleProperties mStrikethroughProperties; ///< The properties of strikethrough style.
38 StrikethroughSpan::StrikethroughSpan()
41 mImpl = std::make_unique<Impl>();
44 StrikethroughSpan ::~StrikethroughSpan()
48 Dali::Toolkit::Text::StrikethroughSpan StrikethroughSpan::New()
50 StrikethroughSpanPtr object = new StrikethroughSpan();
51 Dali::Toolkit::Text::StrikethroughSpan handle = Dali::Toolkit::Text::StrikethroughSpan(object.Get());
55 Dali::Toolkit::Text::StrikethroughSpan StrikethroughSpan::New(Vector4 color, float height)
57 StrikethroughSpanPtr object = new StrikethroughSpan();
58 object->SetColor(color);
59 object->SetHeight(height);
60 Dali::Toolkit::Text::StrikethroughSpan handle = Dali::Toolkit::Text::StrikethroughSpan(object.Get());
66 const Vector4 StrikethroughSpan::GetColor() const
68 return mImpl->mStrikethroughProperties.color;
71 bool StrikethroughSpan::IsColorDefined() const
73 return mImpl->mStrikethroughProperties.colorDefined;
76 void StrikethroughSpan::SetColor(const Vector4& color)
78 mImpl->mStrikethroughProperties.color = color;
79 mImpl->mStrikethroughProperties.colorDefined = true;
82 const float StrikethroughSpan::GetHeight() const
84 return mImpl->mStrikethroughProperties.height;
87 bool StrikethroughSpan::IsHeightDefined() const
89 return mImpl->mStrikethroughProperties.heightDefined;
92 void StrikethroughSpan::SetHeight(const float& height)
94 mImpl->mStrikethroughProperties.height = height;
95 mImpl->mStrikethroughProperties.heightDefined = true;
98 void StrikethroughSpan::CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const
101 StrikethroughCharacterRun strikethroughCharacterRun;
102 strikethroughCharacterRun.characterRun.characterIndex = range.GetStartIndex();
103 strikethroughCharacterRun.characterRun.numberOfCharacters = range.GetNumberOfIndices();
104 strikethroughCharacterRun.properties = mImpl->mStrikethroughProperties;
105 logicalModel->mStrikethroughCharacterRuns.PushBack(strikethroughCharacterRun);
106 logicalModel->mStrikethroughRunsUpdated = true;
109 } // namespace Internal
113 } // namespace Toolkit