1 #ifndef DALI_TOOLKIT_TEXT_INPUT_STYLE_H
2 #define DALI_TOOLKIT_TEXT_INPUT_STYLE_H
5 * Copyright (c) 2021 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>
25 #include <dali-toolkit/internal/text/text-definitions.h>
34 * The input text's style.
42 INPUT_FONT_FAMILY = 0x0002,
43 INPUT_POINT_SIZE = 0x0004,
44 INPUT_FONT_WEIGHT = 0x0008,
45 INPUT_FONT_WIDTH = 0x0010,
46 INPUT_FONT_SLANT = 0x0020,
47 INPUT_LINE_SPACING = 0x0040,
48 INPUT_UNDERLINE = 0x0080,
49 INPUT_SHADOW = 0x0100,
50 INPUT_EMBOSS = 0x0200,
51 INPUT_OUTLINE = 0x0400,
52 INPUT_STRIKETHROUGH = 0x0800
56 : textColor(Color::BLACK),
58 weight(TextAbstraction::FontWeight::NORMAL),
59 width(TextAbstraction::FontWidth::NORMAL),
60 slant(TextAbstraction::FontSlant::NORMAL),
63 underlineProperties(),
67 strikethroughProperties(),
69 isFamilyDefined(false),
70 isWeightDefined(false),
71 isWidthDefined(false),
72 isSlantDefined(false),
74 isLineSpacingDefined(false),
75 isUnderlineDefined(false),
76 isShadowDefined(false),
77 isEmbossDefined(false),
78 isOutlineDefined(false),
79 isStrikethroughDefined(false)
88 * Does not copy the font-style, underline, shadow, emboss and outline property strings.
90 void Copy(const InputStyle& inputStyle)
92 isDefaultColor = inputStyle.isDefaultColor;
93 textColor = inputStyle.textColor;
95 isFamilyDefined = inputStyle.isFamilyDefined;
96 familyName = inputStyle.familyName;
98 isWeightDefined = inputStyle.isWeightDefined;
99 weight = inputStyle.weight;
101 isWidthDefined = inputStyle.isWidthDefined;
102 width = inputStyle.width;
104 isSlantDefined = inputStyle.isSlantDefined;
105 slant = inputStyle.slant;
107 isSizeDefined = inputStyle.isSizeDefined;
108 size = inputStyle.size;
110 isLineSpacingDefined = inputStyle.isLineSpacingDefined;
111 lineSpacing = inputStyle.lineSpacing;
113 isUnderlineDefined = inputStyle.isUnderlineDefined;
114 underlineProperties = inputStyle.underlineProperties;
116 isShadowDefined = inputStyle.isShadowDefined;
117 shadowProperties = inputStyle.shadowProperties;
119 isEmbossDefined = inputStyle.isEmbossDefined;
120 embossProperties = inputStyle.embossProperties;
122 isOutlineDefined = inputStyle.isOutlineDefined;
123 outlineProperties = inputStyle.outlineProperties;
125 isStrikethroughDefined = inputStyle.isStrikethroughDefined;
126 strikethroughProperties = inputStyle.strikethroughProperties;
132 * Does not compare the font-style, underline, shadow, emboss and outline property strings.
134 bool Equal(const InputStyle& inputStyle) const
136 if((isDefaultColor != inputStyle.isDefaultColor) ||
137 (isFamilyDefined != inputStyle.isFamilyDefined) ||
138 (isWeightDefined != inputStyle.isWeightDefined) ||
139 (isWidthDefined != inputStyle.isWidthDefined) ||
140 (isSlantDefined != inputStyle.isSlantDefined) ||
141 (isSizeDefined != inputStyle.isSizeDefined) ||
142 (isLineSpacingDefined != inputStyle.isLineSpacingDefined) ||
143 (isUnderlineDefined != inputStyle.isUnderlineDefined) ||
144 (isShadowDefined != inputStyle.isShadowDefined) ||
145 (isEmbossDefined != inputStyle.isEmbossDefined) ||
146 (isOutlineDefined != inputStyle.isOutlineDefined) ||
147 (textColor != inputStyle.textColor) ||
148 (familyName != inputStyle.familyName) ||
149 (weight != inputStyle.weight) ||
150 (width != inputStyle.width) ||
151 (slant != inputStyle.slant) ||
152 (size != inputStyle.size) ||
153 (lineSpacing != inputStyle.lineSpacing) ||
154 (underlineProperties != inputStyle.underlineProperties) ||
155 (shadowProperties != inputStyle.shadowProperties) ||
156 (embossProperties != inputStyle.embossProperties) ||
157 (outlineProperties != inputStyle.outlineProperties) ||
158 (isStrikethroughDefined != inputStyle.isStrikethroughDefined))
166 Mask GetInputStyleChangeMask(const InputStyle& inputStyle) const
170 if(textColor != inputStyle.textColor)
172 mask = static_cast<Mask>(mask | INPUT_COLOR);
174 if(familyName != inputStyle.familyName)
176 mask = static_cast<Mask>(mask | INPUT_FONT_FAMILY);
178 if(weight != inputStyle.weight)
180 mask = static_cast<Mask>(mask | INPUT_FONT_WEIGHT);
182 if(width != inputStyle.width)
184 mask = static_cast<Mask>(mask | INPUT_FONT_WIDTH);
186 if(slant != inputStyle.slant)
188 mask = static_cast<Mask>(mask | INPUT_FONT_SLANT);
190 if(size != inputStyle.size)
192 mask = static_cast<Mask>(mask | INPUT_POINT_SIZE);
194 if(lineSpacing != inputStyle.lineSpacing)
196 mask = static_cast<Mask>(mask | INPUT_LINE_SPACING);
198 if(underlineProperties != inputStyle.underlineProperties)
200 mask = static_cast<Mask>(mask | INPUT_UNDERLINE);
202 if(shadowProperties != inputStyle.shadowProperties)
204 mask = static_cast<Mask>(mask | INPUT_SHADOW);
206 if(embossProperties != inputStyle.embossProperties)
208 mask = static_cast<Mask>(mask | INPUT_EMBOSS);
210 if(outlineProperties != inputStyle.outlineProperties)
212 mask = static_cast<Mask>(mask | INPUT_OUTLINE);
214 if(strikethroughProperties != inputStyle.strikethroughProperties)
216 mask = static_cast<Mask>(mask | INPUT_STRIKETHROUGH);
222 Vector4 textColor; ///< The text's color.
223 std::string familyName; ///< The font's family name.
224 FontWeight weight; ///< The font's weight.
225 FontWidth width; ///< The font's width.
226 FontSlant slant; ///< The font's slant.
227 float size; ///< The font's size.
229 float lineSpacing; ///< The line's spacing.
231 std::string underlineProperties; ///< The underline properties string.
232 std::string shadowProperties; ///< The shadow properties string.
233 std::string embossProperties; ///< The emboss properties string.
234 std::string outlineProperties; ///< The outline properties string.
235 std::string strikethroughProperties; ///< The strikethrough properties string.
237 bool isDefaultColor : 1; ///< Whether the text's color is the default.
238 bool isFamilyDefined : 1; ///< Whether the font's family is defined.
239 bool isWeightDefined : 1; ///< Whether the font's weight is defined.
240 bool isWidthDefined : 1; ///< Whether the font's width is defined.
241 bool isSlantDefined : 1; ///< Whether the font's slant is defined.
242 bool isSizeDefined : 1; ///< Whether the font's size is defined.
244 bool isLineSpacingDefined : 1; ///< Whether the line spacing is defined.
245 bool isUnderlineDefined : 1; ///< Whether the underline parameters are defined.
246 bool isShadowDefined : 1; ///< Whether the shadow parameters are defined.
247 bool isEmbossDefined : 1; ///< Whether the emboss parameters are defined.
248 bool isOutlineDefined : 1; ///< Whether the outline parameters are defined.
249 bool isStrikethroughDefined : 1; ///< Whether the strikethrough parameters are defined.
254 } // namespace Toolkit
258 #endif // DALI_TOOLKIT_TEXT_INPUT_STYLE_H