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/vector4.h>
26 #include <dali-toolkit/public-api/text/text-enumerations.h>
35 * @brief Properties of underline style.
37 struct UnderlineStyleProperties
42 * Default constructor to set the default values of bitfields
44 UnderlineStyleProperties()
45 : type{Text::Underline::SOLID},
53 dashGapDefined{false},
54 dashWidthDefined{false}
58 UnderlineStyleProperties(Text::Underline::Type type,
67 bool dashWidthDefined)
73 typeDefined{typeDefined},
74 colorDefined{colorDefined},
75 heightDefined{heightDefined},
76 dashGapDefined{dashGapDefined},
77 dashWidthDefined{dashWidthDefined}
81 // Overloading operators
83 bool operator==(const UnderlineStyleProperties& other) const
85 //The property is similar when both are not defined or when both are defined and have the same value.
86 return ((!typeDefined && !other.typeDefined) || ((typeDefined && other.typeDefined) && (type == other.type))) &&
87 ((!colorDefined && !other.colorDefined) || ((colorDefined && other.colorDefined) && (color == other.color))) &&
88 ((!heightDefined && !other.heightDefined) || ((heightDefined && other.heightDefined) && (height == other.height))) &&
89 ((!dashGapDefined && !other.dashGapDefined) || ((dashGapDefined && other.dashGapDefined) && (dashGap == other.dashGap))) &&
90 ((!dashWidthDefined && !other.dashWidthDefined) || ((dashWidthDefined && other.dashWidthDefined) && (dashWidth == other.dashWidth)));
93 bool operator!=(const UnderlineStyleProperties& other) const
95 return !(*this == other);
98 bool IsHeightEqualTo(const UnderlineStyleProperties& other) const
100 return ((!heightDefined && !other.heightDefined) || ((heightDefined && other.heightDefined) && (height == other.height)));
103 UnderlineStyleProperties& CopyIfNotDefined(const UnderlineStyleProperties& other)
105 //Copy only the defined properties in other and not defined in this from other to this
106 if(!typeDefined && other.typeDefined)
112 if(!heightDefined && other.heightDefined)
114 height = other.height;
115 heightDefined = true;
118 if(!colorDefined && other.colorDefined)
124 if(!dashGapDefined && other.dashGapDefined)
126 dashGap = other.dashGap;
127 dashGapDefined = true;
130 if(!dashWidthDefined && other.dashWidthDefined)
132 dashWidth = other.dashWidth;
133 dashWidthDefined = true;
136 // to chain this method
140 UnderlineStyleProperties& OverrideByDefinedProperties(const UnderlineStyleProperties& other)
142 //Copy only the defined properties in other from other to this
143 if(other.typeDefined)
149 if(other.heightDefined)
151 height = other.height;
152 heightDefined = true;
155 if(other.colorDefined)
161 if(other.dashGapDefined)
163 dashGap = other.dashGap;
164 dashGapDefined = true;
167 if(other.dashWidthDefined)
169 dashWidth = other.dashWidth;
170 dashWidthDefined = true;
173 // to chain this method
178 Text::Underline::Type type; ///< The type of underline.
179 Vector4 color; ///< The color of underline.
180 float height; ///< The height of underline.
181 float dashGap; ///< The dash-gap of underline.
182 float dashWidth; ///< The height of underline.
184 bool typeDefined : 1; ///< Whether the type is defined.
185 bool colorDefined : 1; ///< Whether the color is defined.
186 bool heightDefined : 1; ///< Whether the height is defined.
187 bool dashGapDefined : 1; ///< Whether the dash-gap is defined.
188 bool dashWidthDefined : 1; ///< Whether the dash-width is defined.
193 } // namespace Toolkit
197 #endif // DALI_TOOLKIT_TEXT_UNDERLINE_STYLE_PROPERTIES_H