14016c458cbd67160bedf8b7c74f3c0f5f78b2d1
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / underline-style-properties.h
1 #ifndef DALI_TOOLKIT_TEXT_UNDERLINE_STYLE_PROPERTIES_H
2 #define DALI_TOOLKIT_TEXT_UNDERLINE_STYLE_PROPERTIES_H
3
4 /*
5  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/math/vector4.h>
23
24 // INTERNAL INCLUDES
25
26 #include <dali-toolkit/public-api/text/text-enumerations.h>
27
28 namespace Dali
29 {
30 namespace Toolkit
31 {
32 namespace Text
33 {
34 /**
35  * @brief Properties of underline style.
36  */
37 struct UnderlineStyleProperties
38 {
39   // Constructors
40
41   /**
42    * Default constructor to set the default values of bitfields
43    */
44   UnderlineStyleProperties()
45   : type{Text::Underline::SOLID},
46     color{Color::BLACK},
47     height{0u},
48     dashGap{1u},
49     dashWidth{2u},
50     typeDefined{false},
51     colorDefined{false},
52     heightDefined{false},
53     dashGapDefined{false},
54     dashWidthDefined{false}
55   {
56   }
57
58   UnderlineStyleProperties(Text::Underline::Type type,
59                            Vector4               color,
60                            float                 height,
61                            float                 dashGap,
62                            float                 dashWidth,
63                            bool                  typeDefined,
64                            bool                  colorDefined,
65                            bool                  heightDefined,
66                            bool                  dashGapDefined,
67                            bool                  dashWidthDefined)
68   : type{type},
69     color{color},
70     height{height},
71     dashGap{dashGap},
72     dashWidth{dashWidth},
73     typeDefined{typeDefined},
74     colorDefined{colorDefined},
75     heightDefined{heightDefined},
76     dashGapDefined{dashGapDefined},
77     dashWidthDefined{dashWidthDefined}
78   {
79   }
80
81   // Overloading operators
82
83   bool operator==(const UnderlineStyleProperties& other) const
84   {
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)));
91   }
92
93   bool operator!=(const UnderlineStyleProperties& other) const
94   {
95     return !(*this == other);
96   }
97
98   bool IsHeightEqualTo(const UnderlineStyleProperties& other) const
99   {
100     return ((!heightDefined && !other.heightDefined) || ((heightDefined && other.heightDefined) && (height == other.height)));
101   }
102
103   //Attributes
104   Text::Underline::Type type;      ///< The type of underline.
105   Vector4               color;     ///< The color of underline.
106   float                 height;    ///< The height of underline.
107   float                 dashGap;   ///< The dash-gap of underline.
108   float                 dashWidth; ///< The height of underline.
109
110   bool typeDefined : 1;      ///< Whether the type is defined.
111   bool colorDefined : 1;     ///< Whether the color is defined.
112   bool heightDefined : 1;    ///< Whether the height is defined.
113   bool dashGapDefined : 1;   ///< Whether the dash-gap is defined.
114   bool dashWidthDefined : 1; ///< Whether the dash-width is defined.
115 };
116
117 } // namespace Text
118
119 } // namespace Toolkit
120
121 } // namespace Dali
122
123 #endif // DALI_TOOLKIT_TEXT_UNDERLINE_STYLE_PROPERTIES_H