d87e8100436583e93d01e65097a1087045c19108
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-effects-style.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_EFFECTS_STYLE_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_EFFECTS_STYLE_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 // INTERNAL INCLUDES
22 #include <dali-toolkit/internal/text/text-controller.h>
23 #include <dali-toolkit/public-api/text/text-enumerations.h>
24 #include <dali/devel-api/scripting/scripting.h>
25
26 namespace Dali
27 {
28 namespace Toolkit
29 {
30 namespace Text
31 {
32 const Scripting::StringEnum UNDERLINE_TYPE_STRING_TABLE[] =
33   {
34     {"solid", Text::Underline::SOLID},
35     {"dashed", Text::Underline::DASHED},
36     {"double", Text::Underline::DOUBLE}};
37 const unsigned int UNDERLINE_TYPE_STRING_TABLE_COUNT = sizeof(UNDERLINE_TYPE_STRING_TABLE) / sizeof(UNDERLINE_TYPE_STRING_TABLE[0]);
38 namespace EffectStyle
39 {
40 enum Type
41 {
42   DEFAULT, ///< The default text effect style.
43   INPUT    ///< The input text effect style.
44 };
45 };
46
47 /**
48  * @brief Parses the shadow properties.
49  *
50  * @param[in] shadowProperties The map with the shadow properties.
51  * @param[out] colorDefined Whether the shadow's color is defined.
52  * @param[out] color The shadow's color.
53  * @param[out] offsetDefined Whether the shadow's offset is defined.
54  * @param[out] offset The shadow's offset.
55  */
56 bool ParseShadowProperties(const Property::Map& shadowProperties,
57                            bool&                colorDefined,
58                            Vector4&             color,
59                            bool&                offsetDefined,
60                            Vector2&             offset);
61
62 /**
63  * @brief Parses the underline properties.
64  *
65  * @param[in] underlineProperties The map with the underline properties.
66  * @param[out] enabled Whether the underline is enabled.
67  * @param[out] colorDefined Whether the underline's color is defined.
68  * @param[out] color The underline's color.
69  * @param[out] heightDefined Whether the underline's height is defined.
70  * @param[out] height The underline's height.
71  * @param[out] type The underline's type; DASHED, DOUBLE, etc. Default is a solid underline.
72  * @param[out] dashWidth The dashed underline's width.
73  * @param[out] dashGap The dashed underline's gap.
74  */
75 bool ParseUnderlineProperties(const Property::Map&   underlineProperties,
76                               bool&                  enabled,
77                               bool&                  colorDefined,
78                               Vector4&               color,
79                               bool&                  heightDefined,
80                               float&                 height,
81                               bool&                  typeDefined,
82                               Text::Underline::Type& type,
83                               bool&                  widthDefined,
84                               float&                 dashWidth,
85                               bool&                  dashGapDefined,
86                               float&                 dashGap);
87
88 /**
89  * @brief Parses the outline properties.
90  *
91  * @param[in] outlineProperties The map with the outline properties.
92  * @param[out] colorDefined Whether the outline's color is defined.
93  * @param[out] color The outline's color.
94  * @param[out] widthDefined Whether the outline's width is defined.
95  * @param[out] width The outline's width.
96  */
97 bool ParseOutlineProperties(const Property::Map& outlineProperties,
98                             bool&                colorDefined,
99                             Vector4&             color,
100                             bool&                widthDefined,
101                             unsigned int&        width);
102
103 /**
104  * @brief Parses the background properties.
105  *
106  * @param[in] backgroundProperties The map with the background properties.
107  * @param[out] enabled Whether the background is enabled.
108  * @param[out] colorDefined Whether the background color is defined.
109  * @param[out] color The background color.
110  */
111 bool ParseBackgroundProperties(const Property::Map& backgroundProperties,
112                                bool&                enabled,
113                                bool&                colorDefined,
114                                Vector4&             color);
115
116 /**
117  * @brief Parses the strikethrough properties.
118  *
119  * @param[in] strikethroughProperties The map with the strikethrough properties.
120  * @param[out] enabled Whether the strikethrough is enabled.
121  * @param[out] colorDefined Whether the strikethrough's color is defined.
122  * @param[out] color The strikethrough's color.
123  * @param[out] heightDefined Whether the strikethrough's height is defined.
124  * @param[out] height The strikethrough's height.
125  */
126 bool ParseStrikethroughProperties(const Property::Map& strikethroughProperties,
127                                   bool&                enabled,
128                                   bool&                colorDefined,
129                                   Vector4&             color,
130                                   bool&                heightDefined,
131                                   float&               height);
132
133 /**
134  * @brief Sets the underline properties.
135  *
136  * @param[in] controller The text's controller.
137  * @param[in] value The values of the underline's properties.
138  * @param[in] type Whether the property is for the default underline or the input underline.
139  *
140  * @return Whether the underline properties have been updated.
141  */
142 bool SetUnderlineProperties(ControllerPtr controller, const Property::Value& value, EffectStyle::Type type);
143
144 /**
145  * @brief Sets the strikethrough properties.
146  *
147  * @param[in] controller The text's controller.
148  * @param[in] value The values of the strikethrough's properties.
149  * @param[in] type Whether the property is for the default strikethrough or the input strikethrough.
150  *
151  * @return Whether the strikethrough properties have been updated.
152  */
153 bool SetStrikethroughProperties(ControllerPtr controller, const Property::Value& value, EffectStyle::Type type);
154
155 /**
156  * @brief Retrieves the underline's properties.
157  *
158  * @param[in] controller The text's controller.
159  * @param[out] value The value of the underline's properties.
160  * @param[in] type Whether the property is for the default underline or the input underline.
161  */
162 void GetUnderlineProperties(ControllerPtr controller, Property::Value& value, EffectStyle::Type type);
163
164 /**
165  * @brief Retrieves the strikethrough's properties.
166  *
167  * @param[in] controller The text's controller.
168  * @param[out] value The value of the strikethrough's properties.
169  * @param[in] type Whether the property is for the default strikethrough or the input strikethrough.
170  */
171 void GetStrikethroughProperties(ControllerPtr controller, Property::Value& value, EffectStyle::Type type);
172
173 /**
174  * @brief Sets the shadow properties.
175  *
176  * @param[in] controller The text's controller.
177  * @param[in] value The values of the shadow's style.
178  * @param[in] type Whether the property is for the default shadow's style or the input shadow's style.
179  *
180  * @return Whether the shadow properties have been updated.
181  */
182 bool SetShadowProperties(ControllerPtr controller, const Property::Value& value, EffectStyle::Type type);
183
184 /**
185  * @brief Retrieves the shadow's properties.
186  *
187  * @param[in] controller The text's controller.
188  * @param[out] value The value of the shadow's properties.
189  * @param[in] type Whether the property is for the default shadow or the input shadow.
190  */
191 void GetShadowProperties(ControllerPtr controller, Property::Value& value, EffectStyle::Type type);
192
193 /**
194  * @brief Sets the emboss properties.
195  *
196  * @param[in] controller The text's controller.
197  * @param[in] value The values of the emboss's properties.
198  * @param[in] type Whether the property is for the default emboss or the input emboss.
199  *
200  * @return Whether the emboss properties have been updated.
201  */
202 bool SetEmbossProperties(ControllerPtr controller, const Property::Value& value, EffectStyle::Type type);
203
204 /**
205  * @brief Retrieves the emboss's properties.
206  *
207  * @param[in] controller The text's controller.
208  * @param[out] value The value of the emboss's properties.
209  * @param[in] type Whether the property is for the default emboss or the input emboss.
210  */
211 void GetEmbossProperties(ControllerPtr controller, Property::Value& value, EffectStyle::Type type);
212
213 /**
214  * @brief Sets the outline properties.
215  *
216  * @param[in] controller The text's controller.
217  * @param[in] value The values of the outline's properties.
218  * @param[in] type Whether the property is for the default outline or the input outline.
219  *
220  * @return Whether the outline properties have been updated.
221  */
222 bool SetOutlineProperties(ControllerPtr controller, const Property::Value& value, EffectStyle::Type type);
223
224 /**
225  * @brief Retrieves the outline's properties.
226  *
227  * @param[in] controller The text's controller.
228  * @param[out] value The value of the outline's properties.
229  * @param[in] type Whether the property is for the default outline or the input outline.
230  */
231 void GetOutlineProperties(ControllerPtr controller, Property::Value& value, EffectStyle::Type type);
232
233 /**
234  * @brief Sets the background properties.
235  *
236  * @param[in] controller The text's controller.
237  * @param[in] value The values of the background's properties.
238  * @param[in] type Whether the property is for the default background or the input background.
239  *
240  * @return Whether the background properties have been updated.
241  */
242 bool SetBackgroundProperties(ControllerPtr controller, const Property::Value& value, EffectStyle::Type type);
243
244 /**
245  * @brief Retrieves the background's properties.
246  *
247  * @param[in] controller The text's controller.
248  * @param[out] value The value of the underline's properties.
249  * @param[in] type Whether the property is for the default background or the input background.
250  */
251 void GetBackgroundProperties(ControllerPtr controller, Property::Value& value, EffectStyle::Type type);
252
253 /**
254  * @brief Converts a underline type string into @e Underline::Type
255  *
256  * @param[in] underlineTypeStr The underline type string. Must end with '\0'.
257  *
258  * @return The @e Underline::Type value corresponding to the string.
259  */
260 Underline::Type StringToUnderlineType(const char* const underlineTypeStr);
261
262 } // namespace Text
263
264 } // namespace Toolkit
265
266 } // namespace Dali
267
268 #endif // DALI_TOOLKIT_INTERNAL_TEXT_EFFECTS_STYLE_H