Merge remote-tracking branch 'origin/devel/master' into tizen
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / spannable / spans / strikethrough-span-impl.cpp
1 /*
2  * Copyright (c) 2022 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/spannable/spans/strikethrough-span-impl.h>
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/internal/text/color-run.h>
23 #include <dali-toolkit/internal/text/markup-tags-and-attributes.h>
24
25 namespace Dali
26 {
27 namespace Toolkit
28 {
29 namespace Text
30 {
31 namespace Internal
32 {
33 struct StrikethroughSpan::Impl
34 {
35   StrikethroughStyleProperties mStrikethroughProperties; ///< The properties of strikethrough style.
36 };
37
38 StrikethroughSpan::StrikethroughSpan()
39 : BaseSpan(Dali::Toolkit::Text::SpanType::Value::STRIKETHROUGH)
40 {
41   mImpl = std::make_unique<Impl>();
42 }
43
44 StrikethroughSpan ::~StrikethroughSpan()
45 {
46 }
47
48 Dali::Toolkit::Text::StrikethroughSpan StrikethroughSpan::New()
49 {
50   StrikethroughSpanPtr                   object = new StrikethroughSpan();
51   Dali::Toolkit::Text::StrikethroughSpan handle = Dali::Toolkit::Text::StrikethroughSpan(object.Get());
52   return handle;
53 }
54
55 Dali::Toolkit::Text::StrikethroughSpan StrikethroughSpan::New(Vector4 color, float height)
56 {
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());
61
62   return handle;
63 }
64
65 //Methods
66 const Vector4 StrikethroughSpan::GetColor() const
67 {
68   return mImpl->mStrikethroughProperties.color;
69 }
70
71 bool StrikethroughSpan::IsColorDefined() const
72 {
73   return mImpl->mStrikethroughProperties.colorDefined;
74 }
75
76 void StrikethroughSpan::SetColor(const Vector4& color)
77 {
78   mImpl->mStrikethroughProperties.color        = color;
79   mImpl->mStrikethroughProperties.colorDefined = true;
80 }
81
82 const float StrikethroughSpan::GetHeight() const
83 {
84   return mImpl->mStrikethroughProperties.height;
85 }
86
87 bool StrikethroughSpan::IsHeightDefined() const
88 {
89   return mImpl->mStrikethroughProperties.heightDefined;
90 }
91
92 void StrikethroughSpan::SetHeight(const float& height)
93 {
94   mImpl->mStrikethroughProperties.height        = height;
95   mImpl->mStrikethroughProperties.heightDefined = true;
96 }
97
98 void StrikethroughSpan::CreateStyleCharacterRun(IntrusivePtr<LogicalModel>& logicalModel, const Dali::Toolkit::Text::Range& range) const
99
100 {
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;
107 }
108
109 } // namespace Internal
110
111 } // namespace Text
112
113 } // namespace Toolkit
114
115 } // namespace Dali