2017-04-13 10:20:35 +02:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
|
2017-04-13 10:20:35 +02:00
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
|
|
|
#include <stdbool.h>
|
2017-11-23 20:42:14 +01:00
|
|
|
#include "../lv_misc/lv_color.h"
|
|
|
|
#include "../lv_misc/lv_area.h"
|
|
|
|
#include "../lv_misc/lv_font.h"
|
|
|
|
#include "../lv_misc/lv_anim.h"
|
2017-04-13 10:20:35 +02:00
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
2017-11-23 21:28:36 +01:00
|
|
|
#define LV_RADIUS_CIRCLE (LV_COORD_MAX) /*A very big radius to always draw as circle*/
|
2017-04-13 10:20:35 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
2017-04-21 09:15:39 +02:00
|
|
|
|
2017-11-17 15:43:08 +01:00
|
|
|
/*Border types (Use 'OR'ed values)*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
LV_BORDER_NONE = 0x00,
|
|
|
|
LV_BORDER_BOTTOM = 0x01,
|
|
|
|
LV_BORDER_TOP = 0x02,
|
|
|
|
LV_BORDER_LEFT = 0x04,
|
|
|
|
LV_BORDER_RIGHT = 0x08,
|
|
|
|
LV_BORDER_FULL = 0x0F,
|
|
|
|
}lv_border_part_t;
|
|
|
|
|
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
|
|
|
|
2017-04-13 10:20:35 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2018-06-09 08:45:38 +02:00
|
|
|
uint8_t glass :1; /*1: Do not inherit this style*/
|
2017-10-19 12:46:49 +02:00
|
|
|
|
2017-10-18 16:07:19 +02:00
|
|
|
struct {
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_color_t main_color;
|
2018-06-09 08:45:38 +02:00
|
|
|
union {
|
|
|
|
lv_color_t grad_color; /*`grad_color` will be removed in v6.0, use `aux_color` instead*/
|
|
|
|
lv_color_t aux_color;
|
|
|
|
};
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_coord_t radius;
|
2018-06-08 10:26:10 +02:00
|
|
|
lv_coord_t thickness; /*Depending on the object type thickness of something*/
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_opa_t opa;
|
2017-10-20 10:17:02 +02:00
|
|
|
|
|
|
|
struct {
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_color_t color;
|
|
|
|
lv_coord_t width;
|
2017-11-17 15:43:08 +01:00
|
|
|
lv_border_part_t part;
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_opa_t opa;
|
2017-10-20 10:17:02 +02:00
|
|
|
}border;
|
|
|
|
|
|
|
|
struct {
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_color_t color;
|
|
|
|
lv_coord_t width;
|
2017-10-20 10:17:02 +02:00
|
|
|
uint8_t type;
|
|
|
|
}shadow;
|
|
|
|
|
2017-10-19 12:46:49 +02:00
|
|
|
struct {
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_coord_t ver;
|
|
|
|
lv_coord_t hor;
|
|
|
|
lv_coord_t inner;
|
2017-10-19 12:46:49 +02:00
|
|
|
}padding;
|
|
|
|
|
2017-10-18 16:07:19 +02:00
|
|
|
uint8_t empty :1; /*Transparent background (border still drawn)*/
|
|
|
|
}body;
|
|
|
|
|
|
|
|
|
|
|
|
struct {
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_color_t color;
|
|
|
|
const lv_font_t * font;
|
|
|
|
lv_coord_t letter_space;
|
|
|
|
lv_coord_t line_space;
|
|
|
|
lv_opa_t opa;
|
2017-10-19 12:46:49 +02:00
|
|
|
}text;
|
2017-10-18 16:07:19 +02:00
|
|
|
|
|
|
|
struct {
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_color_t color;
|
|
|
|
lv_opa_t intense;
|
|
|
|
lv_opa_t opa;
|
2017-10-19 12:46:49 +02:00
|
|
|
}image;
|
2017-10-18 16:07:19 +02:00
|
|
|
|
|
|
|
struct {
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_color_t color;
|
|
|
|
lv_coord_t width;
|
|
|
|
lv_opa_t opa;
|
2017-10-18 16:07:19 +02:00
|
|
|
}line;
|
2017-04-13 10:20:35 +02:00
|
|
|
}lv_style_t;
|
|
|
|
|
2017-12-07 19:22:23 +01:00
|
|
|
#if USE_LV_ANIMATION
|
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*/
|
2017-12-01 19:40:12 +01:00
|
|
|
lv_anim_cb_t end_cb; /*Call it when the animation is ready (NULL if unused)*/
|
2017-07-28 13:57:56 +02:00
|
|
|
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);
|
|
|
|
*/
|
2017-11-27 17:48:54 +01:00
|
|
|
#endif
|
2017-07-28 13:57:56 +02:00
|
|
|
|
2017-04-13 10:20:35 +02:00
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Init the basic styles
|
|
|
|
*/
|
|
|
|
void lv_style_init (void);
|
|
|
|
|
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
|
|
|
|
*/
|
2017-10-20 10:17:02 +02:00
|
|
|
void lv_style_copy(lv_style_t * dest, const lv_style_t * src);
|
2017-04-13 10:20:35 +02:00
|
|
|
|
2017-12-07 19:22:23 +01:00
|
|
|
#if USE_LV_ANIMATION
|
2018-06-15 09:29:10 +02:00
|
|
|
|
2017-07-28 13:57:56 +02:00
|
|
|
/**
|
2017-07-28 14:19:52 +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)
|
2018-06-15 09:29:10 +02:00
|
|
|
* @return pointer to a descriptor. Really this variable will be animated. (Can be used in `lv_anim_del(dsc, NULL)`)
|
2017-07-28 13:57:56 +02:00
|
|
|
*/
|
2018-06-15 09:29:10 +02:00
|
|
|
void * lv_style_anim_create(lv_style_anim_t * anim);
|
2017-11-27 17:48:54 +01:00
|
|
|
#endif
|
2017-07-28 14:19:52 +02:00
|
|
|
|
2017-10-30 17:31:48 +01:00
|
|
|
/*************************
|
|
|
|
* GLOBAL VARIABLES
|
|
|
|
*************************/
|
|
|
|
extern lv_style_t lv_style_scr;
|
|
|
|
extern lv_style_t lv_style_transp;
|
2017-10-31 16:25:52 +01:00
|
|
|
extern lv_style_t lv_style_transp_fit;
|
2017-10-30 17:31:48 +01:00
|
|
|
extern lv_style_t lv_style_transp_tight;
|
|
|
|
extern lv_style_t lv_style_plain;
|
|
|
|
extern lv_style_t lv_style_plain_color;
|
|
|
|
extern lv_style_t lv_style_pretty;
|
|
|
|
extern lv_style_t lv_style_pretty_color;
|
2017-11-20 14:26:18 +01:00
|
|
|
extern lv_style_t lv_style_btn_rel;
|
|
|
|
extern lv_style_t lv_style_btn_pr;
|
|
|
|
extern lv_style_t lv_style_btn_tgl_rel;
|
|
|
|
extern lv_style_t lv_style_btn_tgl_pr;;
|
|
|
|
extern lv_style_t lv_style_btn_ina;
|
2017-10-30 17:31:48 +01:00
|
|
|
|
2017-04-13 10:20:35 +02:00
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
2017-04-13 10:20:35 +02:00
|
|
|
#endif
|
2017-07-09 15:32:49 +02:00
|
|
|
|
|
|
|
#endif /*LV_STYLE_H*/
|