1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

integrate lv_btnm, add built-in styles, move opa_scale to styles, begin style caching

This commit is contained in:
Gabor Kiss-Vamosi 2019-12-22 22:40:02 +01:00
parent de1683a4ec
commit 095c0bff49
17 changed files with 613 additions and 476 deletions

127
a.txt
View File

@ -1,127 +0,0 @@
diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c
index f28c47eb..74f73686 100644
--- a/src/lv_draw/lv_draw_img.c
+++ b/src/lv_draw/lv_draw_img.c
@@ -406,7 +406,7 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
trans_dsc.cfg.pivot_x = map_w / 2;
trans_dsc.cfg.pivot_y = map_h / 2;
trans_dsc.cfg.color = style->image.color;
- trans_dsc.cfg.antialias = antialaias;
+ trans_dsc.cfg.antialias = true;
lv_img_buf_transform_init(&trans_dsc);
}
diff --git a/src/lv_draw/lv_img_buf.c b/src/lv_draw/lv_img_buf.c
index 2b79c7b1..89a57708 100644
--- a/src/lv_draw/lv_img_buf.c
+++ b/src/lv_draw/lv_img_buf.c
@@ -161,6 +161,68 @@ lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y)
return LV_OPA_COVER;
}
+/**
+ * Set the color of a pixel of an image. The alpha channel won't be affected.
+ * @param dsc pointer to an image descriptor
+ * @param x x coordinate of the point to set
+ * @param y x coordinate of the point to set
+ * @param c color of the point
+ * @param safe true: check out of bounds
+ */
+void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_color_t c)
+{
+ uint8_t * buf_u8 = (uint8_t *)dsc->data;
+
+ if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
+ uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
+ uint32_t px = dsc->header.w * y * px_size + x * px_size;
+ memcpy(&buf_u8[px], &c, px_size);
+ } else if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
+ uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
+ uint32_t px = dsc->header.w * y * px_size + x * px_size;
+ memcpy(&buf_u8[px], &c, px_size - 1); /*-1 to not overwrite the alpha value*/
+ } else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
+ buf_u8 += sizeof(lv_color32_t) * 2; /*Skip the palette*/
+
+ uint8_t bit = x & 0x7;
+ x = x >> 3;
+
+ /* Get the current pixel.
+ * dsc->header.w + 7 means rounding up to 8 because the lines are byte aligned
+ * so the possible real width are 8 ,16, 24 ...*/
+ uint32_t px = ((dsc->header.w + 7) >> 3) * y + x;
+ buf_u8[px] = buf_u8[px] & ~(1 << (7 - bit));
+ buf_u8[px] = buf_u8[px] | ((c.full & 0x1) << (7 - bit));
+ } else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
+ buf_u8 += sizeof(lv_color32_t) * 4; /*Skip the palette*/
+ uint8_t bit = (x & 0x3) * 2;
+ x = x >> 2;
+
+ /* Get the current pixel.
+ * dsc->header.w + 3 means rounding up to 4 because the lines are byte aligned
+ * so the possible real width are 4, 8 ,12 ...*/
+ uint32_t px = ((dsc->header.w + 3) >> 2) * y + x;
+
+ buf_u8[px] = buf_u8[px] & ~(3 << (6 - bit));
+ buf_u8[px] = buf_u8[px] | ((c.full & 0x3) << (6 - bit));
+ } else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
+ buf_u8 += sizeof(lv_color32_t) * 16; /*Skip the palette*/
+ uint8_t bit = (x & 0x1) * 4;
+ x = x >> 1;
+
+ /* Get the current pixel.
+ * dsc->header.w + 1 means rounding up to 2 because the lines are byte aligned
+ * so the possible real width are 2 ,4, 6 ...*/
+ uint32_t px = ((dsc->header.w + 1) >> 1) * y + x;
+ buf_u8[px] = buf_u8[px] & ~(0xF << (4 - bit));
+ buf_u8[px] = buf_u8[px] | ((c.full & 0xF) << (4 - bit));
+ } else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
+ buf_u8 += sizeof(lv_color32_t) * 256; /*Skip the palette*/
+ uint32_t px = dsc->header.w * y + x;
+ buf_u8[px] = c.full;
+ }
+}
+
/**
* Set the alpha value of a pixel of an image. The color won't be affected
* @param dsc pointer to an image descriptor
diff --git a/src/lv_draw/lv_img_buf.h b/src/lv_draw/lv_img_buf.h
index 2629b465..3c1d8273 100644
--- a/src/lv_draw/lv_img_buf.h
+++ b/src/lv_draw/lv_img_buf.h
@@ -205,6 +205,7 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t
*/
lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y);
+
/**
* Set the color of a pixel of an image. The alpha channel won't be affected.
* @param dsc pointer to an image descriptor
diff --git a/src/lv_objx/lv_img.c b/src/lv_objx/lv_img.c
index 982bb8d9..f792867a 100644
--- a/src/lv_objx/lv_img.c
+++ b/src/lv_objx/lv_img.c
@@ -273,7 +273,6 @@ void lv_img_set_angle(lv_obj_t * img, int16_t angle)
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
if(angle == ext->angle) return;
- lv_obj_invalidate(img);
ext->angle = angle;
lv_obj_refresh_ext_draw_pad(img);
lv_obj_invalidate(img);
@@ -296,7 +295,6 @@ void lv_img_set_zoom(lv_obj_t * img, uint16_t zoom)
if(zoom == 0) zoom = 1;
- lv_obj_invalidate(img);
ext->zoom = zoom;
lv_obj_refresh_ext_draw_pad(img);
lv_obj_invalidate(img);
@@ -533,7 +531,7 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
}
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
/*If the image has angle provide enough room for the rotated corners */
- if(ext->angle || ext->zoom != LV_IMG_ZOOM_NONE) {
+ if(ext->angle && ext->zoom) {
lv_sqrt_res_t ds;
lv_sqrt(ext->w * ext->w + ext->h * ext->h, &ds);
ds.i = (ds.i * ext->zoom + 0) >> 8; /*+10 to be sure anything won't be clipped*/

View File

@ -51,7 +51,6 @@ typedef struct _lv_event_temp_data
* STATIC PROTOTYPES
**********************/
static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff);
static inline lv_res_t get_style_prop_core(const lv_obj_t * obj, uint8_t type, lv_style_property_t prop, void * out);
static void report_style_mod_core(void * style_p, lv_obj_t * obj);
static void refresh_children_style(lv_obj_t * obj, uint8_t type);
static void delete_children(lv_obj_t * obj);
@ -210,8 +209,6 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
new_obj->hidden = 0;
new_obj->top = 0;
new_obj->protect = LV_PROTECT_NONE;
new_obj->opa_scale_en = 0;
new_obj->opa_scale = LV_OPA_COVER;
new_obj->parent_event = 0;
#if LV_USE_BIDI
new_obj->base_dir = LV_BIDI_BASE_DIR_DEF;
@ -312,8 +309,6 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const 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->parent_event = 0;
new_obj->reserved = 0;
@ -362,9 +357,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
new_obj->top = copy->top;
new_obj->parent_event = copy->parent_event;
new_obj->opa_scale_en = copy->opa_scale_en;
new_obj->protect = copy->protect;
new_obj->opa_scale = copy->opa_scale;
#if LV_USE_GROUP
/*Add to the same group*/
@ -1214,44 +1207,61 @@ void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right
//}
void lv_obj_set_style_color(lv_obj_t * obj, lv_style_property_t prop, lv_color_t color)
void lv_obj_set_style_color(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_color_t color)
{
lv_style_set_color(&obj->style_dsc.local, prop, color);
lv_style_dsc_t * style_dsc = lv_obj_get_style(obj, type);
lv_style_set_color(&style_dsc->local, prop, color);
lv_obj_refresh_style(obj, type);
}
void lv_obj_set_style_value(lv_obj_t * obj, lv_style_property_t prop, lv_style_value_t value)
void lv_obj_set_style_value(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_style_value_t value)
{
lv_style_set_value(&obj->style_dsc.local, prop, value);
lv_style_dsc_t * style_dsc = lv_obj_get_style(obj, type);
lv_style_set_value(&style_dsc->local, prop, value);
lv_obj_refresh_style(obj, type);
}
void lv_obj_set_style_opa(lv_obj_t * obj, lv_style_property_t prop, lv_opa_t opa)
void lv_obj_set_style_opa(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_opa_t opa)
{
lv_style_set_opa(&obj->style_dsc.local, prop, opa);
lv_style_dsc_t * style_dsc = lv_obj_get_style(obj, type);
lv_style_set_opa(&style_dsc->local, prop, opa);
lv_obj_refresh_style(obj, type);
}
void lv_obj_set_style_ptr(lv_obj_t * obj, lv_style_property_t prop, void * p)
void lv_obj_set_style_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, void * p)
{
lv_style_set_ptr(&obj->style_dsc.local, prop, p);
lv_style_dsc_t * style_dsc = lv_obj_get_style(obj, type);
lv_style_set_ptr(&style_dsc->local, prop, p);
lv_obj_refresh_style(obj, type);
}
void lv_obj_add_style_class(lv_obj_t * obj, uint8_t type, lv_style_t * style)
{
lv_style_classes_t * class = lv_mem_alloc(sizeof(lv_style_classes_t));
lv_style_dsc_t * style_dsc = lv_obj_get_style(obj, type);
if(style_dsc == NULL) {
LV_LOG_WARN("lv_obj_add_style_class: can't find style with `type`");
return;
}
class->style = style;
/* Insert the class to the first place.*/
class->next = style_dsc->classes;
style_dsc->classes = class;
lv_style_dsc_add_class(style_dsc, style);
lv_obj_refresh_style(obj, type);
}
void lv_obj_reset_style(lv_obj_t * obj, uint8_t type)
{
lv_style_dsc_t * style_dsc = lv_obj_get_style(obj, type);
if(style_dsc == NULL) {
LV_LOG_WARN("lv_obj_clean_styles: can't find style with `type`");
return;
}
lv_style_dsc_reset(style_dsc);
lv_obj_refresh_style(obj, type);
}
/**
* Notify an object (and its children) about its style is modified
* @param obj pointer to an object
@ -1421,34 +1431,6 @@ void lv_obj_set_base_dir(lv_obj_t * obj, lv_bidi_dir_t dir)
base_dir_refr_children(obj);
}
/**
* 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)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
obj->opa_scale_en = en ? 1 : 0;
}
/**
* Set the opa scale of an object.
* The opacity of this object and all it's children will be scaled down with this factor.
* `lv_obj_set_opa_scale_enable(obj, true)` needs to be called to enable it.
* (not for all children just for the parent where to start the opa scaling)
* @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)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
obj->opa_scale = opa_scale;
lv_obj_invalidate(obj);
}
/**
* Set a bit or bits in the protect filed
* @param obj pointer to an object
@ -1478,8 +1460,11 @@ void lv_obj_set_state(lv_obj_t * obj, lv_obj_state_t state)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
obj->state |= state;
lv_obj_refresh_style(obj, LV_OBJ_STYLE_ALL);
lv_obj_state_t new_state = obj->state | state;
if(obj->state != new_state) {
obj->state = new_state;
lv_obj_refresh_style(obj, LV_OBJ_STYLE_ALL);
}
}
void lv_obj_clear_state(lv_obj_t * obj, lv_obj_state_t state)
@ -1487,8 +1472,11 @@ void lv_obj_clear_state(lv_obj_t * obj, lv_obj_state_t state)
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
state = (~state) & 0xFF;
obj->state &= state;
lv_obj_refresh_style(obj, LV_OBJ_STYLE_ALL);
lv_obj_state_t new_state = obj->state & state;
if(obj->state != new_state) {
obj->state = new_state;
lv_obj_refresh_style(obj, LV_OBJ_STYLE_ALL);
}
}
/**
@ -2070,8 +2058,8 @@ lv_style_dsc_t * lv_obj_get_style(const lv_obj_t * obj, uint8_t type)
lv_style_value_t lv_obj_get_style_value(const lv_obj_t * obj, uint8_t type, lv_style_property_t prop)
{
uint8_t state = lv_obj_get_state(obj);
prop = (uint16_t)prop + ((uint16_t)state << LV_STYLE_STATE_POS);
uint8_t state;
lv_style_property_t prop_ori = prop;
lv_style_attr_t attr;
attr.full = prop >> 8;
@ -2085,6 +2073,9 @@ lv_style_value_t lv_obj_get_style_value(const lv_obj_t * obj, uint8_t type, lv_s
lv_style_dsc_t * dsc = lv_obj_get_style(parent, type);
if(dsc == NULL) continue;
state = lv_obj_get_state(parent);
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
int16_t weight_act;
lv_style_value_t value_act;
weight_act = lv_style_get_value(&dsc->local, prop, &value_act);
@ -2099,9 +2090,9 @@ lv_style_value_t lv_obj_get_style_value(const lv_obj_t * obj, uint8_t type, lv_s
value = value_act;
}
const lv_style_classes_t * classes = obj->style_dsc.classes;
while(classes) {
weight_act = lv_style_get_value(classes->style, prop, &value_act);
int16_t ci;
for(ci = dsc->class_cnt - 1; ci >= 0; ci--) {
weight_act = lv_style_get_value(dsc->classes[ci], prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
return value_act;
@ -2111,11 +2102,17 @@ lv_style_value_t lv_obj_get_style_value(const lv_obj_t * obj, uint8_t type, lv_s
weight = weight_act;
value = value_act;
}
classes = classes->next;
}
if(attr.bits.inherit == 0) break;
/*If not found, check the `MAIN` style first*/
if(type != LV_OBJ_STYLE_MAIN) {
type = LV_OBJ_STYLE_MAIN;
continue;
}
/*Check the parent too.*/
parent = lv_obj_get_parent(parent);
}
@ -2132,8 +2129,8 @@ lv_style_value_t lv_obj_get_style_value(const lv_obj_t * obj, uint8_t type, lv_s
lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t type, lv_style_property_t prop)
{
uint8_t state = lv_obj_get_state(obj);
prop = (uint16_t)prop + ((uint16_t)state << LV_STYLE_STATE_POS);
uint8_t state;
lv_style_property_t prop_ori = prop;
lv_style_attr_t attr;
attr.full = prop >> 8;
@ -2146,6 +2143,10 @@ lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t type, lv_style_p
while(parent) {
lv_style_dsc_t * dsc = lv_obj_get_style(parent, type);
if(dsc == NULL) continue;
state = lv_obj_get_state(parent);
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
int16_t weight_act;
lv_color_t value_act;
weight_act = lv_style_get_color(&dsc->local, prop, &value_act);
@ -2160,9 +2161,9 @@ lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t type, lv_style_p
value = value_act;
}
const lv_style_classes_t * classes = obj->style_dsc.classes;
while(classes) {
weight_act = lv_style_get_color(classes->style, prop, &value_act);
int16_t ci;
for(ci = dsc->class_cnt - 1; ci >= 0; ci--) {
weight_act = lv_style_get_color(dsc->classes[ci], prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
return value_act;
@ -2172,20 +2173,29 @@ lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t type, lv_style_p
weight = weight_act;
value = value_act;
}
classes = classes->next;
}
if(attr.bits.inherit == 0) break;
/*If not found, check the `MAIN` style first*/
if(type != LV_OBJ_STYLE_MAIN) {
type = LV_OBJ_STYLE_MAIN;
continue;
}
/*Check the parent too.*/
parent = lv_obj_get_parent(parent);
}
if(weight >= 0) return value;
/*Handle unset values*/
prop = prop & (~LV_STYLE_STATE_MASK);
switch(prop) {
case LV_STYLE_TEXT_COLOR:
return LV_COLOR_BLACK;
case LV_STYLE_BORDER_COLOR:
return LV_COLOR_BLACK;
}
return LV_COLOR_WHITE;
@ -2193,8 +2203,8 @@ lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t type, lv_style_p
lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t type, lv_style_property_t prop)
{
uint8_t state = lv_obj_get_state(obj);
prop = (uint16_t)prop + ((uint16_t)state << LV_STYLE_STATE_POS);
uint8_t state;
lv_style_property_t prop_ori = prop;
lv_style_attr_t attr;
attr.full = prop >> 8;
@ -2208,6 +2218,9 @@ lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t type, lv_style_prope
lv_style_dsc_t * dsc = lv_obj_get_style(parent, type);
if(dsc == NULL) continue;
state = lv_obj_get_state(parent);
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
int16_t weight_act;
lv_opa_t value_act;
weight_act = lv_style_get_opa(&dsc->local, prop, &value_act);
@ -2222,9 +2235,9 @@ lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t type, lv_style_prope
value = value_act;
}
const lv_style_classes_t * classes = obj->style_dsc.classes;
while(classes) {
weight_act = lv_style_get_opa(classes->style, prop, &value_act);
int16_t ci;
for(ci = dsc->class_cnt - 1; ci >= 0; ci--) {
weight_act = lv_style_get_opa(dsc->classes[ci], prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
return value_act;
@ -2234,11 +2247,17 @@ lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t type, lv_style_prope
weight = weight_act;
value = value_act;
}
classes = classes->next;
}
if(attr.bits.inherit == 0) break;
/*If not found, check the `MAIN` style first*/
if(type != LV_OBJ_STYLE_MAIN) {
type = LV_OBJ_STYLE_MAIN;
continue;
}
/*Check the parent too.*/
parent = lv_obj_get_parent(parent);
}
@ -2250,8 +2269,8 @@ lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t type, lv_style_prope
void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t type, lv_style_property_t prop)
{
uint8_t state = lv_obj_get_state(obj);
prop = (uint16_t)prop + ((uint16_t)state << LV_STYLE_STATE_POS);
uint8_t state;
lv_style_property_t prop_ori = prop;
lv_style_attr_t attr;
attr.full = prop >> 8;
@ -2265,6 +2284,9 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t type, lv_style_propert
lv_style_dsc_t * dsc = lv_obj_get_style(parent, type);
if(dsc == NULL) continue;
state = lv_obj_get_state(parent);
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
int16_t weight_act;
void * value_act;
weight_act = lv_style_get_ptr(&dsc->local, prop, &value_act);
@ -2279,9 +2301,9 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t type, lv_style_propert
value = value_act;
}
const lv_style_classes_t * classes = obj->style_dsc.classes;
while(classes) {
weight_act = lv_style_get_ptr(classes->style, prop, &value_act);
int16_t ci;
for(ci = dsc->class_cnt - 1; ci >= 0; ci--) {
weight_act = lv_style_get_ptr(dsc->classes[ci], prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
return value_act;
@ -2291,11 +2313,17 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t type, lv_style_propert
weight = weight_act;
value = value_act;
}
classes = classes->next;
}
if(attr.bits.inherit == 0) break;
/*If not found, check the `MAIN` style first*/
if(type != LV_OBJ_STYLE_MAIN) {
type = LV_OBJ_STYLE_MAIN;
continue;
}
/*Check the parent too.*/
parent = lv_obj_get_parent(parent);
}
@ -2428,38 +2456,6 @@ lv_bidi_dir_t lv_obj_get_base_dir(const lv_obj_t * obj)
#endif
}
/**
* 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(const lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
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(const lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
const 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
@ -2488,14 +2484,8 @@ bool lv_obj_is_protected(const lv_obj_t * obj, uint8_t prot)
lv_obj_state_t lv_obj_get_state(const lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
uint8_t state = 0;
const lv_obj_t * parent = obj;
while(parent) {
state |= parent->state;
parent = lv_obj_get_parent(parent);
}
return state;
return obj->state;
}
/**
@ -2696,16 +2686,29 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t type, lv_draw_rect_dsc_t
{
draw_dsc->radius = lv_obj_get_style_value(obj, type, LV_STYLE_RADIUS);
draw_dsc->bg_color = lv_obj_get_style_color(obj, type, LV_STYLE_BG_COLOR);
draw_dsc->bg_opa = lv_obj_get_style_opa(obj, type, LV_STYLE_BG_OPA);
if(draw_dsc->bg_opa > LV_OPA_MIN) {
draw_dsc->bg_color = lv_obj_get_style_color(obj, type, LV_STYLE_BG_COLOR);
draw_dsc->bg_grad_dir = lv_obj_get_style_value(obj, type, LV_STYLE_BG_GRAD_DIR);
if(draw_dsc->bg_grad_dir != LV_GRAD_DIR_NONE) {
draw_dsc->bg_grad_color = lv_obj_get_style_color(obj, type, LV_STYLE_BG_GRAD_COLOR);
}
}
draw_dsc->border_width = lv_obj_get_style_value(obj, type, LV_STYLE_BORDER_WIDTH);
if(draw_dsc->border_width) {
draw_dsc->border_opa = lv_obj_get_style_opa(obj, type, LV_STYLE_BORDER_OPA);
if(draw_dsc->border_opa >= LV_OPA_MIN) {
if(draw_dsc->border_opa > LV_OPA_MIN) {
draw_dsc->border_part = lv_obj_get_style_value(obj, type, LV_STYLE_BORDER_PART);
draw_dsc->border_color = lv_obj_get_style_color(obj, type, LV_STYLE_BORDER_COLOR);
}
}
lv_opa_t opa_scale = lv_obj_get_style_opa(obj, type, LV_STYLE_OPA_SCALE);
if(opa_scale < LV_OPA_MAX) {
draw_dsc->bg_opa = (uint16_t)((uint16_t)draw_dsc->bg_opa * opa_scale) >> 8;
draw_dsc->border_opa = (uint16_t)((uint16_t)draw_dsc->border_opa * opa_scale) >> 8;
}
}
void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t type, lv_draw_label_dsc_t * draw_dsc)
@ -2713,6 +2716,11 @@ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t type, lv_draw_label_dsc_
draw_dsc->color = lv_obj_get_style_color(obj, type, LV_STYLE_TEXT_COLOR);
draw_dsc->font = lv_obj_get_style_ptr(obj, type, LV_STYLE_FONT);
lv_opa_t opa_scale = lv_obj_get_style_opa(obj, type, LV_STYLE_OPA_SCALE);
if(opa_scale < LV_OPA_MAX) {
draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8;
}
}
/**
@ -2730,13 +2738,14 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area
/*Most trivial test. Is the mask fully IN the object? If no it surely doesn't cover it*/
if(lv_area_is_in(clip_area, &obj->coords) == false) return LV_DESIGN_RES_NOT_COVER;
if(lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_BG_CLIP_CORNER)) return LV_DESIGN_RES_MASKED;
if(lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_BG_BLEND_MODE) != LV_BLEND_MODE_NORMAL) return LV_DESIGN_RES_NOT_COVER;
if(lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_BORDER_BLEND_MODE) != LV_BLEND_MODE_NORMAL) return LV_DESIGN_RES_NOT_COVER;
if(lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_BG_CLIP_CORNER)) return LV_DESIGN_RES_MASKED;
/*Can cover the area only if fully solid (no opacity)*/
if(lv_obj_get_style_opa(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_BG_OPA) < LV_OPA_MAX) return LV_DESIGN_RES_NOT_COVER;
if(lv_obj_get_style_opa(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_OPA_SCALE) < LV_OPA_MAX) return LV_DESIGN_RES_NOT_COVER;
/* Because of the radius it is not sure the area is covered
* Check the areas where there is no radius*/
@ -2765,7 +2774,7 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area
lv_draw_rect_dsc_t draw_dsc;
lv_draw_rect_dsc_init(&draw_dsc);
lv_obj_init_draw_rect_dsc(obj, LV_OBJ_STYLE_MAIN, &draw_dsc);
lv_draw_rect(&obj->coords, clip_area, &draw_dsc, lv_obj_get_opa_scale(obj));
lv_draw_rect(&obj->coords, clip_area, &draw_dsc);
if(lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_BG_CLIP_CORNER)) {
lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));

