1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00
lvgl/lv_obj/lv_style.h

178 lines
3.8 KiB
C
Raw Normal View History

/**
* @file lv_style.h
*
*/
#ifndef LV_STYLE_H
#define LV_STYLE_H
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include <stdbool.h>
2017-04-21 09:15:39 +02:00
#include "misc/gfx/color.h"
#include "misc/gfx/area.h"
#include "misc/gfx/font.h"
2017-07-28 13:57:56 +02:00
#include "misc/gfx/anim.h"
/*********************
* DEFINES
*********************/
2017-04-24 16:16:36 +02:00
#define LV_RADIUS_CIRCLE (CORD_MAX) /*A very big radius to always draw as circle*/
/**********************
* TYPEDEFS
**********************/
2017-04-21 09:15:39 +02:00
typedef enum {
2017-10-30 17:11:56 +01:00
LV_TEXT_ALIGN_LEFT = 0,
LV_TEXT_ALIGN_MID,
}lv_text_align_t;
2017-04-21 09:15:39 +02:00
2017-04-24 12:08:24 +02:00
/*Shadow types*/
typedef enum
{
2017-10-19 12:46:49 +02:00
LV_SHADOW_BOTTOM = 0,
LV_SHADOW_FULL,
}lv_shadow_type_t;
2017-04-24 12:08:24 +02:00
typedef struct
{
opa_t opa;
2017-10-19 12:46:49 +02:00
uint8_t glass :1; /*1: Do not inherit this style*/
2017-10-18 16:07:19 +02:00
struct {
color_t color_main;
2017-10-19 12:46:49 +02:00
color_t color_gradient;
cord_t radius;
struct {
color_t color;
cord_t width;
opa_t opa;
}border;
struct {
color_t color;
cord_t width;
uint8_t type;
}shadow;
2017-10-19 12:46:49 +02:00
struct {
cord_t ver;
cord_t hor;
2017-10-19 12:46:49 +02:00
cord_t inner;
}padding;
2017-10-18 16:07:19 +02:00
uint8_t empty :1; /*Transparent background (border still drawn)*/
}body;
struct {
color_t color;
const font_t * font;
cord_t space_letter;
cord_t space_line;
uint8_t align:2;
2017-10-19 12:46:49 +02:00
}text;
2017-10-18 16:07:19 +02:00
struct {
color_t color;
opa_t intense;
2017-10-19 12:46:49 +02:00
}image;
2017-10-18 16:07:19 +02:00
struct {
color_t color;
cord_t width;
}line;
}lv_style_t;
typedef enum {
2017-10-19 12:46:49 +02:00
LV_STYLE_SCREEN,
LV_STYLE_TRANSPARENT,
LV_STYLE_TRANSPARENT_TIGHT,
LV_STYLE_PLAIN,
LV_STYLE_PLAIN_COLOR,
LV_STYLE_PRETTY,
LV_STYLE_PRETTY_COLOR,
2017-10-19 12:46:49 +02:00
LV_STYLE_BUTTON_OFF_RELEASED,
LV_STYLE_BUTTON_OFF_PRESSED,
LV_STYLE_BUTTON_ON_RELEASED,
LV_STYLE_BUTTON_ON_PRESSED,
LV_STYLE_BUTTON_INACTIVE,
}lv_style_name_t;
2017-07-28 13:57:56 +02:00
typedef struct {
const lv_style_t * style_start; /*Pointer to the starting style*/
const lv_style_t * style_end; /*Pointer to the destination style*/
lv_style_t * style_anim; /*Pointer to a style to animate*/
anim_cb_t end_cb; /*Call it when the animation is ready*/
int16_t time; /*Animation time in ms*/
int16_t act_time; /*Current time in animation. Set to negative to make delay.*/
uint16_t playback_pause; /*Wait before play back*/
uint16_t repeat_pause; /*Wait before repeat*/
uint8_t playback :1; /*When the animation is ready play it back*/
uint8_t repeat :1; /*Repeat the animation infinitely*/
}lv_style_anim_t;
/* Example initialization
lv_style_anim_t a;
a.style_anim = &style_to_anim;
a.style_start = &style_1;
a.style_end = &style_2;
a.act_time = 0;
a.time = 1000;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
a.end_cb = NULL;
lv_style_anim_create(&a);
*/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Init the basic styles
*/
void lv_style_init (void);
/**
* Get style from its name
* @param style_name an element of the 'lv_style_name_t' enum
* @return pointer to the requested style (lv_style_def by default)
*/
lv_style_t * lv_style_get(lv_style_name_t style_name);
2017-07-28 13:57:56 +02:00
/**
* Copy a style to an other
* @param dest pointer to the destination style
* @param src pointer to the source style
*/
void lv_style_copy(lv_style_t * dest, const lv_style_t * src);
2017-07-28 13:57:56 +02:00
/**
* Create an animation from a pre-configured 'lv_style_anim_t' variable
* @param anim pointer to a pre-configured 'lv_style_anim_t' variable (will be copied)
2017-07-28 13:57:56 +02:00
*/
void lv_style_anim_create(lv_style_anim_t * anim);
/**********************
* MACROS
**********************/
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
} /* extern "C" */
#endif
2017-07-09 15:32:49 +02:00
#endif /*LV_STYLE_H*/