1 #ifndef DALI_TOOLKIT_TEXT_INPUT_STYLE_H
2 #define DALI_TOOLKIT_TEXT_INPUT_STYLE_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>
26 #include <dali-toolkit/internal/text/text-definitions.h>
35 * The input text's style.
43 INPUT_FONT_FAMILY = 0x0002,
44 INPUT_POINT_SIZE = 0x0004,
45 INPUT_FONT_WEIGHT = 0x0008,
46 INPUT_FONT_WIDTH = 0x0010,
47 INPUT_FONT_SLANT = 0x0020,
48 INPUT_LINE_SPACING = 0x0040,
49 INPUT_UNDERLINE = 0x0080,
50 INPUT_SHADOW = 0x0100,
51 INPUT_EMBOSS = 0x0200,
52 INPUT_OUTLINE = 0x0400,
53 INPUT_STRIKETHROUGH = 0x0800
57 : textColor(Color::BLACK),
59 weight(TextAbstraction::FontWeight::NORMAL),
60 width(TextAbstraction::FontWidth::NORMAL),
61 slant(TextAbstraction::FontSlant::NORMAL),
64 underlineProperties(),
68 strikethroughProperties(),
70 isFamilyDefined(false),
71 isWeightDefined(false),
72 isWidthDefined(false),
73 isSlantDefined(false),
75 isLineSpacingDefined(false),
76 isUnderlineDefined(false),
77 isShadowDefined(false),
78 isEmbossDefined(false),
79 isOutlineDefined(false),
80 isStrikethroughDefined(false)
89 * Does not copy the font-style, underline, shadow, emboss and outline property strings.
91 void Copy(const InputStyle& inputStyle)
93 isDefaultColor = inputStyle.isDefaultColor;
94 textColor = inputStyle.textColor;
96 isFamilyDefined = inputStyle.isFamilyDefined;
97 familyName = inputStyle.familyName;
99 isWeightDefined = inputStyle.isWeightDefined;
100 weight = inputStyle.weight;
102 isWidthDefined = inputStyle.isWidthDefined;
103 width = inputStyle.width;
105 isSlantDefined = inputStyle.isSlantDefined;
106 slant = inputStyle.slant;
108 isSizeDefined = inputStyle.isSizeDefined;
109 size = inputStyle.size;
111 isLineSpacingDefined = inputStyle.isLineSpacingDefined;
112 lineSpacing = inputStyle.lineSpacing;
114 isUnderlineDefined = inputStyle.isUnderlineDefined;
115 underlineProperties = inputStyle.underlineProperties;
117 isShadowDefined = inputStyle.isShadowDefined;
118 shadowProperties = inputStyle.shadowProperties;
120 isEmbossDefined = inputStyle.isEmbossDefined;
121 embossProperties = inputStyle.embossProperties;
123 isOutlineDefined = inputStyle.isOutlineDefined;
124 outlineProperties = inputStyle.outlineProperties;
126 isStrikethroughDefined = inputStyle.isStrikethroughDefined;
127 strikethroughProperties = inputStyle.strikethroughProperties;
133 * Does not compare the font-style, underline, shadow, emboss and outline property strings.
135 bool Equal(const InputStyle& inputStyle) const
137 if((isDefaultColor != inputStyle.isDefaultColor) ||
138 (isFamilyDefined != inputStyle.isFamilyDefined) ||
139 (isWeightDefined != inputStyle.isWeightDefined) ||
140 (isWidthDefined != inputStyle.isWidthDefined) ||
141 (isSlantDefined != inputStyle.isSlantDefined) ||
142 (isSizeDefined != inputStyle.isSizeDefined) ||
143 (isLineSpacingDefined != inputStyle.isLineSpacingDefined) ||
144 (isUnderlineDefined != inputStyle.isUnderlineDefined) ||
145 (isShadowDefined != inputStyle.isShadowDefined) ||
146 (isEmbossDefined != inputStyle.isEmbossDefined) ||
147 (isOutlineDefined != inputStyle.isOutlineDefined) ||
148 (textColor != inputStyle.textColor) ||
149 (familyName != inputStyle.familyName) ||
150 (weight != inputStyle.weight) ||
151 (width != inputStyle.width) ||
152 (slant != inputStyle.slant) ||
153 (!Dali::Equals(size, inputStyle.size)) ||
154 (!Dali::Equals(lineSpacing, inputStyle.lineSpacing)) ||
155 (underlineProperties != inputStyle.underlineProperties) ||
156 (shadowProperties != inputStyle.shadowProperties) ||
157 (embossProperties != inputStyle.embossProperties) ||
158 (outlineProperties != inputStyle.outlineProperties) ||
159 (isStrikethroughDefined != inputStyle.isStrikethroughDefined))
167 Mask GetInputStyleChangeMask(const InputStyle& inputStyle) const
171 if(textColor != inputStyle.textColor)
173 mask = static_cast<Mask>(mask | INPUT_COLOR);
175 if(familyName != inputStyle.familyName)
177 mask = static_cast<Mask>(mask | INPUT_FONT_FAMILY);
179 if(weight != inputStyle.weight)
181 mask = static_cast<Mask>(mask | INPUT_FONT_WEIGHT);
183 if(width != inputStyle.width)
185 mask = static_cast<Mask>(mask | INPUT_FONT_WIDTH);
187 if(slant != inputStyle.slant)
189 mask = static_cast<Mask>(mask | INPUT_FONT_SLANT);
191 if(!Dali::Equals(size, inputStyle.size))
193 mask = static_cast<Mask>(mask | INPUT_POINT_SIZE);
195 if(!Dali::Equals(lineSpacing, inputStyle.lineSpacing))
197 mask = static_cast<Mask>(mask | INPUT_LINE_SPACING);
199 if(underlineProperties != inputStyle.underlineProperties)
201 mask = static_cast<Mask>(mask | INPUT_UNDERLINE);
203 if(shadowProperties != inputStyle.shadowProperties)
205 mask = static_cast<Mask>(mask | INPUT_SHADOW);
207 if(embossProperties != inputStyle.embossProperties)
209 mask = static_cast<Mask>(mask | INPUT_EMBOSS);
211 if(outlineProperties != inputStyle.outlineProperties)
213 mask = static_cast<Mask>(mask | INPUT_OUTLINE);
215 if(strikethroughProperties != inputStyle.strikethroughProperties)
217 mask = static_cast<Mask>(mask | INPUT_STRIKETHROUGH);
223 Vector4 textColor; ///< The text's color.
224 std::string familyName; ///< The font's family name.
225 FontWeight weight; ///< The font's weight.
226 FontWidth width; ///< The font's width.
227 FontSlant slant; ///< The font's slant.
228 float size; ///< The font's size.
230 float lineSpacing; ///< The line's spacing.
232 std::string underlineProperties; ///< The underline properties string.
233 std::string shadowProperties; ///< The shadow properties string.
234 std::string embossProperties; ///< The emboss properties string.
235 std::string outlineProperties; ///< The outline properties string.
236 std::string strikethroughProperties; ///< The strikethrough properties string.
238 bool isDefaultColor : 1; ///< Whether the text's color is the default.
239 bool isFamilyDefined : 1; ///< Whether the font's family is defined.
240 bool isWeightDefined : 1; ///< Whether the font's weight is defined.
241 bool isWidthDefined : 1; ///< Whether the font's width is defined.
242 bool isSlantDefined : 1; ///< Whether the font's slant is defined.
243 bool isSizeDefined : 1; ///< Whether the font's size is defined.
245 bool isLineSpacingDefined : 1; ///< Whether the line spacing is defined.
246 bool isUnderlineDefined : 1; ///< Whether the underline parameters are defined.
247 bool isShadowDefined : 1; ///< Whether the shadow parameters are defined.
248 bool isEmbossDefined : 1; ///< Whether the emboss parameters are defined.
249 bool isOutlineDefined : 1; ///< Whether the outline parameters are defined.
250 bool isStrikethroughDefined : 1; ///< Whether the strikethrough parameters are defined.
255 } // namespace Toolkit
259 #endif // DALI_TOOLKIT_TEXT_INPUT_STYLE_H