lv_style.h

Defines

LV_STYLE_SENTINEL_VALUE
LV_STYLE_PROP_FLAG_NONE

Flags for style behavior

The rest of the flags will have _FLAG added to their name in v9.

LV_STYLE_PROP_FLAG_INHERITABLE
LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE
LV_STYLE_PROP_FLAG_LAYOUT_UPDATE
LV_STYLE_PROP_FLAG_PARENT_LAYOUT_UPDATE
LV_STYLE_PROP_FLAG_LAYER_UPDATE
LV_STYLE_PROP_FLAG_TRANSFORM
LV_STYLE_PROP_FLAG_ALL
LV_SCALE_NONE

Other constants

LV_STYLE_CONST_INIT(var_name, prop_array)
LV_STYLE_CONST_PROPS_END
LV_ASSERT_STYLE(style_p)

Enums

enum lv_blend_mode_t

Possible options how to blend opaque drawings

Values:

enumerator LV_BLEND_MODE_NORMAL

Simply mix according to the opacity value

enumerator LV_BLEND_MODE_ADDITIVE

Add the respective color channels

enumerator LV_BLEND_MODE_SUBTRACTIVE

Subtract the foreground from the background

enumerator LV_BLEND_MODE_MULTIPLY

Multiply the foreground and background

enum lv_text_decor_t

Some options to apply decorations on texts. 'OR'ed values can be used.

Values:

enumerator LV_TEXT_DECOR_NONE
enumerator LV_TEXT_DECOR_UNDERLINE
enumerator LV_TEXT_DECOR_STRIKETHROUGH
enum lv_border_side_t

Selects on which sides border should be drawn 'OR'ed values can be used.

Values:

enumerator LV_BORDER_SIDE_NONE
enumerator LV_BORDER_SIDE_BOTTOM
enumerator LV_BORDER_SIDE_TOP
enumerator LV_BORDER_SIDE_LEFT
enumerator LV_BORDER_SIDE_RIGHT
enumerator LV_BORDER_SIDE_FULL
enumerator LV_BORDER_SIDE_INTERNAL

FOR matrix-like objects (e.g. Button matrix)

enum lv_grad_dir_t

The direction of the gradient.

Values:

enumerator LV_GRAD_DIR_NONE

No gradient (the grad_color property is ignored)

enumerator LV_GRAD_DIR_VER

Simple vertical (top to bottom) gradient

enumerator LV_GRAD_DIR_HOR

Simple horizontal (left to right) gradient

enumerator LV_GRAD_DIR_LINEAR

Linear gradient defined by start and end points. Can be at any angle.

enumerator LV_GRAD_DIR_RADIAL

Radial gradient defined by start and end circles

enumerator LV_GRAD_DIR_CONICAL

Conical gradient defined by center point, start and end angles

enum lv_grad_extend_t

Gradient behavior outside the defined range.

Values:

enumerator LV_GRAD_EXTEND_PAD

Repeat the same color

enumerator LV_GRAD_EXTEND_REPEAT

Repeat the pattern

enumerator LV_GRAD_EXTEND_REFLECT

Repeat the pattern mirrored

enum [anonymous]

Enumeration of all built in style properties

Props are split into groups of 16. When adding a new prop to a group, ensure it does not overflow into the next one.

Values:

enumerator LV_STYLE_PROP_INV
enumerator LV_STYLE_WIDTH
enumerator LV_STYLE_HEIGHT
enumerator LV_STYLE_LENGTH
enumerator LV_STYLE_MIN_WIDTH
enumerator LV_STYLE_MAX_WIDTH
enumerator LV_STYLE_MIN_HEIGHT
enumerator LV_STYLE_MAX_HEIGHT
enumerator LV_STYLE_X
enumerator LV_STYLE_Y
enumerator LV_STYLE_ALIGN
enumerator LV_STYLE_RADIUS
enumerator LV_STYLE_PAD_TOP
enumerator LV_STYLE_PAD_BOTTOM
enumerator LV_STYLE_PAD_LEFT
enumerator LV_STYLE_PAD_RIGHT
enumerator LV_STYLE_PAD_ROW
enumerator LV_STYLE_PAD_COLUMN
enumerator LV_STYLE_LAYOUT
enumerator LV_STYLE_MARGIN_TOP
enumerator LV_STYLE_MARGIN_BOTTOM
enumerator LV_STYLE_MARGIN_LEFT
enumerator LV_STYLE_MARGIN_RIGHT
enumerator LV_STYLE_BG_COLOR
enumerator LV_STYLE_BG_OPA
enumerator LV_STYLE_BG_GRAD_DIR
enumerator LV_STYLE_BG_MAIN_STOP
enumerator LV_STYLE_BG_GRAD_STOP
enumerator LV_STYLE_BG_GRAD_COLOR
enumerator LV_STYLE_BG_MAIN_OPA
enumerator LV_STYLE_BG_GRAD_OPA
enumerator LV_STYLE_BG_GRAD
enumerator LV_STYLE_BASE_DIR
enumerator LV_STYLE_BG_IMAGE_SRC
enumerator LV_STYLE_BG_IMAGE_OPA
enumerator LV_STYLE_BG_IMAGE_RECOLOR
enumerator LV_STYLE_BG_IMAGE_RECOLOR_OPA
enumerator LV_STYLE_BG_IMAGE_TILED
enumerator LV_STYLE_CLIP_CORNER
enumerator LV_STYLE_BORDER_WIDTH
enumerator LV_STYLE_BORDER_COLOR
enumerator LV_STYLE_BORDER_OPA
enumerator LV_STYLE_BORDER_SIDE
enumerator LV_STYLE_BORDER_POST
enumerator LV_STYLE_OUTLINE_WIDTH
enumerator LV_STYLE_OUTLINE_COLOR
enumerator LV_STYLE_OUTLINE_OPA
enumerator LV_STYLE_OUTLINE_PAD
enumerator LV_STYLE_SHADOW_WIDTH
enumerator LV_STYLE_SHADOW_COLOR
enumerator LV_STYLE_SHADOW_OPA
enumerator LV_STYLE_SHADOW_OFFSET_X
enumerator LV_STYLE_SHADOW_OFFSET_Y
enumerator LV_STYLE_SHADOW_SPREAD
enumerator LV_STYLE_IMAGE_OPA
enumerator LV_STYLE_IMAGE_RECOLOR
enumerator LV_STYLE_IMAGE_RECOLOR_OPA
enumerator LV_STYLE_LINE_WIDTH
enumerator LV_STYLE_LINE_DASH_WIDTH
enumerator LV_STYLE_LINE_DASH_GAP
enumerator LV_STYLE_LINE_ROUNDED
enumerator LV_STYLE_LINE_COLOR
enumerator LV_STYLE_LINE_OPA
enumerator LV_STYLE_ARC_WIDTH
enumerator LV_STYLE_ARC_ROUNDED
enumerator LV_STYLE_ARC_COLOR
enumerator LV_STYLE_ARC_OPA
enumerator LV_STYLE_ARC_IMAGE_SRC
enumerator LV_STYLE_TEXT_COLOR
enumerator LV_STYLE_TEXT_OPA
enumerator LV_STYLE_TEXT_FONT
enumerator LV_STYLE_TEXT_LETTER_SPACE
enumerator LV_STYLE_TEXT_LINE_SPACE
enumerator LV_STYLE_TEXT_DECOR
enumerator LV_STYLE_TEXT_ALIGN
enumerator LV_STYLE_OPA
enumerator LV_STYLE_OPA_LAYERED
enumerator LV_STYLE_COLOR_FILTER_DSC
enumerator LV_STYLE_COLOR_FILTER_OPA
enumerator LV_STYLE_ANIM
enumerator LV_STYLE_ANIM_DURATION
enumerator LV_STYLE_TRANSITION
enumerator LV_STYLE_BLEND_MODE
enumerator LV_STYLE_TRANSFORM_WIDTH
enumerator LV_STYLE_TRANSFORM_HEIGHT
enumerator LV_STYLE_TRANSLATE_X
enumerator LV_STYLE_TRANSLATE_Y
enumerator LV_STYLE_TRANSFORM_SCALE_X
enumerator LV_STYLE_TRANSFORM_SCALE_Y
enumerator LV_STYLE_TRANSFORM_ROTATION
enumerator LV_STYLE_TRANSFORM_PIVOT_X
enumerator LV_STYLE_TRANSFORM_PIVOT_Y
enumerator LV_STYLE_TRANSFORM_SKEW_X
enumerator LV_STYLE_TRANSFORM_SKEW_Y
enumerator LV_STYLE_BITMAP_MASK_SRC
enumerator LV_STYLE_ROTARY_SENSITIVITY
enumerator LV_STYLE_FLEX_FLOW
enumerator LV_STYLE_FLEX_MAIN_PLACE
enumerator LV_STYLE_FLEX_CROSS_PLACE
enumerator LV_STYLE_FLEX_TRACK_PLACE
enumerator LV_STYLE_FLEX_GROW
enumerator LV_STYLE_GRID_COLUMN_ALIGN
enumerator LV_STYLE_GRID_ROW_ALIGN
enumerator LV_STYLE_GRID_ROW_DSC_ARRAY
enumerator LV_STYLE_GRID_COLUMN_DSC_ARRAY
enumerator LV_STYLE_GRID_CELL_COLUMN_POS
enumerator LV_STYLE_GRID_CELL_COLUMN_SPAN
enumerator LV_STYLE_GRID_CELL_X_ALIGN
enumerator LV_STYLE_GRID_CELL_ROW_POS
enumerator LV_STYLE_GRID_CELL_ROW_SPAN
enumerator LV_STYLE_GRID_CELL_Y_ALIGN
enumerator LV_STYLE_LAST_BUILT_IN_PROP
enumerator LV_STYLE_NUM_BUILT_IN_PROPS
enumerator LV_STYLE_PROP_ANY
enumerator LV_STYLE_PROP_CONST
enum lv_style_res_t

