1 #ifndef DALI_TOOLKIT_TEXT_UNDERLINE_STYLE_PROPERTIES_H
2 #define DALI_TOOLKIT_TEXT_UNDERLINE_STYLE_PROPERTIES_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/common/constants.h>
23 #include <dali/public-api/math/math-utils.h>
24 #include <dali/public-api/math/vector4.h>
27 #include <dali-toolkit/public-api/text/text-enumerations.h>
36 * @brief Properties of underline style.
38 struct UnderlineStyleProperties
43 * Default constructor to set the default values of bitfields
45 UnderlineStyleProperties()
46 : type{Text::Underline::SOLID},
54 dashGapDefined{false},
55 dashWidthDefined{false}
59 UnderlineStyleProperties(Text::Underline::Type type,
68 bool dashWidthDefined)
74 typeDefined{typeDefined},
75 colorDefined{colorDefined},
76 heightDefined{heightDefined},
77 dashGapDefined{dashGapDefined},
78 dashWidthDefined{dashWidthDefined}
82 // Overloading operators
84 bool operator==(const UnderlineStyleProperties& other) const
86 //The property is similar when both are not defined or when both are defined and have the same value.
87 return ((!typeDefined && !other.typeDefined) || ((typeDefined && other.typeDefined) && (type == other.type))) &&
88 ((!colorDefined && !other.colorDefined) || ((colorDefined && other.colorDefined) && (color == other.color))) &&
89 ((!heightDefined && !other.heightDefined) || ((heightDefined && other.heightDefined) && (Dali::Equals(height, other.height)))) &&
90 ((!dashGapDefined && !other.dashGapDefined) || ((dashGapDefined && other.dashGapDefined) && (Dali::Equals(dashGap, other.dashGap)))) &&
91 ((!dashWidthDefined && !other.dashWidthDefined) || ((dashWidthDefined && other.dashWidthDefined) && (Dali::Equals(dashWidth, other.dashWidth))));
94 bool operator!=(const UnderlineStyleProperties& other) const
96 return !(*this == other);
99 bool IsHeightEqualTo(const UnderlineStyleProperties& other) const
101 return ((!heightDefined && !other.heightDefined) || ((heightDefined && other.heightDefined) && (Dali::Equals(height, other.height))));
104 UnderlineStyleProperties& CopyIfNotDefined(const UnderlineStyleProperties& other)
106 //Copy only the defined properties in other and not defined in this from other to this
107 if(!typeDefined && other.typeDefined)
113 if(!heightDefined && other.heightDefined)
115 height = other.height;
116 heightDefined = true;
119 if(!colorDefined && other.colorDefined)
125 if(!dashGapDefined && other.dashGapDefined)
127 dashGap = other.dashGap;
128 dashGapDefined = true;
131 if(!dashWidthDefined && other.dashWidthDefined)
133 dashWidth = other.dashWidth;
134 dashWidthDefined = true;
137 // to chain this method
141 UnderlineStyleProperties& OverrideByDefinedProperties(const UnderlineStyleProperties& other)
143 //Copy only the defined properties in other from other to this
144 if(other.typeDefined)
150 if(other.heightDefined)
152 height = other.height;
153 heightDefined = true;
156 if(other.colorDefined)
162 if(other.dashGapDefined)
164 dashGap = other.dashGap;
165 dashGapDefined = true;
168 if(other.dashWidthDefined)
170 dashWidth = other.dashWidth;
171 dashWidthDefined = true;
174 // to chain this method
179 Text::Underline::Type type; ///< The type of underline.
180 Vector4 color; ///< The color of underline.
181 float height; ///< The height of underline.
182 float dashGap; ///< The dash-gap of underline.
183 float dashWidth; ///< The height of underline.
185 bool typeDefined : 1; ///< Whether the type is defined.
186 bool colorDefined : 1; ///< Whether the color is defined.
187 bool heightDefined : 1; ///< Whether the height is defined.
188 bool dashGapDefined : 1; ///< Whether the dash-gap is defined.
189 bool dashWidthDefined : 1; ///< Whether the dash-width is defined.
194 } // namespace Toolkit
198 #endif // DALI_TOOLKIT_TEXT_UNDERLINE_STYLE_PROPERTIES_H