mirror of
https://github.com/lvgl/lvgl.git
synced 2024-11-23 09:43:41 +08:00
Further modifications with styles
This commit is contained in:
parent
1b263d5d8a
commit
3316a2ef25
@ -47,14 +47,14 @@ static void (*map_fp)(const area_t * cords_p, const area_t * mask_p, const color
|
||||
#else
|
||||
static void (*fill_fp)(const area_t * cords_p, const area_t * mask_p, color_t color, opa_t opa) = lv_rfill;
|
||||
static void (*letter_fp)(const point_t * pos_p, const area_t * mask_p, const font_t * font_p, uint8_t letter, color_t color, opa_t opa) = lv_rletter;
|
||||
static void (*map_fp)(const area_t * cords_p, const area_t * mask_p, const color_t * map_p, opa_t opa, bool transp) = lv_rmap;
|
||||
static void (*map_fp)(const area_t * cords_p, const area_t * mask_p, const color_t * map_p, opa_t opa, bool transp, color_t recolor, opa_t recolor_opa) = lv_rmap;
|
||||
#endif
|
||||
|
||||
|
||||
static lv_rects_t lv_img_no_pic_rects = {
|
||||
.objs.color = COLOR_BLACK, .gcolor = COLOR_BLACK,
|
||||
.bcolor = COLOR_RED, .bwidth = 2 * LV_STYLE_MULT, .bopa = 100,
|
||||
.round = 0, .objs.empty = 0
|
||||
.round = 0, .empty = 0
|
||||
};
|
||||
|
||||
static lv_labels_t lv_img_no_pic_labels = {
|
||||
@ -80,7 +80,7 @@ static lv_labels_t lv_img_no_pic_labels = {
|
||||
void lv_draw_rect(const area_t * cords_p, const area_t * mask_p,
|
||||
const lv_rects_t * rects_p, opa_t opa)
|
||||
{
|
||||
if(rects_p->objs.empty == 0){
|
||||
if(rects_p->empty == 0){
|
||||
lv_draw_rect_main_mid(cords_p, mask_p, rects_p, opa);
|
||||
|
||||
if(rects_p->round != 0) {
|
||||
|
@ -111,7 +111,7 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p,
|
||||
*/
|
||||
void lv_rmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp,
|
||||
color_t recolor, color_t recolor_opa)
|
||||
color_t recolor, opa_t recolor_opa)
|
||||
{
|
||||
area_t masked_a;
|
||||
bool union_ok;
|
||||
|
@ -31,7 +31,7 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa);
|
||||
void lv_rmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp,
|
||||
color_t recolor, color_t recolor_opa);
|
||||
color_t recolor, opa_t recolor_opa);
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -37,7 +37,7 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
|
||||
void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp,
|
||||
color_t recolor, color_t recolor_opa);
|
||||
color_t recolor, opa_t recolor_opa);
|
||||
|
||||
|
||||
/**********************
|
||||
|
@ -34,10 +34,8 @@ lv_obj_t* def_scr_dp = NULL;
|
||||
lv_obj_t* act_scr_dp = NULL;
|
||||
ll_dsc_t scr_ll;
|
||||
|
||||
lv_objs_t lv_objs_def = {.color = COLOR_GRAY, .empty = 0};
|
||||
lv_objs_t lv_objs_scr = {.color = LV_OBJ_DEF_SCR_COLOR, .empty = 0};
|
||||
lv_objs_t lv_objs_color = {.color = COLOR_RED, .empty = 0};
|
||||
lv_objs_t lv_objs_empty = {.color = COLOR_GRAY, .empty = 1};
|
||||
lv_objs_t lv_objs_def = {.color = COLOR_RED};
|
||||
lv_objs_t lv_objs_scr = {.color = LV_OBJ_DEF_SCR_COLOR};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -326,14 +324,9 @@ lv_objs_t * lv_objs_get(lv_objs_builtin_t style, lv_objs_t * copy_p)
|
||||
case LV_OBJS_DEF:
|
||||
style_p = &lv_objs_def;
|
||||
break;
|
||||
case LV_OBJS_COLOR:
|
||||
style_p = &lv_objs_color;
|
||||
break;
|
||||
case LV_OBJS_SCR:
|
||||
style_p = &lv_objs_scr;
|
||||
break;
|
||||
case LV_OBJS_EMPTY:
|
||||
style_p = &lv_objs_empty;
|
||||
break;
|
||||
default:
|
||||
style_p = NULL;
|
||||
@ -1232,9 +1225,6 @@ static bool lv_obj_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
|
||||
}
|
||||
|
||||
lv_objs_t * objs_p = lv_obj_get_style(obj_dp);
|
||||
|
||||
/*Do not draw the empty objects*/
|
||||
if(objs_p->empty != 0) return true;
|
||||
|
||||
opa_t opa = lv_obj_get_opa(obj_dp);
|
||||
color_t color = objs_p->color;
|
||||
|
@ -133,15 +133,12 @@ typedef enum
|
||||
typedef struct
|
||||
{
|
||||
color_t color;
|
||||
uint8_t empty :1;
|
||||
}lv_objs_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_OBJS_DEF,
|
||||
LV_OBJS_COLOR,
|
||||
LV_OBJS_SCR,
|
||||
LV_OBJS_EMPTY,
|
||||
}lv_objs_builtin_t;
|
||||
|
||||
/**********************
|
||||
|
@ -58,7 +58,7 @@ static lv_btns_t lv_btns_def =
|
||||
|
||||
.rects.bwidth = 2 * LV_STYLE_MULT,
|
||||
.rects.bopa = 50,
|
||||
.rects.objs.empty = 0,
|
||||
.rects.empty = 0,
|
||||
.rects.round = 4 * LV_STYLE_MULT,
|
||||
.rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.rects.vpad = 15 * LV_STYLE_MULT,
|
||||
@ -66,7 +66,7 @@ static lv_btns_t lv_btns_def =
|
||||
static lv_btns_t lv_btns_transp =
|
||||
{
|
||||
.rects.bwidth = 0,
|
||||
.rects.objs.empty = 1,
|
||||
.rects.empty = 1,
|
||||
.rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.rects.vpad = 15 * LV_STYLE_MULT,
|
||||
};
|
||||
@ -79,7 +79,7 @@ static lv_btns_t lv_btns_border =
|
||||
.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_BLACK,
|
||||
.bcolor[LV_BTN_STATE_INA] = COLOR_GRAY,
|
||||
.rects.bwidth = 2 * LV_STYLE_MULT,
|
||||
.rects.objs.empty = 1,
|
||||
.rects.empty = 1,
|
||||
.rects.bopa = 50,
|
||||
.rects.round = 4 * LV_STYLE_MULT,
|
||||
.rects.hpad = 10 * LV_STYLE_MULT,
|
||||
|
@ -71,7 +71,9 @@ lv_obj_t* lv_img_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
img_ext_dp->fn_dp = NULL;
|
||||
img_ext_dp->w = lv_obj_get_width(new_obj_dp);
|
||||
img_ext_dp->h = lv_obj_get_height(new_obj_dp);
|
||||
img_ext_dp->transp = 0;
|
||||
|
||||
/*Enable auto size for non screens*/
|
||||
if(par_dp != NULL) {
|
||||
img_ext_dp->auto_size = 1;
|
||||
} else {
|
||||
@ -190,12 +192,14 @@ void lv_img_set_file(lv_obj_t* obj_dp, const char * fn)
|
||||
/*Create a dummy header*/
|
||||
header.w = lv_obj_get_width(obj_dp);
|
||||
header.h = lv_obj_get_height(obj_dp);
|
||||
header.transp = 0;
|
||||
}
|
||||
|
||||
fs_close(&file);
|
||||
|
||||
img_ext_p->w = header.w;
|
||||
img_ext_p->h = header.h;
|
||||
img_ext_p->transp = header.transp;
|
||||
#if LV_UPSCALE_MAP != 0
|
||||
img_ext_p->w *= LV_DOWNSCALE;
|
||||
img_ext_p->h *= LV_DOWNSCALE;
|
||||
@ -257,9 +261,10 @@ bool lv_img_get_auto_size(lv_obj_t* obj_dp)
|
||||
static bool lv_img_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode)
|
||||
{
|
||||
lv_imgs_t * imgs_p = lv_obj_get_style(obj_dp);
|
||||
lv_img_ext_t * ext_p = lv_obj_get_ext(obj_dp);
|
||||
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
if(imgs_p->objs.empty == 0) {
|
||||
if(ext_p->transp == 0) {
|
||||
bool cover;
|
||||
cover = area_is_in(mask_p, &obj_dp->cords);
|
||||
return cover;
|
||||
@ -267,7 +272,6 @@ static bool lv_img_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
|
||||
else return false;
|
||||
}
|
||||
|
||||
lv_img_ext_t * img_ext_p = lv_obj_get_ext(obj_dp);
|
||||
area_t cords;
|
||||
|
||||
lv_obj_get_cords(obj_dp, &cords);
|
||||
@ -275,13 +279,13 @@ static bool lv_img_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
|
||||
|
||||
area_t cords_tmp;
|
||||
cords_tmp.y1 = cords.y1;
|
||||
cords_tmp.y2 = cords.y1 + img_ext_p->h - 1;
|
||||
cords_tmp.y2 = cords.y1 + ext_p->h - 1;
|
||||
|
||||
for(; cords_tmp.y1 < cords.y2; cords_tmp.y1 += img_ext_p->h, cords_tmp.y2 += img_ext_p->h) {
|
||||
for(; cords_tmp.y1 < cords.y2; cords_tmp.y1 += ext_p->h, cords_tmp.y2 += ext_p->h) {
|
||||
cords_tmp.x1 = cords.x1;
|
||||
cords_tmp.x2 = cords.x1 + img_ext_p->w - 1;
|
||||
for(; cords_tmp.x1 < cords.x2; cords_tmp.x1 += img_ext_p->w, cords_tmp.x2 += img_ext_p->w) {
|
||||
lv_draw_img(&cords_tmp, mask_p, lv_obj_get_style(obj_dp),opa, img_ext_p->fn_dp);
|
||||
cords_tmp.x2 = cords.x1 + ext_p->w - 1;
|
||||
for(; cords_tmp.x1 < cords.x2; cords_tmp.x1 += ext_p->w, cords_tmp.x2 += ext_p->w) {
|
||||
lv_draw_img(&cords_tmp, mask_p, imgs_p, opa, ext_p->fn_dp);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -35,6 +35,7 @@ typedef struct
|
||||
cord_t w;
|
||||
cord_t h;
|
||||
uint8_t auto_size :1;
|
||||
uint8_t transp :1; /*Transp. bit in the images header (library handles this)*/
|
||||
}lv_img_ext_t;
|
||||
|
||||
typedef enum
|
||||
|
@ -38,7 +38,7 @@ static lv_pages_t lv_pages_def =
|
||||
.bg_rects.bopa = 50,
|
||||
.bg_rects.bwidth = 0 * LV_STYLE_MULT,
|
||||
.bg_rects.round = 2 * LV_STYLE_MULT,
|
||||
.bg_rects.objs.empty = 0,
|
||||
.bg_rects.empty = 0,
|
||||
.bg_rects.hpad = 10,
|
||||
.bg_rects.vpad = 10,
|
||||
|
||||
@ -48,7 +48,7 @@ static lv_pages_t lv_pages_def =
|
||||
.sb_rects.bopa = 50,
|
||||
.sb_rects.bwidth = 1 * LV_STYLE_MULT,
|
||||
.sb_rects.round = 5 * LV_STYLE_MULT,
|
||||
.sb_rects.objs.empty = 0,
|
||||
.sb_rects.empty = 0,
|
||||
|
||||
.sb_width= 8 * LV_STYLE_MULT,
|
||||
.sb_opa=50,
|
||||
@ -69,7 +69,7 @@ static lv_pages_t lv_pages_paper =
|
||||
.bg_rects.bopa = 100,
|
||||
.bg_rects.bwidth = 2 * LV_STYLE_MULT,
|
||||
.bg_rects.round = 0 * LV_STYLE_MULT,
|
||||
.bg_rects.objs.empty = 0,
|
||||
.bg_rects.empty = 0,
|
||||
.bg_rects.hpad = 20 * LV_STYLE_MULT,
|
||||
.bg_rects.vpad = 20 * LV_STYLE_MULT,
|
||||
|
||||
@ -79,7 +79,7 @@ static lv_pages_t lv_pages_paper =
|
||||
.sb_rects.bopa = 100,
|
||||
.sb_rects.bwidth = 1 * LV_STYLE_MULT,
|
||||
.sb_rects.round = 5 * LV_STYLE_MULT,
|
||||
.sb_rects.objs.empty = 0,
|
||||
.sb_rects.empty = 0,
|
||||
|
||||
.sb_width = 10 * LV_STYLE_MULT,
|
||||
.sb_opa=50,
|
||||
@ -93,7 +93,7 @@ static lv_pages_t lv_pages_paper =
|
||||
|
||||
static lv_pages_t lv_pages_transp =
|
||||
{
|
||||
.bg_rects.objs.empty = 1,
|
||||
.bg_rects.empty = 1,
|
||||
.bg_rects.hpad = 1,
|
||||
.bg_rects.vpad = 1,
|
||||
|
||||
@ -103,7 +103,7 @@ static lv_pages_t lv_pages_transp =
|
||||
.sb_rects.bopa = 0,
|
||||
.sb_rects.bwidth = 1 * LV_STYLE_MULT,
|
||||
.sb_rects.round = 5 * LV_STYLE_MULT,
|
||||
.sb_rects.objs.empty = 0,
|
||||
.sb_rects.empty = 0,
|
||||
|
||||
.sb_width = 8 * LV_STYLE_MULT,
|
||||
.sb_opa = 50,
|
||||
|
@ -57,7 +57,6 @@ typedef enum
|
||||
LV_PAGES_TRANSP,
|
||||
}lv_pages_builtin_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
@ -33,16 +33,16 @@ static bool lv_rect_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
|
||||
static lv_rects_t lv_rects_def =
|
||||
{ .objs.color = COLOR_MAKE(0x50, 0x70, 0x90), .gcolor = COLOR_MAKE(0x20, 0x40, 0x60),
|
||||
.bcolor = COLOR_WHITE, .bwidth = 2 * LV_STYLE_MULT, .bopa = 50,
|
||||
.round = 4 * LV_STYLE_MULT, .objs.empty = 0,
|
||||
.round = 4 * LV_STYLE_MULT, .empty = 0,
|
||||
.hpad = 0, .vpad = 0 };
|
||||
|
||||
static lv_rects_t lv_rects_transp =
|
||||
{ .bwidth = 0, .objs.empty = 0,
|
||||
{ .bwidth = 0, .empty = 1,
|
||||
.hpad = 0, .vpad = 0 };
|
||||
|
||||
static lv_rects_t lv_rects_border =
|
||||
{ .bcolor = COLOR_BLACK, .bwidth = 2 * LV_STYLE_MULT, .bopa = 100,
|
||||
.round = 4 * LV_STYLE_MULT, .objs.empty = 1,
|
||||
.round = 4 * LV_STYLE_MULT, .empty = 1,
|
||||
.hpad = 0, .vpad = 0};
|
||||
|
||||
/**********************
|
||||
@ -265,7 +265,7 @@ static bool lv_rect_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
|
||||
{
|
||||
/* Because of the radius it is not sure the area is covered*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
if(LV_SA(obj_dp, lv_rects_t)->objs.empty != 0) return false;
|
||||
if(LV_SA(obj_dp, lv_rects_t)->empty != 0) return false;
|
||||
|
||||
uint16_t r = LV_SA(obj_dp, lv_rects_t)->round;
|
||||
area_t area_tmp;
|
||||
|
@ -31,8 +31,9 @@ typedef struct
|
||||
uint16_t bwidth;
|
||||
cord_t hpad;
|
||||
cord_t vpad;
|
||||
uint8_t bopa;
|
||||
uint16_t round;
|
||||
uint8_t bopa;
|
||||
uint8_t empty :1;
|
||||
}lv_rects_t;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user