Values:

enumerator LV_STYLE_RES_NOT_FOUND
enumerator LV_STYLE_RES_FOUND

Functions

void lv_style_init(lv_style_t *style)

Initialize a style

备注

Do not call lv_style_init on styles that already have some properties because this function won't free the used memory, just sets a default state for the style. In other words be sure to initialize styles only once!

参数:

style -- pointer to a style to initialize

void lv_style_reset(lv_style_t *style)

Clear all properties from a style and free all allocated memories.

参数:

style -- pointer to a style

static inline bool lv_style_is_const(const lv_style_t *style)

Check if a style is constant

参数:

style -- pointer to a style

返回:

true: the style is constant

lv_style_prop_t lv_style_register_prop(uint8_t flag)
lv_style_prop_t lv_style_get_num_custom_props(void)

Get the number of custom properties that have been registered thus far.

bool lv_style_remove_prop(lv_style_t *style, lv_style_prop_t prop)

Remove a property from a style

参数:
  • style -- pointer to a style

  • prop -- a style property ORed with a state.

返回:

true: the property was found and removed; false: the property wasn't found

void lv_style_set_prop(lv_style_t *style, lv_style_prop_t prop, lv_style_value_t value)

Set the value of property in a style. This function shouldn't be used directly by the user. Instead use lv_style_set_<prop_name>(). E.g. lv_style_set_bg_color()

参数:
  • style -- pointer to style

  • prop -- the ID of a property (e.g. LV_STYLE_BG_COLOR)

  • value -- lv_style_value_t variable in which a field is set according to the type of prop

lv_style_res_t lv_style_get_prop(const lv_style_t *style, lv_style_prop_t prop, lv_style_value_t *value)

Get the value of a property

备注

For performance reasons there are no sanity check on style

参数:
  • style -- pointer to a style

  • prop -- the ID of a property

  • value -- pointer to a lv_style_value_t variable to store the value

返回:

LV_RESULT_INVALID: the property wasn't found in the style (value is unchanged) LV_RESULT_OK: the property was fond, and value is set accordingly

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)
lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop)

Get the default value of a property

参数:

prop -- the ID of a property

返回:

the default value

static inline lv_style_res_t lv_style_get_prop_inlined(const lv_style_t *style, lv_style_prop_t prop, lv_style_value_t *value)

Get the value of a property

备注

For performance reasons there are no sanity check on style

备注

This function is the same as lv_style_get_prop but inlined. Use it only on performance critical places

参数:
  • style -- pointer to a style

  • prop -- the ID of a property

  • value -- pointer to a lv_style_value_t variable to store the value

返回:

LV_RESULT_INVALID: the property wasn't found in the style (value is unchanged) LV_RESULT_OK: the property was fond, and value is set accordingly

bool lv_style_is_empty(const lv_style_t *style)

Checks if a style is empty (has no properties)

参数:

style -- pointer to a style

返回:

true if the style is empty

static inline uint32_t lv_style_get_prop_group(lv_style_prop_t prop)

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. It allows early skipping the style if the property is not exists in the style at all.

参数:

prop -- a style property

返回:

the group [0..30] 30 means all the custom properties with index > 120

uint8_t lv_style_prop_lookup_flags(lv_style_prop_t prop)

Get the flags of a built-in or custom property.

参数:

prop -- a style property

返回:

the flags of the property

static inline void lv_style_set_size(lv_style_t *style, int32_t width, int32_t height)
static inline void lv_style_set_pad_all(lv_style_t *style, int32_t value)
static inline void lv_style_set_pad_hor(lv_style_t *style, int32_t value)
static inline void lv_style_set_pad_ver(lv_style_t *style, int32_t value)
static inline void lv_style_set_pad_gap(lv_style_t *style, int32_t value)
static inline void lv_style_set_transform_scale(lv_style_t *style, int32_t value)
static inline bool lv_style_prop_has_flag(lv_style_prop_t prop, uint8_t flag)

Check if the style property has a specified behavioral flag.

Do not pass multiple flags to this function as backwards-compatibility is not guaranteed for that.

参数:
  • prop -- Property ID

  • flag -- Flag

返回:

true if the flag is set for this property

Variables

const lv_style_prop_t lv_style_const_prop_id_inv
struct lv_gradient_stop_t
#include <lv_style.h>

A gradient stop definition. This matches a color and a position in a virtual 0-255 scale.

Public Members

lv_color_t color

The stop color

lv_opa_t opa

The opacity of the color

uint8_t frac

The stop position in 1/255 unit

struct lv_grad_dsc_t
#include <lv_style.h>

A descriptor of a gradient.

Public Members

lv_gradient_stop_t stops[2]

A gradient stop array

uint8_t stops_count

The number of used stops in the array

lv_grad_dir_t dir

The gradient direction. Any of LV_GRAD_DIR_NONE, LV_GRAD_DIR_VER, LV_GRAD_DIR_HOR, LV_GRAD_TYPE_LINEAR, LV_GRAD_TYPE_RADIAL, LV_GRAD_TYPE_CONICAL

lv_grad_extend_t extend

Behaviour outside the defined range. LV_GRAD_EXTEND_NONE, LV_GRAD_EXTEND_PAD, LV_GRAD_EXTEND_REPEAT, LV_GRAD_EXTEND_REFLECT

lv_point_t start

Linear gradient vector start point

lv_point_t end

Linear gradient vector end point

Center of the ending circle in local coordinates

struct lv_grad_dsc_t::[anonymous]::[anonymous] linear
lv_point_t focal

Center of the focal (starting) circle in local coordinates

lv_point_t focal_extent

Point on the circle (can be the same as the center)

lv_point_t end_extent

Point on the circle determining the radius of the gradient

struct lv_grad_dsc_t::[anonymous]::[anonymous] radial
lv_point_t center

Conical gradient center point

int16_t start_angle

Start angle 0..3600

int16_t end_angle

End angle 0..3600

struct lv_grad_dsc_t::[anonymous]::[anonymous] conical
union lv_grad_dsc_t::[anonymous] params
void *state
union lv_style_value_t
#include <lv_style.h>

A common type to handle all the property types in the same way.

Public Members

int32_t num

Number integer number (opacity, enums, booleans or "normal" numbers)

const void *ptr

Constant pointers (font, cone text, etc)

lv_color_t color

Colors

struct lv_style_transition_dsc_t
#include <lv_style.h>

Descriptor for style transitions

Public Members

const lv_style_prop_t *props

An array with the properties to animate.

void *user_data

A custom user data that will be passed to the animation's user_data

lv_anim_path_cb_t path_xcb

A path for the animation.

uint32_t time

Duration of the transition in [ms]

uint32_t delay

Delay before the transition in [ms]

struct lv_style_const_prop_t
#include <lv_style.h>

Descriptor of a constant style property.

Public Members

lv_style_prop_t prop
lv_style_value_t value
struct lv_style_t
#include <lv_style.h>

Descriptor of a style (a collection of properties and values).

Public Members

uint32_t sentinel
void *values_and_props
uint32_t has_group
uint8_t prop_cnt

255 means it's a constant style