BigW Consortium Gitlab

Commit 27fa1699 by Gabor

lv_img transp_en moved to img header + minor modsin objx

parent 2666ed5f
......@@ -43,7 +43,7 @@ static uint16_t lv_draw_rect_radius_corr(uint16_t r, cord_t w, cord_t h);
#if LV_VDB_SIZE != 0
static void (*fill_fp)(const area_t * cords_p, const area_t * mask_p, color_t color, opa_t opa) = lv_vfill;
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_vletter;
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_vmap;
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_vmap;
#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;
......@@ -58,7 +58,7 @@ static lv_rects_t lv_img_no_pic_rects = {
};
static lv_labels_t lv_img_no_pic_labels = {
.font = LV_FONT_DEFAULT, .color = COLOR_WHITE,
.font = LV_FONT_DEFAULT, .objs.color = COLOR_WHITE,
.letter_space = 1 * LV_STYLE_MULT, .line_space = 1 * LV_STYLE_MULT,
.mid = 1,
};
......@@ -134,7 +134,7 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p,
while(txt[line_start] != '\0') {
/*Write all letter of a line*/
for(i = line_start; i < line_end; i++) {
letter_fp(&pos, mask_p, font_p, txt[i], labels_p->color, opa);
letter_fp(&pos, mask_p, font_p, txt[i], labels_p->objs.color, opa);
pos.x += font_get_width(font_p, txt[i]) + labels_p->letter_space;
}
/*Go to next line*/
......@@ -163,80 +163,80 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p,
* @param opa opacity of the image (0..255)
*/
void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
const lv_imgs_t * imgs_p, opa_t opa, const char * fn, const color_t * map_p)
const lv_imgs_t * imgs_p, opa_t opa, const char * fn)
{
if(map_p != NULL) {
map_fp(cords_p, mask_p, map_p, opa, imgs_p->transp_en);
} else if(fn != NULL) {
fs_file_t file;
fs_res_t res = fs_open(&file, fn, FS_MODE_RD);
if(res == FS_RES_OK) {
cord_t row;
color_t buf[LV_HOR_RES];
uint32_t br;
area_t act_area;
uint8_t ds_shift = 0;
uint8_t ds_num = 0;
#if LV_DOWNSCALE <= 1 || LV_UPSCALE_MAP == 0
ds_shift = 0;
ds_num = 1;
#elif LV_DOWNSCALE == 2
ds_shift = 1;
ds_num = 2;
#elif LV_DOWNSCALE == 4
ds_shift = 2;
ds_num = 4;
#else
#error "LV: not supported LV_DOWNSCALE value"
#endif
area_t mask_sub;
bool union_ok;
union_ok = area_union(&mask_sub, mask_p, cords_p);
if(fn == NULL) {
lv_draw_rect(cords_p, mask_p, &lv_img_no_pic_rects, opa);
lv_draw_label(cords_p, mask_p,&lv_img_no_pic_labels, opa, "No data");
} else {
fs_file_t file;
fs_res_t res = fs_open(&file, fn, FS_MODE_RD);
if(res == FS_RES_OK) {
cord_t row;
color_t buf[LV_HOR_RES];
uint32_t br;
area_t act_area;
uint8_t ds_shift = 0;
uint8_t ds_num = 0;
#if LV_DOWNSCALE <= 1 || LV_UPSCALE_MAP == 0
ds_shift = 0;
ds_num = 1;
#elif LV_DOWNSCALE == 2
ds_shift = 1;
ds_num = 2;
#elif LV_DOWNSCALE == 4
ds_shift = 2;
ds_num = 4;
#else
#error "LV: not supported LV_DOWNSCALE value"
#endif
area_t mask_sub;
bool union_ok;
union_ok = area_union(&mask_sub, mask_p, cords_p);
if(union_ok == false) {
fs_close(&file);
return;
}
lv_img_raw_header_t header;
res = fs_read(&file, &header, sizeof(lv_img_raw_header_t), &br);
uint32_t start_offset = sizeof(lv_img_raw_header_t);
uint32_t start_offset = 0;
start_offset += (area_get_width(cords_p) >> ds_shift) *
((mask_sub.y1 - cords_p->y1) >> ds_shift) * sizeof(color_t); /*First row*/
((mask_sub.y1 - cords_p->y1) >> ds_shift) * sizeof(color_t); /*First row*/
start_offset += ((mask_sub.x1 - cords_p->x1) >> ds_shift) * sizeof(color_t); /*First col*/
fs_seek(&file, start_offset);
fs_seek(&file, start_offset);
uint32_t useful_data = (area_get_width(&mask_sub) >> ds_shift)* sizeof(color_t);
uint32_t useful_data = (area_get_width(&mask_sub) >> ds_shift)* sizeof(color_t);
uint32_t next_row = (area_get_width(cords_p) >> ds_shift) * sizeof(color_t) - useful_data;
area_cpy(&act_area, &mask_sub);
act_area.y2 = act_area.y1 + ds_num - 1;
uint32_t act_pos;
for(row = mask_sub.y1; row <= mask_sub.y2; row += ds_num) {
res = fs_read(&file, buf, useful_data, &br);
map_fp(&act_area, &mask_sub, buf, opa, imgs_p->transp_en);
fs_tell(&file, &act_pos);
fs_seek(&file, act_pos + next_row);
act_area.y1 += ds_num;
act_area.y2 += ds_num;
}
}
fs_close(&file);
area_cpy(&act_area, &mask_sub);
act_area.y2 = act_area.y1 + ds_num - 1;
uint32_t act_pos;
for(row = mask_sub.y1; row <= mask_sub.y2; row += ds_num) {
res = fs_read(&file, buf, useful_data, &br);
map_fp(&act_area, &mask_sub, buf, opa, header.transp,
imgs_p->objs.color, imgs_p->recolor_opa);
fs_tell(&file, &act_pos);
fs_seek(&file, act_pos + next_row);
act_area.y1 += ds_num;
act_area.y2 += ds_num;
}
if(res != FS_RES_OK) {
lv_draw_rect(cords_p, mask_p, &lv_img_no_pic_rects, opa);
lv_draw_label(cords_p, mask_p,&lv_img_no_pic_labels, opa, fn);
}
}
fs_close(&file);
} else {
lv_draw_rect(cords_p, mask_p, &lv_img_no_pic_rects, opa);
lv_draw_label(cords_p, mask_p,&lv_img_no_pic_labels, opa, "No data");
}
if(res != FS_RES_OK) {
lv_draw_rect(cords_p, mask_p, &lv_img_no_pic_rects, opa);
lv_draw_label(cords_p, mask_p,&lv_img_no_pic_labels, opa, fn);
}
}
}
/**
* Draw a line
* @param p1 first point of the line
......@@ -248,158 +248,6 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
const lv_lines_t * lines_p, opa_t opa)
{
/*Draw circle*//*
point_t c1;
point_t c2;
cord_t ctmp1;
cord_t ctmp2;
area_t tmp_a;
circ_init(&c1, &ctmp1, lines_p->line_width);
cord_t dx = abs(p2->x - p1->x);
cord_t dy = abs(p2->y - p1->y);
uint16_t width;
uint16_t wcor;
opa = OPA_20;
static const uint8_t width_corr_array[] = {
64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66,
67, 67, 67, 68, 68, 68, 69, 69, 69, 70, 70, 71, 71, 72, 72, 72, 73, 73, 74,
74, 75, 75, 76, 77, 77, 78, 78, 79, 79, 80, 81, 81, 82, 82, 83, 84, 84, 85,
86, 86, 87, 88, 88, 89, 90, 91,
};
wcor = (dy * LINE_WIDTH_CORR_BASE) / dx;
width = ((lines_p->line_width) * LV_DOWNSCALE * width_corr_array[wcor]) >> LINE_WIDTH_CORR_SHIFT;
point_t e;
int32_t x_tmp = ((width*dy*dx)/(dx*dx+dy*dy));
e.x = p2->x + x_tmp;
e.y = p2->y - (x_tmp * dx)/dy;
area_t e_area;
e_area.x1 = e.x-3;
e_area.x2 = e.x+3;
e_area.y1 = e.y-3;
e_area.y2 = e.y+3;
lv_vfill(&e_area, mask_p, COLOR_GREEN, OPA_40);
color_t rnd_clr = {{130, 43, 99}};
uint16_t cnt = 0;
while(circ_cont(&c1)) {
area_set(&tmp_a, CIRC_OCT1_X(c1)+p2->x, CIRC_OCT1_Y(c1)+p2->y, CIRC_OCT1_X(c1)+p2->x, CIRC_OCT1_Y(c1)+p2->y);
lv_vfill(&tmp_a, mask_p, COLOR_BLUE, OPA_COVER);
area_set(&tmp_a, CIRC_OCT2_X(c1)+p2->x, CIRC_OCT2_Y(c1)+p2->y, CIRC_OCT2_X(c1)+p2->x, CIRC_OCT2_Y(c1)+p2->y);
lv_vfill(&tmp_a, mask_p, lines_p->color, opa);
area_set(&tmp_a, CIRC_OCT3_X(c1)+p2->x, CIRC_OCT3_Y(c1)+p2->y, CIRC_OCT3_X(c1)+p2->x, CIRC_OCT3_Y(c1)+p2->y);
lv_vfill(&tmp_a, mask_p, lines_p->color, opa);
area_set(&tmp_a, CIRC_OCT4_X(c1)+p2->x, CIRC_OCT4_Y(c1)+p2->y, CIRC_OCT4_X(c1)+p2->x, CIRC_OCT4_Y(c1)+p2->y);
lv_vfill(&tmp_a, mask_p, lines_p->color, opa);
area_set(&tmp_a, CIRC_OCT5_X(c1)+p2->x, CIRC_OCT5_Y(c1)+p2->y, CIRC_OCT5_X(c1)+p2->x, CIRC_OCT5_Y(c1)+p2->y);
lv_vfill(&tmp_a, mask_p, lines_p->color, opa);
area_set(&tmp_a, CIRC_OCT6_X(c1)+p2->x, CIRC_OCT6_Y(c1)+p2->y, CIRC_OCT6_X(c1)+p2->x, CIRC_OCT6_Y(c1)+p2->y);
lv_vfill(&tmp_a, mask_p, lines_p->color, opa);
area_set(&tmp_a, CIRC_OCT7_X(c1)+p2->x, CIRC_OCT7_Y(c1)+p2->y, CIRC_OCT7_X(c1)+p2->x, CIRC_OCT7_Y(c1)+p2->y);
lv_vfill(&tmp_a, mask_p, COLOR_PURPLE, OPA_COVER);
area_set(&tmp_a, CIRC_OCT8_X(c1)+p2->x, CIRC_OCT8_Y(c1)+p2->y, CIRC_OCT8_X(c1)+p2->x, CIRC_OCT8_Y(c1)+p2->y);
lv_vfill(&tmp_a, mask_p, lines_p->color, opa);
cord_t err = (dx > dy ? dx : -dy) / 2;
cord_t e2;
point_t act_point;
act_point.x = p1->x;
act_point.y = p1->y;
rnd_clr.full += 0x238993;
while(1){
//if(c1.y > 4) break;
area_t act_area;
*/
/*if(act_point.x < p2->x + CIRC_OCT8_X(c1))
{
act_area.x1 = act_point.x;
act_area.x2 = act_point.x;
act_area.y1 = act_point.y - ((CIRC_OCT8_X(c1)*dy) - (CIRC_OCT8_Y(c1)*dx)) / (dx);
act_area.y2 = act_point.y - ((CIRC_OCT8_X(c1)*dy) - (CIRC_OCT8_Y(c1)*dx)) / (dx);// (dy * c1.x)/dx + CIRC_OCT8_Y(c1);
lv_vfill(&act_area, mask_p, COLOR_RED, OPA_50);
}*/
/*
if(act_point.x < p2->x + CIRC_OCT1_X(c1)) {
act_area.x1 = act_point.x;
act_area.x2 = act_point.x;
act_area.y1 = act_point.y - (dy * c1.x)/dx + CIRC_OCT1_Y(c1);
act_area.y2 = act_point.y - (dy * c1.x)/dx + CIRC_OCT1_Y(c1);
lv_vfill(&act_area, mask_p, COLOR_RED, OPA_50);
}
if(act_point.x < p2->x + CIRC_OCT2_X(c1)) {
act_area.x1 = act_point.x;
act_area.x2 = act_point.x;
act_area.y1 = act_point.y - (dy * CIRC_OCT2_X(c1))/dx + CIRC_OCT2_Y(c1);
act_area.y2 = act_point.y - (dy * CIRC_OCT2_X(c1))/dx + CIRC_OCT2_Y(c1);
lv_vfill(&act_area, mask_p, COLOR_RED, OPA_50);
}
if(act_point.x < p2->x + CIRC_OCT3_X(c1)) {
act_area.x1 = act_point.x;
act_area.x2 = act_point.x;
act_area.y1 = act_point.y - (dy * CIRC_OCT3_X(c1))/dx + CIRC_OCT3_Y(c1);
act_area.y2 = act_point.y - (dy * CIRC_OCT3_X(c1))/dx + CIRC_OCT3_Y(c1);
lv_vfill(&act_area, mask_p, COLOR_RED, OPA_50);
}
*//*
if(e.x > p2->x && e.x < p2->x + lines_p->line_width / 2 &&
act_point.x < p2->x + CIRC_OCT7_X(c1))
{
act_area.x1 = act_point.x;
act_area.x2 = act_point.x;
act_area.y1 = act_point.y - (dy * CIRC_OCT7_X(c1))/dx + CIRC_OCT7_Y(c1);
act_area.y2 = act_area.y1;
lv_vfill(&act_area, mask_p, COLOR_RED, OPA_50);
}*/
/*
if(act_point.x < p2->x + CIRC_OCT7_X(c1)) {
act_area.x1 = act_point.x;
act_area.x2 = act_point.x;
act_area.y1 = act_point.y - (dy * CIRC_OCT7_X(c1))/dx + CIRC_OCT7_Y(c1);
act_area.y2 = act_point.y - (dy * CIRC_OCT7_X(c1))/dx + CIRC_OCT7_Y(c1);
lv_vfill(&act_area, mask_p, COLOR_RED, OPA_50);
}
*/
//printf("hor x1:%d, y1:%d, x2:%d, y2:%d\n", act_area.x1, act_area.y1, act_area.x2, act_area.y2);
/*if (act_point.x == p2->x + c1.x)
{
printf("line end x%d, y%d\n", act_area.x1, act_area.y1);
cnt++;
if(cnt == 11) {
cnt++;
cnt--;
}
break;
}
e2 = err;
if (e2 >-dx) {
err -= dy;
act_point.x ++;
}
if (e2 < dy) {
err += dx;
act_point.y ++;
}
}
circ_next(&c1, &ctmp1);
}
return;*/
if(lines_p->width == 0) return;
if(p1->x == p2->x && p1->y == p2->y) return;
......
......@@ -33,7 +33,7 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p,
void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
const lv_lines_t * lines_p, opa_t opa);
void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
const lv_imgs_t * imgs_p, opa_t opa, const char * fn, const color_t * map_p);
const lv_imgs_t * imgs_p, opa_t opa, const char * fn);
/**********************
* MACROS
**********************/
......
......@@ -110,7 +110,8 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p,
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
*/
void lv_rmap(const area_t * cords_p, const area_t * mask_p,
const color_t * map_p, opa_t opa, bool transp)
const color_t * map_p, opa_t opa, bool transp,
color_t recolor, color_t recolor_opa)
{
area_t masked_a;
bool union_ok;
......
......@@ -30,7 +30,8 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p,
const font_t * font_p, uint8_t letter,
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);
const color_t * map_p, opa_t opa, bool transp,
color_t recolor, color_t recolor_opa);
/**********************
* MACROS
**********************/
......
......@@ -146,7 +146,8 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
*/
void lv_vmap(const area_t * cords_p, const area_t * mask_p,
const color_t * map_p, opa_t opa, bool transp)
const color_t * map_p, opa_t opa, bool transp,
color_t recolor, opa_t recolor_opa)
{
area_t masked_a;
bool union_ok;
......@@ -196,6 +197,7 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
cord_t row;
cord_t col;
color_t transp_color = LV_IMG_COLOR_TRANSP;
color_t color_tmp;
cord_t map_i;
map_p -= map_width; /*Compensate the first row % LV_DOWNSCALE*/
for(row = masked_a.y1; row <= masked_a.y2; row++) {
......@@ -203,9 +205,12 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
map_i = masked_a.x1 >> ds_shift;
map_i--; /*Compensate the first col % LV_DOWNSCALE*/
for(col = masked_a.x1; col <= masked_a.x2; col++) {
if(col % LV_DOWNSCALE == 0) map_i++;
if(col % LV_DOWNSCALE == 0) {
map_i++;
color_tmp = color_mix(recolor, map_p[map_i], recolor_opa);
}
if(transp == false || map_p[map_i].full != transp_color.full) {
vdb_buf_tmp[col] = color_mix(map_p[map_i], vdb_buf_tmp[col], opa);
vdb_buf_tmp[col] = color_mix(color_tmp, vdb_buf_tmp[col], opa);
}
}
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
......@@ -232,32 +237,70 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
}
}
/*To recolor draw simply a rectangle above the image*/
#if LV_VDB_SIZE != 0
lv_vfill(cords_p, mask_p, recolor, recolor_opa);
#endif
} else { /*transp == true: Check all pixels */
cord_t row;
cord_t col;
color_t transp_color = LV_IMG_COLOR_TRANSP;
if(opa == OPA_COVER) { /*no opa */
for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
if(map_p[col].full != transp_color.full) {
vdb_buf_tmp[col] = map_p[col];
}
}
map_p += map_width; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
}
} else {
for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
if(map_p[col].full != transp_color.full) {
vdb_buf_tmp[col] = color_mix( map_p[col], vdb_buf_tmp[col], opa);
}
}
map_p += map_width; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
}
if(recolor_opa == OPA_TRANSP)/*No recolor*/
{
if(opa == OPA_COVER) { /*no opa */
for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
if(map_p[col].full != transp_color.full) {
vdb_buf_tmp[col] = map_p[col];
}
}
map_p += map_width; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
}
} else {
for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
if(map_p[col].full != transp_color.full) {
vdb_buf_tmp[col] = color_mix( map_p[col], vdb_buf_tmp[col], opa);
}
}
map_p += map_width; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
}
}
} else { /*Recolor needed*/
color_t color_tmp;
if(opa == OPA_COVER) { /*no opa */
for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
if(map_p[col].full != transp_color.full) {
color_tmp = color_mix(recolor, map_p[col], recolor_opa);
vdb_buf_tmp[col] = color_tmp;
}
}
map_p += map_width; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
}
} else {
for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
if(map_p[col].full != transp_color.full) {
color_tmp = color_mix(recolor, map_p[col], recolor_opa);
vdb_buf_tmp[col] = color_mix(color_tmp, vdb_buf_tmp[col], opa);
}
}
map_p += map_width; /*Next row on the map*/
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
}
}
}
}
#endif /*No upscale and no downscale*/
......@@ -347,4 +390,9 @@ static bool lv_vletter_get_px(const font_t * font_p, uint8_t letter, cord_t x, c
if((map_byte & (1 << col_sub)) == 0) return false;
else return true;
}
#endif
......@@ -36,7 +36,8 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
color_t color, opa_t opa);
void lv_vmap(const area_t * cords_p, const area_t * mask_p,
const color_t * map_p, opa_t opa, bool transp);
const color_t * map_p, opa_t opa, bool transp,
color_t recolor, color_t recolor_opa);
/**********************
......
......@@ -34,11 +34,10 @@ 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, .auto_color = 1};
lv_objs_t lv_objs_color = {.color = COLOR_RED, .empty = 0, .auto_color = 0};
lv_objs_t lv_objs_scr = {.color = LV_OBJ_DEF_SCR_COLOR, .empty = 0, .auto_color = 0};
lv_objs_t lv_objs_empty = {.color = COLOR_GRAY, .empty = 1, .auto_color = 0};
lv_objs_t lv_objs_autocolor = {.color = COLOR_GRAY, .empty = 0, .auto_color = 1};
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};
/**********************
* MACROS
......@@ -336,9 +335,6 @@ lv_objs_t * lv_objs_get(lv_objs_builtin_t style, lv_objs_t * copy_p)
case LV_OBJS_EMPTY:
style_p = &lv_objs_empty;
break;
case LV_OBJS_AUTOCOLOR:
style_p = &lv_objs_autocolor;
break;
default:
style_p = NULL;
}
......@@ -1243,29 +1239,6 @@ static bool lv_obj_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
opa_t opa = lv_obj_get_opa(obj_dp);
color_t color = objs_p->color;
/*Calculate the color*/
if(objs_p->auto_color != 0) {
lv_obj_t* par_dp = lv_obj_get_parent(obj_dp);
if(par_dp == NULL) { /*If it is a screen use the default color*/
color = LV_OBJ_DEF_SCR_COLOR;
} else { /*Add a random color on every level*/
color = COLOR_WHITE;
while(par_dp != NULL) {
#if COLOR_DEPTH == 1
color.full ++;
#elif COLOR_DEPTH == 8
color.full += 0x52;
#elif COLOR_DEPTH == 16
color.full += 0xA953;
#elif COLOR_DEPTH == 24
color.full +=0x2963A9;
#endif
par_dp = lv_obj_get_parent(par_dp);
}
}
}
/*Simply draw a rectangle*/
#if LV_VDB_SIZE == 0
lv_rfill(&obj_dp->cords, mask_p, color, opa);
......
......@@ -80,8 +80,8 @@ typedef struct __LV_OBJ_T
area_t cords;
/*Basic appearance*/
opa_t opa;
opa_t opa;
/*Attributes and states*/
uint8_t click_en :1; /*1: can be pressed by a display input device*/
uint8_t drag_en :1; /*1: enable the dragging*/
......@@ -134,7 +134,6 @@ typedef struct
{
color_t color;
uint8_t empty :1;
uint8_t auto_color :1;
}lv_objs_t;
typedef enum
......@@ -143,7 +142,6 @@ typedef enum
LV_OBJS_COLOR,
LV_OBJS_SCR,
LV_OBJS_EMPTY,
LV_OBJS_AUTOCOLOR,
}lv_objs_builtin_t;
/**********************
......
......@@ -351,7 +351,7 @@ lv_btns_t * lv_btns_get(lv_btns_builtin_t style, lv_btns_t * copy_p)
style_p = &lv_btns_border;
break;
default:
style_p = NULL;
style_p = &lv_btns_def;
}
if(copy_p != NULL) {
......
......@@ -33,8 +33,9 @@ static bool lv_img_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
/*-----------------
* Style definition
*-----------------*/
static lv_imgs_t lv_imgs_def = {.transp_en = 0};
static lv_imgs_t lv_imgs_transp = {.transp_en = 1};
static lv_imgs_t lv_imgs_def = {.recolor_opa=OPA_TRANSP};
static lv_imgs_t lv_imgs_light = {.objs.color = COLOR_WHITE, .recolor_opa=OPA_50};
static lv_imgs_t lv_imgs_dark = {.objs.color = COLOR_BLACK, .recolor_opa=OPA_50};
/**********************
* MACROS
......@@ -129,11 +130,14 @@ lv_imgs_t * lv_imgs_get(lv_imgs_builtin_t style, lv_imgs_t * copy_p)
case LV_IMGS_DEF:
style_p = &lv_imgs_def;
break;
case LV_IMGS_TRANSP:
style_p = &lv_imgs_transp;
case LV_IMGS_LIGHT:
style_p = &lv_imgs_light;
break;
case LV_IMGS_DARK:
style_p = &lv_imgs_dark;
break;
default:
style_p = NULL;
style_p = &lv_imgs_def;
}
if(copy_p != NULL) {
......@@ -252,9 +256,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);
if(mode == LV_DESIGN_COVER_CHK) {
lv_imgs_t * imgs_p = lv_obj_get_style(obj_dp);
if(imgs_p->transp_en == 0) {
if(imgs_p->objs.empty == 0) {
bool cover;
cover = area_is_in(mask_p, &obj_dp->cords);
return cover;
......@@ -276,10 +281,9 @@ static bool lv_img_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
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, NULL);
lv_draw_img(&cords_tmp, mask_p, lv_obj_get_style(obj_dp),opa, img_ext_p->fn_dp);
}
}
return true;
}
......
......@@ -26,7 +26,7 @@
typedef struct
{
lv_objs_t objs;
uint8_t transp_en :1;
opa_t recolor_opa;
}lv_imgs_t;
typedef struct
......@@ -34,21 +34,22 @@ typedef struct
char* fn_dp;
cord_t w;
cord_t h;
uint8_t auto_size :1;
uint8_t auto_size :1;
}lv_img_ext_t;
typedef enum
{
LV_IMGS_DEF,
LV_IMGS_TRANSP
LV_IMGS_LIGHT,
LV_IMGS_DARK,
}lv_imgs_builtin_t;
typedef struct
{
uint16_t w;
uint16_t h;
uint16_t res1;
uint16_t res2;
uint16_t cd; /*Color depth*/
uint16_t transp :1; /*Do not draw LV_IMG_TRANSP_COLOR pixels*/
}lv_img_raw_header_t;
......
......@@ -32,25 +32,25 @@ static bool lv_label_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_m
* STATIC VARIABLES
**********************/
static lv_labels_t lv_labels_def = {
.font = LV_FONT_DEFAULT, .color = COLOR_MAKE(0x10, 0x18, 0x20),
.font = LV_FONT_DEFAULT, .objs.color = COLOR_MAKE(0x10, 0x18, 0x20),
.letter_space = 2 * LV_STYLE_MULT, .line_space = 2 * LV_STYLE_MULT,
.mid = 1
};
static lv_labels_t lv_labels_btn = {
.font = LV_FONT_DEFAULT, .color = COLOR_MAKE(0xd0, 0xe0, 0xf0),
.font = LV_FONT_DEFAULT, .objs.color = COLOR_MAKE(0xd0, 0xe0, 0xf0),
.letter_space = 2 * LV_STYLE_MULT, .line_space = 2 * LV_STYLE_MULT,
.mid = 1,
};
static lv_labels_t lv_labels_title = {
.font = LV_FONT_DEFAULT, .color = COLOR_MAKE(0x10, 0x20, 0x30),
.font = LV_FONT_DEFAULT, .objs.color = COLOR_MAKE(0x10, 0x20, 0x30),
.letter_space = 4 * LV_STYLE_MULT, .line_space = 4 * LV_STYLE_MULT,
.mid = 0,
};
static lv_labels_t lv_labels_txt = {
.font = LV_FONT_DEFAULT, .color = COLOR_MAKE(0x16, 0x23, 0x34),
.font = LV_FONT_DEFAULT, .objs.color = COLOR_MAKE(0x16, 0x23, 0x34),
.letter_space = 1 * LV_STYLE_MULT, .line_space = 2 * LV_STYLE_MULT,
.mid = 0,
};
......@@ -274,7 +274,7 @@ lv_labels_t * lv_labels_get(lv_labels_builtin_t style, lv_labels_t * copy_p)
style_p = &lv_labels_title;
break;
default:
style_p = NULL;
style_p = &lv_labels_def;
}
if(copy_p != NULL) {
......
......@@ -25,8 +25,8 @@
typedef struct
{
lv_objs_t objs;
font_types_t font;
color_t color;
uint16_t letter_space;
uint16_t line_space;
uint8_t mid :1;
......
......@@ -38,14 +38,11 @@ static bool lv_line_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
/**********************
* STATIC VARIABLES
**********************/
static lv_lines_t lv_lines_def = { .width = 2 * LV_STYLE_MULT, .objs.color = COLOR_RED,
.bg_color = COLOR_BLACK, .bg_opa = 0};
static lv_lines_t lv_lines_def = { .width = 2 * LV_STYLE_MULT, .objs.color = COLOR_RED};
static lv_lines_t lv_lines_decor = { .width = 1 * LV_STYLE_MULT, .objs.color = COLOR_GRAY,
.bg_color = COLOR_BLACK, .bg_opa = 0};
static lv_lines_t lv_lines_decor = { .width = 1 * LV_STYLE_MULT, .objs.color = COLOR_GRAY};
static lv_lines_t lv_lines_chart = { .width = 3 * LV_STYLE_MULT, .objs.color = COLOR_BLUE,
.bg_color = COLOR_BLACK, .bg_opa = 0};
static lv_lines_t lv_lines_chart = { .width = 3 * LV_STYLE_MULT, .objs.color = COLOR_BLUE};
/**********************
* MACROS
......@@ -265,7 +262,7 @@ lv_lines_t * lv_lines_get(lv_lines_builtin_t style, lv_lines_t * copy_p)
style_p = &lv_lines_chart;
break;
default:
style_p = NULL;
style_p = &lv_lines_def;
}
if(copy_p != NULL) {
......@@ -298,13 +295,7 @@ static bool lv_line_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
if(ext_p->point_num == 0 || ext_p->point_p == NULL) return false;
lv_lines_t * lines_p = lv_obj_get_style(obj_dp);
if(lines_p->bg_opa != 0) {
#if LV_VDB_SIZE != 0
lv_vfill(&obj_dp->cords, mask_p, lines_p->bg_color, lines_p->bg_opa * 255 / 100);
#else
lv_rfill(&obj_dp->cords, mask_p, lines_p->bg_color, lines_p->bg_opa * 255 / 100);
#endif
}
opa_t opa = lv_obj_get_opa(obj_dp);
area_t area;
lv_obj_get_cords(obj_dp, &area);
......
......@@ -33,9 +33,7 @@ typedef struct
typedef struct
{
lv_objs_t objs;
color_t bg_color;
uint16_t width;
opa_t bg_opa;
}lv_lines_t;
typedef enum
......
......@@ -156,6 +156,7 @@ lv_obj_t* lv_page_create(lv_obj_t * par_dp, lv_obj_t * ori_dp)
page_p->sbh_dp = lv_rect_create(par_dp, NULL);
lv_obj_set_height(page_p->sbh_dp, pages_p->sb_width);
lv_obj_set_style(page_p->sbh_dp, &pages_p->sb_rects);
lv_obj_set_click(page_p->sbh_dp, false);
if(pages_p->sb_mode == LV_PAGE_SB_MODE_ON) {
lv_obj_set_opa(page_p->sbh_dp, (pages_p->sb_opa * OPA_COVER) / 100);
} else {
......@@ -166,6 +167,7 @@ lv_obj_t* lv_page_create(lv_obj_t * par_dp, lv_obj_t * ori_dp)
page_p->sbv_dp =lv_rect_create(par_dp, NULL);
lv_obj_set_width(page_p->sbv_dp, pages_p->sb_width);
lv_obj_set_style(page_p->sbv_dp, &pages_p->sb_rects);
lv_obj_set_click(page_p->sbv_dp, false);
if(lv_pages_def.sb_mode == LV_PAGE_SB_MODE_ON) {
lv_obj_set_opa(page_p->sbv_dp, (pages_p->sb_opa * OPA_COVER) / 100);
} else {
......@@ -299,7 +301,6 @@ bool lv_page_signal(lv_obj_t* obj_dp, lv_signal_t sign, void* param)
}
return obj_valid;
}
/**
......@@ -334,7 +335,7 @@ lv_pages_t * lv_pages_get(lv_pages_builtin_t style, lv_pages_t * to_copy)
style_p = &lv_pages_transp;
break;
default:
style_p = NULL;
style_p = &lv_pages_def;
}
if(to_copy != NULL) {
......
......@@ -229,7 +229,7 @@ lv_rects_t * lv_rects_get(lv_rects_builtin_t style, lv_rects_t * copy_p)
style_p = &lv_rects_transp;
break;
default:
style_p = NULL;
style_p = &lv_rects_def;
}
if(copy_p != NULL) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment