shadow draw iprovments
This commit is contained in:
@@ -1046,8 +1046,6 @@ static void lv_draw_cont_border_corner(const area_t * cords_p, const area_t * ma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define S_OLD 0
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a shadow
|
* Draw a shadow
|
||||||
* @param rect pointer to rectangle object
|
* @param rect pointer to rectangle object
|
||||||
@@ -1074,61 +1072,11 @@ static void lv_draw_cont_shadow(const area_t * cords_p, const area_t * mask_p, c
|
|||||||
area_tmp.y2 -= radius;
|
area_tmp.y2 -= radius;
|
||||||
if(area_is_in(mask_p, &area_tmp) != false) return;
|
if(area_is_in(mask_p, &area_tmp) != false) return;
|
||||||
|
|
||||||
|
|
||||||
#if S_OLD == 0
|
|
||||||
if(style->stype == LV_STYPE_FULL) {
|
if(style->stype == LV_STYPE_FULL) {
|
||||||
lv_draw_cont_shadow_full(cords_p, mask_p, style);
|
lv_draw_cont_shadow_full(cords_p, mask_p, style);
|
||||||
} else if(style->stype == LV_STYPE_BOTTOM) {
|
} else if(style->stype == LV_STYPE_BOTTOM) {
|
||||||
lv_draw_cont_shadow_bottom(cords_p, mask_p, style);
|
lv_draw_cont_shadow_bottom(cords_p, mask_p, style);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
|
|
||||||
cord_t swidth = style->swidth;
|
|
||||||
if(swidth == 0) return;
|
|
||||||
uint8_t res = LV_DOWNSCALE * 1;
|
|
||||||
if(swidth < res) return;
|
|
||||||
|
|
||||||
area_t shadow_area;
|
|
||||||
lv_style_t shadow_style;
|
|
||||||
memcpy(&shadow_area, cords_p, sizeof(area_t));
|
|
||||||
|
|
||||||
memcpy(&shadow_style, style, sizeof(lv_style_t));
|
|
||||||
|
|
||||||
shadow_style.empty = 1;
|
|
||||||
shadow_style.bwidth = swidth;
|
|
||||||
shadow_style.radius = style->radius;
|
|
||||||
if(shadow_style.radius == LV_DRAW_CIRCLE) {
|
|
||||||
shadow_style.radius = MATH_MIN(area_get_width(cords_p), area_get_height(cords_p));
|
|
||||||
}
|
|
||||||
shadow_style.radius += swidth + 1;
|
|
||||||
shadow_style.bcolor = style->scolor;
|
|
||||||
shadow_style.bopa = style->opa;
|
|
||||||
|
|
||||||
shadow_area.x1 -= swidth - 1;
|
|
||||||
shadow_area.y1 -= swidth - 1;
|
|
||||||
shadow_area.x2 += swidth - 1;
|
|
||||||
shadow_area.y2 += swidth - 1;
|
|
||||||
|
|
||||||
cord_t i;
|
|
||||||
shadow_style.bopa = style->opa / (swidth / res);
|
|
||||||
|
|
||||||
static color_t x;
|
|
||||||
x.full = 0x1C224;
|
|
||||||
|
|
||||||
for(i = 1; i < swidth; i += res) {
|
|
||||||
x.full += 0xFCA34;
|
|
||||||
// shadow_style.bcolor.full = x.full;
|
|
||||||
lv_draw_cont_border_straight(&shadow_area, mask_p, &shadow_style);
|
|
||||||
lv_draw_cont_border_corner(&shadow_area, mask_p, &shadow_style);
|
|
||||||
shadow_style.radius -= res;
|
|
||||||
shadow_style.bwidth -= res;
|
|
||||||
shadow_area.x1 += res;
|
|
||||||
shadow_area.y1 += res;
|
|
||||||
shadow_area.x2 -= res;
|
|
||||||
shadow_area.y2 -= res;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style)
|
static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style)
|
||||||
@@ -1152,11 +1100,11 @@ static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask
|
|||||||
}
|
}
|
||||||
int16_t row;
|
int16_t row;
|
||||||
|
|
||||||
opa_t opa_h_result[LV_HOR_RES];
|
uint16_t opa_h_result[LV_HOR_RES];
|
||||||
int16_t filter_size = 2 * style->swidth + 1;
|
int16_t filter_size = 2 * style->swidth + 1;
|
||||||
|
|
||||||
for(row = 0; row < filter_size; row++) {
|
for(row = 0; row < filter_size; row++) {
|
||||||
opa_h_result[row] = (uint32_t)((uint32_t)(filter_size - row) * style->opa) / (filter_size);
|
opa_h_result[row] = (uint32_t)((uint32_t)(filter_size - row) * style->opa * 2) / (filter_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t p;
|
uint16_t p;
|
||||||
@@ -1201,7 +1149,7 @@ static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask
|
|||||||
{
|
{
|
||||||
int16_t p_tmp = p - (cruve_x[row_v] - cruve_x[row]);
|
int16_t p_tmp = p - (cruve_x[row_v] - cruve_x[row]);
|
||||||
if(p_tmp < -style->swidth) { /*Cols before the filtered shadow (still not blurred)*/
|
if(p_tmp < -style->swidth) { /*Cols before the filtered shadow (still not blurred)*/
|
||||||
opa_tmp += style->opa;
|
opa_tmp += style->opa * 2;
|
||||||
}
|
}
|
||||||
/*Cols after the filtered shadow (already no effect) */
|
/*Cols after the filtered shadow (already no effect) */
|
||||||
else if (p_tmp > style->swidth) {
|
else if (p_tmp > style->swidth) {
|
||||||
@@ -1218,7 +1166,7 @@ static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask
|
|||||||
}
|
}
|
||||||
if(swidth_out == false) {
|
if(swidth_out == false) {
|
||||||
opa_tmp = opa_tmp / (filter_size);
|
opa_tmp = opa_tmp / (filter_size);
|
||||||
opa_v_result[p] = opa_tmp;
|
opa_v_result[p] = opa_tmp > OPA_COVER ? OPA_COVER : opa_tmp;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
break;
|
break;
|
||||||
@@ -1367,7 +1315,7 @@ static void lv_draw_cont_shadow_full_straight(const area_t * cords_p, const area
|
|||||||
|
|
||||||
int16_t d;
|
int16_t d;
|
||||||
for(d = 0; d < style->swidth; d++) {
|
for(d = 0; d < style->swidth; d++) {
|
||||||
fill_fp(&sider_area, mask_p, style->scolor, map[d]);
|
fill_fp(&sider_area, mask_p, style->scolor, map[d]);
|
||||||
sider_area.x1++;
|
sider_area.x1++;
|
||||||
sider_area.x2++;
|
sider_area.x2++;
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ void lv_style_init (void)
|
|||||||
lv_style_set_mcolor(&lv_style_pretty_color, COLOR_MAKE(0x6b, 0x9a, 0xc7));
|
lv_style_set_mcolor(&lv_style_pretty_color, COLOR_MAKE(0x6b, 0x9a, 0xc7));
|
||||||
lv_style_set_gcolor(&lv_style_pretty_color, COLOR_MAKE(0x2b, 0x59, 0x8b));
|
lv_style_set_gcolor(&lv_style_pretty_color, COLOR_MAKE(0x2b, 0x59, 0x8b));
|
||||||
lv_style_set_bcolor(&lv_style_pretty_color, COLOR_MAKE(0x15, 0x2c, 0x42));
|
lv_style_set_bcolor(&lv_style_pretty_color, COLOR_MAKE(0x15, 0x2c, 0x42));
|
||||||
lv_style_set_scolor(&lv_style_pretty_color, COLOR_MAKE(0x6a, 0x8f, 0xb4));
|
lv_style_set_scolor(&lv_style_pretty_color, COLOR_GRAY);
|
||||||
lv_style_set_swidth(&lv_style_pretty_color, 0);
|
lv_style_set_swidth(&lv_style_pretty_color, 0);
|
||||||
|
|
||||||
/*Transparent style*/
|
/*Transparent style*/
|
||||||
|
|||||||
@@ -181,12 +181,9 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
|
|||||||
/**
|
/**
|
||||||
* Set a function to call when a new option is chosen
|
* Set a function to call when a new option is chosen
|
||||||
* @param ddlist pointer to a drop down list
|
* @param ddlist pointer to a drop down list
|
||||||
* @param cb pointer to a call back function. Its prototype is:
|
* @param cb pointer to a call back function
|
||||||
* parameter 1: pointer to the drop down list
|
|
||||||
* parameter 2: id of the chosen item (0 ... number of options - 1)
|
|
||||||
* return LV_ACTION_RES_INV if the drop down list is deleted in the function else LV_ACTION_RES_OK
|
|
||||||
*/
|
*/
|
||||||
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_res_t (*cb)(lv_obj_t *, uint16_t))
|
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t cb)
|
||||||
{
|
{
|
||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||||
ext->cb = cb;
|
ext->cb = cb;
|
||||||
@@ -355,7 +352,7 @@ static lv_action_res_t lv_ddlist_rel_action(lv_obj_t * ddlist, lv_dispi_t * disp
|
|||||||
ext->sel_opt = new_opt;
|
ext->sel_opt = new_opt;
|
||||||
|
|
||||||
if(ext->cb != NULL) {
|
if(ext->cb != NULL) {
|
||||||
ext->cb(ddlist, ext->sel_opt);
|
ext->cb(ddlist, dispi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if LV_DDLIST_ANIM_TIME == 0
|
#if LV_DDLIST_ANIM_TIME == 0
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ typedef struct
|
|||||||
/*New data for this type */
|
/*New data for this type */
|
||||||
lv_obj_t * opt_label; /*Label for the options*/
|
lv_obj_t * opt_label; /*Label for the options*/
|
||||||
lv_style_t * style_sel; /*Style of the selected option*/
|
lv_style_t * style_sel; /*Style of the selected option*/
|
||||||
lv_action_res_t (*cb)(lv_obj_t *, uint16_t); /*Pointer to function to call when an option is slected*/
|
lv_action_t cb; /*Pointer to function to call when an option is slected*/
|
||||||
uint16_t sel_opt; /*Index of the current option*/
|
uint16_t sel_opt; /*Index of the current option*/
|
||||||
uint8_t opened :1; /*1: The list is opened*/
|
uint8_t opened :1; /*1: The list is opened*/
|
||||||
uint8_t auto_size :1; /*1: Set height to show all options. 0: Set height maximum to the parent bottom*/
|
uint8_t auto_size :1; /*1: Set height to show all options. 0: Set height maximum to the parent bottom*/
|
||||||
@@ -73,15 +73,13 @@ void lv_ddlist_set_options(lv_obj_t * ddlist, const char ** options);
|
|||||||
*/
|
*/
|
||||||
void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt);
|
void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a function to call when a new option is chosen
|
* Set a function to call when a new option is chosen
|
||||||
* @param ddlist pointer to a drop down list
|
* @param ddlist pointer to a drop down list
|
||||||
* @param cb pointer to a call back function. Its prototype is:
|
* @param cb pointer to a call back function
|
||||||
* parameter 1: pointer to the drop down list
|
|
||||||
* parameter 2: id of the chosen item (0 ... number of options - 1)
|
|
||||||
* return LV_ACTION_RES_INV if the drop down list is deleted in the function else LV_ACTION_RES_OK
|
|
||||||
*/
|
*/
|
||||||
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_res_t (*cb)(lv_obj_t *, uint16_t));
|
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t cb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the auto size attribute. If enabled the height will reduced to be visible on the parent.
|
* Set the auto size attribute. If enabled the height will reduced to be visible on the parent.
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
#define LV_LED_WIDTH_DEF (LV_DPI / 2)
|
#define LV_LED_WIDTH_DEF (LV_DPI / 3)
|
||||||
#define LV_LED_HEIGHT_DEF (LV_DPI / 2)
|
#define LV_LED_HEIGHT_DEF (LV_DPI / 3)
|
||||||
#define LV_LED_BRIGHT_OFF 128
|
#define LV_LED_BRIGHT_OFF 128
|
||||||
#define LV_LED_BRIGHT_ON 255
|
#define LV_LED_BRIGHT_ON 255
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user