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
55 : textColor(Color::BLACK),
57 weight(TextAbstraction::FontWeight::NORMAL),
58 width(TextAbstraction::FontWidth::NORMAL),
59 slant(TextAbstraction::FontSlant::NORMAL),
62 underlineProperties(),
67 isFamilyDefined(false),
68 isWeightDefined(false),
69 isWidthDefined(false),
70 isSlantDefined(false),
72 isLineSpacingDefined(false),
73 isUnderlineDefined(false),
74 isShadowDefined(false),
75 isEmbossDefined(false),
76 isOutlineDefined(false)
85 * Does not copy the font-style, underline, shadow, emboss and outline property strings.
87 void Copy(const InputStyle& inputStyle)
89 isDefaultColor = inputStyle.isDefaultColor;
90 textColor = inputStyle.textColor;
92 isFamilyDefined = inputStyle.isFamilyDefined;
93 familyName = inputStyle.familyName;
95 isWeightDefined = inputStyle.isWeightDefined;
96 weight = inputStyle.weight;
98 isWidthDefined = inputStyle.isWidthDefined;
99 width = inputStyle.width;
101 isSlantDefined = inputStyle.isSlantDefined;
102 slant = inputStyle.slant;
104 isSizeDefined = inputStyle.isSizeDefined;
105 size = inputStyle.size;
107 isLineSpacingDefined = inputStyle.isLineSpacingDefined;
108 lineSpacing = inputStyle.lineSpacing;
110 isUnderlineDefined = inputStyle.isUnderlineDefined;
111 underlineProperties = inputStyle.underlineProperties;
113 isShadowDefined = inputStyle.isShadowDefined;
114 shadowProperties = inputStyle.shadowProperties;
116 isEmbossDefined = inputStyle.isEmbossDefined;
117 embossProperties = inputStyle.embossProperties;
119 isOutlineDefined = inputStyle.isOutlineDefined;
120 outlineProperties = inputStyle.outlineProperties;
126 * Does not compare the font-style, underline, shadow, emboss and outline property strings.
128 bool Equal(const InputStyle& inputStyle) const
130 if((isDefaultColor != inputStyle.isDefaultColor) ||
131 (isFamilyDefined != inputStyle.isFamilyDefined) ||
132 (isWeightDefined != inputStyle.isWeightDefined) ||
133 (isWidthDefined != inputStyle.isWidthDefined) ||
134 (isSlantDefined != inputStyle.isSlantDefined) ||
135 (isSizeDefined != inputStyle.isSizeDefined) ||
136 (isLineSpacingDefined != inputStyle.isLineSpacingDefined) ||
137 (isUnderlineDefined != inputStyle.isUnderlineDefined) ||
138 (isShadowDefined != inputStyle.isShadowDefined) ||
139 (isEmbossDefined != inputStyle.isEmbossDefined) ||
140 (isOutlineDefined != inputStyle.isOutlineDefined) ||
141 (textColor != inputStyle.textColor) ||
142 (familyName != inputStyle.familyName) ||
143 (weight != inputStyle.weight) ||
144 (width != inputStyle.width) ||
145 (slant != inputStyle.slant) ||
146 (size != inputStyle.size) ||
147 (lineSpacing != inputStyle.lineSpacing) ||
148 (underlineProperties != inputStyle.underlineProperties) ||
149 (shadowProperties != inputStyle.shadowProperties) ||
150 (embossProperties != inputStyle.embossProperties) ||
151 (outlineProperties != inputStyle.outlineProperties))
159 Mask GetInputStyleChangeMask(const InputStyle& inputStyle) const
163 if(textColor != inputStyle.textColor)
165 mask = static_cast<Mask>(mask | INPUT_COLOR);
167 if(familyName != inputStyle.familyName)
169 mask = static_cast<Mask>(mask | INPUT_FONT_FAMILY);
171 if(weight != inputStyle.weight)
173 mask = static_cast<Mask>(mask | INPUT_FONT_WEIGHT);
175 if(width != inputStyle.width)
177 mask = static_cast<Mask>(mask | INPUT_FONT_WIDTH);
179 if(slant != inputStyle.slant)
181 mask = static_cast<Mask>(mask | INPUT_FONT_SLANT);
183 if(size != inputStyle.size)
185 mask = static_cast<Mask>(mask | INPUT_POINT_SIZE);
187 if(lineSpacing != inputStyle.lineSpacing)
189 mask = static_cast<Mask>(mask | INPUT_LINE_SPACING);
191 if(underlineProperties != inputStyle.underlineProperties)
193 mask = static_cast<Mask>(mask | INPUT_UNDERLINE);
195 if(shadowProperties != inputStyle.shadowProperties)
197 mask = static_cast<Mask>(mask | INPUT_SHADOW);
199 if(embossProperties != inputStyle.embossProperties)
201 mask = static_cast<Mask>(mask | INPUT_EMBOSS);
203 if(outlineProperties != inputStyle.outlineProperties)
205 mask = static_cast<Mask>(mask | INPUT_OUTLINE);
211 Vector4 textColor; ///< The text's color.
212 std::string familyName; ///< The font's family name.
213 FontWeight weight; ///< The font's weight.
214 FontWidth width; ///< The font's width.
215 FontSlant slant; ///< The font's slant.
216 float size; ///< The font's size.
218 float lineSpacing; ///< The line's spacing.
220 std::string underlineProperties; ///< The underline properties string.
221 std::string shadowProperties; ///< The shadow properties string.
222 std::string embossProperties; ///< The emboss properties string.
223 std::string outlineProperties; ///< The outline properties string.
225 bool isDefaultColor : 1; ///< Whether the text's color is the default.
226 bool isFamilyDefined : 1; ///< Whether the font's family is defined.
227 bool isWeightDefined : 1; ///< Whether the font's weight is defined.
228 bool isWidthDefined : 1; ///< Whether the font's width is defined.
229 bool isSlantDefined : 1; ///< Whether the font's slant is defined.
230 bool isSizeDefined : 1; ///< Whether the font's size is defined.
232 bool isLineSpacingDefined : 1; ///< Whether the line spacing is defined.
233 bool isUnderlineDefined : 1; ///< Whether the underline parameters are defined.
234 bool isShadowDefined : 1; ///< Whether the shadow parameters are defined.
235 bool isEmbossDefined : 1; ///< Whether the emboss parameters are defined.
236 bool isOutlineDefined : 1; ///< Whether the outline parameters are defined.
241 } // namespace Toolkit
245 #endif // DALI_TOOLKIT_TEXT_INPUT_STYLE_H