View File

@ -187,7 +187,7 @@ typedef struct
uint8_t auto_realign : 1;
uint8_t origo_align : 1; /**< 1: the origo (center of the object) was aligned with
`lv_obj_align_origo`*/
} lv_reailgn_t;
} lv_realign_t;
#endif
/*Protect some attributes (max. 8 bit)*/
@ -249,7 +249,6 @@ typedef struct _lv_obj_t
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*/
uint8_t parent_event : 1; /**< 1: Send the object's events to the parent too. */
lv_drag_dir_t drag_dir : 3; /**< Which directions the object can be dragged in */
lv_bidi_dir_t base_dir : 2; /**< Base direction of texts related to this object */
@ -257,12 +256,11 @@ typedef struct _lv_obj_t
uint8_t protect; /**< Automatically happening actions can be prevented. 'OR'ed values from
`lv_protect_t`*/
uint8_t state;
lv_opa_t opa_scale; /**< Scale down the opacity by this factor. Effects all children as well*/
lv_coord_t ext_draw_pad; /**< EXTtend the size in every direction for drawing. */
#if LV_USE_OBJ_REALIGN
lv_reailgn_t realign; /**< Information about the last call to ::lv_obj_align. */
lv_realign_t realign; /**< Information about the last call to ::lv_obj_align. */
#endif
#if LV_USE_USER_DATA
@ -464,15 +462,19 @@ void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right
*/
void lv_obj_set_style(lv_obj_t * obj, const lv_style_t * style);
void lv_obj_set_style_color(lv_obj_t * obj, lv_style_property_t prop, lv_color_t color);
void lv_obj_set_style_color(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_color_t color);
void lv_obj_set_style_value(lv_obj_t * obj, lv_style_property_t prop, lv_style_value_t value);
void lv_obj_set_style_value(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_style_value_t value);
void lv_obj_set_style_opa(lv_obj_t * obj, lv_style_property_t prop, lv_opa_t opa);
void lv_obj_set_style_opa(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_opa_t opa);
void lv_obj_set_style_ptr(lv_obj_t * obj, lv_style_property_t prop, void * p);
void lv_obj_set_style_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, void * p);
void lv_obj_add_style_class(lv_obj_t * obj, uint8_t type, lv_style_t * style);
void lv_obj_reset_style(lv_obj_t * obj, uint8_t type);
/**
* Notify an object about its style is modified
* @param obj pointer to an object
@ -580,6 +582,10 @@ void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot);
*/
void lv_obj_clear_protect(lv_obj_t * obj, uint8_t prot);
void lv_obj_set_state(lv_obj_t * obj, lv_obj_state_t state);
void lv_obj_clear_state(lv_obj_t * obj, lv_obj_state_t state);
/**
* Set a an event handler function for an object.
* Used by the user to react on event which happens with the object.

View File

@ -435,8 +435,7 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
/*If no better children check this object*/
if(found_p == NULL) {
if(design_res == LV_DESIGN_RES_COVER &&
lv_obj_get_opa_scale(obj) == LV_OPA_COVER) {
if(design_res == LV_DESIGN_RES_COVER) {
found_p = obj;
}
}

View File

@ -41,6 +41,31 @@ static void style_animator(lv_style_anim_dsc_t * dsc, lv_anim_value_t val);
static void style_animation_common_end_cb(lv_anim_t * a);
#endif
/**********************
* GLOABAL VARIABLES
**********************/
/*Basic styles*/
lv_style_t lv_style_plain;
lv_style_t lv_style_panel;
lv_style_t lv_style_panel;
lv_style_t lv_style_btn;
/*Color styles*/
lv_style_t lv_style_dark;
lv_style_t lv_style_light;
lv_style_t lv_style_red;
lv_style_t lv_style_green;
lv_style_t lv_style_blue;
/*Transparent styles*/
lv_style_t lv_style_transp;
lv_style_t lv_style_frame;
/*Padding styles*/
lv_style_t lv_style_tight;
lv_style_t lv_style_fit;
/**********************
* STATIC VARIABLES
**********************/
@ -59,6 +84,107 @@ static void style_animation_common_end_cb(lv_anim_t * a);
void lv_style_built_in_init(void)
{
lv_mem_monitor_t mon;
lv_mem_monitor(&mon);
printf("used: %6d (%3d %%), frag: %3d %%, biggest free: %6d\n", (int)mon.total_size - mon.free_size,
mon.used_pct,
mon.frag_pct,
(int)mon.free_biggest_size);
/*Basic styles*/
lv_style_init(&lv_style_plain);
lv_style_set_value(&lv_style_plain, LV_STYLE_PAD_LEFT, LV_DPI / 12);
lv_style_set_value(&lv_style_plain, LV_STYLE_PAD_RIGHT, LV_DPI / 12);
lv_style_set_value(&lv_style_plain, LV_STYLE_PAD_TOP, LV_DPI / 12);
lv_style_set_value(&lv_style_plain, LV_STYLE_PAD_BOTTOM, LV_DPI / 12);
lv_style_set_value(&lv_style_plain, LV_STYLE_PAD_INNER, LV_DPI / 16);
lv_style_init(&lv_style_panel);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_LEFT, LV_DPI / 12);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_RIGHT, LV_DPI / 12);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_TOP, LV_DPI / 12);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_BOTTOM, LV_DPI / 12);
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_INNER, LV_DPI / 20);
lv_style_set_value(&lv_style_panel, LV_STYLE_RADIUS, LV_DPI / 16);
lv_style_set_value(&lv_style_panel, LV_STYLE_BORDER_WIDTH, LV_DPI / 50 > 0 ? LV_DPI / 50 : 1);
lv_style_set_color(&lv_style_panel, LV_STYLE_BG_COLOR, LV_COLOR_SILVER);
lv_style_set_color(&lv_style_panel, LV_STYLE_BG_GRAD_COLOR, LV_COLOR_GRAY);
lv_style_set_color(&lv_style_panel, LV_STYLE_BORDER_COLOR, LV_COLOR_GRAY);
lv_style_init(&lv_style_btn);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_LEFT, LV_DPI / 6);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_RIGHT, LV_DPI / 6);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_TOP, LV_DPI / 10);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_BOTTOM, LV_DPI / 10);
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_INNER, LV_DPI / 16);
lv_style_set_value(&lv_style_btn, LV_STYLE_RADIUS, LV_DPI / 20);
lv_style_set_value(&lv_style_btn, LV_STYLE_BORDER_WIDTH, LV_DPI / 50 > 0 ? LV_DPI / 50 : 1);
lv_style_set_value(&lv_style_btn, LV_STYLE_BG_GRAD_DIR, LV_GRAD_DIR_VER);
lv_style_set_color(&lv_style_btn, LV_STYLE_BG_COLOR, LV_COLOR_BLUE);
lv_style_set_color(&lv_style_btn, LV_STYLE_BG_GRAD_COLOR, LV_COLOR_NAVY);
lv_style_set_color(&lv_style_btn, LV_STYLE_BORDER_COLOR, LV_COLOR_NAVY);
lv_style_set_color(&lv_style_btn, LV_STYLE_BG_GRAD_COLOR | LV_STYLE_STATE_PRESSED, LV_COLOR_BLACK);
lv_style_set_color(&lv_style_btn, LV_STYLE_TEXT_COLOR, LV_COLOR_WHITE);
/*Color styles*/
lv_style_init(&lv_style_light);
lv_style_set_color(&lv_style_light, LV_STYLE_BG_COLOR, LV_COLOR_SILVER);
lv_style_set_color(&lv_style_light, LV_STYLE_BG_GRAD_COLOR, LV_COLOR_GRAY);
lv_style_set_color(&lv_style_light, LV_STYLE_BORDER_COLOR, LV_COLOR_GRAY);
lv_style_init(&lv_style_dark);
lv_style_set_color(&lv_style_dark, LV_STYLE_BG_COLOR, lv_color_hex3(0x444));
lv_style_set_color(&lv_style_dark, LV_STYLE_BG_GRAD_COLOR, lv_color_hex3(0x222));
lv_style_set_color(&lv_style_dark, LV_STYLE_BORDER_COLOR, LV_COLOR_GRAY);
lv_style_set_color(&lv_style_blue, LV_STYLE_TEXT_COLOR, LV_COLOR_WHITE);
lv_style_init(&lv_style_red);
lv_style_set_color(&lv_style_red, LV_STYLE_BG_COLOR, LV_COLOR_RED);
lv_style_set_color(&lv_style_red, LV_STYLE_BG_GRAD_COLOR, LV_COLOR_MAROON);
lv_style_set_color(&lv_style_red, LV_STYLE_BORDER_COLOR, LV_COLOR_MAROON);
lv_style_set_color(&lv_style_blue, LV_STYLE_TEXT_COLOR, LV_COLOR_WHITE);
lv_style_init(&lv_style_green);
lv_style_set_color(&lv_style_green, LV_STYLE_BG_COLOR, LV_COLOR_LIME);
lv_style_set_color(&lv_style_green, LV_STYLE_BG_GRAD_COLOR, LV_COLOR_GREEN);
lv_style_set_color(&lv_style_green, LV_STYLE_BORDER_COLOR, LV_COLOR_GREEN);
lv_style_set_color(&lv_style_blue, LV_STYLE_TEXT_COLOR, LV_COLOR_WHITE);
lv_style_init(&lv_style_blue);
lv_style_set_color(&lv_style_blue, LV_STYLE_BG_COLOR, LV_COLOR_BLUE);
lv_style_set_color(&lv_style_blue, LV_STYLE_BG_GRAD_COLOR, LV_COLOR_NAVY);
lv_style_set_color(&lv_style_blue, LV_STYLE_BORDER_COLOR, LV_COLOR_NAVY);
lv_style_set_color(&lv_style_blue, LV_STYLE_BG_GRAD_COLOR | LV_STYLE_STATE_PRESSED, LV_COLOR_BLACK);
lv_style_set_color(&lv_style_blue, LV_STYLE_TEXT_COLOR, LV_COLOR_WHITE);
/*Transparent styles*/
lv_style_init(&lv_style_transp);
lv_style_set_opa(&lv_style_transp, LV_STYLE_BG_OPA, LV_OPA_TRANSP);
lv_style_set_opa(&lv_style_transp, LV_STYLE_BORDER_OPA, LV_OPA_TRANSP);
lv_style_init(&lv_style_frame);
lv_style_set_opa(&lv_style_frame, LV_STYLE_BG_OPA, LV_OPA_TRANSP);
/*Padding styles*/
lv_style_init(&lv_style_tight);
lv_style_set_value(&lv_style_tight, LV_STYLE_PAD_LEFT, 0);
lv_style_set_value(&lv_style_tight, LV_STYLE_PAD_RIGHT, 0);
lv_style_set_value(&lv_style_tight, LV_STYLE_PAD_TOP, 0);
lv_style_set_value(&lv_style_tight, LV_STYLE_PAD_BOTTOM, 0);
lv_style_set_value(&lv_style_tight, LV_STYLE_PAD_INNER, 0);
lv_style_init(&lv_style_fit);
lv_style_set_value(&lv_style_fit, LV_STYLE_PAD_LEFT, 0);
lv_style_set_value(&lv_style_fit, LV_STYLE_PAD_RIGHT, 0);
lv_style_set_value(&lv_style_fit, LV_STYLE_PAD_TOP, 0);
lv_style_set_value(&lv_style_fit, LV_STYLE_PAD_BOTTOM, 0);
lv_mem_monitor(&mon);
printf("used: %6d (%3d %%), frag: %3d %%, biggest free: %6d\n", (int)mon.total_size - mon.free_size,
mon.used_pct,
mon.frag_pct,
(int)mon.free_biggest_size);
}
void lv_style_init(lv_style_t * style)
@ -72,6 +198,62 @@ void lv_style_dsc_init(lv_style_dsc_t * style_dsc)
{
lv_style_init(&style_dsc->local);
style_dsc->classes = NULL;
style_dsc->class_cnt = 0;
}
void lv_style_dsc_add_class(lv_style_dsc_t * style_dsc, lv_style_t * class)
{
lv_style_t ** new_classes = lv_mem_realloc(style_dsc->classes, sizeof(lv_style_t *) * (style_dsc->class_cnt + 1));
LV_ASSERT_MEM(new_classes);
if(new_classes == NULL) {
LV_LOG_WARN("lv_style_dsc_add_class: couldn't add the class");
return;
}
new_classes[style_dsc->class_cnt] = class;
style_dsc->class_cnt++;
style_dsc->classes = new_classes;
}
void lv_style_dsc_remove_class(lv_style_dsc_t * style_dsc, lv_style_t * class)
{
if(style_dsc->class_cnt == 0) return;
lv_style_t ** new_classes = lv_mem_realloc(style_dsc->classes, sizeof(lv_style_t *) * (style_dsc->class_cnt - 1));
LV_ASSERT_MEM(new_classes);
if(new_classes == NULL) {
LV_LOG_WARN("lv_style_dsc_remove_class: couldn't remove the class");
return;
}
uint8_t i,j;
for(i = 0, j = 0; i < style_dsc->class_cnt; i++) {
if(style_dsc->classes[i] == class) continue;
new_classes[j] = style_dsc->classes[i];
j++;
}
style_dsc->class_cnt--;
style_dsc->classes = new_classes;
}
void lv_style_dsc_reset(lv_style_dsc_t * style_dsc)
{
lv_mem_free(style_dsc->classes);
style_dsc->classes = NULL;
style_dsc->class_cnt = 0;
lv_style_reset(&style_dsc->local);
}
void lv_style_reset(lv_style_t * style)
{
lv_mem_free(style->map);
style->map = NULL;
style->size = 0;
style->used_groups = 0;
}
/**
@ -109,6 +291,10 @@ void lv_style_set_value(lv_style_t * style, lv_style_property_t prop, lv_style_v
memcpy(style->map + style->size - (sizeof(lv_style_property_t) + sizeof(lv_style_value_t)), &prop, sizeof(lv_style_property_t));
memcpy(style->map + style->size - sizeof(lv_style_value_t), &value, sizeof(lv_style_value_t));
/*Set that group is used this style*/
uint16_t group = (prop >> 4) & 0xF;
style->used_groups |= 1 << group;
}
void lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_t color)
@ -136,6 +322,10 @@ void lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_t
memcpy(style->map + style->size - (sizeof(lv_style_property_t) + sizeof(lv_color_t)), &prop, sizeof(lv_style_property_t));
memcpy(style->map + style->size - sizeof(lv_color_t), &color, sizeof(lv_color_t));
/*Set that group is used this style*/
uint16_t group = (prop >> 4) & 0xF;
style->used_groups |= 1 << group;
}
void lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t opa)
@ -163,6 +353,10 @@ void lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t opa
memcpy(style->map + style->size - (sizeof(lv_style_property_t) + sizeof(lv_opa_t)), &prop, sizeof(lv_style_property_t));
memcpy(style->map + style->size - sizeof(lv_opa_t), &opa, sizeof(lv_opa_t));
/*Set that group is used this style*/
uint16_t group = (prop >> 4) & 0xF;
style->used_groups |= 1 << group;
}
void lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, void * p)
@ -190,6 +384,10 @@ void lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, void * p)
memcpy(style->map + style->size - (sizeof(lv_style_property_t) + sizeof(void *)), &prop, sizeof(lv_style_property_t));
memcpy(style->map + style->size - sizeof(void *), &p, sizeof(void *));
/*Set that group is used this style*/
uint16_t group = (prop >> 4) & 0xF;
style->used_groups |= 1 << group;
}
@ -366,15 +564,40 @@ void lv_style_anim_set_styles(lv_anim_t * a, lv_style_t * to_anim, const lv_styl
static inline int32_t get_property_index(const lv_style_t * style, lv_style_property_t prop)
{
static uint32_t stat[256];
static uint32_t s = 0;
uint8_t id_to_find = prop & 0xFF;
lv_style_attr_t attr;
attr.full = (prop >> 8) & 0xFF;
stat[id_to_find]++;
// if(s > 1000) {
// printf("\n\n");
// s = 0;
// uint32_t i;
// for(i = 0; i < 256; i++) {
// if(stat[i] == 0) continue;
// printf("%02x;%d;\n", i, stat[i]);
// }
// }
int16_t weight = -1;
int16_t id_guess = -1;
uint16_t group = (id_to_find >> 4) & 0xF;
if((style->used_groups & (1 << group)) == 0) return id_guess;
size_t i = 0;
while(i < style->size) {
// s++;
// printf("style search:%d\n", s);
lv_style_attr_t attr_act;
attr_act.full = style->map[i + 1];
if(style->map[i] == id_to_find) {

View File

@ -76,6 +76,7 @@ typedef union {
enum {
LV_STYLE_PROP_INIT(LV_STYLE_RADIUS, 0x0, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OPA_SCALE, 0x0, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_PAD_TOP, 0x1, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PAD_BOTTOM, 0x1, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
@ -85,7 +86,9 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_BG_CLIP_CORNER, 0x2, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_BLEND_MODE, 0x2, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_GRAD_DIR, 0x2, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_MAIN_COLOR_STOP, 0x2, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_GRAD_COLOR_STOP, 0x2, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_GRAD_DIR, 0x2, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_COLOR, 0x2, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_GRAD_COLOR, 0x2, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BG_OPA, 0x2, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
@ -96,7 +99,6 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_BORDER_COLOR, 0x3, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BORDER_OPA, 0x3, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_WIDTH, 0x4, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFFSET_X, 0x4, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFFSET_Y, 0x4, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
@ -139,14 +141,35 @@ typedef struct {
uint16_t reserved :7;
}lv_style_t;
typedef struct _lv_style_classes_t {
lv_style_t * style;
struct _lv_style_classes_t * next;
}lv_style_classes_t;
typedef struct {
const lv_font_t * font;
lv_color_t bg_color;
lv_color_t text_color;
lv_style_value_t radius;
lv_style_value_t pad_left;
lv_style_value_t pad_right;
lv_style_value_t pad_top;
lv_style_value_t pad_bottom;
lv_style_value_t pad_inner;
lv_style_value_t border_width;
lv_style_value_t shadow_width;
lv_style_value_t letter_space;
lv_style_value_t line_space;
lv_style_value_t bg_grad_dir;
lv_opa_t opa_scale;
lv_opa_t bg_opa;
lv_opa_t border_opa;
lv_opa_t txt_opa;
lv_opa_t img_opa;
}lv_style_cache_t;
typedef struct {
lv_style_t local;
lv_style_classes_t * classes;
lv_style_t ** classes;
uint8_t class_cnt;
#if LV_STYLE_CACHING
lv_style_cache_t cache;
#endif
}lv_style_dsc_t;
@ -178,6 +201,14 @@ void lv_style_init(lv_style_t * style);
void lv_style_dsc_init(lv_style_dsc_t * style_dsc);
void lv_style_dsc_add_class(lv_style_dsc_t * style_dsc, lv_style_t * style);
void lv_style_dsc_remove_class(lv_style_dsc_t * style_dsc, lv_style_t * class);
void lv_style_dsc_reset(lv_style_dsc_t * style_dsc);
void lv_style_reset(lv_style_t * style);
/**
* Copy a style to an other
* @param dest pointer to the destination style
@ -302,19 +333,27 @@ static inline void lv_style_anim_create(lv_anim_t * a)
/*************************
* GLOBAL VARIABLES
*************************/
//extern lv_style_t lv_style_scr;
//extern lv_style_t lv_style_transp;
//extern lv_style_t lv_style_transp_fit;
//extern lv_style_t lv_style_transp_tight;
//extern lv_style_t lv_style_plain;
//extern lv_style_t lv_style_plain_color;
//extern lv_style_t lv_style_pretty;
//extern lv_style_t lv_style_pretty_color;
//extern lv_style_t lv_style_btn_rel;
//extern lv_style_t lv_style_btn_pr;
//extern lv_style_t lv_style_btn_tgl_rel;
//extern lv_style_t lv_style_btn_tgl_pr;
//extern lv_style_t lv_style_btn_ina;
/*Basic styles*/
extern lv_style_t lv_style_plain;
extern lv_style_t lv_style_panel;
extern lv_style_t lv_style_panel;
extern lv_style_t lv_style_btn;
/*Color styles*/
extern lv_style_t lv_style_dark;
extern lv_style_t lv_style_light;
extern lv_style_t lv_style_red;
extern lv_style_t lv_style_green;
extern lv_style_t lv_style_blue;
/*Transparent styles*/
extern lv_style_t lv_style_transp;
extern lv_style_t lv_style_frame;
/*Padding styles*/
extern lv_style_t lv_style_tight;
extern lv_style_t lv_style_fit;
/**********************
* MACROS

View File

@ -63,7 +63,7 @@ void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc)
{
memset(dsc, 0x00, sizeof(lv_draw_label_dsc_t));
dsc->opa = LV_OPA_COVER;
dsc->color = LV_COLOR_RED;
dsc->color = LV_COLOR_BLACK;
dsc->font = LV_FONT_DEFAULT;
dsc->sel_start = LV_DRAW_LABEL_NO_TXT_SEL;
dsc->sel_end = LV_DRAW_LABEL_NO_TXT_SEL;
@ -75,15 +75,11 @@ void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc)
* Write a text
* @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
* @paramdsc->flag settings for the text from 'txt_flag_t' enum
* @param offset text offset in x and y direction (NULL if unused)
* @param sel make the text selected in the range by drawing a background there
* @param dsc pointer to draw descriptor
* @param txt `\0` terminated text to write
*/
void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_label_dsc_t * dsc,
const char * txt, lv_opa_t opa_scale, lv_draw_label_hint_t * hint)
const char * txt, lv_draw_label_hint_t * hint)
{
const lv_font_t * font = dsc->font;
lv_coord_t w;
@ -167,7 +163,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
pos.x += lv_area_get_width(coords) - line_width;
}
lv_opa_t opa = opa_scale == LV_OPA_COVER ? dsc->opa : (uint16_t)((uint16_t)dsc->opa * opa_scale) >> 8;
lv_opa_t opa = dsc->opa;
uint16_t sel_start = dsc->sel_start;
uint16_t sel_end = dsc->sel_end;

View File

@ -63,20 +63,16 @@ typedef struct {
void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc);
/**
* Write a text
* @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)
* @param sel_start start index of selected area (`LV_LABEL_TXT_SEL_OFF` if none)
* @param bidi_dir base direction of the text
* @param dsc pointer to draw descriptor
* @param txt `\0` terminated text to write
*/
void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_label_dsc_t * dsc,
const char * txt, lv_opa_t opa_scale, lv_draw_label_hint_t * hint);
const char * txt, lv_draw_label_hint_t * hint);
/**********************
* MACROS

View File

@ -26,9 +26,9 @@
/**********************
* STATIC PROTOTYPES
**********************/
static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc, lv_opa_t opa_scale);
static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc, lv_opa_t opa_scale);
static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc, lv_opa_t opa_scale);
static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
static lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i);
static void shadow_draw_corner_buf(const lv_area_t * coords, lv_opa_t * sh_buf, lv_coord_t s, lv_coord_t r);
static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, lv_opa_t * res_buf, uint16_t * sh_ups_buf);
@ -49,7 +49,9 @@ void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
{
memset(dsc, 0x00, sizeof(lv_draw_rect_dsc_t));
dsc->bg_opa = LV_OPA_COVER;
dsc->bg_grad_color_stop = 0xFF;
dsc->border_opa = LV_OPA_COVER;
}
/**
@ -57,15 +59,14 @@ void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
* @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 * clip, lv_draw_rect_dsc_t * dsc, lv_opa_t opa_scale)
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
{
if(lv_area_get_height(coords) < 1 || lv_area_get_width(coords) < 1) return;
draw_shadow(coords, clip, dsc, opa_scale);
draw_bg(coords, clip, dsc, opa_scale);
draw_border(coords, clip, dsc, opa_scale);
draw_shadow(coords, clip, dsc);
draw_bg(coords, clip, dsc);
draw_border(coords, clip, dsc);
}
/**
@ -75,7 +76,7 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect
* @param style pointer to a style
* @param opa_scale scale down the opacity by the factor
*/
void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style, lv_opa_t opa_scale)
void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style)
{
// lv_opa_t opa = style->body.opa;
// if(opa_scale != LV_OPA_COVER) opa = (opa * opa_scale) >> 8;
@ -104,7 +105,7 @@ void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_
* STATIC FUNCTIONS
**********************/
static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc, lv_opa_t opa_scale)
static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
{
lv_area_t coords_bg;
lv_area_copy(&coords_bg, coords);
@ -118,7 +119,6 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
}
lv_opa_t opa = dsc->bg_opa;
if(opa_scale != LV_OPA_COVER) opa = (opa * opa_scale) >> 8;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
@ -275,13 +275,12 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
}
static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc, lv_opa_t opa_scale)
static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
{
lv_coord_t border_width = dsc->border_width;
if(border_width == 0) return;
lv_opa_t opa = dsc->border_opa;
if(opa_scale != LV_OPA_COVER) opa = (opa * opa_scale) >> 8;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
@ -474,20 +473,20 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
static lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i)
{
// lv_coord_t min = (style->body.main_color_stop * s) >> 8;
// if(i <= min) return style->body.main_color;
//
// lv_coord_t max = (style->body.grad_color_stop * s) >> 8;
// if(i >= max) return style->body.grad_color;
//
// lv_coord_t d = style->body.grad_color_stop - style->body.main_color_stop;
// d = (s * d) >> 8;
// i -= min;
// lv_opa_t mix = (i * 255) / d;
// return lv_color_mix(style->body.grad_color, style->body.main_color, mix);
lv_coord_t min = (dsc->bg_main_color_stop * s) >> 8;
if(i <= min) return dsc->bg_color;
lv_coord_t max = (dsc->bg_grad_color_stop * s) >> 8;
if(i >= max) return dsc->bg_grad_color;
lv_coord_t d = dsc->bg_grad_color_stop - dsc->bg_main_color_stop;
d = (s * d) >> 8;
i -= min;
lv_opa_t mix = (i * 255) / d;
return lv_color_mix(dsc->bg_grad_color, dsc->bg_color, mix);
}
static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc, lv_opa_t opa_scale)
static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
{
// /*Check whether the shadow is visible*/
// if(style->body.shadow.width == 0) return;

View File

@ -31,6 +31,8 @@ typedef struct {
lv_color_t bg_color;
lv_color_t bg_grad_color;
lv_grad_dir_t bg_grad_dir;
lv_style_value_t bg_main_color_stop;
lv_style_value_t bg_grad_color_stop;
lv_blend_mode_t bg_blend_mode;
lv_opa_t bg_opa;
@ -61,18 +63,16 @@ void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc);
* @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, lv_draw_rect_dsc_t * dsc, lv_opa_t opa_scale);
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, lv_draw_rect_dsc_t * dsc);
/**
* Draw a pixel
* @param point the coordinates of the point to draw
* @param mask the pixel will be drawn only in this mask
* @param style pointer to a style
* @param opa_scale scale down the opacity by the factor
*/
void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style, lv_opa_t opa_scale);
void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style);
/**********************
* MACROS

View File

@ -154,7 +154,7 @@ void lv_draw_polygon(const lv_point_t * points, uint16_t point_cnt, const lv_are
lv_draw_rect(&poly_mask, &poly_mask, style, opa_scale);
lv_draw_rect(&poly_mask, &poly_mask, style);
lv_draw_mask_remove_custom(mp);

View File

@ -139,10 +139,8 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/
disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/
disp->sys_layer = lv_obj_create(NULL, NULL); /*Create sys layer on the display*/
// lv_obj_set_style(disp->top_layer, &lv_style_transp);
// lv_obj_set_style(disp->sys_layer, &lv_style_transp);
lv_obj_set_hidden(disp->top_layer, true);
lv_obj_set_hidden(disp->sys_layer, true);
lv_obj_add_style_class(disp->top_layer, LV_OBJ_STYLE_MAIN, &lv_style_transp);
lv_obj_add_style_class(disp->sys_layer, LV_OBJ_STYLE_MAIN, &lv_style_transp);
lv_obj_invalidate(disp->act_scr);

View File

@ -451,13 +451,12 @@ static lv_design_res_t lv_btn_design(lv_obj_t * btn, const lv_area_t * clip_area
}
}
#else
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
lv_draw_rect_dsc_t draw_dsc;
lv_draw_rect_dsc_init(&draw_dsc);
lv_obj_init_draw_rect_dsc(btn, LV_OBJ_STYLE_MAIN, &draw_dsc);
lv_draw_rect(&btn->coords, clip_area, &draw_dsc, lv_obj_get_opa_scale(btn));
lv_draw_rect(&btn->coords, clip_area, &draw_dsc);
if(lv_obj_get_style_value(btn, LV_OBJ_STYLE_MAIN, LV_STYLE_BG_CLIP_CORNER)) {
lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
@ -492,7 +491,6 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
if(res != LV_RES_OK) return res;
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
bool tgl = lv_btn_get_toggle(btn);
lv_btn_state_t state = lv_btn_get_state(btn);
if(sign == LV_SIGNAL_PRESSED) {

View File

@ -85,19 +85,15 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
return NULL;
}
ext->btn_cnt = 0;
ext->btn_id_pr = LV_BTNM_BTN_NONE;
ext->btn_id_act = LV_BTNM_BTN_NONE;
ext->button_areas = NULL;
ext->ctrl_bits = NULL;
ext->map_p = NULL;
ext->recolor = 0;
ext->one_toggle = 0;
ext->styles_btn[LV_BTN_STATE_REL] = &lv_style_btn_rel;
ext->styles_btn[LV_BTN_STATE_PR] = &lv_style_btn_pr;
ext->styles_btn[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_rel;
ext->styles_btn[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pr;
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina;
ext->btn_cnt = 0;
ext->btn_id_pr = LV_BTNM_BTN_NONE;
ext->btn_id_act = LV_BTNM_BTN_NONE;
ext->button_areas = NULL;
ext->ctrl_bits = NULL;
ext->map_p = NULL;
ext->recolor = 0;
ext->one_toggle = 0;
lv_style_dsc_init(&ext->style_btn);
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_cb(new_btnm);
@ -112,21 +108,24 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BG, th->style.btnm.bg);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_REL, th->style.btnm.btn.rel);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_PR, th->style.btnm.btn.pr);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_REL, th->style.btnm.btn.tgl_rel);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_PR, th->style.btnm.btn.tgl_pr);
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_INA, th->style.btnm.btn.ina);
// lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BG, th->style.btnm.bg);
// lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_REL, th->style.btnm.btn.rel);
// lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_PR, th->style.btnm.btn.pr);
// lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_REL, th->style.btnm.btn.tgl_rel);
// lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_PR, th->style.btnm.btn.tgl_pr);
// lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_INA, th->style.btnm.btn.ina);
} else {
lv_obj_set_style(new_btnm, &lv_style_pretty);
lv_obj_reset_style(new_btnm, LV_BTNM_STYLE_MAIN);
lv_obj_add_style_class(new_btnm, LV_BTNM_STYLE_MAIN, &lv_style_panel);
lv_obj_add_style_class(new_btnm, LV_BTNM_STYLE_BTN, &lv_style_btn);
// lv_obj_set_style(new_btnm, &lv_style_pretty);
}
}
/*Copy an existing object*/
else {
lv_btnm_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
memcpy((void*)ext->styles_btn, copy_ext->styles_btn, sizeof(ext->styles_btn));
lv_btnm_set_map(new_btnm, lv_btnm_get_map_array(copy));
// lv_btnm_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
// memcpy((void*)ext->styles_btn, copy_ext->styles_btn, sizeof(ext->styles_btn));
// lv_btnm_set_map(new_btnm, lv_btnm_get_map_array(copy));
}
LV_LOG_INFO("button matrix created");
@ -170,10 +169,16 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[])
ext->map_p = map;
/*Set size and positions of the buttons*/
const lv_style_t * style_bg = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG);
lv_coord_t max_w = lv_obj_get_width(btnm) - style_bg->body.padding.left - style_bg->body.padding.right;
lv_coord_t max_h = lv_obj_get_height(btnm) - style_bg->body.padding.top - style_bg->body.padding.bottom;
lv_coord_t act_y = style_bg->body.padding.top;
lv_style_value_t left = lv_obj_get_style_value(btnm, LV_BTNM_STYLE_MAIN, LV_STYLE_PAD_LEFT);
lv_style_value_t right = lv_obj_get_style_value(btnm, LV_BTNM_STYLE_MAIN, LV_STYLE_PAD_RIGHT);
lv_style_value_t top = lv_obj_get_style_value(btnm, LV_BTNM_STYLE_MAIN, LV_STYLE_PAD_TOP);
lv_style_value_t bottom = lv_obj_get_style_value(btnm, LV_BTNM_STYLE_MAIN, LV_STYLE_PAD_BOTTOM);
lv_style_value_t inner = lv_obj_get_style_value(btnm, LV_BTNM_STYLE_MAIN, LV_STYLE_PAD_INNER);
lv_coord_t max_w = lv_obj_get_width(btnm) - left - right;
lv_coord_t max_h = lv_obj_get_height(btnm) - top - bottom;
lv_coord_t act_y = top;
/*Count the lines to calculate button height*/
uint8_t line_cnt = 1;
@ -182,7 +187,7 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[])
if(strcmp(map[li], "\n") == 0) line_cnt++;
}
lv_coord_t btn_h = max_h - ((line_cnt - 1) * style_bg->body.padding.inner);
lv_coord_t btn_h = max_h - ((line_cnt - 1) * inner);
btn_h = btn_h / line_cnt;
btn_h--; /*-1 because e.g. height = 100 means 101 pixels (0..100)*/
@ -207,7 +212,7 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[])
/*Make sure the last row is at the bottom of 'btnm'*/
if(map_p_tmp[btn_cnt][0] == '\0') { /*Last row?*/
btn_h = lv_obj_get_height(btnm)- act_y - style_bg->body.padding.bottom - 1;
btn_h = lv_obj_get_height(btnm)- act_y - bottom - 1;
}
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(btnm);
@ -215,7 +220,7 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[])
/*Only deal with the non empty lines*/
if(btn_cnt != 0) {
/*Calculate the width of all units*/
lv_coord_t all_unit_w = max_w - ((btn_cnt - 1) * style_bg->body.padding.inner);
lv_coord_t all_unit_w = max_w - ((btn_cnt - 1) * inner);
/*Set the button size and positions and set the texts*/
uint16_t i;
@ -232,16 +237,16 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[])
/*Always recalculate act_x because of rounding errors */
if(base_dir == LV_BIDI_DIR_RTL) {
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * style_bg->body.padding.inner;
act_x = lv_obj_get_width(btnm) - style_bg->body.padding.right - act_x - act_unit_w - 1;
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * inner;
act_x = lv_obj_get_width(btnm) - right - act_x - act_unit_w - 1;
} else {
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * style_bg->body.padding.inner +
style_bg->body.padding.left;
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * inner +
left;
}
/* Set the button's area.
* If inner padding is zero then use the prev. button x2 as x1 to avoid rounding
* errors*/
if(style_bg->body.padding.inner == 0 && act_x != style_bg->body.padding.left) {
if(inner == 0 && act_x != left) {
lv_area_set(&ext->button_areas[btn_i], ext->button_areas[btn_i - 1].x2, act_y, act_x + act_unit_w,
act_y + btn_h);
} else {
@ -254,7 +259,7 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[])
btn_i++;
}
}
act_y += btn_h + style_bg->body.padding.inner + 1;
act_y += btn_h + inner + 1;
if(strlen(map_p_tmp[btn_cnt]) == 0) break; /*Break on end of map*/
map_p_tmp = &map_p_tmp[btn_cnt + 1]; /*Set the map to the next line*/
@ -306,42 +311,6 @@ void lv_btnm_set_pressed(const lv_obj_t * btnm, uint16_t id)
lv_obj_invalidate(btnm);
}
/**
* Set a style of a button matrix
* @param btnm pointer to a button matrix object
* @param type which style should be set
* @param style pointer to a style
*/
void lv_btnm_set_style(lv_obj_t * btnm, lv_btnm_style_t type, const lv_style_t * style)
{
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
switch(type) {
case LV_BTNM_STYLE_BG: lv_obj_set_style(btnm, style); break;
case LV_BTNM_STYLE_BTN_REL:
ext->styles_btn[LV_BTN_STATE_REL] = style;
lv_obj_invalidate(btnm);
break;
case LV_BTNM_STYLE_BTN_PR:
ext->styles_btn[LV_BTN_STATE_PR] = style;
lv_obj_invalidate(btnm);
break;
case LV_BTNM_STYLE_BTN_TGL_REL:
ext->styles_btn[LV_BTN_STATE_TGL_REL] = style;
lv_obj_invalidate(btnm);
break;
case LV_BTNM_STYLE_BTN_TGL_PR:
ext->styles_btn[LV_BTN_STATE_TGL_PR] = style;
lv_obj_invalidate(btnm);
break;
case LV_BTNM_STYLE_BTN_INA:
ext->styles_btn[LV_BTN_STATE_INA] = style;
lv_obj_invalidate(btnm);
break;
}
}
/**
* Enable recoloring of button's texts
@ -592,30 +561,27 @@ bool lv_btnm_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl)
return ext->ctrl_bits[btn_id] & ctrl ? true : false;
}
/**
* Get a style of a button matrix
* @param btnm pointer to a button matrix object
* @param type which style should be get
* @return style pointer to a style
*/
const lv_style_t * lv_btnm_get_style(const lv_obj_t * btnm, lv_btnm_style_t type)
lv_style_dsc_t * lv_btnm_get_style(lv_obj_t * btnm, uint8_t type)
{
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
const lv_style_t * style = NULL;
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_style_dsc_t * style_dsc_p;
switch(type) {
case LV_BTNM_STYLE_BG: style = lv_obj_get_style(btnm); break;
case LV_BTNM_STYLE_BTN_REL: style = ext->styles_btn[LV_BTN_STATE_REL]; break;
case LV_BTNM_STYLE_BTN_PR: style = ext->styles_btn[LV_BTN_STATE_PR]; break;
case LV_BTNM_STYLE_BTN_TGL_REL: style = ext->styles_btn[LV_BTN_STATE_TGL_REL]; break;
case LV_BTNM_STYLE_BTN_TGL_PR: style = ext->styles_btn[LV_BTN_STATE_TGL_PR]; break;
case LV_BTNM_STYLE_BTN_INA: style = ext->styles_btn[LV_BTN_STATE_INA]; break;
default: style = NULL; break;
case LV_BTNM_STYLE_MAIN:
style_dsc_p = &btnm->style_dsc;
break;
case LV_BTNM_STYLE_BTN:
style_dsc_p = &ext->style_btn;
break;
default:
style_dsc_p = NULL;
}
return style;
return style_dsc_p;
}
/**
@ -656,9 +622,6 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
ancestor_design_f(btnm, clip_area, mode);
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
const lv_style_t * bg_style = lv_obj_get_style(btnm);
const 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);
@ -669,9 +632,42 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
uint16_t btn_i = 0;
uint16_t txt_i = 0;
lv_style_t style_tmp;
lv_txt_flag_t txt_flag = LV_TXT_FLAG_NONE;
lv_draw_rect_dsc_t draw_rect_dsc[_LV_BTN_STATE_NUM];
lv_draw_label_dsc_t draw_label_dsc[_LV_BTN_STATE_NUM];
uint8_t i;
for(i = 0; i < _LV_BTN_STATE_NUM; i++) {
lv_draw_rect_dsc_init(&draw_rect_dsc[i]);
lv_draw_label_dsc_init(&draw_label_dsc[i]);
}
uint8_t state_ori = btnm->state;
btnm->state = 0;
lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_STYLE_BTN, &draw_rect_dsc[LV_BTN_STATE_REL]);
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_STYLE_BTN, &draw_label_dsc[LV_BTN_STATE_REL]);
btnm->state = LV_OBJ_STATE_PRESSED;
lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_STYLE_BTN, &draw_rect_dsc[LV_BTN_STATE_PR]);
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_STYLE_BTN, &draw_label_dsc[LV_BTN_STATE_PR]);
btnm->state = LV_OBJ_STATE_CHECKED;
lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_STYLE_BTN, &draw_rect_dsc[LV_BTN_STATE_TGL_REL]);
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_STYLE_BTN, &draw_label_dsc[LV_BTN_STATE_TGL_REL]);
btnm->state = LV_OBJ_STATE_PRESSED | LV_OBJ_STATE_CHECKED;
lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_STYLE_BTN, &draw_rect_dsc[LV_BTN_STATE_TGL_PR]);
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_STYLE_BTN, &draw_label_dsc[LV_BTN_STATE_TGL_PR]);
btnm->state = LV_OBJ_STATE_DISABLED;
lv_obj_init_draw_rect_dsc(btnm, LV_BTNM_STYLE_BTN, &draw_rect_dsc[LV_BTN_STATE_INA]);
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_STYLE_BTN, &draw_label_dsc[LV_BTN_STATE_INA]);
btnm->state = state_ori;
lv_style_value_t padding_top = lv_obj_get_style_value(btnm, LV_BTNM_STYLE_MAIN, LV_STYLE_PAD_TOP);
lv_style_value_t padding_bottom = lv_obj_get_style_value(btnm, LV_BTNM_STYLE_MAIN, LV_STYLE_PAD_BOTTOM);
if(ext->recolor) txt_flag = LV_TXT_FLAG_RECOLOR;
for(btn_i = 0; btn_i < ext->btn_cnt; btn_i++, txt_i++) {
/*Search the next valid text in the map*/
@ -693,55 +689,57 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
/*Load the style*/
bool tgl_state = button_get_tgl_state(ext->ctrl_bits[btn_i]);
lv_btn_state_t act_state = LV_BTN_STATE_REL;
if(button_is_inactive(ext->ctrl_bits[btn_i]))
btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_INA);
else if(btn_i != ext->btn_id_pr && tgl_state == false)
btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_REL);
act_state = LV_BTN_STATE_INA;
else if(btn_i == ext->btn_id_pr && tgl_state == false)
btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_PR);
act_state = LV_BTN_STATE_PR;
else if(btn_i != ext->btn_id_pr && tgl_state == true)
btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_REL);
act_state = LV_BTN_STATE_TGL_REL;
else if(btn_i == ext->btn_id_pr && tgl_state == true)
btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_PR);
else
btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_REL); /*Not possible option, just to be sure*/
act_state = LV_BTN_STATE_TGL_PR;
lv_style_copy(&style_tmp, btn_style);
lv_style_value_t border_part_ori = draw_rect_dsc[act_state].border_part;
/*Remove borders on the edges if `LV_BORDER_INTERNAL`*/
if(style_tmp.body.border.part & LV_BORDER_PART_INTERNAL) {
if(area_tmp.y1 == btnm->coords.y1 + bg_style->body.padding.top) {
style_tmp.body.border.part &= ~LV_BORDER_PART_TOP;
if(border_part_ori & LV_BORDER_PART_INTERNAL) {
/*Top/Bottom lines*/
if(area_tmp.y1 == btnm->coords.y1 + padding_top) {
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_PART_TOP;
}
if(area_tmp.y2 == btnm->coords.y2 - bg_style->body.padding.bottom) {
style_tmp.body.border.part &= ~LV_BORDER_PART_BOTTOM;
if(area_tmp.y2 == btnm->coords.y2 - padding_bottom) {
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_PART_BOTTOM;
}
if(txt_i == 0) {
style_tmp.body.border.part &= ~LV_BORDER_PART_LEFT;
/*Left/right columns*/
if(txt_i == 0) { /*First button*/
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_PART_LEFT;
} else if(strcmp(ext->map_p[txt_i - 1], "\n") == 0) {
style_tmp.body.border.part &= ~LV_BORDER_PART_LEFT;
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_PART_LEFT;
}
if(ext->map_p[txt_i + 1][0] == '\0' || strcmp(ext->map_p[txt_i + 1], "\n") == 0) {
style_tmp.body.border.part &= ~LV_BORDER_PART_RIGHT;
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_PART_RIGHT;
}
}
lv_draw_rect(&area_tmp, clip_area, &style_tmp, opa_scale);
lv_draw_rect(&area_tmp, clip_area, &draw_rect_dsc[act_state]);
/*Calculate the size of the text*/
if(btn_style->glass) btn_style = bg_style;
const lv_font_t * font = btn_style->text.font;
const lv_font_t * font = draw_label_dsc[act_state].font;
lv_style_value_t letter_space = draw_label_dsc[act_state].letter_space;
lv_style_value_t line_space = draw_label_dsc[act_state].line_space;
const char * txt = ext->map_p[txt_i];
lv_point_t txt_size;
lv_txt_get_size(&txt_size, ext->map_p[txt_i], font, btn_style->text.letter_space,
btn_style->text.line_space, lv_area_get_width(&area_btnm), txt_flag);
lv_txt_get_size(&txt_size, txt, font, letter_space,
line_space, lv_area_get_width(&area_btnm), txt_flag);
area_tmp.x1 += (btn_w - txt_size.x) / 2;
area_tmp.y1 += (btn_h - txt_size.y) / 2;
area_tmp.x2 = area_tmp.x1 + txt_size.x;
area_tmp.y2 = area_tmp.y1 + txt_size.y;
lv_draw_label(&area_tmp, clip_area, btn_style, opa_scale, ext->map_p[txt_i], txt_flag, NULL, NULL, NULL, lv_obj_get_base_dir(btnm));
lv_draw_label(&area_tmp, clip_area, &draw_label_dsc[act_state], txt, NULL);
}
}
return LV_DESIGN_RES_OK;
@ -757,6 +755,12 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
{
lv_res_t res;
if(sign == LV_SIGNAL_GET_STYLE) {
uint8_t ** type_p = param;
lv_style_dsc_t ** style_dsc_p = param;
*style_dsc_p = lv_btnm_get_style(btnm, **type_p);
return LV_RES_OK;
}
/* Include the ancient signal function */
res = ancestor_signal(btnm, sign, param);
@ -906,7 +910,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
ext->btn_id_act = ext->btn_id_pr;
lv_obj_invalidate(btnm);
} else if(c == LV_KEY_DOWN) {
const lv_style_t * style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG);
lv_style_value_t pad_inner = lv_obj_get_style_value(btnm, LV_BTNM_STYLE_MAIN, LV_STYLE_PAD_INNER);
/*Find the area below the the current*/
if(ext->btn_id_pr == LV_BTNM_BTN_NONE) {
ext->btn_id_pr = 0;
@ -918,7 +922,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
for(area_below = ext->btn_id_pr; area_below < ext->btn_cnt; area_below++) {
if(ext->button_areas[area_below].y1 > ext->button_areas[ext->btn_id_pr].y1 &&
pr_center >= ext->button_areas[area_below].x1 &&
pr_center <= ext->button_areas[area_below].x2 + style->body.padding.inner) {
pr_center <= ext->button_areas[area_below].x2 + pad_inner) {
break;
}
}
@ -928,7 +932,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
ext->btn_id_act = ext->btn_id_pr;
lv_obj_invalidate(btnm);
} else if(c == LV_KEY_UP) {
const lv_style_t * style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG);
lv_style_value_t pad_inner = lv_obj_get_style_value(btnm, LV_BTNM_STYLE_MAIN, LV_STYLE_PAD_INNER);
/*Find the area below the the current*/
if(ext->btn_id_pr == LV_BTNM_BTN_NONE) {
ext->btn_id_pr = 0;
@ -939,7 +943,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
for(area_above = ext->btn_id_pr; area_above >= 0; area_above--) {
if(ext->button_areas[area_above].y1 < ext->button_areas[ext->btn_id_pr].y1 &&
pr_center >= ext->button_areas[area_above].x1 - style->body.padding.inner &&
pr_center >= ext->button_areas[area_above].x1 - pad_inner &&
pr_center <= ext->button_areas[area_above].x2) {
break;
}

View File

@ -56,7 +56,7 @@ typedef struct
const char ** map_p; /*Pointer to the current map*/
lv_area_t * button_areas; /*Array of areas of buttons*/
lv_btnm_ctrl_t * ctrl_bits; /*Array of control bytes*/
const lv_style_t * styles_btn[_LV_BTN_STATE_NUM]; /*Styles of buttons in each state*/
lv_style_dsc_t style_btn; /*Styles of buttons in each state*/
uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/
uint16_t btn_id_pr; /*Index of the currently pressed button or LV_BTNM_BTN_NONE*/
uint16_t btn_id_act; /*Index of the active button (being pressed/released etc) or LV_BTNM_BTN_NONE */
@ -65,12 +65,8 @@ typedef struct
} lv_btnm_ext_t;
enum {
LV_BTNM_STYLE_BG,
LV_BTNM_STYLE_BTN_REL,
LV_BTNM_STYLE_BTN_PR,
LV_BTNM_STYLE_BTN_TGL_REL,
LV_BTNM_STYLE_BTN_TGL_PR,
LV_BTNM_STYLE_BTN_INA,
LV_BTNM_STYLE_MAIN,
LV_BTNM_STYLE_BTN,
};
typedef uint8_t lv_btnm_style_t;
@ -249,13 +245,8 @@ const char * lv_btnm_get_btn_text(const lv_obj_t * btnm, uint16_t btn_id);
*/
bool lv_btnm_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl);
/**
* Get a style of a button matrix
* @param btnm pointer to a button matrix object
* @param type which style should be get
* @return style pointer to a style
*/
const lv_style_t * lv_btnm_get_style(const lv_obj_t * btnm, lv_btnm_style_t type);
lv_style_dsc_t * lv_btnm_get_style(lv_obj_t * btnm, uint8_t type);
/**
* Find whether "one toggle" mode is enabled.

View File

@ -635,6 +635,10 @@ static void lv_cont_layout_grid(lv_obj_t * cont)
*/
static void lv_cont_refr_autofit(lv_obj_t * cont)
{
static uint32_t t = 0;
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
if(ext->fit_left == LV_FIT_NONE && ext->fit_right == LV_FIT_NONE && ext->fit_top == LV_FIT_NONE &&
@ -642,6 +646,9 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
return;
}
t++;
printf("autofit:%d\n", t);
lv_area_t tight_area;
lv_area_t ori;
lv_obj_t * child_i;

View File

@ -1047,7 +1047,6 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_
const lv_font_t * font = lv_obj_get_style_ptr(label, LV_LABEL_STYLE_MAIN, LV_STYLE_FONT);
lv_style_value_t line_space = lv_obj_get_style_value(label, LV_LABEL_STYLE_MAIN, LV_STYLE_LINE_SPACE);
lv_style_value_t letter_space = lv_obj_get_style_value(label, LV_LABEL_STYLE_MAIN, LV_STYLE_LETTER_SPACE);
lv_opa_t opa_scale = lv_obj_get_opa_scale(label);
lv_obj_get_coords(label, &coords);
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
@ -1068,7 +1067,7 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_
lv_draw_rect_dsc_init(&draw_rect_dsc);
lv_obj_init_draw_rect_dsc(label, LV_LABEL_STYLE_MAIN, &draw_rect_dsc);
lv_draw_rect(&bg, clip_area, &draw_rect_dsc, lv_obj_get_opa_scale(label));
lv_draw_rect(&bg, clip_area, &draw_rect_dsc);
}
lv_label_align_t align = lv_label_get_align(label);
@ -1111,7 +1110,7 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_
label_draw_dsc.flag = flag;
lv_obj_init_draw_label_dsc(label, LV_LABEL_STYLE_MAIN, &label_draw_dsc);
lv_draw_label(&coords, clip_area, &label_draw_dsc, ext->text, opa_scale, hint);
lv_draw_label(&coords, clip_area, &label_draw_dsc, ext->text, hint);
if(ext->long_mode == LV_LABEL_LONG_SROLL_CIRC) {
lv_point_t size;
@ -1124,7 +1123,7 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_
lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
label_draw_dsc.ofs_y = ext->offset.y;
lv_draw_label(&coords, clip_area, &label_draw_dsc, ext->text, opa_scale, hint);
lv_draw_label(&coords, clip_area, &label_draw_dsc, ext->text, hint);
}
/*Draw the text again below the original to make an circular effect */
@ -1132,7 +1131,7 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_
label_draw_dsc.ofs_x = ext->offset.x;
label_draw_dsc.ofs_y = ext->offset.y + size.y + lv_font_get_line_height(font);
lv_draw_label(&coords, clip_area, &label_draw_dsc, ext->text, opa_scale, hint);
lv_draw_label(&coords, clip_area, &label_draw_dsc, ext->text, hint);
}
}
}