add opa_scale attribute
This commit is contained in:
@@ -161,7 +161,9 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
new_obj->drag_parent = 0;
|
||||
new_obj->hidden = 0;
|
||||
new_obj->top = 0;
|
||||
new_obj->opa_scale_en = 0;
|
||||
new_obj->protect = LV_PROTECT_NONE;
|
||||
new_obj->opa_scale = LV_OPA_COVER;
|
||||
|
||||
new_obj->ext_attr = NULL;
|
||||
}
|
||||
@@ -208,6 +210,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
new_obj->hidden = 0;
|
||||
new_obj->top = 0;
|
||||
new_obj->protect = LV_PROTECT_NONE;
|
||||
new_obj->opa_scale = LV_OPA_COVER;
|
||||
new_obj->opa_scale_en = 0;
|
||||
|
||||
new_obj->ext_attr = NULL;
|
||||
}
|
||||
@@ -230,7 +234,9 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
new_obj->drag_parent = copy->drag_parent;
|
||||
new_obj->hidden = copy->hidden;
|
||||
new_obj->top = copy->top;
|
||||
new_obj->opa_scale_en = copy->opa_scale_en;
|
||||
new_obj->protect = copy->protect;
|
||||
new_obj->opa_scale = copy->opa_scale;
|
||||
|
||||
new_obj->style_p = copy->style_p;
|
||||
|
||||
@@ -818,6 +824,27 @@ void lv_obj_set_drag_parent(lv_obj_t * obj, bool en)
|
||||
obj->drag_parent = (en == true ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the opa scale enable parameter (required to set opa_scale with `lv_obj_set_opa_scale()`)
|
||||
* @param obj pointer to an object
|
||||
* @param en true: opa scaling is enabled for this object and all children; false: no opa scaling
|
||||
*/
|
||||
void lv_obj_set_opa_scale_enable(lv_obj_t * obj, bool en)
|
||||
{
|
||||
obj->opa_scale_en = en ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the opa scale of an object
|
||||
* @param obj pointer to an object
|
||||
* @param opa_scale a factor to scale down opacity [0..255]
|
||||
*/
|
||||
void lv_obj_set_opa_scale(lv_obj_t * obj, lv_opa_t opa_scale)
|
||||
{
|
||||
obj->opa_scale = opa_scale;
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a bit or bits in the protect filed
|
||||
* @param obj pointer to an object
|
||||
@@ -1301,6 +1328,33 @@ bool lv_obj_get_drag_parent(lv_obj_t * obj)
|
||||
return obj->drag_parent == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the opa scale enable parameter
|
||||
* @param obj pointer to an object
|
||||
* @return true: opa scaling is enabled for this object and all children false: no opa scaling
|
||||
*/
|
||||
lv_opa_t lv_obj_get_opa_scale_enable(lv_obj_t * obj)
|
||||
{
|
||||
return obj->opa_scale_en == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the opa scale parameter of an object
|
||||
* @param obj pointer to an object
|
||||
* @return opa scale [0..255]
|
||||
*/
|
||||
lv_opa_t lv_obj_get_opa_scale(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * parent = obj;
|
||||
|
||||
while(parent) {
|
||||
if(parent->opa_scale_en) return parent->opa_scale;
|
||||
parent = lv_obj_get_parent(parent);
|
||||
}
|
||||
|
||||
return LV_OPA_COVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the protect field of an object
|
||||
* @param obj pointer to an object
|
||||
@@ -1464,7 +1518,7 @@ static bool lv_obj_design(lv_obj_t * obj, const lv_area_t * mask_p, lv_design_m
|
||||
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
lv_draw_rect(&obj->coords, mask_p, style);
|
||||
lv_draw_rect(&obj->coords, mask_p, style, lv_obj_get_opa_scale(obj));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -123,17 +123,17 @@ typedef struct _lv_obj_t
|
||||
void * group_p; /*Pointer to the group of the object*/
|
||||
#endif
|
||||
/*Attributes and states*/
|
||||
uint8_t click :1; /*1: Can be pressed by an input device*/
|
||||
uint8_t drag :1; /*1: Enable the dragging*/
|
||||
uint8_t drag_throw:1; /*1: Enable throwing with drag*/
|
||||
uint8_t drag_parent :1; /*1: Parent will be dragged instead*/
|
||||
uint8_t hidden :1; /*1: Object is hidden*/
|
||||
uint8_t top :1; /*1: If the object or its children is clicked it goes to the foreground*/
|
||||
uint8_t reserved :1;
|
||||
|
||||
uint8_t click :1; /*1: Can be pressed by an input device*/
|
||||
uint8_t drag :1; /*1: Enable the dragging*/
|
||||
uint8_t drag_throw :1; /*1: Enable throwing with drag*/
|
||||
uint8_t drag_parent :1; /*1: Parent will be dragged instead*/
|
||||
uint8_t hidden :1; /*1: Object is hidden*/
|
||||
uint8_t top :1; /*1: If the object or its children is clicked it goes to the foreground*/
|
||||
uint8_t opa_scale_en :1; /*1: opa_scale is set*/
|
||||
lv_opa_t opa_scale; /*Scale down the opacity by this factor. Effects all children as well*/
|
||||
uint8_t protect; /*Automatically happening actions can be prevented. 'OR'ed values from lv_obj_prot_t*/
|
||||
|
||||
lv_coord_t ext_size; /*EXTtend the size of the object in every direction. E.g. for shadow drawing*/
|
||||
lv_coord_t ext_size; /*EXTtend the size of the object in every direction. E.g. for shadow drawing*/
|
||||
|
||||
#ifdef LV_OBJ_FREE_NUM_TYPE
|
||||
LV_OBJ_FREE_NUM_TYPE free_num; /*Application specific identifier (set it freely)*/
|
||||
@@ -392,6 +392,20 @@ void lv_obj_set_drag_throw(lv_obj_t * obj, bool en);
|
||||
*/
|
||||
void lv_obj_set_drag_parent(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Set the opa scale enable parameter (required to set opa_scale with `lv_obj_set_opa_scale()`)
|
||||
* @param obj pointer to an object
|
||||
* @param en true: opa scaling is enabled for this object and all children; false: no opa scaling
|
||||
*/
|
||||
void lv_obj_set_opa_scale_enable(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Set the opa scale of an object
|
||||
* @param obj pointer to an object
|
||||
* @param opa_scale a factor to scale down opacity [0..255]
|
||||
*/
|
||||
void lv_obj_set_opa_scale(lv_obj_t * obj, lv_opa_t opa_scale);
|
||||
|
||||
/**
|
||||
* Set a bit or bits in the protect filed
|
||||
* @param obj pointer to an object
|
||||
@@ -644,6 +658,13 @@ bool lv_obj_get_drag_throw(lv_obj_t * obj);
|
||||
*/
|
||||
bool lv_obj_get_drag_parent(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the opa scale parameter of an object
|
||||
* @param obj pointer to an object
|
||||
* @return opa scale [0..255]
|
||||
*/
|
||||
lv_opa_t lv_obj_get_opa_scale(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the protect field of an object
|
||||
* @param obj pointer to an object
|
||||
|
||||
@@ -47,9 +47,10 @@ static bool deg_test_inv(uint16_t deg, uint16_t start, uint16_t end);
|
||||
* @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right)
|
||||
* @param end_angle the end angle of the arc
|
||||
* @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used)
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, const lv_area_t * mask,
|
||||
uint16_t start_angle, uint16_t end_angle, const lv_style_t * style)
|
||||
uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
lv_coord_t thickness = style->body.thickness;
|
||||
if(thickness > radius) thickness = radius;
|
||||
@@ -62,7 +63,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, cons
|
||||
lv_coord_t x_end[4];
|
||||
|
||||
lv_color_t color = style->body.main_color;
|
||||
lv_opa_t opa = style->body.opa;
|
||||
lv_opa_t opa = (uint16_t)((uint16_t) style->body.opa * opa_scale) >> 8;
|
||||
|
||||
|
||||
bool (*deg_test)(uint16_t, uint16_t, uint16_t);
|
||||
|
||||
@@ -36,9 +36,10 @@ extern "C" {
|
||||
* @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right)
|
||||
* @param end_angle the end angle of the arc
|
||||
* @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used)
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, const lv_area_t * mask,
|
||||
uint16_t start_angle, uint16_t end_angle, const lv_style_t * style);
|
||||
uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -38,19 +38,23 @@
|
||||
* Draw an image
|
||||
* @param coords the coordinates of the image
|
||||
* @param mask the image will be drawn only in this area
|
||||
* @param map_p pointer to a lv_color_t array which contains the pixels of the image
|
||||
* @param opa opacity of the image (0..255)
|
||||
* @param src pointer to a lv_color_t array which contains the pixels of the image
|
||||
* @param style style of the image
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, const void * src)
|
||||
const void * src, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
|
||||
if(src == NULL) {
|
||||
lv_draw_rect(coords, mask, &lv_style_plain);
|
||||
lv_draw_label(coords, mask, &lv_style_plain, "No\ndata", LV_TXT_FLAG_NONE, NULL);
|
||||
lv_draw_rect(coords, mask, &lv_style_plain, LV_OPA_COVER);
|
||||
lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
lv_opa_t opa = (uint16_t)((uint16_t) style->image.opa * opa_scale) >> 8;
|
||||
|
||||
const uint8_t * u8_p = (uint8_t*) src;
|
||||
if(u8_p[0] >= 'A' && u8_p[0] <= 'Z') { /*It will be a path of a file*/
|
||||
#if USE_LV_FILESYSTEM
|
||||
@@ -110,7 +114,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
for(row = mask_com.y1; row <= mask_com.y2; row ++) {
|
||||
res = lv_fs_read(&file, buf, useful_data, &br);
|
||||
|
||||
map_fp(&line, &mask_com, (uint8_t *)buf, style->image.opa, img_data.header.chroma_keyed, img_data.header.alpha_byte,
|
||||
map_fp(&line, &mask_com, (uint8_t *)buf, opa, img_data.header.chroma_keyed, img_data.header.alpha_byte,
|
||||
style->image.color, style->image.intense);
|
||||
|
||||
lv_fs_tell(&file, &act_pos);
|
||||
@@ -122,8 +126,8 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
lv_fs_close(&file);
|
||||
|
||||
if(res != LV_FS_RES_OK) {
|
||||
lv_draw_rect(coords, mask, &lv_style_plain);
|
||||
lv_draw_label(coords, mask, &lv_style_plain, "No data", LV_TXT_FLAG_NONE, NULL);
|
||||
lv_draw_rect(coords, mask, &lv_style_plain, LV_OPA_COVER);
|
||||
lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No data", LV_TXT_FLAG_NONE, NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -137,7 +141,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
return; /*Out of mask*/
|
||||
}
|
||||
|
||||
map_fp(coords, mask, img_var->pixel_map, style->image.opa, img_var->header.chroma_keyed, img_var->header.alpha_byte, style->image.color, style->image.intense);
|
||||
map_fp(coords, mask, img_var->pixel_map, opa, img_var->header.chroma_keyed, img_var->header.alpha_byte, style->image.color, style->image.intense);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -28,15 +28,18 @@ extern "C" {
|
||||
**********************/
|
||||
|
||||
#if USE_LV_IMG
|
||||
|
||||
/**
|
||||
* Draw an image
|
||||
* @param coords the coordinates of the image
|
||||
* @param mask the image will be drawn only in this area
|
||||
* @param map_p pointer to a lv_color_t array which contains the pixels of the image
|
||||
* @param opa opacity of the image (0..255)
|
||||
* @param src pointer to a lv_color_t array which contains the pixels of the image
|
||||
* @param style style of the image
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, const void * src);
|
||||
const void * src, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -47,15 +47,15 @@ static uint8_t hex_char_to_num(char hex);
|
||||
* @param coords coordinates of the label
|
||||
* @param mask the label will be drawn only in this area
|
||||
* @param style pointer to a style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
* @param txt 0 terminated text to write
|
||||
* @param flag settings for the text from 'txt_flag_t' enum
|
||||
* @param offset text offset in x and y direction (NULL if unused)
|
||||
*
|
||||
*/
|
||||
void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_style_t * style,
|
||||
void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale,
|
||||
const char * txt, lv_txt_flag_t flag, lv_point_t * offset)
|
||||
{
|
||||
|
||||
const lv_font_t * font = style->text.font;
|
||||
lv_coord_t w;
|
||||
if((flag & LV_TXT_FLAG_EXPAND) == 0) {
|
||||
@@ -82,6 +82,8 @@ void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_sty
|
||||
pos.x += (w - line_length) / 2;
|
||||
}
|
||||
|
||||
lv_opa_t opa = (uint16_t)((uint16_t) style->text.opa * opa_scale) >> 8;
|
||||
|
||||
cmd_state_t cmd_state = CMD_STATE_WAIT;
|
||||
uint32_t i;
|
||||
uint16_t par_start = 0;
|
||||
@@ -153,7 +155,7 @@ void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_sty
|
||||
|
||||
if(cmd_state == CMD_STATE_IN) color = recolor;
|
||||
|
||||
letter_fp(&pos, mask, font, letter, color, style->text.opa);
|
||||
letter_fp(&pos, mask, font, letter, color, opa);
|
||||
letter_w = lv_font_get_width(font, letter);
|
||||
|
||||
pos.x += letter_w + style->text.letter_space;
|
||||
|
||||
@@ -32,12 +32,13 @@ extern "C" {
|
||||
* @param coords coordinates of the label
|
||||
* @param mask the label will be drawn only in this area
|
||||
* @param style pointer to a style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
* @param txt 0 terminated text to write
|
||||
* @param flag settings for the text from 'txt_flag_t' enum
|
||||
* @param offset text offset in x and y direction (NULL if unused)
|
||||
*
|
||||
*/
|
||||
void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_style_t * style,
|
||||
void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale,
|
||||
const char * txt, lv_txt_flag_t flag, lv_point_t * offset);
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -45,9 +45,9 @@ typedef struct {
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style);
|
||||
static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style);
|
||||
static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style);
|
||||
static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void line_init(line_draw_t * line, const lv_point_t * p1, const lv_point_t * p2);
|
||||
static bool line_next(line_draw_t * line);
|
||||
static bool line_next_y(line_draw_t * line);
|
||||
@@ -67,13 +67,14 @@ static bool line_next_x(line_draw_t * line);
|
||||
|
||||
/**
|
||||
* Draw a line
|
||||
* @param p1 first point of the line
|
||||
* @param p2 second point of the line
|
||||
* @param maskthe line will be drawn only on this area
|
||||
* @param lines_p pointer to a line style
|
||||
* @param point1 first point of the line
|
||||
* @param point2 second point of the line
|
||||
* @param mask the line will be drawn only on this area
|
||||
* @param style pointer to a line's style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask,
|
||||
const lv_style_t * style)
|
||||
const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
|
||||
if(style->line.width == 0) return;
|
||||
@@ -119,15 +120,15 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
|
||||
/*Special case draw a horizontal line*/
|
||||
if(main_line.p1.y == main_line.p2.y ) {
|
||||
line_draw_hor(&main_line, mask, style);
|
||||
line_draw_hor(&main_line, mask, style, opa_scale);
|
||||
}
|
||||
/*Special case draw a vertical line*/
|
||||
else if(main_line.p1.x == main_line.p2.x ) {
|
||||
line_draw_ver(&main_line, mask, style);
|
||||
line_draw_ver(&main_line, mask, style, opa_scale);
|
||||
}
|
||||
/*Arbitrary skew line*/
|
||||
else {
|
||||
line_draw_skew(&main_line, mask, style);
|
||||
line_draw_skew(&main_line, mask, style, opa_scale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,11 +138,12 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
**********************/
|
||||
|
||||
|
||||
static void line_draw_hor(line_draw_t * line, const lv_area_t * mask, const lv_style_t * style)
|
||||
static void line_draw_hor(line_draw_t * line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
lv_coord_t width = style->line.width - 1;
|
||||
lv_coord_t width_half = width >> 1;
|
||||
lv_coord_t width_1 = width & 0x1;
|
||||
lv_opa_t opa = (uint16_t)((uint16_t) style->line.opa * opa_scale) >> 8;
|
||||
|
||||
lv_area_t act_area;
|
||||
act_area.x1 = line->p1.x;
|
||||
@@ -154,16 +156,17 @@ static void line_draw_hor(line_draw_t * line, const lv_area_t * mask, const lv_s
|
||||
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask, style->line.color, style->line.opa);
|
||||
fill_fp(&draw_area, mask, style->line.color, opa);
|
||||
}
|
||||
|
||||
static void line_draw_ver(line_draw_t * line, const lv_area_t * mask, const lv_style_t * style)
|
||||
static void line_draw_ver(line_draw_t * line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
lv_coord_t width = style->line.width - 1;
|
||||
lv_coord_t width_half = width >> 1;
|
||||
lv_coord_t width_1 = width & 0x1;
|
||||
lv_area_t act_area;
|
||||
lv_opa_t opa = (uint16_t)((uint16_t) style->line.opa * opa_scale) >> 8;
|
||||
|
||||
lv_area_t act_area;
|
||||
act_area.x1 = line->p1.x - width_half;
|
||||
act_area.x2 = line->p2.x + width_half + width_1;
|
||||
act_area.y1 = line->p1.y;
|
||||
@@ -174,14 +177,15 @@ static void line_draw_ver(line_draw_t * line, const lv_area_t * mask, const lv_s
|
||||
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask, style->line.color, style->line.opa);
|
||||
fill_fp(&draw_area, mask, style->line.color, opa);
|
||||
}
|
||||
|
||||
static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style)
|
||||
static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
lv_coord_t width;
|
||||
width = style->line.width;
|
||||
lv_coord_t width_safe = width;
|
||||
lv_opa_t opa = (uint16_t)((uint16_t) style->line.opa * opa_scale) >> 8;
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
width--;
|
||||
@@ -257,16 +261,16 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
|
||||
lv_coord_t seg_w = pattern[i].y - pattern[aa_last_corner].y;
|
||||
if(main_line->sy < 0) {
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y + seg_w + 1,
|
||||
seg_w, mask, style->line.color, LV_OPA_50);
|
||||
seg_w, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y + seg_w + 1,
|
||||
-seg_w, mask, style->line.color, LV_OPA_50);
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
} else {
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y,
|
||||
seg_w, mask, style->line.color, LV_OPA_50);
|
||||
seg_w, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y,
|
||||
-seg_w, mask, style->line.color, LV_OPA_50);
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
}
|
||||
aa_last_corner = i;
|
||||
}
|
||||
@@ -275,16 +279,16 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
|
||||
lv_coord_t seg_w = pattern[i].x - pattern[aa_last_corner].x;
|
||||
if(main_line->sx < 0) {
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w + 1, main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
seg_w, mask, style->line.color, LV_OPA_50);
|
||||
seg_w, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w + 1, main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
-seg_w, mask, style->line.color, LV_OPA_50);
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
} else {
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x, main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
seg_w, mask, style->line.color, LV_OPA_50);
|
||||
seg_w, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x, main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
-seg_w, mask, style->line.color, LV_OPA_50);
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
}
|
||||
aa_last_corner = i;
|
||||
}
|
||||
@@ -302,33 +306,33 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
|
||||
lv_coord_t seg_w = pattern[width_safe - 1].y - pattern[aa_last_corner].y;
|
||||
if(main_line->sy < 0) {
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y + seg_w,
|
||||
seg_w + main_line->sy, mask, style->line.color, LV_OPA_50);
|
||||
seg_w + main_line->sy, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y + seg_w,
|
||||
-(seg_w + main_line->sy), mask, style->line.color, LV_OPA_50);
|
||||
-(seg_w + main_line->sy), mask, style->line.color, opa);
|
||||
|
||||
} else {
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y,
|
||||
seg_w + main_line->sy, mask, style->line.color, LV_OPA_50);
|
||||
seg_w + main_line->sy, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y,
|
||||
-(seg_w + main_line->sy), mask, style->line.color, LV_OPA_50);
|
||||
-(seg_w + main_line->sy), mask, style->line.color, opa);
|
||||
}
|
||||
} else {
|
||||
lv_coord_t seg_w = pattern[width_safe - 1].x - pattern[aa_last_corner].x;
|
||||
if(main_line->sx < 0) {
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w, main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
seg_w + main_line->sx, mask, style->line.color, LV_OPA_50);
|
||||
seg_w + main_line->sx, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w, main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
-(seg_w + main_line->sx), mask, style->line.color, LV_OPA_50);
|
||||
-(seg_w + main_line->sx), mask, style->line.color, opa);
|
||||
|
||||
} else {
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x, main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
seg_w + main_line->sx, mask, style->line.color, LV_OPA_50);
|
||||
seg_w + main_line->sx, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x , main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
-(seg_w + main_line->sx), mask, style->line.color, LV_OPA_50);
|
||||
-(seg_w + main_line->sx), mask, style->line.color, opa);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -336,7 +340,7 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
|
||||
/*With with value shift the anti aliasing on the edges (-1, 1 or 0 (zero only in case width == 0))*/
|
||||
/*Shift the anti aliasing on the edges (-1, 1 or 0 (zero only in case width == 0))*/
|
||||
lv_coord_t aa_shift1;
|
||||
lv_coord_t aa_shift2;
|
||||
|
||||
@@ -357,9 +361,6 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
|
||||
aa_shift1 = width == 0 ? 0 : aa_shift2;
|
||||
}
|
||||
}
|
||||
// aa_shift1 = main_line->hor ? main_line->sy : main_line->sx;
|
||||
// aa_shift2 = width == 0 ? 0 : aa_shift1;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -377,20 +378,20 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
|
||||
draw_area.y1 = prev_p.y + pattern[i].y;
|
||||
draw_area.x2 = draw_area.x1 + main_line->p_act.x - prev_p.x - 1;
|
||||
draw_area.y2 = draw_area.y1;
|
||||
fill_fp(&draw_area, mask, style->line.color, style->line.opa);
|
||||
fill_fp(&draw_area, mask, style->line.color, opa);
|
||||
|
||||
/* Fill the gaps
|
||||
* When stepping in y one pixel remains empty on every corner (don't do this on the first segment ) */
|
||||
if(i != 0 && pattern[i].x != pattern[i - 1].x && !first_run) {
|
||||
px_fp(draw_area.x1 , draw_area.y1 - main_line->sy, mask, style->line.color, style->line.opa);
|
||||
px_fp(draw_area.x1 , draw_area.y1 - main_line->sy, mask, style->line.color, opa);
|
||||
}
|
||||
}
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[0].x, prev_p.y + pattern[0].y - aa_shift1,
|
||||
-(main_line->p_act.x - prev_p.x), mask, style->line.color, style->line.opa);
|
||||
-(main_line->p_act.x - prev_p.x), mask, style->line.color, opa);
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[width_safe - 1].x, prev_p.y + pattern[width_safe - 1].y + aa_shift2,
|
||||
main_line->p_act.x - prev_p.x, mask, style->line.color, style->line.opa);
|
||||
main_line->p_act.x - prev_p.x, mask, style->line.color, opa);
|
||||
#endif
|
||||
|
||||
first_run = false;
|
||||
@@ -404,20 +405,20 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
|
||||
draw_area.y1 = prev_p.y + pattern[i].y;
|
||||
draw_area.x2 = draw_area.x1 + main_line->p_act.x - prev_p.x;
|
||||
draw_area.y2 = draw_area.y1;
|
||||
fill_fp(&draw_area, mask, style->line.color , style->line.opa);
|
||||
fill_fp(&draw_area, mask, style->line.color , opa);
|
||||
|
||||
/* Fill the gaps
|
||||
* When stepping in y one pixel remains empty on every corner */
|
||||
if(i != 0 && pattern[i].x != pattern[i - 1].x && !first_run) {
|
||||
px_fp(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, style->line.opa);
|
||||
px_fp(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, opa);
|
||||
}
|
||||
}
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[0].x, prev_p.y + pattern[0].y - aa_shift1,
|
||||
-(main_line->p_act.x - prev_p.x + 1), mask, style->line.color, style->line.opa);
|
||||
-(main_line->p_act.x - prev_p.x + 1), mask, style->line.color, opa);
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[width_safe - 1].x, prev_p.y + pattern[width_safe - 1].y + aa_shift2,
|
||||
main_line->p_act.x - prev_p.x + 1, mask, style->line.color, style->line.opa);
|
||||
main_line->p_act.x - prev_p.x + 1, mask, style->line.color, opa);
|
||||
#endif
|
||||
}
|
||||
/*Rather a vertical line*/
|
||||
@@ -430,21 +431,21 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
|
||||
draw_area.x2 = draw_area.x1;
|
||||
draw_area.y2 = draw_area.y1 + main_line->p_act.y - prev_p.y - 1;
|
||||
|
||||
fill_fp(&draw_area, mask, style->line.color, style->line.opa);
|
||||
fill_fp(&draw_area, mask, style->line.color, opa);
|
||||
|
||||
/* Fill the gaps
|
||||
* When stepping in x one pixel remains empty on every corner (don't do this on the first segment ) */
|
||||
if(i != 0 && pattern[i].y != pattern[i - 1].y && !first_run) {
|
||||
px_fp(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, style->line.opa);
|
||||
px_fp(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[0].x - aa_shift1, prev_p.y + pattern[0].y,
|
||||
-(main_line->p_act.y - prev_p.y), mask, style->line.color, style->line.opa);
|
||||
-(main_line->p_act.y - prev_p.y), mask, style->line.color, opa);
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[width_safe - 1].x + aa_shift2, prev_p.y + pattern[width_safe - 1].y,
|
||||
main_line->p_act.y - prev_p.y, mask, style->line.color, style->line.opa);
|
||||
main_line->p_act.y - prev_p.y, mask, style->line.color, opa);
|
||||
#endif
|
||||
|
||||
first_run = false;
|
||||
@@ -460,20 +461,20 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
|
||||
draw_area.x2 = draw_area.x1;
|
||||
draw_area.y2 = draw_area.y1 + main_line->p_act.y - prev_p.y;
|
||||
|
||||
fill_fp(&draw_area, mask, style->line.color, style->line.opa);
|
||||
fill_fp(&draw_area, mask, style->line.color, opa);
|
||||
|
||||
/* Fill the gaps
|
||||
* When stepping in x one pixel remains empty on every corner */
|
||||
if(i != 0 && pattern[i].y != pattern[i - 1].y && !first_run) {
|
||||
px_fp(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, style->line.opa);
|
||||
px_fp(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa);
|
||||
}
|
||||
}
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[0].x - aa_shift1, prev_p.y + pattern[0].y,
|
||||
-(main_line->p_act.y - prev_p.y + 1), mask, style->line.color, style->line.opa);
|
||||
-(main_line->p_act.y - prev_p.y + 1), mask, style->line.color, opa);
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[width_safe - 1].x + aa_shift2, prev_p.y + pattern[width_safe - 1].y,
|
||||
main_line->p_act.y - prev_p.y + 1, mask, style->line.color, style->line.opa);
|
||||
main_line->p_act.y - prev_p.y + 1, mask, style->line.color, opa);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,13 +28,14 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* Draw a line
|
||||
* @param p1 first point of the line
|
||||
* @param p2 second point of the line
|
||||
* @param maskthe line will be drawn only on this area
|
||||
* @param lines_p pointer to a line style
|
||||
* @param point1 first point of the line
|
||||
* @param point2 second point of the line
|
||||
* @param mask the line will be drawn only on this area
|
||||
* @param style pointer to a line's style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask,
|
||||
const lv_style_t * style);
|
||||
const lv_style_t * style, lv_opa_t opa_scale);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -25,14 +25,14 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style);
|
||||
static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style);
|
||||
static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style);
|
||||
static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style);
|
||||
static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
#if USE_LV_SHADOW && LV_VDB_SIZE
|
||||
static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style);
|
||||
static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style);
|
||||
static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style);
|
||||
static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_shadow_full_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, const lv_opa_t * map);
|
||||
#endif
|
||||
static uint16_t lv_draw_cont_radius_corr(uint16_t r, lv_coord_t w, lv_coord_t h);
|
||||
@@ -55,29 +55,30 @@ static lv_opa_t antialias_get_opa_circ(lv_coord_t seg, lv_coord_t px_id, lv_opa_
|
||||
* @param coords the coordinates of the rectangle
|
||||
* @param mask the rectangle will be drawn only in this mask
|
||||
* @param style pointer to a style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style)
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
if(lv_area_get_height(coords) < 1 || lv_area_get_width(coords) < 1) return;
|
||||
|
||||
#if USE_LV_SHADOW && LV_VDB_SIZE
|
||||
if(style->body.shadow.width != 0) {
|
||||
lv_draw_shadow(coords, mask, style);
|
||||
lv_draw_shadow(coords, mask, style, opa_scale);
|
||||
}
|
||||
#endif
|
||||
if(style->body.empty == 0){
|
||||
lv_draw_rect_main_mid(coords, mask, style);
|
||||
lv_draw_rect_main_mid(coords, mask, style, opa_scale);
|
||||
|
||||
if(style->body.radius != 0) {
|
||||
lv_draw_rect_main_corner(coords, mask, style);
|
||||
lv_draw_rect_main_corner(coords, mask, style, opa_scale);
|
||||
}
|
||||
}
|
||||
|
||||
if(style->body.border.width != 0 && style->body.border.part != LV_BORDER_NONE) {
|
||||
lv_draw_rect_border_straight(coords, mask, style);
|
||||
lv_draw_rect_border_straight(coords, mask, style, opa_scale);
|
||||
|
||||
if(style->body.radius != 0) {
|
||||
lv_draw_rect_border_corner(coords, mask, style);
|
||||
lv_draw_rect_border_corner(coords, mask, style, opa_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,17 +92,18 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_sty
|
||||
* @param coords the coordinates of the original rectangle
|
||||
* @param mask the rectangle will be drawn only on this area
|
||||
* @param rects_p pointer to a rectangle style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style)
|
||||
static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
uint16_t radius = style->body.radius;
|
||||
|
||||
lv_color_t mcolor = style->body.main_color;
|
||||
lv_color_t gcolor = style->body.grad_color;
|
||||
uint8_t mix;
|
||||
lv_opa_t opa = style->body.opa;
|
||||
lv_coord_t height = lv_area_get_height(coords);
|
||||
lv_coord_t width = lv_area_get_width(coords);
|
||||
lv_opa_t opa = (uint16_t)((uint16_t) style->body.opa * opa_scale) >> 8;
|
||||
|
||||
radius = lv_draw_cont_radius_corr(radius, width, height);
|
||||
|
||||
@@ -160,15 +162,16 @@ static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * ma
|
||||
* @param coords the coordinates of the original rectangle
|
||||
* @param mask the rectangle will be drawn only on this area
|
||||
* @param rects_p pointer to a rectangle style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style)
|
||||
static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
uint16_t radius = style->body.radius;
|
||||
|
||||
lv_color_t mcolor = style->body.main_color;
|
||||
lv_color_t gcolor = style->body.grad_color;
|
||||
lv_color_t act_color;
|
||||
lv_opa_t opa = style->body.opa;
|
||||
lv_opa_t opa = (uint16_t)((uint16_t) style->body.opa * opa_scale) >> 8;
|
||||
uint8_t mix;
|
||||
lv_coord_t height = lv_area_get_height(coords);
|
||||
lv_coord_t width = lv_area_get_width(coords);
|
||||
@@ -251,9 +254,9 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
for(i = 0; i < seg_size; i++) {
|
||||
lv_opa_t aa_opa;
|
||||
if(seg_size > CIRCLE_AA_NON_LINEAR_OPA_THRESHOLD) { /*Use non-linear opa mapping on the first segment*/
|
||||
aa_opa = antialias_get_opa_circ(seg_size, i, style->body.opa);
|
||||
aa_opa = antialias_get_opa_circ(seg_size, i, opa);
|
||||
} else {
|
||||
aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, style->body.opa);
|
||||
aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
}
|
||||
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, aa_color_hor_bottom, aa_opa);
|
||||
@@ -304,8 +307,8 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
else {
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - mid_top_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
}
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
fill_fp(&mid_top_area, mask, act_color, opa);
|
||||
}
|
||||
|
||||
@@ -438,7 +441,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
aa_color_hor_top = lv_color_mix(gcolor, mcolor, mix);
|
||||
aa_color_hor_bottom = lv_color_mix(mcolor, gcolor, mix);
|
||||
|
||||
lv_opa_t aa_opa = style->body.opa >> 1;
|
||||
lv_opa_t aa_opa = opa >> 1;
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, aa_color_hor_bottom, aa_opa);
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, aa_color_hor_bottom, aa_opa);
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, aa_color_hor_top, aa_opa);
|
||||
@@ -455,15 +458,16 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
* @param coords the coordinates of the original rectangle
|
||||
* @param mask_ the rectangle will be drawn only on this area
|
||||
* @param rstyle pointer to a rectangle style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style)
|
||||
static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
uint16_t radius = style->body.radius;
|
||||
|
||||
lv_coord_t width = lv_area_get_width(coords);
|
||||
lv_coord_t height = lv_area_get_height(coords);
|
||||
uint16_t bwidth = style->body.border.width;
|
||||
lv_opa_t opa = style->body.border.opa;
|
||||
lv_opa_t opa = (uint16_t)((uint16_t) style->body.border.opa * opa_scale) >> 8;
|
||||
lv_border_part_t part = style->body.border.part;
|
||||
lv_color_t color = style->body.border.color;
|
||||
lv_area_t work_area;
|
||||
@@ -647,16 +651,16 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
* Draw the corners of a rectangle border
|
||||
* @param coords the coordinates of the original rectangle
|
||||
* @param mask the rectangle will be drawn only on this area
|
||||
* @param rects_p pointer to a rectangle style
|
||||
* @param opa opacity of the rectangle (0..255)
|
||||
* @param style pointer to a style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style)
|
||||
static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
uint16_t radius = style->body.radius ;
|
||||
uint16_t bwidth = style->body.border.width;
|
||||
lv_color_t color = style->body.border.color;
|
||||
lv_opa_t opa = style->body.border.opa;
|
||||
lv_border_part_t part = style->body.border.part;
|
||||
lv_opa_t opa = (uint16_t)((uint16_t) style->body.border.opa * opa_scale) >> 8;
|
||||
|
||||
/*0 px border width drawn as 1 px, so decrement the bwidth*/
|
||||
bwidth--;
|
||||
@@ -743,9 +747,9 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
lv_opa_t aa_opa;
|
||||
|
||||
if(seg_size > CIRCLE_AA_NON_LINEAR_OPA_THRESHOLD) { /*Use non-linear opa mapping on the first segment*/
|
||||
aa_opa = antialias_get_opa_circ(seg_size, i, style->body.border.opa);
|
||||
aa_opa = antialias_get_opa_circ(seg_size, i, opa);
|
||||
} else {
|
||||
aa_opa = style->body.border.opa - lv_draw_aa_get_opa(seg_size, i, style->body.border.opa);
|
||||
aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
@@ -788,9 +792,9 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
lv_opa_t aa_opa;
|
||||
|
||||
if(seg_size > CIRCLE_AA_NON_LINEAR_OPA_THRESHOLD) { /*Use non-linear opa mapping on the first segment*/
|
||||
aa_opa = style->body.border.opa - antialias_get_opa_circ(seg_size, i, style->body.border.opa);
|
||||
aa_opa = opa - antialias_get_opa_circ(seg_size, i, opa);
|
||||
} else {
|
||||
aa_opa = lv_draw_aa_get_opa(seg_size, i, style->body.border.opa);
|
||||
aa_opa = lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
@@ -925,7 +929,7 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
|
||||
lv_coord_t i;
|
||||
for(i = 0; i < seg_size; i++) {
|
||||
lv_opa_t aa_opa = style->body.border.opa - lv_draw_aa_get_opa(seg_size, i, style->body.border.opa);
|
||||
lv_opa_t aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
@@ -952,7 +956,7 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
aa_p.x = out_x_last;
|
||||
aa_p.y = out_x_last;
|
||||
|
||||
lv_opa_t aa_opa = style->body.border.opa >> 1;
|
||||
lv_opa_t aa_opa = opa >> 1;
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, style->body.border.color, aa_opa);
|
||||
@@ -978,7 +982,7 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
seg_size = in_y_seg_end - in_y_seg_start;
|
||||
|
||||
for(i = 0; i < seg_size; i++) {
|
||||
lv_opa_t aa_opa = lv_draw_aa_get_opa(seg_size, i, style->body.border.opa);
|
||||
lv_opa_t aa_opa = lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
@@ -1024,8 +1028,9 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
* Draw a shadow
|
||||
* @param rect pointer to rectangle object
|
||||
* @param mask pointer to a mask area (from the design functions)
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style)
|
||||
static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
/* If mask is in the middle of cords do not draw shadow*/
|
||||
lv_coord_t radius = style->body.radius;
|
||||
@@ -1047,13 +1052,13 @@ static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, con
|
||||
if(lv_area_is_in(mask, &area_tmp) != false) return;
|
||||
|
||||
if(style->body.shadow.type == LV_SHADOW_FULL) {
|
||||
lv_draw_shadow_full(coords, mask, style);
|
||||
lv_draw_shadow_full(coords, mask, style, opa_scale);
|
||||
} else if(style->body.shadow.type == LV_SHADOW_BOTTOM) {
|
||||
lv_draw_shadow_bottom(coords, mask, style);
|
||||
lv_draw_shadow_bottom(coords, mask, style, opa_scale);
|
||||
}
|
||||
}
|
||||
|
||||
static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style)
|
||||
static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
|
||||
lv_coord_t radius = style->body.radius;
|
||||
@@ -1098,8 +1103,9 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
# endif
|
||||
#endif
|
||||
/*1D Blur horizontally*/
|
||||
lv_opa_t opa = (uint16_t)((uint16_t) style->body.opa * opa_scale) >> 8;
|
||||
for(line = 0; line < filter_width; line++) {
|
||||
line_1d_blur[line] = (uint32_t)((uint32_t)(filter_width - line) * (style->body.opa * 2) << SHADOW_OPA_EXTRA_PRECISION) / (filter_width * filter_width);
|
||||
line_1d_blur[line] = (uint32_t)((uint32_t)(filter_width - line) * (opa * 2) << SHADOW_OPA_EXTRA_PRECISION) / (filter_width * filter_width);
|
||||
}
|
||||
|
||||
uint16_t col;
|
||||
@@ -1214,7 +1220,7 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
}
|
||||
|
||||
|
||||
static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style)
|
||||
static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
lv_coord_t radius = style->body.radius;
|
||||
lv_coord_t swidth = style->body.shadow.width;
|
||||
@@ -1253,8 +1259,9 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma
|
||||
# endif
|
||||
#endif
|
||||
|
||||
lv_opa_t opa = (uint16_t)((uint16_t) style->body.opa * opa_scale) >> 8;
|
||||
for(col = 0; col < swidth; col++) {
|
||||
line_1d_blur[col] = (uint32_t)((uint32_t)(swidth - col) * style->body.opa / 2) / (swidth);
|
||||
line_1d_blur[col] = (uint32_t)((uint32_t)(swidth - col) * opa / 2) / (swidth);
|
||||
}
|
||||
|
||||
lv_point_t point_l;
|
||||
|
||||
@@ -32,8 +32,9 @@ extern "C" {
|
||||
* @param coords the coordinates of the rectangle
|
||||
* @param mask the rectangle will be drawn only in this mask
|
||||
* @param style pointer to a style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style);
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -220,8 +220,8 @@ static bool lv_arc_design(lv_obj_t * arc, const lv_area_t * mask, lv_design_mode
|
||||
lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(arc), lv_obj_get_height(arc))) / 2;
|
||||
lv_coord_t x = arc->coords.x1 + lv_obj_get_width(arc) / 2;
|
||||
lv_coord_t y = arc->coords.y1 + lv_obj_get_height(arc) / 2;
|
||||
|
||||
lv_draw_arc(x, y, r, mask, ext->angle_start, ext->angle_end, style);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(arc);
|
||||
lv_draw_arc(x, y, r, mask, ext->angle_start, ext->angle_end, style, opa_scale);
|
||||
|
||||
|
||||
if(style->body.radius == LV_RADIUS_CIRCLE) {
|
||||
@@ -239,7 +239,7 @@ static bool lv_arc_design(lv_obj_t * arc, const lv_area_t * mask, lv_design_mode
|
||||
cir_area.x2 = cir_x + x + thick_2;
|
||||
cir_area.y2 = cir_y + y + thick_2;
|
||||
|
||||
lv_draw_rect(&cir_area, mask, &cir_style);
|
||||
lv_draw_rect(&cir_area, mask, &cir_style, lv_obj_get_opa_scale(arc));
|
||||
|
||||
cir_x = ((r - thick_2) * lv_trigo_sin(ext->angle_end) >> LV_TRIGO_SHIFT);
|
||||
cir_y = ((r - thick_2) * lv_trigo_sin(ext->angle_end + 90) >> LV_TRIGO_SHIFT);
|
||||
@@ -249,7 +249,7 @@ static bool lv_arc_design(lv_obj_t * arc, const lv_area_t * mask, lv_design_mode
|
||||
cir_area.x2 = cir_x + x + thick_2;
|
||||
cir_area.y2 = cir_y + y + thick_2;
|
||||
|
||||
lv_draw_rect(&cir_area, mask, &cir_style);
|
||||
lv_draw_rect(&cir_area, mask, &cir_style, lv_obj_get_opa_scale(arc));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
|
||||
}
|
||||
|
||||
/*Draw the indicator*/
|
||||
lv_draw_rect(&indic_area, mask, style_indic);
|
||||
lv_draw_rect(&indic_area, mask, style_indic, lv_obj_get_opa_scale(bar));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -396,6 +396,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
lv_style_t * bg_style = lv_obj_get_style(btnm);
|
||||
lv_style_t * btn_style;
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(btnm);
|
||||
|
||||
lv_area_t area_btnm;
|
||||
lv_obj_get_coords(btnm, &area_btnm);
|
||||
@@ -439,7 +440,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo
|
||||
}
|
||||
}
|
||||
|
||||
lv_draw_rect(&area_tmp, mask, btn_style);
|
||||
lv_draw_rect(&area_tmp, mask, btn_style, opa_scale);
|
||||
|
||||
if(border_mod) {
|
||||
border_mod = false;
|
||||
@@ -461,7 +462,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo
|
||||
|
||||
|
||||
if(btn_style->glass) btn_style = bg_style;
|
||||
lv_draw_label(&area_tmp, mask, btn_style, ext->map_p[txt_i], LV_TXT_FLAG_NONE, NULL);
|
||||
lv_draw_label(&area_tmp, mask, btn_style, opa_scale, ext->map_p[txt_i], LV_TXT_FLAG_NONE, NULL);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -414,7 +414,7 @@ static bool lv_chart_design(lv_obj_t * chart, const lv_area_t * mask, lv_design_
|
||||
return ancestor_design_f(chart, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Draw the background*/
|
||||
lv_draw_rect(&chart->coords, mask, lv_obj_get_style(chart));
|
||||
lv_draw_rect(&chart->coords, mask, lv_obj_get_style(chart), lv_obj_get_opa_scale(chart));
|
||||
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
|
||||
@@ -470,6 +470,7 @@ static void lv_chart_draw_div(lv_obj_t * chart, const lv_area_t * mask)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_style_t * style = lv_obj_get_style(chart);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(chart);
|
||||
|
||||
uint8_t div_i;
|
||||
uint8_t div_i_end;
|
||||
@@ -500,7 +501,7 @@ static void lv_chart_draw_div(lv_obj_t * chart, const lv_area_t * mask)
|
||||
if(div_i == div_i_end) p1.y -= (style->line.width >> 1) + 1; /*The last line might not be visible*/
|
||||
|
||||
p2.y = p1.y;
|
||||
lv_draw_line(&p1, &p2, mask, style);
|
||||
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,7 +523,7 @@ static void lv_chart_draw_div(lv_obj_t * chart, const lv_area_t * mask)
|
||||
if(div_i == div_i_start) p1.x += (style->line.width >> 1) + 1; /*The first line might not be visible*/
|
||||
if(div_i == div_i_end) p1.x -= (style->line.width >> 1) + 1; /*The last line might not be visible*/
|
||||
p2.x = p1.x;
|
||||
lv_draw_line(&p1, &p2, mask, style);
|
||||
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -544,14 +545,15 @@ static void lv_chart_draw_lines(lv_obj_t * chart, const lv_area_t * mask)
|
||||
lv_coord_t y_ofs = chart->coords.y1;
|
||||
int32_t y_tmp;
|
||||
lv_chart_series_t *ser;
|
||||
lv_style_t lines;
|
||||
lv_style_copy(&lines, &lv_style_plain);
|
||||
lines.line.opa = ext->series.opa;
|
||||
lines.line.width = ext->series.width;
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(chart);
|
||||
lv_style_t style;
|
||||
lv_style_copy(&style, &lv_style_plain);
|
||||
style.line.opa = ext->series.opa;
|
||||
style.line.width = ext->series.width;
|
||||
|
||||
/*Go through all data lines*/
|
||||
LL_READ_BACK(ext->series_ll, ser) {
|
||||
lines.line.color = ser->color;
|
||||
style.line.color = ser->color;
|
||||
|
||||
p1.x = 0 + x_ofs;
|
||||
p2.x = 0 + x_ofs;
|
||||
@@ -569,7 +571,7 @@ static void lv_chart_draw_lines(lv_obj_t * chart, const lv_area_t * mask)
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
|
||||
lv_draw_line(&p1, &p2, mask, &lines);
|
||||
lv_draw_line(&p1, &p2, mask, &style, opa_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -617,7 +619,7 @@ static void lv_chart_draw_points(lv_obj_t * chart, const lv_area_t * mask)
|
||||
cir_a.y2 = cir_a.y1 + style_point.body.radius;
|
||||
cir_a.y1 -= style_point.body.radius;
|
||||
|
||||
lv_draw_rect(&cir_a, mask, &style_point);
|
||||
lv_draw_rect(&cir_a, mask, &style_point, lv_obj_get_opa_scale(chart));
|
||||
}
|
||||
series_cnt++;
|
||||
}
|
||||
@@ -673,7 +675,7 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const lv_area_t * mask)
|
||||
|
||||
mask_ret = lv_area_union(&col_mask, mask, &col_a);
|
||||
if(mask_ret != false) {
|
||||
lv_draw_rect(&chart->coords, &col_mask, &rects);
|
||||
lv_draw_rect(&chart->coords, &col_mask, &rects, lv_obj_get_opa_scale(chart));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,6 +431,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
||||
ancestor_design(ddlist, mask, mode);
|
||||
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(ddlist);
|
||||
|
||||
/*If the list is opened draw a rectangle under the selected item*/
|
||||
if(ext->opened != 0) {
|
||||
@@ -448,7 +449,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
||||
rect_area.x1 = ddlist->coords.x1;
|
||||
rect_area.x2 = ddlist->coords.x2;
|
||||
|
||||
lv_draw_rect(&rect_area, mask, ext->sel_style);
|
||||
lv_draw_rect(&rect_area, mask, ext->sel_style, opa_scale);
|
||||
}
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
@@ -457,6 +458,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
||||
|
||||
/*Redraw the text on the selected area with a different color*/
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(ddlist);
|
||||
|
||||
/*Redraw only in opened state*/
|
||||
if(ext->opened == 0) return true;
|
||||
@@ -482,7 +484,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
||||
lv_style_copy(&new_style, style);
|
||||
new_style.text.color = sel_style->text.color;
|
||||
new_style.text.opa = sel_style->text.opa;
|
||||
lv_draw_label(&ext->label->coords, &mask_sel, &new_style,
|
||||
lv_draw_label(&ext->label->coords, &mask_sel, &new_style, opa_scale,
|
||||
lv_label_get_text(ext->label), LV_TXT_FLAG_NONE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,6 +337,7 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
lv_style_t * style = lv_obj_get_style(gauge);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(gauge);
|
||||
lv_coord_t r = lv_obj_get_width(gauge) / 2 - (3 * style->body.padding.hor) - style->body.padding.inner;
|
||||
lv_coord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->coords.x1;
|
||||
lv_coord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->coords.y1;
|
||||
@@ -372,7 +373,7 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
label_cord.x2 = label_cord.x1 + label_size.x;
|
||||
label_cord.y2 = label_cord.y1 + label_size.y;
|
||||
|
||||
lv_draw_label(&label_cord, mask, style, scale_txt, LV_TXT_FLAG_NONE, NULL);
|
||||
lv_draw_label(&label_cord, mask, style, opa_scale, scale_txt, LV_TXT_FLAG_NONE, NULL);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -385,6 +386,7 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
lv_style_t style_needle;
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
lv_style_t * style = lv_gauge_get_style(gauge);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(gauge);
|
||||
|
||||
lv_coord_t r = lv_obj_get_width(gauge) / 2 - style->body.padding.hor;
|
||||
lv_coord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->coords.x1;
|
||||
@@ -411,7 +413,7 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
if(ext->needle_colors == NULL) style_needle.line.color = LV_GAUGE_DEF_NEEDLE_COLOR;
|
||||
else style_needle.line.color = ext->needle_colors[i];
|
||||
|
||||
lv_draw_line(&p_mid, &p_end, mask, &style_needle);
|
||||
lv_draw_line(&p_mid, &p_end, mask, &style_needle, opa_scale);
|
||||
}
|
||||
|
||||
/*Draw the needle middle area*/
|
||||
@@ -427,7 +429,7 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
nm_cord.x2 = x_ofs + style->body.padding.ver;
|
||||
nm_cord.y2 = y_ofs + style->body.padding.ver;
|
||||
|
||||
lv_draw_rect(&nm_cord, mask, &style_neddle_mid);
|
||||
lv_draw_rect(&nm_cord, mask, &style_neddle_mid, lv_obj_get_opa_scale(gauge));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -292,6 +292,7 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
if(ext->h == 0 || ext->w == 0) return true;
|
||||
lv_area_t coords;
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(img);
|
||||
|
||||
lv_obj_get_coords(img, &coords);
|
||||
|
||||
@@ -304,16 +305,16 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
|
||||
cords_tmp.x1 = coords.x1;
|
||||
cords_tmp.x2 = coords.x1 + ext->w - 1;
|
||||
for(; cords_tmp.x1 < coords.x2; cords_tmp.x1 += ext->w, cords_tmp.x2 += ext->w) {
|
||||
lv_draw_img(&cords_tmp, mask, style, ext->src);
|
||||
lv_draw_img(&cords_tmp, mask, ext->src, style, opa_scale);
|
||||
}
|
||||
}
|
||||
} else if(ext->src_type == LV_IMG_SRC_SYMBOL) {
|
||||
lv_draw_label(&coords, mask, style, ext->src, LV_TXT_FLAG_NONE, NULL);
|
||||
lv_draw_label(&coords, mask, style, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL);
|
||||
|
||||
} else {
|
||||
|
||||
/*Trigger the error handler of image drawer*/
|
||||
lv_draw_img(&img->coords, mask, style, NULL);
|
||||
lv_draw_img(&img->coords, mask, NULL, style, opa_scale);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,12 +641,13 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_area_t coords;
|
||||
lv_style_t * style = lv_obj_get_style(label);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(label);
|
||||
lv_obj_get_coords(label, &coords);
|
||||
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(label);
|
||||
if(lv_group_get_focused(g) == label) {
|
||||
lv_draw_rect(&coords, mask, style);
|
||||
lv_draw_rect(&coords, mask, style, opa_scale);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -660,7 +661,7 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_
|
||||
bg.y1 -= style->body.padding.ver;
|
||||
bg.y2 += style->body.padding.ver;
|
||||
|
||||
lv_draw_rect(&bg, mask, style);
|
||||
lv_draw_rect(&bg, mask, style, lv_obj_get_opa_scale(label));
|
||||
}
|
||||
|
||||
/*TEST: draw a background for the label*/
|
||||
@@ -672,7 +673,7 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_
|
||||
if(ext->no_break != 0) flag |= LV_TXT_FLAG_NO_BREAK;
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER;
|
||||
|
||||
lv_draw_label(&coords, mask, style, ext->text, flag, &ext->offset);
|
||||
lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ext->offset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -206,6 +206,7 @@ static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mo
|
||||
if(ext->point_num == 0 || ext->point_array == NULL) return false;
|
||||
|
||||
lv_style_t * style = lv_obj_get_style(line);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(line);
|
||||
lv_area_t area;
|
||||
lv_obj_get_coords(line, &area);
|
||||
lv_coord_t x_ofs = area.x1;
|
||||
@@ -214,7 +215,6 @@ static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mo
|
||||
lv_point_t p2;
|
||||
lv_coord_t h = lv_obj_get_height(line);
|
||||
uint16_t i;
|
||||
|
||||
lv_style_t circle_style;
|
||||
lv_style_copy(&circle_style, style);
|
||||
circle_style.body.radius = LV_RADIUS_CIRCLE;
|
||||
@@ -236,7 +236,7 @@ static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mo
|
||||
p1.y = h - ext->point_array[i].y + y_ofs;
|
||||
p2.y = h - ext->point_array[i + 1].y + y_ofs;
|
||||
}
|
||||
lv_draw_line(&p1, &p2, mask, style);
|
||||
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
||||
|
||||
circle_area.x1 = p1.x - (style->line.width >> 1);
|
||||
circle_area.y1 = p1.y - (style->line.width >> 1);
|
||||
|
||||
@@ -246,6 +246,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||
lv_style_t * style = lv_obj_get_style(lmeter);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(lmeter);
|
||||
lv_style_t style_tmp;
|
||||
memcpy(&style_tmp, style, sizeof(lv_style_t));
|
||||
|
||||
@@ -302,7 +303,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig
|
||||
style_tmp.line.color = lv_color_mix(style->body.grad_color, style->body.main_color, (255 * i) / ext->line_cnt);
|
||||
}
|
||||
|
||||
lv_draw_line(&p1, &p2, mask, &style_tmp);
|
||||
lv_draw_line(&p1, &p2, mask, &style_tmp, opa_scale);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mo
|
||||
lv_style_t *style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
||||
lv_coord_t border_width_tmp = style->body.border.width;
|
||||
style->body.border.width = 0;
|
||||
lv_draw_rect(&page->coords, mask, style);
|
||||
lv_draw_rect(&page->coords, mask, style, lv_obj_get_opa_scale(page));
|
||||
style->body.border.width = border_width_tmp;
|
||||
|
||||
} else if(mode == LV_DESIGN_DRAW_POST) { /*Draw the scroll bars finally*/
|
||||
@@ -376,7 +376,7 @@ static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mo
|
||||
uint8_t empty_tmp = style->body.empty;
|
||||
style->body.shadow.width = 0;
|
||||
style->body.empty = 1;
|
||||
lv_draw_rect(&page->coords, mask, style);
|
||||
lv_draw_rect(&page->coords, mask, style, lv_obj_get_opa_scale(page));
|
||||
style->body.shadow.width = shadow_width_tmp;
|
||||
style->body.empty = empty_tmp;
|
||||
|
||||
@@ -392,7 +392,7 @@ static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mo
|
||||
sb_area.y1 += page->coords.y1;
|
||||
sb_area.x2 += page->coords.x1;
|
||||
sb_area.y2 += page->coords.y1;
|
||||
lv_draw_rect(&sb_area, mask, ext->sb.style);
|
||||
lv_draw_rect(&sb_area, mask, ext->sb.style, lv_obj_get_opa_scale(page));
|
||||
}
|
||||
|
||||
if(ext->sb.ver_draw) {
|
||||
@@ -402,7 +402,7 @@ static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mo
|
||||
sb_area.y1 += page->coords.y1;
|
||||
sb_area.x2 += page->coords.x1;
|
||||
sb_area.y2 += page->coords.y1;
|
||||
lv_draw_rect(&sb_area, mask, ext->sb.style);
|
||||
lv_draw_rect(&sb_area, mask, ext->sb.style, lv_obj_get_opa_scale(page));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ static bool lv_preload_design(lv_obj_t * preload, const lv_area_t * mask, lv_des
|
||||
bg_area.x2 = x + r;
|
||||
bg_area.y2 = y + r;
|
||||
|
||||
if(style->body.empty == 0) lv_draw_rect(&bg_area, mask, &bg_style);
|
||||
if(style->body.empty == 0) lv_draw_rect(&bg_area, mask, &bg_style, lv_obj_get_opa_scale(preload));
|
||||
|
||||
/*Draw the arc above the background circle */
|
||||
ancestor_design(preload, mask, mode);
|
||||
|
||||
@@ -220,6 +220,7 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig
|
||||
draw_bg(roller, mask);
|
||||
|
||||
lv_style_t *style = lv_roller_get_style(roller, LV_ROLLER_STYLE_BG);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(roller);
|
||||
const lv_font_t * font = style->text.font;
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||
lv_coord_t font_h = lv_font_get_height(font);
|
||||
@@ -229,7 +230,7 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig
|
||||
rect_area.x1 = roller->coords.x1;
|
||||
rect_area.x2 = roller->coords.x2;
|
||||
|
||||
lv_draw_rect(&rect_area, mask, ext->ddlist.sel_style);
|
||||
lv_draw_rect(&rect_area, mask, ext->ddlist.sel_style, opa_scale);
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
@@ -237,6 +238,7 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||
const lv_font_t * font = style->text.font;
|
||||
lv_coord_t font_h = lv_font_get_height(font);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(roller);
|
||||
|
||||
/*Redraw the text on the selected area with a different color*/
|
||||
lv_area_t rect_area;
|
||||
@@ -253,7 +255,7 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig
|
||||
lv_style_copy(&new_style, style);
|
||||
new_style.text.color = sel_style->text.color;
|
||||
new_style.text.opa = sel_style->text.opa;
|
||||
lv_draw_label(&ext->ddlist.label->coords, &mask_sel, &new_style,
|
||||
lv_draw_label(&ext->ddlist.label->coords, &mask_sel, &new_style, opa_scale,
|
||||
lv_label_get_text(ext->ddlist.label), LV_TXT_FLAG_CENTER, NULL);
|
||||
}
|
||||
}
|
||||
@@ -424,7 +426,7 @@ static void draw_bg(lv_obj_t *roller, const lv_area_t *mask)
|
||||
half_roller.y2 += style->body.radius;
|
||||
|
||||
if(union_ok) {
|
||||
lv_draw_rect(&half_roller, &half_mask, style);
|
||||
lv_draw_rect(&half_roller, &half_mask, style, lv_obj_get_opa_scale(roller));
|
||||
}
|
||||
|
||||
half_roller.x1 -= roller->ext_size; /*Add ext size too (e.g. because of shadow draw) */
|
||||
@@ -446,7 +448,7 @@ static void draw_bg(lv_obj_t *roller, const lv_area_t *mask)
|
||||
|
||||
style->body.main_color = grad_tmp;
|
||||
style->body.grad_color = main_tmp;
|
||||
lv_draw_rect(&half_roller, &half_mask, style);
|
||||
lv_draw_rect(&half_roller, &half_mask, style,lv_obj_get_opa_scale(roller));
|
||||
style->body.main_color = main_tmp;
|
||||
style->body.grad_color = grad_tmp;
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
|
||||
area_bg.y1 += slider_w > slider_h ? pad_ver_bg : 0; /*Pad only for horizontal slider*/
|
||||
area_bg.y2 -= slider_w > slider_h ? pad_ver_bg : 0; /*Pad only for horizontal slider*/
|
||||
}
|
||||
lv_draw_rect(&area_bg, mask, style_bg);
|
||||
lv_draw_rect(&area_bg, mask, style_bg, lv_obj_get_opa_scale(slider));
|
||||
|
||||
/*Draw the indicator*/
|
||||
lv_area_t area_indic;
|
||||
@@ -328,7 +328,7 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
|
||||
area_indic.y1 = area_indic.y2 - area_indic.y1 + 1;
|
||||
}
|
||||
|
||||
if(cur_value != min_value) lv_draw_rect(&area_indic, mask, style_indic);
|
||||
if(cur_value != min_value) lv_draw_rect(&area_indic, mask, style_indic, lv_obj_get_opa_scale(slider));
|
||||
|
||||
/*Draw the knob*/
|
||||
lv_area_t knob_area;
|
||||
@@ -360,7 +360,7 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
|
||||
|
||||
}
|
||||
|
||||
lv_draw_rect(&knob_area, mask, style_knob);
|
||||
lv_draw_rect(&knob_area, mask, style_knob, lv_obj_get_opa_scale(slider));
|
||||
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
|
||||
@@ -760,6 +760,7 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_
|
||||
lv_obj_t * ta = lv_obj_get_parent(scrl);
|
||||
lv_ta_ext_t * ta_ext = lv_obj_get_ext_attr(ta);
|
||||
lv_style_t * label_style = lv_obj_get_style(ta_ext->label);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(ta);
|
||||
if(ta_ext->cursor.type == LV_CURSOR_NONE ||
|
||||
(ta_ext->cursor.type & LV_CURSOR_HIDDEN) ||
|
||||
ta_ext->cursor.state == 0 ||
|
||||
@@ -838,14 +839,14 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + (cur_style.line.width >> 1);
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h;
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
lv_draw_rect(&cur_area, mask, &cur_style, opa_scale);
|
||||
} else if(ta_ext->cursor.type == LV_CURSOR_BLOCK) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 - cur_style.body.padding.hor;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 - cur_style.body.padding.ver;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h;
|
||||
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
lv_draw_rect(&cur_area, mask, &cur_style, opa_scale);
|
||||
|
||||
/*Get the current letter*/
|
||||
#if LV_TXT_UTF8 == 0
|
||||
@@ -858,7 +859,7 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_
|
||||
#endif
|
||||
cur_area.x1 += cur_style.body.padding.hor;
|
||||
cur_area.y1 += cur_style.body.padding.ver;
|
||||
lv_draw_label(&cur_area, mask, &cur_style, letter_buf, LV_TXT_FLAG_NONE, 0);
|
||||
lv_draw_label(&cur_area, mask, &cur_style, opa_scale, letter_buf, LV_TXT_FLAG_NONE, 0);
|
||||
|
||||
} else if(ta_ext->cursor.type == LV_CURSOR_OUTLINE) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 - cur_style.body.padding.hor;
|
||||
@@ -868,14 +869,14 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_
|
||||
|
||||
cur_style.body.empty = 1;
|
||||
if(cur_style.body.border.width == 0) cur_style.body.border.width = 1; /*Be sure the border will be drawn*/
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
lv_draw_rect(&cur_area, mask, &cur_style, opa_scale);
|
||||
} else if(ta_ext->cursor.type == LV_CURSOR_UNDERLINE) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h - (cur_style.line.width >> 1);
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h + (cur_style.line.width >> 1) + (cur_style.line.width & 0x1);
|
||||
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
lv_draw_rect(&cur_area, mask, &cur_style, opa_scale);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user