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-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"
|
2017-04-13 10:20:35 +02:00
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
2017-04-24 16:16:36 +02:00
|
|
|
#define LV_RADIUS_CIRCLE (CORD_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
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
LV_TXT_ALIGN_LEFT = 0,
|
|
|
|
LV_TXT_ALIGN_MID,
|
|
|
|
}lv_txt_align_t;
|
|
|
|
|
2017-04-24 12:08:24 +02:00
|
|
|
|
|
|
|
/*Shadow types*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
LV_STYPE_BOTTOM = 0,
|
|
|
|
LV_STYPE_FULL,
|
|
|
|
}lv_stype_t;
|
|
|
|
|
2017-04-13 10:20:35 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/*Object level styles*/
|
|
|
|
color_t ccolor; /*Content color (e.g. text or image re-color )*/
|
|
|
|
opa_t opa; /*Opacity of the object*/
|
2017-04-24 16:16:36 +02:00
|
|
|
uint8_t glass :1; /*1: Do not inherit this style*/
|
2017-04-13 10:20:35 +02:00
|
|
|
uint8_t empty :1; /*Transparent background (border drawn)*/
|
2017-04-28 16:12:35 +02:00
|
|
|
uint8_t stype :2; /*Shadow type from 'lv_shadow_type_t'*/
|
|
|
|
uint8_t txt_align:2;
|
2017-04-13 10:20:35 +02:00
|
|
|
color_t mcolor; /*Main color of background*/
|
|
|
|
color_t gcolor; /*Gradient color of background*/
|
|
|
|
color_t bcolor; /*Border color of background*/
|
|
|
|
color_t scolor; /*Shadow color of background*/
|
|
|
|
cord_t radius; /*Corner radius of background*/
|
|
|
|
cord_t bwidth; /*Width of the background border*/
|
|
|
|
cord_t swidth; /*Width of the background shadow effect*/
|
|
|
|
cord_t vpad; /*Vertical padding*/
|
|
|
|
cord_t hpad; /*Horizontal padding*/
|
|
|
|
cord_t opad; /*Object padding on the background*/
|
|
|
|
opa_t bopa; /*Opacity of background border*/
|
|
|
|
const font_t * font;
|
|
|
|
cord_t letter_space;
|
|
|
|
cord_t line_space;
|
|
|
|
opa_t img_recolor;
|
|
|
|
cord_t line_width;
|
|
|
|
}lv_style_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
LV_STYLE_SCR,
|
|
|
|
LV_STYLE_TRANSP,
|
|
|
|
LV_STYLE_TRANSP_TIGHT,
|
|
|
|
LV_STYLE_PLAIN,
|
|
|
|
LV_STYLE_PLAIN_COLOR,
|
|
|
|
LV_STYLE_PRETTY,
|
|
|
|
LV_STYLE_PRETTY_COLOR,
|
|
|
|
LV_STYLE_BTN_REL,
|
|
|
|
LV_STYLE_BTN_PR,
|
|
|
|
LV_STYLE_BTN_TREL,
|
|
|
|
LV_STYLE_BTN_TPR,
|
|
|
|
LV_STYLE_BTN_INA,
|
|
|
|
}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);
|
|
|
|
*/
|
|
|
|
|
2017-04-13 10:20:35 +02:00
|
|
|
/**********************
|
|
|
|
* 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, lv_style_t * copy);
|
|
|
|
|
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-05-08 10:09:41 +02:00
|
|
|
void lv_style_cpy(lv_style_t * dest, const lv_style_t * src);
|
2017-04-13 10:20:35 +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)
|
2017-07-28 13:57:56 +02:00
|
|
|
*/
|
2017-07-28 14:19:52 +02:00
|
|
|
void lv_style_anim_create(lv_style_anim_t * anim);
|
|
|
|
|
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*/
|