Add post processor
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / input-style.h
1 #ifndef DALI_TOOLKIT_TEXT_INPUT_STYLE_H
2 #define DALI_TOOLKIT_TEXT_INPUT_STYLE_H
3
4 /*
5  * Copyright (c) 2021 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/common/constants.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/text/text-definitions.h>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace Text
32 {
33 /**
34  * The input text's style.
35  */
36 struct InputStyle
37 {
38   enum Mask
39   {
40     NONE               = 0x0000,
41     INPUT_COLOR        = 0x0001,
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   };
53
54   InputStyle()
55   : textColor(Color::BLACK),
56     familyName(),
57     weight(TextAbstraction::FontWeight::NORMAL),
58     width(TextAbstraction::FontWidth::NORMAL),
59     slant(TextAbstraction::FontSlant::NORMAL),
60     size(0.f),
61     lineSpacing(0.f),
62     underlineProperties(),
63     shadowProperties(),
64     embossProperties(),
65     outlineProperties(),
66     isDefaultColor(true),
67     isFamilyDefined(false),
68     isWeightDefined(false),
69     isWidthDefined(false),
70     isSlantDefined(false),
71     isSizeDefined(false),
72     isLineSpacingDefined(false),
73     isUnderlineDefined(false),
74     isShadowDefined(false),
75     isEmbossDefined(false),
76     isOutlineDefined(false)
77   {
78   }
79
80   ~InputStyle(){};
81
82   /**
83    * @brief
84    *
85    * Does not copy the font-style, underline, shadow, emboss and outline property strings.
86    */
87   void Copy(const InputStyle& inputStyle)
88   {
89     isDefaultColor = inputStyle.isDefaultColor;
90     textColor      = inputStyle.textColor;
91
92     isFamilyDefined = inputStyle.isFamilyDefined;
93     familyName      = inputStyle.familyName;
94
95     isWeightDefined = inputStyle.isWeightDefined;
96     weight          = inputStyle.weight;
97
98     isWidthDefined = inputStyle.isWidthDefined;
99     width          = inputStyle.width;
100
101     isSlantDefined = inputStyle.isSlantDefined;
102     slant          = inputStyle.slant;
103
104     isSizeDefined = inputStyle.isSizeDefined;
105     size          = inputStyle.size;
106
107     isLineSpacingDefined = inputStyle.isLineSpacingDefined;
108     lineSpacing          = inputStyle.lineSpacing;
109
110     isUnderlineDefined  = inputStyle.isUnderlineDefined;
111     underlineProperties = inputStyle.underlineProperties;
112
113     isShadowDefined  = inputStyle.isShadowDefined;
114     shadowProperties = inputStyle.shadowProperties;
115
116     isEmbossDefined  = inputStyle.isEmbossDefined;
117     embossProperties = inputStyle.embossProperties;
118
119     isOutlineDefined  = inputStyle.isOutlineDefined;
120     outlineProperties = inputStyle.outlineProperties;
121   }
122
123   /**
124    * @brief
125    *
126    * Does not compare the font-style, underline, shadow, emboss and outline property strings.
127    */
128   bool Equal(const InputStyle& inputStyle) const
129   {
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))
152     {
153       return false;
154     }
155
156     return true;
157   }
158
159   Mask GetInputStyleChangeMask(const InputStyle& inputStyle) const
160   {
161     Mask mask = NONE;
162
163     if(textColor != inputStyle.textColor)
164     {
165       mask = static_cast<Mask>(mask | INPUT_COLOR);
166     }
167     if(familyName != inputStyle.familyName)
168     {
169       mask = static_cast<Mask>(mask | INPUT_FONT_FAMILY);
170     }
171     if(weight != inputStyle.weight)
172     {
173       mask = static_cast<Mask>(mask | INPUT_FONT_WEIGHT);
174     }
175     if(width != inputStyle.width)
176     {
177       mask = static_cast<Mask>(mask | INPUT_FONT_WIDTH);
178     }
179     if(slant != inputStyle.slant)
180     {
181       mask = static_cast<Mask>(mask | INPUT_FONT_SLANT);
182     }
183     if(size != inputStyle.size)
184     {
185       mask = static_cast<Mask>(mask | INPUT_POINT_SIZE);
186     }
187     if(lineSpacing != inputStyle.lineSpacing)
188     {
189       mask = static_cast<Mask>(mask | INPUT_LINE_SPACING);
190     }
191     if(underlineProperties != inputStyle.underlineProperties)
192     {
193       mask = static_cast<Mask>(mask | INPUT_UNDERLINE);
194     }
195     if(shadowProperties != inputStyle.shadowProperties)
196     {
197       mask = static_cast<Mask>(mask | INPUT_SHADOW);
198     }
199     if(embossProperties != inputStyle.embossProperties)
200     {
201       mask = static_cast<Mask>(mask | INPUT_EMBOSS);
202     }
203     if(outlineProperties != inputStyle.outlineProperties)
204     {
205       mask = static_cast<Mask>(mask | INPUT_OUTLINE);
206     }
207
208     return mask;
209   }
210
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.
217
218   float lineSpacing; ///< The line's spacing.
219
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.
224
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.
231
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.
237 };
238
239 } // namespace Text
240
241 } // namespace Toolkit
242
243 } // namespace Dali
244
245 #endif // DALI_TOOLKIT_TEXT_INPUT_STYLE_H