1 /**
2 * @file lv_style.h
3 *
4 */
5
6 #ifndef LV_STYLE_H
7 #define LV_STYLE_H
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 /*********************
14 * INCLUDES
15 *********************/
16 #include "../font/lv_font.h"
17 #include "lv_color.h"
18 #include "lv_area.h"
19 #include "lv_anim.h"
20 #include "lv_text.h"
21 #include "lv_types.h"
22 #include "lv_assert.h"
23 #include "lv_bidi.h"
24 #include "../layouts/lv_layout.h"
25
26 /*********************
27 * DEFINES
28 *********************/
29
30 #define LV_STYLE_SENTINEL_VALUE 0xAABBCCDD
31
32 /*
33 * Flags for style behavior
34 */
35 #define LV_STYLE_PROP_FLAG_NONE (0) /**< No special behavior */
36 #define LV_STYLE_PROP_FLAG_INHERITABLE (1 << 0) /**< Inherited */
37 #define LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE (1 << 1) /**< Requires ext. draw size update when changed */
38 #define LV_STYLE_PROP_FLAG_LAYOUT_UPDATE (1 << 2) /**< Requires layout update when changed */
39 #define LV_STYLE_PROP_FLAG_PARENT_LAYOUT_UPDATE (1 << 3) /**< Requires layout update on parent when changed */
40 #define LV_STYLE_PROP_FLAG_LAYER_UPDATE (1 << 4) /**< Affects layer handling */
41 #define LV_STYLE_PROP_FLAG_TRANSFORM (1 << 5) /**< Affects the object's transformation */
42 #define LV_STYLE_PROP_FLAG_ALL (0x3F) /**< Indicating all flags */
43
44 /*
45 * Other constants
46 */
47 #define LV_SCALE_NONE 256 /**< Value for not zooming the image */
48 LV_EXPORT_CONST_INT(LV_SCALE_NONE);
49
50 // *INDENT-OFF*
51 #if LV_USE_ASSERT_STYLE
52 #define LV_STYLE_CONST_INIT(var_name, prop_array) \
53 const lv_style_t var_name = { \
54 .sentinel = LV_STYLE_SENTINEL_VALUE, \
55 .values_and_props = (void*)prop_array, \
56 .has_group = 0xFFFFFFFF, \
57 .prop_cnt = 255 \
58 }
59 #else
60 #define LV_STYLE_CONST_INIT(var_name, prop_array) \
61 const lv_style_t var_name = { \
62 .values_and_props = (void*)prop_array, \
63 .has_group = 0xFFFFFFFF, \
64 .prop_cnt = 255, \
65 }
66 #endif
67 // *INDENT-ON*
68
69 #define LV_STYLE_CONST_PROPS_END { .prop = LV_STYLE_PROP_INV, .value = { .num = 0 } }
70
71 /**********************
72 * TYPEDEFS
73 **********************/
74
75 /**
76 * Possible options for blending opaque drawings
77 */
78 typedef enum {
79 LV_BLEND_MODE_NORMAL, /**< Simply mix according to the opacity value*/
80 LV_BLEND_MODE_ADDITIVE, /**< Add the respective color channels*/
81 LV_BLEND_MODE_SUBTRACTIVE,/**< Subtract the foreground from the background*/
82 LV_BLEND_MODE_MULTIPLY, /**< Multiply the foreground and background*/
83 } lv_blend_mode_t;
84
85 /**
86 * Some options to apply decorations on texts.
87 * 'OR'ed values can be used.
88 */
89 typedef enum {
90 LV_TEXT_DECOR_NONE = 0x00,
91 LV_TEXT_DECOR_UNDERLINE = 0x01,
92 LV_TEXT_DECOR_STRIKETHROUGH = 0x02,
93 } lv_text_decor_t;
94
95 /**
96 * Selects on which sides border should be drawn
97 * 'OR'ed values can be used.
98 */
99 typedef enum {
100 LV_BORDER_SIDE_NONE = 0x00,
101 LV_BORDER_SIDE_BOTTOM = 0x01,
102 LV_BORDER_SIDE_TOP = 0x02,
103 LV_BORDER_SIDE_LEFT = 0x04,
104 LV_BORDER_SIDE_RIGHT = 0x08,
105 LV_BORDER_SIDE_FULL = 0x0F,
106 LV_BORDER_SIDE_INTERNAL = 0x10, /**< FOR matrix-like objects (e.g. Button matrix)*/
107 } lv_border_side_t;
108
109 /**
110 * The direction of the gradient.
111 */
112 typedef enum {
113 LV_GRAD_DIR_NONE, /**< No gradient (the `grad_color` property is ignored)*/
114 LV_GRAD_DIR_VER, /**< Simple vertical (top to bottom) gradient*/
115 LV_GRAD_DIR_HOR, /**< Simple horizontal (left to right) gradient*/
116 LV_GRAD_DIR_LINEAR, /**< Linear gradient defined by start and end points. Can be at any angle.*/
117 LV_GRAD_DIR_RADIAL, /**< Radial gradient defined by start and end circles*/
118 LV_GRAD_DIR_CONICAL, /**< Conical gradient defined by center point, start and end angles*/
119 } lv_grad_dir_t;
120
121 /**
122 * Gradient behavior outside the defined range.
123 */
124 typedef enum {
125 LV_GRAD_EXTEND_PAD, /**< Repeat the same color*/
126 LV_GRAD_EXTEND_REPEAT, /**< Repeat the pattern*/
127 LV_GRAD_EXTEND_REFLECT, /**< Repeat the pattern mirrored*/
128 } lv_grad_extend_t;
129
130 /** A gradient stop definition.
131 * This matches a color and a position in a virtual 0-255 scale.
132 */
133 typedef struct {
134 lv_color_t color; /**< The stop color */
135 lv_opa_t opa; /**< The opacity of the color*/
136 uint8_t frac; /**< The stop position in 1/255 unit */
137 } lv_gradient_stop_t;
138
139 /** A descriptor of a gradient. */
140 typedef struct {
141 lv_gradient_stop_t stops[LV_GRADIENT_MAX_STOPS]; /**< A gradient stop array */
142 uint8_t stops_count; /**< The number of used stops in the array */
143 lv_grad_dir_t dir : 4; /**< The gradient direction.
144 * Any of LV_GRAD_DIR_NONE, LV_GRAD_DIR_VER, LV_GRAD_DIR_HOR,
145 * LV_GRAD_TYPE_LINEAR, LV_GRAD_TYPE_RADIAL, LV_GRAD_TYPE_CONICAL */
146 lv_grad_extend_t extend : 3; /**< Behaviour outside the defined range.
147 * LV_GRAD_EXTEND_NONE, LV_GRAD_EXTEND_PAD, LV_GRAD_EXTEND_REPEAT, LV_GRAD_EXTEND_REFLECT */
148 #if LV_USE_DRAW_SW_COMPLEX_GRADIENTS
149 union {
150 /*Linear gradient parameters*/
151 struct {
152 lv_point_t start; /**< Linear gradient vector start point */
153 lv_point_t end; /**< Linear gradient vector end point */
154 } linear;
155 /*Radial gradient parameters*/
156 struct {
157 lv_point_t focal; /**< Center of the focal (starting) circle in local coordinates */
158 /* (can be the same as the ending circle to create concentric circles) */
159 lv_point_t focal_extent; /**< Point on the circle (can be the same as the center) */
160 lv_point_t end; /**< Center of the ending circle in local coordinates */
161 lv_point_t end_extent; /**< Point on the circle determining the radius of the gradient */
162 } radial;
163 /*Conical gradient parameters*/
164 struct {
165 lv_point_t center; /**< Conical gradient center point */
166 int16_t start_angle; /**< Start angle 0..3600 */
167 int16_t end_angle; /**< End angle 0..3600 */
168 } conical;
169 } params;
170 void * state;
171 #endif
172 } lv_grad_dsc_t;
173
174 /**
175 * A common type to handle all the property types in the same way.
176 */
177 typedef union {
178 int32_t num; /**< Number integer number (opacity, enums, booleans or "normal" numbers)*/
179 const void * ptr; /**< Constant pointers (font, cone text, etc)*/
180 lv_color_t color; /**< Colors*/
181 } lv_style_value_t;
182
183 /**
184 * Enumeration of all built in style properties
185 *
186 * Props are split into groups of 16. When adding a new prop to a group, ensure it does not overflow into the next one.
187 */
188 enum {
189 LV_STYLE_PROP_INV = 0,
190
191 /*Group 0*/
192 LV_STYLE_WIDTH = 1,
193 LV_STYLE_HEIGHT = 2,
194 LV_STYLE_LENGTH = 3,
195
196 LV_STYLE_MIN_WIDTH = 4,
197 LV_STYLE_MAX_WIDTH = 5,
198 LV_STYLE_MIN_HEIGHT = 6,
199 LV_STYLE_MAX_HEIGHT = 7,
200
201 LV_STYLE_X = 8,
202 LV_STYLE_Y = 9,
203 LV_STYLE_ALIGN = 10,
204
205 LV_STYLE_RADIUS = 12,
206 LV_STYLE_RADIAL_OFFSET = 13,
207 LV_STYLE_PAD_RADIAL = 14,
208
209 /*Group 1*/
210 LV_STYLE_PAD_TOP = 16,
211 LV_STYLE_PAD_BOTTOM = 17,
212 LV_STYLE_PAD_LEFT = 18,
213 LV_STYLE_PAD_RIGHT = 19,
214
215 LV_STYLE_PAD_ROW = 20,
216 LV_STYLE_PAD_COLUMN = 21,
217 LV_STYLE_LAYOUT = 22,
218
219 LV_STYLE_MARGIN_TOP = 24,
220 LV_STYLE_MARGIN_BOTTOM = 25,
221 LV_STYLE_MARGIN_LEFT = 26,
222 LV_STYLE_MARGIN_RIGHT = 27,
223
224 /*Group 2*/
225 LV_STYLE_BG_COLOR = 28,
226 LV_STYLE_BG_OPA = 29,
227
228 LV_STYLE_BG_GRAD_DIR = 32,
229 LV_STYLE_BG_MAIN_STOP = 33,
230 LV_STYLE_BG_GRAD_STOP = 34,
231 LV_STYLE_BG_GRAD_COLOR = 35,
232
233 LV_STYLE_BG_MAIN_OPA = 36,
234 LV_STYLE_BG_GRAD_OPA = 37,
235 LV_STYLE_BG_GRAD = 38,
236 LV_STYLE_BASE_DIR = 39,
237
238 LV_STYLE_BG_IMAGE_SRC = 40,
239 LV_STYLE_BG_IMAGE_OPA = 41,
240 LV_STYLE_BG_IMAGE_RECOLOR = 42,
241 LV_STYLE_BG_IMAGE_RECOLOR_OPA = 43,
242
243 LV_STYLE_BG_IMAGE_TILED = 44,
244 LV_STYLE_CLIP_CORNER = 45,
245
246 /*Group 3*/
247 LV_STYLE_BORDER_WIDTH = 48,
248 LV_STYLE_BORDER_COLOR = 49,
249 LV_STYLE_BORDER_OPA = 50,
250
251 LV_STYLE_BORDER_SIDE = 52,
252 LV_STYLE_BORDER_POST = 53,
253
254 LV_STYLE_OUTLINE_WIDTH = 56,
255 LV_STYLE_OUTLINE_COLOR = 57,
256 LV_STYLE_OUTLINE_OPA = 58,
257 LV_STYLE_OUTLINE_PAD = 59,
258
259 /*Group 4*/
260 LV_STYLE_SHADOW_WIDTH = 60,
261 LV_STYLE_SHADOW_COLOR = 61,
262 LV_STYLE_SHADOW_OPA = 62,
263
264 LV_STYLE_SHADOW_OFFSET_X = 64,
265 LV_STYLE_SHADOW_OFFSET_Y = 65,
266 LV_STYLE_SHADOW_SPREAD = 66,
267
268 LV_STYLE_IMAGE_OPA = 68,
269 LV_STYLE_IMAGE_RECOLOR = 69,
270 LV_STYLE_IMAGE_RECOLOR_OPA = 70,
271
272 LV_STYLE_LINE_WIDTH = 72,
273 LV_STYLE_LINE_DASH_WIDTH = 73,
274 LV_STYLE_LINE_DASH_GAP = 74,
275 LV_STYLE_LINE_ROUNDED = 75,
276 LV_STYLE_LINE_COLOR = 76,
277 LV_STYLE_LINE_OPA = 77,
278
279 /*Group 5*/
280 LV_STYLE_ARC_WIDTH = 80,
281 LV_STYLE_ARC_ROUNDED = 81,
282 LV_STYLE_ARC_COLOR = 82,
283 LV_STYLE_ARC_OPA = 83,
284 LV_STYLE_ARC_IMAGE_SRC = 84,
285
286 LV_STYLE_TEXT_COLOR = 88,
287 LV_STYLE_TEXT_OPA = 89,
288 LV_STYLE_TEXT_FONT = 90,
289
290 LV_STYLE_TEXT_LETTER_SPACE = 91,
291 LV_STYLE_TEXT_LINE_SPACE = 92,
292 LV_STYLE_TEXT_DECOR = 93,
293 LV_STYLE_TEXT_ALIGN = 94,
294
295 LV_STYLE_OPA = 95,
296 LV_STYLE_OPA_LAYERED = 96,
297 LV_STYLE_COLOR_FILTER_DSC = 97,
298 LV_STYLE_COLOR_FILTER_OPA = 98,
299 LV_STYLE_ANIM = 99,
300 LV_STYLE_ANIM_DURATION = 100,
301 LV_STYLE_TRANSITION = 102,
302 LV_STYLE_BLEND_MODE = 103,
303 LV_STYLE_TRANSFORM_WIDTH = 104,
304 LV_STYLE_TRANSFORM_HEIGHT = 105,
305 LV_STYLE_TRANSLATE_X = 106,
306 LV_STYLE_TRANSLATE_Y = 107,
307 LV_STYLE_TRANSFORM_SCALE_X = 108,
308 LV_STYLE_TRANSFORM_SCALE_Y = 109,
309 LV_STYLE_TRANSFORM_ROTATION = 110,
310 LV_STYLE_TRANSFORM_PIVOT_X = 111,
311 LV_STYLE_TRANSFORM_PIVOT_Y = 112,
312 LV_STYLE_TRANSFORM_SKEW_X = 113,
313 LV_STYLE_TRANSFORM_SKEW_Y = 114,
314 LV_STYLE_BITMAP_MASK_SRC = 115,
315 LV_STYLE_ROTARY_SENSITIVITY = 116,
316 LV_STYLE_TRANSLATE_RADIAL = 117,
317
318 LV_STYLE_FLEX_FLOW = 125,
319 LV_STYLE_FLEX_MAIN_PLACE = 126,
320 LV_STYLE_FLEX_CROSS_PLACE = 127,
321 LV_STYLE_FLEX_TRACK_PLACE = 128,
322 LV_STYLE_FLEX_GROW = 129,
323
324 LV_STYLE_GRID_COLUMN_ALIGN = 130,
325 LV_STYLE_GRID_ROW_ALIGN = 131,
326 LV_STYLE_GRID_ROW_DSC_ARRAY = 132,
327 LV_STYLE_GRID_COLUMN_DSC_ARRAY = 133,
328 LV_STYLE_GRID_CELL_COLUMN_POS = 134,
329 LV_STYLE_GRID_CELL_COLUMN_SPAN = 135,
330 LV_STYLE_GRID_CELL_X_ALIGN = 136,
331 LV_STYLE_GRID_CELL_ROW_POS = 137,
332 LV_STYLE_GRID_CELL_ROW_SPAN = 138,
333 LV_STYLE_GRID_CELL_Y_ALIGN = 139,
334
335 LV_STYLE_LAST_BUILT_IN_PROP = 140,
336
337 LV_STYLE_NUM_BUILT_IN_PROPS = LV_STYLE_LAST_BUILT_IN_PROP + 1,
338
339 LV_STYLE_PROP_ANY = 0xFF,
340 LV_STYLE_PROP_CONST = 0xFF /* magic value for const styles */
341 };
342
343 typedef enum {
344 LV_STYLE_RES_NOT_FOUND,
345 LV_STYLE_RES_FOUND,
346 } lv_style_res_t;
347
348 /**
349 * Descriptor for style transitions
350 */
351 typedef struct {
352 const lv_style_prop_t * props; /**< An array with the properties to animate.*/
353 void * user_data; /**< A custom user data that will be passed to the animation's user_data */
354 lv_anim_path_cb_t path_xcb; /**< A path for the animation.*/
355 uint32_t time; /**< Duration of the transition in [ms]*/
356 uint32_t delay; /**< Delay before the transition in [ms]*/
357 } lv_style_transition_dsc_t;
358
359 /**
360 * Descriptor of a constant style property.
361 */
362 typedef struct {
363 lv_style_prop_t prop;
364 lv_style_value_t value;
365 } lv_style_const_prop_t;
366
367 /**
368 * Descriptor of a style (a collection of properties and values).
369 */
370 typedef struct {
371
372 #if LV_USE_ASSERT_STYLE
373 uint32_t sentinel;
374 #endif
375
376 void * values_and_props;
377
378 uint32_t has_group;
379 uint8_t prop_cnt; /**< 255 means it's a constant style*/
380 } lv_style_t;
381
382 /**********************
383 * GLOBAL PROTOTYPES
384 **********************/
385
386 /**
387 * Initialize a style
388 * @param style pointer to a style to initialize
389 * @note Do not call `lv_style_init` on styles that already have some properties
390 * because this function won't free the used memory, just sets a default state for the style.
391 * In other words be sure to initialize styles only once!
392 */
393 void lv_style_init(lv_style_t * style);
394
395 /**
396 * Clear all properties from a style and free all allocated memories.
397 * @param style pointer to a style
398 */
399 void lv_style_reset(lv_style_t * style);
400
401 /**
402 * Check if a style is constant
403 * @param style pointer to a style
404 * @return true: the style is constant
405 */
lv_style_is_const(const lv_style_t * style)406 static inline bool lv_style_is_const(const lv_style_t * style)
407 {
408 if(style->prop_cnt == 255) return true;
409 return false;
410 }
411
412 /**
413 * Register a new style property for custom usage
414 * @return a new property ID, or LV_STYLE_PROP_INV if there are no more available.
415 *
416 * Example:
417 * @code
418 * lv_style_prop_t MY_PROP;
419 * static inline void lv_style_set_my_prop(lv_style_t * style, lv_color_t value) {
420 * lv_style_value_t v = {.color = value}; lv_style_set_prop(style, MY_PROP, v); }
421 *
422 * ...
423 * MY_PROP = lv_style_register_prop();
424 * ...
425 * lv_style_set_my_prop(&style1, lv_palette_main(LV_PALETTE_RED));
426 * @endcode
427 */
428 lv_style_prop_t lv_style_register_prop(uint8_t flag);
429
430 /**
431 * Get the number of custom properties that have been registered thus far.
432 */
433 lv_style_prop_t lv_style_get_num_custom_props(void);
434
435 /**
436 * Remove a property from a style
437 * @param style pointer to a style
438 * @param prop a style property ORed with a state.
439 * @return true: the property was found and removed; false: the property wasn't found
440 */
441 bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop);
442
443 /**
444 * Set the value of property in a style.
445 * This function shouldn't be used directly by the user.
446 * Instead use `lv_style_set_<prop_name>()`. E.g. `lv_style_set_bg_color()`
447 * @param style pointer to style
448 * @param prop the ID of a property (e.g. `LV_STYLE_BG_COLOR`)
449 * @param value `lv_style_value_t` variable in which a field is set according to the type of `prop`
450 */
451 void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value);
452
453 /**
454 * Get the value of a property
455 * @param style pointer to a style
456 * @param prop the ID of a property
457 * @param value pointer to a `lv_style_value_t` variable to store the value
458 * @return LV_RESULT_INVALID: the property wasn't found in the style (`value` is unchanged)
459 * LV_RESULT_OK: the property was fond, and `value` is set accordingly
460 * @note For performance reasons there are no sanity check on `style`
461 */
462 lv_style_res_t lv_style_get_prop(const lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value);
463
464 /**
465 * Initialize a transition descriptor.
466 * @param tr pointer to a transition descriptor to initialize
467 * @param props an array with the properties to transition. The last element must be zero.
468 * @param path_cb an animation path (ease) callback. If `NULL` liner path will be used.
469 * @param time duration of the transition in [ms]
470 * @param delay delay before the transition in [ms]
471 * @param user_data any custom data that will be saved in the transition animation and will be available when `path_cb` is called
472 *
473 * Example:
474 * @code
475 * const static lv_style_prop_t trans_props[] = { LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR, 0 };
476 * static lv_style_transition_dsc_t trans1;
477 * lv_style_transition_dsc_init(&trans1, trans_props, NULL, 300, 0, NULL);
478 * @endcode
479 */
480 void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t props[],
481 lv_anim_path_cb_t path_cb, uint32_t time, uint32_t delay, void * user_data);
482
483 /**
484 * Get the default value of a property
485 * @param prop the ID of a property
486 * @return the default value
487 */
488 lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop);
489
490 /**
491 * Get the value of a property
492 * @param style pointer to a style
493 * @param prop the ID of a property
494 * @param value pointer to a `lv_style_value_t` variable to store the value
495 * @return LV_RESULT_INVALID: the property wasn't found in the style (`value` is unchanged)
496 * LV_RESULT_OK: the property was fond, and `value` is set accordingly
497 * @note For performance reasons there are no sanity check on `style`
498 * @note This function is the same as ::lv_style_get_prop but inlined. Use it only on performance critical places
499 */
lv_style_get_prop_inlined(const lv_style_t * style,lv_style_prop_t prop,lv_style_value_t * value)500 static inline lv_style_res_t lv_style_get_prop_inlined(const lv_style_t * style, lv_style_prop_t prop,
501 lv_style_value_t * value)
502 {
503 if(lv_style_is_const(style)) {
504 lv_style_const_prop_t * props = (lv_style_const_prop_t *)style->values_and_props;
505 uint32_t i;
506 for(i = 0; props[i].prop != LV_STYLE_PROP_INV; i++) {
507 if(props[i].prop == prop) {
508 *value = props[i].value;
509 return LV_STYLE_RES_FOUND;
510 }
511 }
512 }
513 else {
514 lv_style_prop_t * props = (lv_style_prop_t *)style->values_and_props + style->prop_cnt * sizeof(lv_style_value_t);
515 uint32_t i;
516 for(i = 0; i < style->prop_cnt; i++) {
517 if(props[i] == prop) {
518 lv_style_value_t * values = (lv_style_value_t *)style->values_and_props;
519 *value = values[i];
520 return LV_STYLE_RES_FOUND;
521 }
522 }
523 }
524 return LV_STYLE_RES_NOT_FOUND;
525 }
526
527 /**
528 * Checks if a style is empty (has no properties)
529 * @param style pointer to a style
530 * @return true if the style is empty
531 */
532 bool lv_style_is_empty(const lv_style_t * style);
533
534 /**
535 * Tell the group of a property. If the a property from a group is set in a style the (1 << group) bit of style->has_group is set.
536 * It allows early skipping the style if the property is not exists in the style at all.
537 * @param prop a style property
538 * @return the group [0..30] 30 means all the custom properties with index > 120
539 */
lv_style_get_prop_group(lv_style_prop_t prop)540 static inline uint32_t lv_style_get_prop_group(lv_style_prop_t prop)
541 {
542 uint32_t group = prop >> 2;
543 if(group > 30) group = 31; /*The MSB marks all the custom properties*/
544 return group;
545
546 }
547
548 /**
549 * Get the flags of a built-in or custom property.
550 *
551 * @param prop a style property
552 * @return the flags of the property
553 */
554 uint8_t lv_style_prop_lookup_flags(lv_style_prop_t prop);
555
556 #include "lv_style_gen.h"
557
lv_style_set_size(lv_style_t * style,int32_t width,int32_t height)558 static inline void lv_style_set_size(lv_style_t * style, int32_t width, int32_t height)
559 {
560 lv_style_set_width(style, width);
561 lv_style_set_height(style, height);
562 }
563
lv_style_set_pad_all(lv_style_t * style,int32_t value)564 static inline void lv_style_set_pad_all(lv_style_t * style, int32_t value)
565 {
566 lv_style_set_pad_left(style, value);
567 lv_style_set_pad_right(style, value);
568 lv_style_set_pad_top(style, value);
569 lv_style_set_pad_bottom(style, value);
570 }
571
lv_style_set_pad_hor(lv_style_t * style,int32_t value)572 static inline void lv_style_set_pad_hor(lv_style_t * style, int32_t value)
573 {
574 lv_style_set_pad_left(style, value);
575 lv_style_set_pad_right(style, value);
576 }
577
lv_style_set_pad_ver(lv_style_t * style,int32_t value)578 static inline void lv_style_set_pad_ver(lv_style_t * style, int32_t value)
579 {
580 lv_style_set_pad_top(style, value);
581 lv_style_set_pad_bottom(style, value);
582 }
583
lv_style_set_pad_gap(lv_style_t * style,int32_t value)584 static inline void lv_style_set_pad_gap(lv_style_t * style, int32_t value)
585 {
586 lv_style_set_pad_row(style, value);
587 lv_style_set_pad_column(style, value);
588 }
589
lv_style_set_margin_hor(lv_style_t * style,int32_t value)590 static inline void lv_style_set_margin_hor(lv_style_t * style, int32_t value)
591 {
592 lv_style_set_margin_left(style, value);
593 lv_style_set_margin_right(style, value);
594 }
595
lv_style_set_margin_ver(lv_style_t * style,int32_t value)596 static inline void lv_style_set_margin_ver(lv_style_t * style, int32_t value)
597 {
598 lv_style_set_margin_top(style, value);
599 lv_style_set_margin_bottom(style, value);
600 }
601
lv_style_set_margin_all(lv_style_t * style,int32_t value)602 static inline void lv_style_set_margin_all(lv_style_t * style, int32_t value)
603 {
604 lv_style_set_margin_left(style, value);
605 lv_style_set_margin_right(style, value);
606 lv_style_set_margin_top(style, value);
607 lv_style_set_margin_bottom(style, value);
608 }
609
lv_style_set_transform_scale(lv_style_t * style,int32_t value)610 static inline void lv_style_set_transform_scale(lv_style_t * style, int32_t value)
611 {
612 lv_style_set_transform_scale_x(style, value);
613 lv_style_set_transform_scale_y(style, value);
614 }
615
616 /**
617 * @brief Check if the style property has a specified behavioral flag.
618 *
619 * Do not pass multiple flags to this function as backwards-compatibility is not guaranteed
620 * for that.
621 *
622 * @param prop Property ID
623 * @param flag Flag
624 * @return true if the flag is set for this property
625 */
lv_style_prop_has_flag(lv_style_prop_t prop,uint8_t flag)626 static inline bool lv_style_prop_has_flag(lv_style_prop_t prop, uint8_t flag)
627 {
628 return lv_style_prop_lookup_flags(prop) & flag;
629 }
630
631 /*************************
632 * GLOBAL VARIABLES
633 *************************/
634
635 LV_ATTRIBUTE_EXTERN_DATA extern const lv_style_prop_t lv_style_const_prop_id_inv;
636
637 /**********************
638 * MACROS
639 **********************/
640
641 #if LV_USE_ASSERT_STYLE
642 # define LV_ASSERT_STYLE(style_p) \
643 do { \
644 LV_ASSERT_MSG(style_p != NULL, "The style is NULL"); \
645 LV_ASSERT_MSG(style_p->sentinel == LV_STYLE_SENTINEL_VALUE, "Style is not initialized or corrupted"); \
646 } while(0)
647 #else
648 # define LV_ASSERT_STYLE(p) do{}while(0)
649 #endif
650
651 #ifdef __cplusplus
652 } /*extern "C"*/
653 #endif
654
655 #endif /*LV_STYLE_H*/
656