mikroSDK Reference Manual
/home/software/git/clicks/click_repository/scripts/generateDoxyFull/tmp/mikroSDK_help/sdk/thirdparty/lvgl/src/misc/lv_style.h

Register a new style property for custom usage

Returns
a new property ID, or LV_STYLE_PROP_INV if there are no more available.

lv_style_prop_t MY_PROP; static inline void lv_style_set_my_prop(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, MY_PROP, v); }

... MY_PROP = lv_style_register_prop(); ... lv_style_set_my_prop(&style1, lv_palette_main(LV_PALETTE_RED));

#ifndef LV_STYLE_H
#define LV_STYLE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include <stdbool.h>
#include <stdint.h>
#include "../font/lv_font.h"
#include "lv_color.h"
#include "lv_area.h"
#include "lv_anim.h"
#include "lv_txt.h"
#include "lv_types.h"
#include "lv_assert.h"
#include "lv_bidi.h"
/*********************
* DEFINES
*********************/
#define LV_STYLE_SENTINEL_VALUE 0xAABBCCDD
#define LV_STYLE_PROP_FLAG_NONE (0)
#define LV_STYLE_PROP_INHERIT (1 << 0) /*Inherited*/
#define LV_STYLE_PROP_EXT_DRAW (1 << 1) /*Requires ext. draw size update when changed*/
#define LV_STYLE_PROP_LAYOUT_REFR (1 << 2) /*Requires layout update when changed*/
#define LV_STYLE_PROP_PARENT_LAYOUT_REFR (1 << 3) /*Requires layout update on parent when changed*/
#define LV_STYLE_PROP_LAYER_REFR (1 << 4) /*Affects layer handling*/
#define LV_STYLE_PROP_ALL (0x1F) /*Indicating all flags*/
#define LV_IMG_ZOOM_NONE 256 /*Value for not zooming the image*/
LV_EXPORT_CONST_INT(LV_IMG_ZOOM_NONE);
// *INDENT-OFF*
#if LV_USE_ASSERT_STYLE
#define LV_STYLE_CONST_INIT(var_name, prop_array) \
const lv_style_t var_name = { \
.sentinel = LV_STYLE_SENTINEL_VALUE, \
.v_p = { .const_props = prop_array }, \
.has_group = 0xFF, \
.prop1 = LV_STYLE_PROP_ANY, \
.prop_cnt = (sizeof(prop_array) / sizeof((prop_array)[0])), \
}
#else
#define LV_STYLE_CONST_INIT(var_name, prop_array) \
const lv_style_t var_name = { \
.v_p = { .const_props = prop_array }, \
.has_group = 0xFF, \
.prop1 = LV_STYLE_PROP_ANY, \
.prop_cnt = (sizeof(prop_array) / sizeof((prop_array)[0])), \
}
#endif
// *INDENT-ON*
#define LV_STYLE_PROP_META_INHERIT 0x8000
#define LV_STYLE_PROP_META_INITIAL 0x4000
#define LV_STYLE_PROP_META_MASK (LV_STYLE_PROP_META_INHERIT | LV_STYLE_PROP_META_INITIAL)
#define LV_STYLE_PROP_ID_MASK(prop) ((lv_style_prop_t)((prop) & ~LV_STYLE_PROP_META_MASK))
/**********************
* TYPEDEFS
**********************/
enum {
};
typedef uint8_t lv_blend_mode_t;
enum {
LV_TEXT_DECOR_NONE = 0x00,
LV_TEXT_DECOR_UNDERLINE = 0x01,
LV_TEXT_DECOR_STRIKETHROUGH = 0x02,
};
typedef uint8_t lv_text_decor_t;
enum {
LV_BORDER_SIDE_NONE = 0x00,
LV_BORDER_SIDE_BOTTOM = 0x01,
LV_BORDER_SIDE_TOP = 0x02,
LV_BORDER_SIDE_LEFT = 0x04,
LV_BORDER_SIDE_RIGHT = 0x08,
LV_BORDER_SIDE_FULL = 0x0F,
};
typedef uint8_t lv_border_side_t;
enum {
};
typedef uint8_t lv_grad_dir_t;
enum {
};
typedef uint8_t lv_dither_mode_t;
typedef struct {
lv_color_t color;
uint8_t frac;
typedef struct {
lv_gradient_stop_t stops[LV_GRADIENT_MAX_STOPS];
uint8_t stops_count;
lv_grad_dir_t dir : 3;
lv_dither_mode_t dither : 3;
typedef union {
int32_t num;
const void * ptr;
lv_color_t color;
typedef enum {
LV_STYLE_PROP_INV = 0,
/*Group 0*/
LV_STYLE_WIDTH = 1,
LV_STYLE_MIN_WIDTH = 2,
LV_STYLE_MAX_WIDTH = 3,
LV_STYLE_HEIGHT = 4,
LV_STYLE_MIN_HEIGHT = 5,
LV_STYLE_MAX_HEIGHT = 6,
LV_STYLE_X = 7,
LV_STYLE_Y = 8,
LV_STYLE_ALIGN = 9,
LV_STYLE_LAYOUT = 10,
LV_STYLE_RADIUS = 11,
/*Group 1*/
LV_STYLE_PAD_TOP = 16,
LV_STYLE_PAD_BOTTOM = 17,
LV_STYLE_PAD_LEFT = 18,
LV_STYLE_PAD_RIGHT = 19,
LV_STYLE_PAD_ROW = 20,
LV_STYLE_PAD_COLUMN = 21,
LV_STYLE_BASE_DIR = 22,
LV_STYLE_CLIP_CORNER = 23,
/*Group 2*/
LV_STYLE_BG_COLOR = 32,
LV_STYLE_BG_OPA = 33,
LV_STYLE_BG_GRAD_COLOR = 34,
LV_STYLE_BG_GRAD_DIR = 35,
LV_STYLE_BG_MAIN_STOP = 36,
LV_STYLE_BG_GRAD_STOP = 37,
LV_STYLE_BG_GRAD = 38,
LV_STYLE_BG_DITHER_MODE = 39,
LV_STYLE_BG_IMG_SRC = 40,
LV_STYLE_BG_IMG_OPA = 41,
LV_STYLE_BG_IMG_RECOLOR = 42,
LV_STYLE_BG_IMG_RECOLOR_OPA = 43,
LV_STYLE_BG_IMG_TILED = 44,
/*Group 3*/
LV_STYLE_BORDER_COLOR = 48,
LV_STYLE_BORDER_OPA = 49,
LV_STYLE_BORDER_WIDTH = 50,
LV_STYLE_BORDER_SIDE = 51,
LV_STYLE_BORDER_POST = 52,
LV_STYLE_OUTLINE_WIDTH = 53,
LV_STYLE_OUTLINE_COLOR = 54,
LV_STYLE_OUTLINE_OPA = 55,
LV_STYLE_OUTLINE_PAD = 56,
/*Group 4*/
LV_STYLE_SHADOW_WIDTH = 64,
LV_STYLE_SHADOW_OFS_X = 65,
LV_STYLE_SHADOW_OFS_Y = 66,
LV_STYLE_SHADOW_SPREAD = 67,
LV_STYLE_SHADOW_COLOR = 68,
LV_STYLE_SHADOW_OPA = 69,
LV_STYLE_IMG_OPA = 70,
LV_STYLE_IMG_RECOLOR = 71,
LV_STYLE_IMG_RECOLOR_OPA = 72,
LV_STYLE_LINE_WIDTH = 73,
LV_STYLE_LINE_DASH_WIDTH = 74,
LV_STYLE_LINE_DASH_GAP = 75,
LV_STYLE_LINE_ROUNDED = 76,
LV_STYLE_LINE_COLOR = 77,
LV_STYLE_LINE_OPA = 78,
/*Group 5*/
LV_STYLE_ARC_WIDTH = 80,
LV_STYLE_ARC_ROUNDED = 81,
LV_STYLE_ARC_COLOR = 82,
LV_STYLE_ARC_OPA = 83,
LV_STYLE_ARC_IMG_SRC = 84,
LV_STYLE_TEXT_COLOR = 85,
LV_STYLE_TEXT_OPA = 86,
LV_STYLE_TEXT_FONT = 87,
LV_STYLE_TEXT_LETTER_SPACE = 88,
LV_STYLE_TEXT_LINE_SPACE = 89,
LV_STYLE_TEXT_DECOR = 90,
LV_STYLE_TEXT_ALIGN = 91,
/*Group 6*/
LV_STYLE_OPA = 96,
LV_STYLE_COLOR_FILTER_DSC = 97,
LV_STYLE_COLOR_FILTER_OPA = 98,
LV_STYLE_ANIM = 99,
LV_STYLE_ANIM_TIME = 100,
LV_STYLE_ANIM_SPEED = 101,
LV_STYLE_TRANSITION = 102,
LV_STYLE_BLEND_MODE = 103,
LV_STYLE_TRANSFORM_WIDTH = 104,
LV_STYLE_TRANSFORM_HEIGHT = 105,
LV_STYLE_TRANSLATE_X = 106,
LV_STYLE_TRANSLATE_Y = 107,
LV_STYLE_TRANSFORM_ZOOM = 108,
LV_STYLE_TRANSFORM_ANGLE = 109,
LV_STYLE_TRANSFORM_PIVOT_X = 110,
LV_STYLE_TRANSFORM_PIVOT_Y = 111,
_LV_STYLE_LAST_BUILT_IN_PROP = 111,
_LV_STYLE_NUM_BUILT_IN_PROPS = _LV_STYLE_LAST_BUILT_IN_PROP + 1,
LV_STYLE_PROP_ANY = 0xFFFF,
_LV_STYLE_PROP_CONST = 0xFFFF /* magic value for const styles */
enum {
LV_STYLE_RES_NOT_FOUND,
LV_STYLE_RES_FOUND,
LV_STYLE_RES_INHERIT
};
typedef uint8_t lv_style_res_t;
typedef struct {
const lv_style_prop_t * props;
#if LV_USE_USER_DATA
void * user_data;
#endif
lv_anim_path_cb_t path_xcb;
uint32_t time;
uint32_t delay;
typedef struct {
typedef struct {
#if LV_USE_ASSERT_STYLE
uint32_t sentinel;
#endif
/*If there is only one property store it directly.
*For more properties allocate an array*/
union {
uint8_t * values_and_props;
const lv_style_const_prop_t * const_props;
} v_p;
uint16_t prop1;
uint8_t has_group;
uint8_t prop_cnt;
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_style_init(lv_style_t * style);
void lv_style_reset(lv_style_t * style);
lv_style_prop_t lv_style_register_prop(uint8_t flag);
void lv_style_set_prop_meta(lv_style_t * style, lv_style_prop_t prop, uint16_t meta);
lv_style_res_t lv_style_get_prop(const lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value);
void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t props[],
lv_anim_path_cb_t path_cb, uint32_t time, uint32_t delay, void * user_data);
static inline lv_style_res_t lv_style_get_prop_inlined(const lv_style_t * style, lv_style_prop_t prop,
{
if(style->prop1 == LV_STYLE_PROP_ANY) {
const lv_style_const_prop_t * const_prop;
uint32_t i;
for(i = 0; i < style->prop_cnt; i++) {
const_prop = style->v_p.const_props + i;
lv_style_prop_t prop_id = LV_STYLE_PROP_ID_MASK(const_prop->prop);
if(prop_id == prop) {
if(const_prop->prop & LV_STYLE_PROP_META_INHERIT)
return LV_STYLE_RES_INHERIT;
*value = (const_prop->prop & LV_STYLE_PROP_META_INITIAL) ? lv_style_prop_get_default(prop_id) : const_prop->value;
return LV_STYLE_RES_FOUND;
}
}
return LV_STYLE_RES_NOT_FOUND;
}
if(style->prop_cnt == 0) return LV_STYLE_RES_NOT_FOUND;
if(style->prop_cnt > 1) {
uint8_t * tmp = style->v_p.values_and_props + style->prop_cnt * sizeof(lv_style_value_t);
uint16_t * props = (uint16_t *)tmp;
uint32_t i;
for(i = 0; i < style->prop_cnt; i++) {
lv_style_prop_t prop_id = LV_STYLE_PROP_ID_MASK(props[i]);
if(prop_id == prop) {
if(props[i] & LV_STYLE_PROP_META_INHERIT)
return LV_STYLE_RES_INHERIT;
if(props[i] & LV_STYLE_PROP_META_INITIAL)
*value = lv_style_prop_get_default(prop_id);
else {
lv_style_value_t * values = (lv_style_value_t *)style->v_p.values_and_props;
*value = values[i];
}
return LV_STYLE_RES_FOUND;
}
}
}
else if(LV_STYLE_PROP_ID_MASK(style->prop1) == prop) {
if(style->prop1 & LV_STYLE_PROP_META_INHERIT)
return LV_STYLE_RES_INHERIT;
*value = (style->prop1 & LV_STYLE_PROP_META_INITIAL) ? lv_style_prop_get_default(LV_STYLE_PROP_ID_MASK(
style->prop1)) : style->v_p.value1;
return LV_STYLE_RES_FOUND;
}
return LV_STYLE_RES_NOT_FOUND;
}
bool lv_style_is_empty(const lv_style_t * style);
#include "lv_style_gen.h"
static inline void lv_style_set_size(lv_style_t * style, lv_coord_t value)
{
lv_style_set_width(style, value);
lv_style_set_height(style, value);
}
static inline void lv_style_set_pad_all(lv_style_t * style, lv_coord_t value)
{
lv_style_set_pad_left(style, value);
lv_style_set_pad_right(style, value);
lv_style_set_pad_top(style, value);
lv_style_set_pad_bottom(style, value);
}
static inline void lv_style_set_pad_hor(lv_style_t * style, lv_coord_t value)
{
lv_style_set_pad_left(style, value);
lv_style_set_pad_right(style, value);
}
static inline void lv_style_set_pad_ver(lv_style_t * style, lv_coord_t value)
{
lv_style_set_pad_top(style, value);
lv_style_set_pad_bottom(style, value);
}
static inline void lv_style_set_pad_gap(lv_style_t * style, lv_coord_t value)
{
lv_style_set_pad_row(style, value);
lv_style_set_pad_column(style, value);
}
static inline bool lv_style_prop_has_flag(lv_style_prop_t prop, uint8_t flag)
{
return _lv_style_prop_lookup_flags(prop) & flag;
}
/*************************
* GLOBAL VARIABLES
*************************/
/**********************
* MACROS
**********************/
#if LV_USE_ASSERT_STYLE
# define LV_ASSERT_STYLE(style_p) \
do { \
LV_ASSERT_MSG(style_p != NULL, "The style is NULL"); \
LV_ASSERT_MSG(style_p->sentinel == LV_STYLE_SENTINEL_VALUE, "Style is not initialized or corrupted"); \
} while(0)
#else
# define LV_ASSERT_STYLE(p) do{}while(0)
#endif
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_STYLE_H*/
int32_t(* lv_anim_path_cb_t)(const struct _lv_anim_t *)
Definition lv_anim.h:46
void lv_style_set_prop_meta(lv_style_t *style, lv_style_prop_t prop, uint16_t meta)
#define LV_IMG_ZOOM_NONE
Definition lv_style.h:49
@ LV_BLEND_MODE_REPLACE
Definition lv_style.h:91
@ LV_BLEND_MODE_MULTIPLY
Definition lv_style.h:90
@ LV_BLEND_MODE_SUBTRACTIVE
Definition lv_style.h:89
@ LV_BLEND_MODE_ADDITIVE
Definition lv_style.h:88
@ LV_BLEND_MODE_NORMAL
Definition lv_style.h:87
lv_style_prop_t
Definition lv_style.h:178
uint8_t _lv_style_get_prop_group(lv_style_prop_t prop)
void lv_style_set_prop(lv_style_t *style, lv_style_prop_t prop, lv_style_value_t value)
uint8_t _lv_style_prop_lookup_flags(lv_style_prop_t prop)
void lv_style_init(lv_style_t *style)
bool lv_style_is_empty(const lv_style_t *style)
@ LV_BORDER_SIDE_INTERNAL
Definition lv_style.h:119
lv_style_res_t lv_style_get_prop(const lv_style_t *style, lv_style_prop_t prop, lv_style_value_t *value)
bool lv_style_remove_prop(lv_style_t *style, lv_style_prop_t prop)
lv_style_prop_t lv_style_get_num_custom_props(void)
lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop)
@ LV_DITHER_NONE
Definition lv_style.h:139
@ LV_DITHER_ORDERED
Definition lv_style.h:140
@ LV_DITHER_ERR_DIFF
Definition lv_style.h:141
@ LV_GRAD_DIR_VER
Definition lv_style.h:128
@ LV_GRAD_DIR_NONE
Definition lv_style.h:127
@ LV_GRAD_DIR_HOR
Definition lv_style.h:129
void lv_style_reset(lv_style_t *style)
Definition lv_style.h:155
Definition lv_style.h:149
Definition lv_style.h:310
Definition lv_style.h:318
Definition lv_style.h:297
Definition lv_style.h:167