mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
style: integrate page + fixes + refactoring
This commit is contained in:
parent
302f21cbd5
commit
584e88da08
@ -240,7 +240,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
|||||||
new_obj->drag = 0;
|
new_obj->drag = 0;
|
||||||
new_obj->drag_throw = 0;
|
new_obj->drag_throw = 0;
|
||||||
new_obj->drag_parent = 0;
|
new_obj->drag_parent = 0;
|
||||||
new_obj->drag_dir = 0;
|
new_obj->drag_dir = LV_DRAG_DIR_BOTH;
|
||||||
new_obj->hidden = 0;
|
new_obj->hidden = 0;
|
||||||
new_obj->top = 0;
|
new_obj->top = 0;
|
||||||
new_obj->protect = LV_PROTECT_NONE;
|
new_obj->protect = LV_PROTECT_NONE;
|
||||||
@ -260,9 +260,9 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
|||||||
lv_style_dsc_init(&new_obj->style_dsc);
|
lv_style_dsc_init(&new_obj->style_dsc);
|
||||||
|
|
||||||
if(parent != NULL) {
|
if(parent != NULL) {
|
||||||
lv_obj_add_style_class(new_obj, LV_OBJ_STYLE_MAIN, &lv_style_panel);
|
lv_obj_add_style_class(new_obj, LV_OBJ_PART_MAIN, &lv_style_panel);
|
||||||
} else {
|
} else {
|
||||||
lv_obj_update_style_cache(new_obj, LV_OBJ_STYLE_MAIN);
|
lv_obj_update_style_cache(new_obj, LV_OBJ_PART_MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1428,7 +1428,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_obj_state_t state)
|
|||||||
lv_obj_state_t new_state = obj->state | state;
|
lv_obj_state_t new_state = obj->state | state;
|
||||||
if(obj->state != new_state) {
|
if(obj->state != new_state) {
|
||||||
obj->state = new_state;
|
obj->state = new_state;
|
||||||
lv_obj_refresh_style(obj, LV_OBJ_STYLE_ALL);
|
lv_obj_refresh_style(obj, LV_OBJ_PART_ALL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1440,7 +1440,7 @@ void lv_obj_clear_state(lv_obj_t * obj, lv_obj_state_t state)
|
|||||||
lv_obj_state_t new_state = obj->state & state;
|
lv_obj_state_t new_state = obj->state & state;
|
||||||
if(obj->state != new_state) {
|
if(obj->state != new_state) {
|
||||||
obj->state = new_state;
|
obj->state = new_state;
|
||||||
lv_obj_refresh_style(obj, LV_OBJ_STYLE_ALL);
|
lv_obj_refresh_style(obj, LV_OBJ_PART_ALL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1796,16 +1796,16 @@ void lv_obj_get_inner_coords(const lv_obj_t * obj, lv_area_t * coords_p)
|
|||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_border_part_t part = lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_BORDER_PART);
|
lv_border_side_t part = lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_BORDER_PART);
|
||||||
lv_coord_t w = lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_BORDER_WIDTH);
|
lv_coord_t w = lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_BORDER_WIDTH);
|
||||||
|
|
||||||
if(part & LV_BORDER_PART_LEFT) coords_p->x1 += w;
|
if(part & LV_BORDER_SIDE_LEFT) coords_p->x1 += w;
|
||||||
|
|
||||||
if(part & LV_BORDER_PART_RIGHT) coords_p->x2 -= w;
|
if(part & LV_BORDER_SIDE_RIGHT) coords_p->x2 -= w;
|
||||||
|
|
||||||
if(part & LV_BORDER_PART_TOP) coords_p->y1 += w;
|
if(part & LV_BORDER_SIDE_TOP) coords_p->y1 += w;
|
||||||
|
|
||||||
if(part & LV_BORDER_PART_BOTTOM) coords_p->y2 -= w;
|
if(part & LV_BORDER_SIDE_BOTTOM) coords_p->y2 -= w;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1879,8 +1879,8 @@ lv_coord_t lv_obj_get_width_fit(const lv_obj_t * obj)
|
|||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_style_value_t left = lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_PAD_LEFT);
|
lv_style_value_t left = lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_PAD_LEFT);
|
||||||
lv_style_value_t right = lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_PAD_RIGHT);
|
lv_style_value_t right = lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_PAD_RIGHT);
|
||||||
|
|
||||||
return lv_obj_get_width(obj) - left - right;
|
return lv_obj_get_width(obj) - left - right;
|
||||||
}
|
}
|
||||||
@ -1894,8 +1894,8 @@ lv_coord_t lv_obj_get_height_fit(const lv_obj_t * obj)
|
|||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
lv_style_value_t top = lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_PAD_TOP);
|
lv_style_value_t top = lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_PAD_TOP);
|
||||||
lv_style_value_t bottom = lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_PAD_BOTTOM);
|
lv_style_value_t bottom = lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_PAD_BOTTOM);
|
||||||
|
|
||||||
return lv_obj_get_height(obj) - top - bottom;
|
return lv_obj_get_height(obj) - top - bottom;
|
||||||
}
|
}
|
||||||
@ -2158,8 +2158,8 @@ lv_style_value_t lv_obj_get_style_value(const lv_obj_t * obj, uint8_t type, lv_s
|
|||||||
if(attr.bits.inherit == 0) break;
|
if(attr.bits.inherit == 0) break;
|
||||||
|
|
||||||
/*If not found, check the `MAIN` style first*/
|
/*If not found, check the `MAIN` style first*/
|
||||||
if(type != LV_OBJ_STYLE_MAIN) {
|
if(type != LV_OBJ_PART_MAIN) {
|
||||||
type = LV_OBJ_STYLE_MAIN;
|
type = LV_OBJ_PART_MAIN;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2173,7 +2173,9 @@ lv_style_value_t lv_obj_get_style_value(const lv_obj_t * obj, uint8_t type, lv_s
|
|||||||
prop = prop & (~LV_STYLE_STATE_MASK);
|
prop = prop & (~LV_STYLE_STATE_MASK);
|
||||||
switch(prop) {
|
switch(prop) {
|
||||||
case LV_STYLE_BORDER_PART:
|
case LV_STYLE_BORDER_PART:
|
||||||
return LV_BORDER_PART_FULL;
|
return LV_BORDER_SIDE_FULL;
|
||||||
|
case LV_STYLE_SCROLLBAR_WIDTH:
|
||||||
|
return LV_DPI/10;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -2236,8 +2238,8 @@ lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t type, lv_style_p
|
|||||||
if(attr.bits.inherit == 0) break;
|
if(attr.bits.inherit == 0) break;
|
||||||
|
|
||||||
/*If not found, check the `MAIN` style first*/
|
/*If not found, check the `MAIN` style first*/
|
||||||
if(type != LV_OBJ_STYLE_MAIN) {
|
if(type != LV_OBJ_PART_MAIN) {
|
||||||
type = LV_OBJ_STYLE_MAIN;
|
type = LV_OBJ_PART_MAIN;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2350,8 +2352,8 @@ lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t type, lv_style_prope
|
|||||||
if(attr.bits.inherit == 0) break;
|
if(attr.bits.inherit == 0) break;
|
||||||
|
|
||||||
/*If not found, check the `MAIN` style first*/
|
/*If not found, check the `MAIN` style first*/
|
||||||
if(type != LV_OBJ_STYLE_MAIN) {
|
if(type != LV_OBJ_PART_MAIN) {
|
||||||
type = LV_OBJ_STYLE_MAIN;
|
type = LV_OBJ_PART_MAIN;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2417,8 +2419,8 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t type, lv_style_propert
|
|||||||
if(attr.bits.inherit == 0) break;
|
if(attr.bits.inherit == 0) break;
|
||||||
|
|
||||||
/*If not found, check the `MAIN` style first*/
|
/*If not found, check the `MAIN` style first*/
|
||||||
if(type != LV_OBJ_STYLE_MAIN) {
|
if(type != LV_OBJ_PART_MAIN) {
|
||||||
type = LV_OBJ_STYLE_MAIN;
|
type = LV_OBJ_PART_MAIN;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2441,11 +2443,11 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t type, lv_style_propert
|
|||||||
|
|
||||||
void lv_obj_update_style_cache(lv_obj_t * obj, uint8_t type)
|
void lv_obj_update_style_cache(lv_obj_t * obj, uint8_t type)
|
||||||
{
|
{
|
||||||
if(type != LV_OBJ_STYLE_ALL) {
|
if(type != LV_OBJ_PART_ALL) {
|
||||||
style_cache_update_core(obj, type);
|
style_cache_update_core(obj, type);
|
||||||
} else {
|
} else {
|
||||||
uint8_t type_sub;
|
uint8_t type_sub;
|
||||||
for(type_sub = 0; type_sub != LV_OBJ_STYLE_ALL; type_sub++) {
|
for(type_sub = 0; type_sub != LV_OBJ_PART_ALL; type_sub++) {
|
||||||
lv_res_t res;
|
lv_res_t res;
|
||||||
res = style_cache_update_core(obj, type_sub);
|
res = style_cache_update_core(obj, type_sub);
|
||||||
if(res == LV_RES_INV) break;
|
if(res == LV_RES_INV) break;
|
||||||
@ -2907,18 +2909,18 @@ 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*/
|
/*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_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_PART_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_PART_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_PART_MAIN, LV_STYLE_BORDER_BLEND_MODE) != LV_BLEND_MODE_NORMAL) return LV_DESIGN_RES_NOT_COVER;
|
||||||
|
|
||||||
/*Can cover the area only if fully solid (no opacity)*/
|
/*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_PART_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;
|
if(lv_obj_get_style_opa(obj, LV_OBJ_PART_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
|
/* Because of the radius it is not sure the area is covered
|
||||||
* Check the areas where there is no radius*/
|
* Check the areas where there is no radius*/
|
||||||
lv_coord_t r = lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_RADIUS);
|
lv_coord_t r = lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_RADIUS);
|
||||||
|
|
||||||
if(r == LV_RADIUS_CIRCLE) return LV_DESIGN_RES_NOT_COVER;
|
if(r == LV_RADIUS_CIRCLE) return LV_DESIGN_RES_NOT_COVER;
|
||||||
|
|
||||||
@ -2942,13 +2944,13 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area
|
|||||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||||
lv_draw_rect_dsc_t draw_dsc;
|
lv_draw_rect_dsc_t draw_dsc;
|
||||||
lv_draw_rect_dsc_init(&draw_dsc);
|
lv_draw_rect_dsc_init(&draw_dsc);
|
||||||
lv_obj_init_draw_rect_dsc(obj, LV_OBJ_STYLE_MAIN, &draw_dsc);
|
lv_obj_init_draw_rect_dsc(obj, LV_OBJ_PART_MAIN, &draw_dsc);
|
||||||
lv_draw_rect(&obj->coords, clip_area, &draw_dsc);
|
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)) {
|
if(lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_BG_CLIP_CORNER)) {
|
||||||
lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
|
lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
|
||||||
|
|
||||||
lv_coord_t r = lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_RADIUS);
|
lv_coord_t r = lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_RADIUS);
|
||||||
|
|
||||||
lv_draw_mask_radius_init(mp, &obj->coords, r, false);
|
lv_draw_mask_radius_init(mp, &obj->coords, r, false);
|
||||||
/*Add the mask and use `obj+8` as custom id. Don't use `obj` directly because it might be used by the user*/
|
/*Add the mask and use `obj+8` as custom id. Don't use `obj` directly because it might be used by the user*/
|
||||||
@ -2956,8 +2958,7 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||||
// const lv_style_t * style_dsc = lv_obj_get_style(obj);
|
if(lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_BG_CLIP_CORNER)) {
|
||||||
if(lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_BG_CLIP_CORNER)) {
|
|
||||||
lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(obj + 8);
|
lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(obj + 8);
|
||||||
lv_mem_buf_release(param);
|
lv_mem_buf_release(param);
|
||||||
}
|
}
|
||||||
@ -2978,7 +2979,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
|||||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||||
uint8_t ** type_p = param;
|
uint8_t ** type_p = param;
|
||||||
lv_style_dsc_t ** style_dsc_p = param;
|
lv_style_dsc_t ** style_dsc_p = param;
|
||||||
if((**type_p) == LV_OBJ_STYLE_MAIN) *style_dsc_p = &obj->style_dsc;
|
if((**type_p) == LV_OBJ_PART_MAIN) *style_dsc_p = &obj->style_dsc;
|
||||||
else *style_dsc_p = NULL;
|
else *style_dsc_p = NULL;
|
||||||
return LV_RES_OK;
|
return LV_RES_OK;
|
||||||
}
|
}
|
||||||
@ -2990,10 +2991,10 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
|||||||
/*Return 'invalid' if the child change signal is not enabled*/
|
/*Return 'invalid' if the child change signal is not enabled*/
|
||||||
if(lv_obj_is_protected(obj, LV_PROTECT_CHILD_CHG) != false) res = LV_RES_INV;
|
if(lv_obj_is_protected(obj, LV_PROTECT_CHILD_CHG) != false) res = LV_RES_INV;
|
||||||
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||||
lv_coord_t shadow = (lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_SHADOW_WIDTH) >> 1) + 1;
|
lv_coord_t shadow = (lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_SHADOW_WIDTH) >> 1) + 1;
|
||||||
shadow += lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_SHADOW_SPREAD);
|
shadow += lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_SHADOW_SPREAD);
|
||||||
shadow += LV_MATH_MAX(LV_MATH_ABS(lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_SHADOW_OFFSET_X)),
|
shadow += LV_MATH_MAX(LV_MATH_ABS(lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_SHADOW_OFFSET_X)),
|
||||||
LV_MATH_ABS(lv_obj_get_style_value(obj, LV_OBJ_STYLE_MAIN, LV_STYLE_SHADOW_OFFSET_Y)));
|
LV_MATH_ABS(lv_obj_get_style_value(obj, LV_OBJ_PART_MAIN, LV_STYLE_SHADOW_OFFSET_Y)));
|
||||||
|
|
||||||
if(shadow > obj->ext_draw_pad) obj->ext_draw_pad = shadow;
|
if(shadow > obj->ext_draw_pad) obj->ext_draw_pad = shadow;
|
||||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||||
|
@ -267,11 +267,11 @@ typedef struct _lv_obj_t
|
|||||||
} lv_obj_t;
|
} lv_obj_t;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
LV_OBJ_STYLE_MAIN,
|
LV_OBJ_PART_MAIN,
|
||||||
LV_OBJ_STYLE_ALL = 0xFF,
|
LV_OBJ_PART_ALL = 0xFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef uint8_t lv_obj_style_t;
|
typedef uint8_t lv_obj_part_t;
|
||||||
|
|
||||||
/** Used by `lv_obj_get_type()`. The object's and its ancestor types are stored here*/
|
/** Used by `lv_obj_get_type()`. The object's and its ancestor types are stored here*/
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -101,10 +101,10 @@ void lv_style_built_in_init(void)
|
|||||||
lv_style_set_value(&lv_style_plain, LV_STYLE_PAD_INNER, LV_DPI / 16);
|
lv_style_set_value(&lv_style_plain, LV_STYLE_PAD_INNER, LV_DPI / 16);
|
||||||
|
|
||||||
lv_style_init(&lv_style_panel);
|
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_LEFT, LV_DPI / 20);
|
||||||
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_RIGHT, LV_DPI / 12);
|
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_RIGHT, LV_DPI / 20);
|
||||||
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_TOP, LV_DPI / 12);
|
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_TOP, LV_DPI / 20);
|
||||||
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_BOTTOM, LV_DPI / 12);
|
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_BOTTOM, LV_DPI / 20);
|
||||||
lv_style_set_value(&lv_style_panel, LV_STYLE_PAD_INNER, LV_DPI / 20);
|
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_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_value(&lv_style_panel, LV_STYLE_BORDER_WIDTH, LV_DPI / 50 > 0 ? LV_DPI / 50 : 1);
|
||||||
@ -113,10 +113,10 @@ void lv_style_built_in_init(void)
|
|||||||
lv_style_set_color(&lv_style_panel, LV_STYLE_BORDER_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_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_LEFT, LV_DPI / 20);
|
||||||
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_RIGHT, LV_DPI / 6);
|
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_RIGHT, LV_DPI / 20);
|
||||||
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_TOP, LV_DPI / 10);
|
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_TOP, LV_DPI / 20);
|
||||||
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_BOTTOM, LV_DPI / 10);
|
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_BOTTOM, LV_DPI / 20);
|
||||||
lv_style_set_value(&lv_style_btn, LV_STYLE_PAD_INNER, LV_DPI / 16);
|
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_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_BORDER_WIDTH, LV_DPI / 50 > 0 ? LV_DPI / 50 : 1);
|
||||||
|
@ -25,8 +25,6 @@ extern "C" {
|
|||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
#define LV_RADIUS_CIRCLE (LV_COORD_MAX) /**< A very big radius to always draw as circle*/
|
#define LV_RADIUS_CIRCLE (LV_COORD_MAX) /**< A very big radius to always draw as circle*/
|
||||||
#define LV_STYLE_DEGUG_SENTINEL_VALUE 0x12345678
|
|
||||||
#define LV_STYLE_WEIGHT_MAX 0xFF
|
|
||||||
|
|
||||||
LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE);
|
LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE);
|
||||||
|
|
||||||
@ -36,15 +34,15 @@ LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE);
|
|||||||
|
|
||||||
/*Border types (Use 'OR'ed values)*/
|
/*Border types (Use 'OR'ed values)*/
|
||||||
enum {
|
enum {
|
||||||
LV_BORDER_PART_NONE = 0x00,
|
LV_BORDER_SIDE_NONE = 0x00,
|
||||||
LV_BORDER_PART_BOTTOM = 0x01,
|
LV_BORDER_SIDE_BOTTOM = 0x01,
|
||||||
LV_BORDER_PART_TOP = 0x02,
|
LV_BORDER_SIDE_TOP = 0x02,
|
||||||
LV_BORDER_PART_LEFT = 0x04,
|
LV_BORDER_SIDE_LEFT = 0x04,
|
||||||
LV_BORDER_PART_RIGHT = 0x08,
|
LV_BORDER_SIDE_RIGHT = 0x08,
|
||||||
LV_BORDER_PART_FULL = 0x0F,
|
LV_BORDER_SIDE_FULL = 0x0F,
|
||||||
LV_BORDER_PART_INTERNAL = 0x10, /**< FOR matrix-like objects (e.g. Button matrix)*/
|
LV_BORDER_SIDE_INTERNAL = 0x10, /**< FOR matrix-like objects (e.g. Button matrix)*/
|
||||||
};
|
};
|
||||||
typedef uint8_t lv_border_part_t;
|
typedef uint8_t lv_border_side_t;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
LV_GRAD_DIR_NONE,
|
LV_GRAD_DIR_NONE,
|
||||||
@ -70,10 +68,10 @@ typedef union {
|
|||||||
}lv_style_attr_t;
|
}lv_style_attr_t;
|
||||||
|
|
||||||
|
|
||||||
#define LV_STYLE_ID_VALUE 0x0
|
#define LV_STYLE_ID_VALUE 0x0 /*max 6 pcs*/
|
||||||
#define LV_STYLE_ID_COLOR 0x6
|
#define LV_STYLE_ID_COLOR 0x6 /*max 4 pcs*/
|
||||||
#define LV_STYLE_ID_OPA 0xA
|
#define LV_STYLE_ID_OPA 0xA /*max 4 pcs*/
|
||||||
#define LV_STYLE_ID_PTR 0xE
|
#define LV_STYLE_ID_PTR 0xE /*max 2 pcs*/
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
LV_STYLE_PROP_INIT(LV_STYLE_RADIUS, 0x0, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
|
LV_STYLE_PROP_INIT(LV_STYLE_RADIUS, 0x0, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
|
||||||
@ -126,6 +124,10 @@ enum {
|
|||||||
|
|
||||||
LV_STYLE_PROP_INIT(LV_STYLE_OVERLAY_COLOR, 0x8, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_INHERIT),
|
LV_STYLE_PROP_INIT(LV_STYLE_OVERLAY_COLOR, 0x8, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_INHERIT),
|
||||||
LV_STYLE_PROP_INIT(LV_STYLE_OVERLAY_OPA, 0x8, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
|
LV_STYLE_PROP_INIT(LV_STYLE_OVERLAY_OPA, 0x8, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
|
||||||
|
|
||||||
|
LV_STYLE_PROP_INIT(LV_STYLE_SCROLLBAR_WIDTH, 0x9, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef uint16_t lv_style_property_t;
|
typedef uint16_t lv_style_property_t;
|
||||||
|
@ -188,9 +188,10 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
|||||||
lv_color_t recolor;
|
lv_color_t recolor;
|
||||||
lv_coord_t letter_w;
|
lv_coord_t letter_w;
|
||||||
|
|
||||||
// lv_style_t sel_style;
|
|
||||||
// lv_style_copy(&sel_style, &lv_style_plain_color);
|
lv_draw_rect_dsc_t draw_dsc_sel;
|
||||||
// sel_style.body.main_color = sel_style.body.grad_color = dsc->sel_color;
|
lv_draw_rect_dsc_init(&draw_dsc_sel);
|
||||||
|
draw_dsc_sel.bg_color = dsc->sel_color;
|
||||||
|
|
||||||
lv_coord_t pos_x_start = pos.x;
|
lv_coord_t pos_x_start = pos.x;
|
||||||
/*Write out all lines*/
|
/*Write out all lines*/
|
||||||
@ -268,16 +269,16 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
|||||||
|
|
||||||
letter_w = lv_font_get_glyph_width(font, letter, letter_next);
|
letter_w = lv_font_get_glyph_width(font, letter, letter_next);
|
||||||
|
|
||||||
// if(sel_start != 0xFFFF && sel_end != 0xFFFF) {
|
if(sel_start != 0xFFFF && sel_end != 0xFFFF) {
|
||||||
// if(logical_char_pos >= sel_start && logical_char_pos < sel_end) {
|
if(logical_char_pos >= sel_start && logical_char_pos < sel_end) {
|
||||||
// lv_area_t sel_coords;
|
lv_area_t sel_coords;
|
||||||
// sel_coords.x1 = pos.x;
|
sel_coords.x1 = pos.x;
|
||||||
// sel_coords.y1 = pos.y;
|
sel_coords.y1 = pos.y;
|
||||||
// sel_coords.x2 = pos.x + letter_w + dsc->letter_space - 1;
|
sel_coords.x2 = pos.x + letter_w + dsc->letter_space - 1;
|
||||||
// sel_coords.y2 = pos.y + line_height - 1;
|
sel_coords.y2 = pos.y + line_height - 1;
|
||||||
// lv_draw_rect(&sel_coords, mask, &sel_style, opa);
|
lv_draw_rect(&sel_coords, mask, &draw_dsc_sel);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
lv_draw_letter(&pos, mask, font, letter, color, opa);
|
lv_draw_letter(&pos, mask, font, letter, color, opa);
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
|||||||
|
|
||||||
bool simple_mode = true;
|
bool simple_mode = true;
|
||||||
if(lv_draw_mask_get_cnt()!= 0) simple_mode = false;
|
if(lv_draw_mask_get_cnt()!= 0) simple_mode = false;
|
||||||
else if(dsc->border_part != LV_BORDER_PART_FULL) simple_mode = false;
|
else if(dsc->border_part != LV_BORDER_SIDE_FULL) simple_mode = false;
|
||||||
else if(dsc->bg_grad_dir == LV_GRAD_DIR_HOR) simple_mode = false;
|
else if(dsc->bg_grad_dir == LV_GRAD_DIR_HOR) simple_mode = false;
|
||||||
|
|
||||||
int16_t mask_rout_id = LV_MASK_ID_INV;
|
int16_t mask_rout_id = LV_MASK_ID_INV;
|
||||||
@ -337,10 +337,10 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
|||||||
/*Get the inner area*/
|
/*Get the inner area*/
|
||||||
lv_area_t area_small;
|
lv_area_t area_small;
|
||||||
lv_area_copy(&area_small, coords);
|
lv_area_copy(&area_small, coords);
|
||||||
area_small.x1 += ((dsc->border_part & LV_BORDER_PART_LEFT) ? border_width : - (border_width + rout));
|
area_small.x1 += ((dsc->border_part & LV_BORDER_SIDE_LEFT) ? border_width : - (border_width + rout));
|
||||||
area_small.x2 -= ((dsc->border_part & LV_BORDER_PART_RIGHT) ? border_width : - (border_width + rout));
|
area_small.x2 -= ((dsc->border_part & LV_BORDER_SIDE_RIGHT) ? border_width : - (border_width + rout));
|
||||||
area_small.y1 += ((dsc->border_part & LV_BORDER_PART_TOP) ? border_width : - (border_width + rout));
|
area_small.y1 += ((dsc->border_part & LV_BORDER_SIDE_TOP) ? border_width : - (border_width + rout));
|
||||||
area_small.y2 -= ((dsc->border_part & LV_BORDER_PART_BOTTOM) ? border_width : - (border_width + rout));
|
area_small.y2 -= ((dsc->border_part & LV_BORDER_SIDE_BOTTOM) ? border_width : - (border_width + rout));
|
||||||
|
|
||||||
/*Create inner the mask*/
|
/*Create inner the mask*/
|
||||||
lv_draw_mask_radius_param_t mask_rin_param;
|
lv_draw_mask_radius_param_t mask_rin_param;
|
||||||
@ -397,7 +397,7 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*Draw the lower corner area corner area*/
|
/*Draw the lower corner area corner area*/
|
||||||
if(dsc->border_part & LV_BORDER_PART_BOTTOM) {
|
if(dsc->border_part & LV_BORDER_SIDE_BOTTOM) {
|
||||||
lv_coord_t lower_corner_end = coords->y2 - disp_area->y1 - corner_size;
|
lv_coord_t lower_corner_end = coords->y2 - disp_area->y1 - corner_size;
|
||||||
if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1;
|
if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1;
|
||||||
fill_area.y1 = disp_area->y1 + lower_corner_end;
|
fill_area.y1 = disp_area->y1 + lower_corner_end;
|
||||||
|
@ -139,8 +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->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->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*/
|
disp->sys_layer = lv_obj_create(NULL, NULL); /*Create sys layer on the display*/
|
||||||
lv_obj_add_style_class(disp->top_layer, LV_OBJ_STYLE_MAIN, &lv_style_transp);
|
lv_obj_add_style_class(disp->top_layer, LV_OBJ_PART_MAIN, &lv_style_transp);
|
||||||
lv_obj_add_style_class(disp->sys_layer, LV_OBJ_STYLE_MAIN, &lv_style_transp);
|
lv_obj_add_style_class(disp->sys_layer, LV_OBJ_PART_MAIN, &lv_style_transp);
|
||||||
|
|
||||||
lv_obj_invalidate(disp->act_scr);
|
lv_obj_invalidate(disp->act_scr);
|
||||||
|
|
||||||
|
@ -121,8 +121,8 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
// lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->style.btn.tgl_pr);
|
// lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->style.btn.tgl_pr);
|
||||||
// lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->style.btn.ina);
|
// lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->style.btn.ina);
|
||||||
} else {
|
} else {
|
||||||
lv_obj_reset_style(new_btn, LV_BTN_STYLE_MAIN);
|
lv_obj_reset_style(new_btn, LV_BTN_PART_MAIN);
|
||||||
lv_obj_add_style_class(new_btn, LV_BTN_STYLE_MAIN, &lv_style_btn);
|
lv_obj_add_style_class(new_btn, LV_BTN_PART_MAIN, &lv_style_btn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*Copy 'copy'*/
|
/*Copy 'copy'*/
|
||||||
@ -137,7 +137,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
// memcpy((void*) ext->styles, copy_ext->styles, sizeof(ext->styles));
|
// memcpy((void*) ext->styles, copy_ext->styles, sizeof(ext->styles));
|
||||||
|
|
||||||
/*Refresh the style with new signal function*/
|
/*Refresh the style with new signal function*/
|
||||||
lv_obj_refresh_style(new_btn,LV_BTN_STYLE_MAIN);
|
lv_obj_refresh_style(new_btn,LV_BTN_PART_MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
LV_LOG_INFO("button created");
|
LV_LOG_INFO("button created");
|
||||||
@ -362,7 +362,7 @@ lv_style_dsc_t * lv_btn_get_style(lv_obj_t * cont, uint8_t type)
|
|||||||
{
|
{
|
||||||
lv_style_dsc_t * style_dsc_p;
|
lv_style_dsc_t * style_dsc_p;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_BTN_STYLE_MAIN:
|
case LV_BTN_PART_MAIN:
|
||||||
style_dsc_p = &cont->style_dsc;
|
style_dsc_p = &cont->style_dsc;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -455,14 +455,14 @@ static lv_design_res_t lv_btn_design(lv_obj_t * btn, const lv_area_t * clip_area
|
|||||||
|
|
||||||
lv_draw_rect_dsc_t draw_dsc;
|
lv_draw_rect_dsc_t draw_dsc;
|
||||||
lv_draw_rect_dsc_init(&draw_dsc);
|
lv_draw_rect_dsc_init(&draw_dsc);
|
||||||
lv_obj_init_draw_rect_dsc(btn, LV_OBJ_STYLE_MAIN, &draw_dsc);
|
lv_obj_init_draw_rect_dsc(btn, LV_OBJ_PART_MAIN, &draw_dsc);
|
||||||
|
|
||||||
lv_draw_rect(&btn->coords, clip_area, &draw_dsc);
|
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)) {
|
if(lv_obj_get_style_value(btn, LV_OBJ_PART_MAIN, LV_STYLE_BG_CLIP_CORNER)) {
|
||||||
lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
|
lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
|
||||||
|
|
||||||
lv_coord_t r = lv_obj_get_style_value(btn, LV_OBJ_STYLE_MAIN, LV_STYLE_RADIUS);
|
lv_coord_t r = lv_obj_get_style_value(btn, LV_OBJ_PART_MAIN, LV_STYLE_RADIUS);
|
||||||
|
|
||||||
lv_draw_mask_radius_init(mp, &btn->coords, r, false);
|
lv_draw_mask_radius_init(mp, &btn->coords, r, false);
|
||||||
/*Add the mask and use `obj+8` as custom id. Don't use `obj` directly because it might be used by the user*/
|
/*Add the mask and use `obj+8` as custom id. Don't use `obj` directly because it might be used by the user*/
|
||||||
|
@ -68,10 +68,10 @@ typedef struct
|
|||||||
|
|
||||||
/**Styles*/
|
/**Styles*/
|
||||||
enum {
|
enum {
|
||||||
LV_BTN_STYLE_MAIN,
|
LV_BTN_PART_MAIN,
|
||||||
|
|
||||||
};
|
};
|
||||||
typedef uint8_t lv_btn_style_t;
|
typedef uint8_t lv_btn_part_t;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* GLOBAL PROTOTYPES
|
* GLOBAL PROTOTYPES
|
||||||
@ -183,7 +183,7 @@ void lv_btn_set_ink_out_time(lv_obj_t * btn, uint16_t time);
|
|||||||
* @param type which style should be set
|
* @param type which style should be set
|
||||||
* @param style pointer to a style
|
* @param style pointer to a style
|
||||||
* */
|
* */
|
||||||
void lv_btn_set_style(lv_obj_t * btn, lv_btn_style_t type, const lv_style_t * style);
|
void lv_btn_set_style(lv_obj_t * btn, lv_btn_part_t type, const lv_style_t * style);
|
||||||
|
|
||||||
/*=====================
|
/*=====================
|
||||||
* Getter functions
|
* Getter functions
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
**********************/
|
**********************/
|
||||||
static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param);
|
static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param);
|
||||||
static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_area, lv_design_mode_t mode);
|
static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_area, lv_design_mode_t mode);
|
||||||
|
static lv_style_dsc_t * lv_btnm_get_style(lv_obj_t * btnm, uint8_t type);
|
||||||
|
|
||||||
static uint8_t get_button_width(lv_btnm_ctrl_t ctrl_bits);
|
static uint8_t get_button_width(lv_btnm_ctrl_t ctrl_bits);
|
||||||
static bool button_is_hidden(lv_btnm_ctrl_t ctrl_bits);
|
static bool button_is_hidden(lv_btnm_ctrl_t ctrl_bits);
|
||||||
static bool button_is_repeat_disabled(lv_btnm_ctrl_t ctrl_bits);
|
static bool button_is_repeat_disabled(lv_btnm_ctrl_t ctrl_bits);
|
||||||
@ -115,13 +117,13 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
// 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_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_BTN_INA, th->style.btnm.btn.ina);
|
||||||
} else {
|
} else {
|
||||||
lv_obj_reset_style(new_btnm, LV_BTNM_STYLE_MAIN);
|
lv_obj_reset_style(new_btnm, LV_BTNM_PART_MAIN);
|
||||||
lv_obj_add_style_class(new_btnm, LV_BTNM_STYLE_MAIN, &lv_style_panel);
|
lv_obj_add_style_class(new_btnm, LV_BTNM_PART_MAIN, &lv_style_panel);
|
||||||
|
|
||||||
/* Do not cache the button style because it's independent from the object's style.
|
/* Do not cache the button style because it's independent from the object's style.
|
||||||
* (Therefore it can't be cached)*/
|
* (Therefore it can't be cached)*/
|
||||||
ext->style_btn.cache.enabled = 0;
|
ext->style_btn.cache.enabled = 0;
|
||||||
lv_obj_add_style_class(new_btnm, LV_BTNM_STYLE_BTN, &lv_style_btn);
|
lv_obj_add_style_class(new_btnm, LV_BTNM_PART_BTN, &lv_style_btn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*Copy an existing object*/
|
/*Copy an existing object*/
|
||||||
@ -172,11 +174,11 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[])
|
|||||||
ext->map_p = map;
|
ext->map_p = map;
|
||||||
|
|
||||||
/*Set size and positions of the buttons*/
|
/*Set size and positions of the buttons*/
|
||||||
lv_style_value_t left = lv_obj_get_style_value(btnm, LV_BTNM_STYLE_MAIN, LV_STYLE_PAD_LEFT);
|
lv_style_value_t left = lv_obj_get_style_value(btnm, LV_BTNM_PART_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 right = lv_obj_get_style_value(btnm, LV_BTNM_PART_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 top = lv_obj_get_style_value(btnm, LV_BTNM_PART_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 bottom = lv_obj_get_style_value(btnm, LV_BTNM_PART_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_style_value_t inner = lv_obj_get_style_value(btnm, LV_BTNM_PART_MAIN, LV_STYLE_PAD_INNER);
|
||||||
|
|
||||||
|
|
||||||
lv_coord_t max_w = lv_obj_get_width(btnm) - left - right;
|
lv_coord_t max_w = lv_obj_get_width(btnm) - left - right;
|
||||||
@ -565,28 +567,6 @@ bool lv_btnm_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lv_style_dsc_t * lv_btnm_get_style(lv_obj_t * btnm, uint8_t type)
|
|
||||||
{
|
|
||||||
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
|
||||||
|
|
||||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
|
||||||
|
|
||||||
lv_style_dsc_t * style_dsc_p;
|
|
||||||
|
|
||||||
switch(type) {
|
|
||||||
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_dsc_p;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find whether "one toggle" mode is enabled.
|
* Find whether "one toggle" mode is enabled.
|
||||||
* @param btnm Button matrix object
|
* @param btnm Button matrix object
|
||||||
@ -647,29 +627,29 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
|
|||||||
|
|
||||||
uint8_t state_ori = btnm->state;
|
uint8_t state_ori = btnm->state;
|
||||||
btnm->state = 0;
|
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_rect_dsc(btnm, LV_BTNM_PART_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]);
|
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_dsc[LV_BTN_STATE_REL]);
|
||||||
|
|
||||||
btnm->state = LV_OBJ_STATE_PRESSED;
|
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_rect_dsc(btnm, LV_BTNM_PART_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]);
|
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_dsc[LV_BTN_STATE_PR]);
|
||||||
|
|
||||||
btnm->state = LV_OBJ_STATE_CHECKED;
|
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_rect_dsc(btnm, LV_BTNM_PART_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]);
|
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_dsc[LV_BTN_STATE_TGL_REL]);
|
||||||
|
|
||||||
btnm->state = LV_OBJ_STATE_PRESSED | LV_OBJ_STATE_CHECKED;
|
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_rect_dsc(btnm, LV_BTNM_PART_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]);
|
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_dsc[LV_BTN_STATE_TGL_PR]);
|
||||||
|
|
||||||
btnm->state = LV_OBJ_STATE_DISABLED;
|
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_rect_dsc(btnm, LV_BTNM_PART_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]);
|
lv_obj_init_draw_label_dsc(btnm, LV_BTNM_PART_BTN, &draw_label_dsc[LV_BTN_STATE_INA]);
|
||||||
|
|
||||||
btnm->state = state_ori;
|
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_top = lv_obj_get_style_value(btnm, LV_BTNM_PART_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);
|
lv_style_value_t padding_bottom = lv_obj_get_style_value(btnm, LV_BTNM_PART_MAIN, LV_STYLE_PAD_BOTTOM);
|
||||||
|
|
||||||
if(ext->recolor) txt_flag = LV_TXT_FLAG_RECOLOR;
|
if(ext->recolor) txt_flag = LV_TXT_FLAG_RECOLOR;
|
||||||
for(btn_i = 0; btn_i < ext->btn_cnt; btn_i++, txt_i++) {
|
for(btn_i = 0; btn_i < ext->btn_cnt; btn_i++, txt_i++) {
|
||||||
@ -705,24 +685,24 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
|
|||||||
lv_style_value_t border_part_ori = draw_rect_dsc[act_state].border_part;
|
lv_style_value_t border_part_ori = draw_rect_dsc[act_state].border_part;
|
||||||
|
|
||||||
/*Remove borders on the edges if `LV_BORDER_INTERNAL`*/
|
/*Remove borders on the edges if `LV_BORDER_INTERNAL`*/
|
||||||
if(border_part_ori & LV_BORDER_PART_INTERNAL) {
|
if(border_part_ori & LV_BORDER_SIDE_INTERNAL) {
|
||||||
/*Top/Bottom lines*/
|
/*Top/Bottom lines*/
|
||||||
if(area_tmp.y1 == btnm->coords.y1 + padding_top) {
|
if(area_tmp.y1 == btnm->coords.y1 + padding_top) {
|
||||||
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_PART_TOP;
|
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_SIDE_TOP;
|
||||||
}
|
}
|
||||||
if(area_tmp.y2 == btnm->coords.y2 - padding_bottom) {
|
if(area_tmp.y2 == btnm->coords.y2 - padding_bottom) {
|
||||||
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_PART_BOTTOM;
|
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_SIDE_BOTTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Left/right columns*/
|
/*Left/right columns*/
|
||||||
if(txt_i == 0) { /*First button*/
|
if(txt_i == 0) { /*First button*/
|
||||||
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_PART_LEFT;
|
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_SIDE_LEFT;
|
||||||
} else if(strcmp(ext->map_p[txt_i - 1], "\n") == 0) {
|
} else if(strcmp(ext->map_p[txt_i - 1], "\n") == 0) {
|
||||||
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_PART_LEFT;
|
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_SIDE_LEFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ext->map_p[txt_i + 1][0] == '\0' || strcmp(ext->map_p[txt_i + 1], "\n") == 0) {
|
if(ext->map_p[txt_i + 1][0] == '\0' || strcmp(ext->map_p[txt_i + 1], "\n") == 0) {
|
||||||
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_PART_RIGHT;
|
draw_rect_dsc[act_state].border_part &= ~LV_BORDER_SIDE_RIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -825,9 +805,9 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
|||||||
/*Toggle the button if enabled*/
|
/*Toggle the button if enabled*/
|
||||||
if(button_is_tgl_enabled(ext->ctrl_bits[ext->btn_id_pr])) {
|
if(button_is_tgl_enabled(ext->ctrl_bits[ext->btn_id_pr])) {
|
||||||
if(button_get_tgl_state(ext->ctrl_bits[ext->btn_id_pr])) {
|
if(button_get_tgl_state(ext->ctrl_bits[ext->btn_id_pr])) {
|
||||||
ext->ctrl_bits[ext->btn_id_pr] &= (~LV_BTNM_CTRL_TGL_STATE);
|
ext->ctrl_bits[ext->btn_id_pr] &= (~LV_BTNM_CTRL_CHECHK_STATE);
|
||||||
} else {
|
} else {
|
||||||
ext->ctrl_bits[ext->btn_id_pr] |= LV_BTNM_CTRL_TGL_STATE;
|
ext->ctrl_bits[ext->btn_id_pr] |= LV_BTNM_CTRL_CHECHK_STATE;
|
||||||
}
|
}
|
||||||
if(ext->one_toggle) make_one_button_toggled(btnm, ext->btn_id_pr);
|
if(ext->one_toggle) make_one_button_toggled(btnm, ext->btn_id_pr);
|
||||||
}
|
}
|
||||||
@ -913,7 +893,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;
|
ext->btn_id_act = ext->btn_id_pr;
|
||||||
lv_obj_invalidate(btnm);
|
lv_obj_invalidate(btnm);
|
||||||
} else if(c == LV_KEY_DOWN) {
|
} else if(c == LV_KEY_DOWN) {
|
||||||
lv_style_value_t pad_inner = lv_obj_get_style_value(btnm, LV_BTNM_STYLE_MAIN, LV_STYLE_PAD_INNER);
|
lv_style_value_t pad_inner = lv_obj_get_style_value(btnm, LV_BTNM_PART_MAIN, LV_STYLE_PAD_INNER);
|
||||||
/*Find the area below the the current*/
|
/*Find the area below the the current*/
|
||||||
if(ext->btn_id_pr == LV_BTNM_BTN_NONE) {
|
if(ext->btn_id_pr == LV_BTNM_BTN_NONE) {
|
||||||
ext->btn_id_pr = 0;
|
ext->btn_id_pr = 0;
|
||||||
@ -935,7 +915,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;
|
ext->btn_id_act = ext->btn_id_pr;
|
||||||
lv_obj_invalidate(btnm);
|
lv_obj_invalidate(btnm);
|
||||||
} else if(c == LV_KEY_UP) {
|
} else if(c == LV_KEY_UP) {
|
||||||
lv_style_value_t pad_inner = lv_obj_get_style_value(btnm, LV_BTNM_STYLE_MAIN, LV_STYLE_PAD_INNER);
|
lv_style_value_t pad_inner = lv_obj_get_style_value(btnm, LV_BTNM_PART_MAIN, LV_STYLE_PAD_INNER);
|
||||||
/*Find the area below the the current*/
|
/*Find the area below the the current*/
|
||||||
if(ext->btn_id_pr == LV_BTNM_BTN_NONE) {
|
if(ext->btn_id_pr == LV_BTNM_BTN_NONE) {
|
||||||
ext->btn_id_pr = 0;
|
ext->btn_id_pr = 0;
|
||||||
@ -963,6 +943,27 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static lv_style_dsc_t * lv_btnm_get_style(lv_obj_t * btnm, uint8_t type)
|
||||||
|
{
|
||||||
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||||
|
|
||||||
|
lv_style_dsc_t * style_dsc_p;
|
||||||
|
|
||||||
|
switch(type) {
|
||||||
|
case LV_BTNM_PART_MAIN:
|
||||||
|
style_dsc_p = &btnm->style_dsc;
|
||||||
|
break;
|
||||||
|
case LV_BTNM_PART_BTN:
|
||||||
|
style_dsc_p = &ext->style_btn;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
style_dsc_p = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return style_dsc_p;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Create the required number of buttons and control bytes according to a map
|
* Create the required number of buttons and control bytes according to a map
|
||||||
* @param btnm pointer to button matrix object
|
* @param btnm pointer to button matrix object
|
||||||
@ -1035,12 +1036,12 @@ static bool button_is_click_trig(lv_btnm_ctrl_t ctrl_bits)
|
|||||||
|
|
||||||
static bool button_is_tgl_enabled(lv_btnm_ctrl_t ctrl_bits)
|
static bool button_is_tgl_enabled(lv_btnm_ctrl_t ctrl_bits)
|
||||||
{
|
{
|
||||||
return ctrl_bits & LV_BTNM_CTRL_TGL_ENABLE ? true : false;
|
return ctrl_bits & LV_BTNM_CTRL_CHECKABLE ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool button_get_tgl_state(lv_btnm_ctrl_t ctrl_bits)
|
static bool button_get_tgl_state(lv_btnm_ctrl_t ctrl_bits)
|
||||||
{
|
{
|
||||||
return ctrl_bits & LV_BTNM_CTRL_TGL_STATE ? true : false;
|
return ctrl_bits & LV_BTNM_CTRL_CHECHK_STATE ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1121,11 +1122,11 @@ static bool maps_are_identical(const char ** map1, const char ** map2)
|
|||||||
static void make_one_button_toggled(lv_obj_t * btnm, uint16_t btn_idx)
|
static void make_one_button_toggled(lv_obj_t * btnm, uint16_t btn_idx)
|
||||||
{
|
{
|
||||||
/*Save whether the button was toggled*/
|
/*Save whether the button was toggled*/
|
||||||
bool was_toggled = lv_btnm_get_btn_ctrl(btnm, btn_idx, LV_BTNM_CTRL_TGL_STATE);
|
bool was_toggled = lv_btnm_get_btn_ctrl(btnm, btn_idx, LV_BTNM_CTRL_CHECHK_STATE);
|
||||||
|
|
||||||
lv_btnm_clear_btn_ctrl_all(btnm, LV_BTNM_CTRL_TGL_STATE);
|
lv_btnm_clear_btn_ctrl_all(btnm, LV_BTNM_CTRL_CHECHK_STATE);
|
||||||
|
|
||||||
if(was_toggled) lv_btnm_set_btn_ctrl(btnm, btn_idx, LV_BTNM_CTRL_TGL_STATE);
|
if(was_toggled) lv_btnm_set_btn_ctrl(btnm, btn_idx, LV_BTNM_CTRL_CHECHK_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,13 +33,14 @@ LV_EXPORT_CONST_INT(LV_BTNM_BTN_NONE);
|
|||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
/** Type to store button control bits (disabled, hidden etc.) */
|
/** Type to store button control bits (disabled, hidden etc.)
|
||||||
|
* The first 3 bits are used to store the width */
|
||||||
enum {
|
enum {
|
||||||
LV_BTNM_CTRL_HIDDEN = 0x0008, /**< Button hidden */
|
LV_BTNM_CTRL_HIDDEN = 0x0008, /**< Button hidden */
|
||||||
LV_BTNM_CTRL_NO_REPEAT = 0x0010, /**< Do not repeat press this button. */
|
LV_BTNM_CTRL_NO_REPEAT = 0x0010, /**< Do not repeat press this button. */
|
||||||
LV_BTNM_CTRL_INACTIVE = 0x0020, /**< Disable this button. */
|
LV_BTNM_CTRL_INACTIVE = 0x0020, /**< Disable this button. */
|
||||||
LV_BTNM_CTRL_TGL_ENABLE = 0x0040, /**< Button *can* be toggled. */
|
LV_BTNM_CTRL_CHECKABLE = 0x0040, /**< Button *can* be toggled. */
|
||||||
LV_BTNM_CTRL_TGL_STATE = 0x0080, /**< Button is currently toggled (e.g. checked). */
|
LV_BTNM_CTRL_CHECHK_STATE = 0x0080, /**< Button is currently toggled (e.g. checked). */
|
||||||
LV_BTNM_CTRL_CLICK_TRIG = 0x0100, /**< 1: Send LV_EVENT_SELECTED on CLICK, 0: Send LV_EVENT_SELECTED on PRESS*/
|
LV_BTNM_CTRL_CLICK_TRIG = 0x0100, /**< 1: Send LV_EVENT_SELECTED on CLICK, 0: Send LV_EVENT_SELECTED on PRESS*/
|
||||||
};
|
};
|
||||||
typedef uint16_t lv_btnm_ctrl_t;
|
typedef uint16_t lv_btnm_ctrl_t;
|
||||||
@ -61,10 +62,10 @@ typedef struct
|
|||||||
} lv_btnm_ext_t;
|
} lv_btnm_ext_t;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
LV_BTNM_STYLE_MAIN,
|
LV_BTNM_PART_MAIN,
|
||||||
LV_BTNM_STYLE_BTN,
|
LV_BTNM_PART_BTN,
|
||||||
};
|
};
|
||||||
typedef uint8_t lv_btnm_style_t;
|
typedef uint8_t lv_btnm_part_t;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* GLOBAL PROTOTYPES
|
* GLOBAL PROTOTYPES
|
||||||
@ -120,7 +121,7 @@ void lv_btnm_set_pressed(const lv_obj_t * btnm, uint16_t id);
|
|||||||
* @param type which style should be set
|
* @param type which style should be set
|
||||||
* @param style pointer to a style
|
* @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);
|
void lv_btnm_set_style(lv_obj_t * btnm, lv_btnm_part_t type, const lv_style_t * style);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable recoloring of button's texts
|
* Enable recoloring of button's texts
|
||||||
@ -241,9 +242,6 @@ 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);
|
bool lv_btnm_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl);
|
||||||
|
|
||||||
|
|
||||||
lv_style_dsc_t * lv_btnm_get_style(lv_obj_t * btnm, uint8_t type);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find whether "one toggle" mode is enabled.
|
* Find whether "one toggle" mode is enabled.
|
||||||
* @param btnm Button matrix object
|
* @param btnm Button matrix object
|
||||||
|
@ -99,9 +99,9 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
if(par != NULL) {
|
if(par != NULL) {
|
||||||
lv_theme_t * th = lv_theme_get_current();
|
lv_theme_t * th = lv_theme_get_current();
|
||||||
if(th) {
|
if(th) {
|
||||||
// lv_cont_set_style(new_cont, LV_CONT_STYLE_MAIN, th->style_dsc.cont);
|
// lv_cont_set_style(new_cont, LV_CONT_PART_MAIN, th->style_dsc.cont);
|
||||||
} else {
|
} else {
|
||||||
lv_obj_add_style_class(new_cont, LV_CONT_STYLE_MAIN, &lv_style_panel);
|
lv_obj_add_style_class(new_cont, LV_CONT_PART_MAIN, &lv_style_panel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
ext->layout = copy_ext->layout;
|
ext->layout = copy_ext->layout;
|
||||||
|
|
||||||
/*Refresh the style with new signal function*/
|
/*Refresh the style with new signal function*/
|
||||||
lv_obj_refresh_style(new_cont, LV_CONT_STYLE_MAIN);
|
lv_obj_refresh_style(new_cont, LV_CONT_PART_MAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
LV_LOG_INFO("container created");
|
LV_LOG_INFO("container created");
|
||||||
@ -247,7 +247,7 @@ lv_style_dsc_t * lv_cont_get_style(lv_obj_t * cont, uint8_t type)
|
|||||||
{
|
{
|
||||||
lv_style_dsc_t * style_dsc_p;
|
lv_style_dsc_t * style_dsc_p;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_CONT_STYLE_MAIN:
|
case LV_CONT_PART_MAIN:
|
||||||
style_dsc_p = &cont->style_dsc;
|
style_dsc_p = &cont->style_dsc;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -336,10 +336,10 @@ static void lv_cont_refr_layout(lv_obj_t * cont)
|
|||||||
*/
|
*/
|
||||||
static void lv_cont_layout_col(lv_obj_t * cont)
|
static void lv_cont_layout_col(lv_obj_t * cont)
|
||||||
{
|
{
|
||||||
lv_coord_t left = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_LEFT);
|
lv_coord_t left = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_LEFT);
|
||||||
lv_coord_t right = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_RIGHT);
|
lv_coord_t right = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_RIGHT);
|
||||||
lv_coord_t top = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_TOP);
|
lv_coord_t top = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_TOP);
|
||||||
lv_coord_t inner = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_INNER);
|
lv_coord_t inner = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_INNER);
|
||||||
|
|
||||||
lv_layout_t type = lv_cont_get_layout(cont);
|
lv_layout_t type = lv_cont_get_layout(cont);
|
||||||
lv_obj_t * child;
|
lv_obj_t * child;
|
||||||
@ -399,7 +399,7 @@ static void lv_cont_layout_row(lv_obj_t * cont)
|
|||||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(cont);
|
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(cont);
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_LAYOUT_ROW_T:
|
case LV_LAYOUT_ROW_T:
|
||||||
vpad_corr = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_TOP);
|
vpad_corr = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_TOP);
|
||||||
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_TOP_RIGHT : LV_ALIGN_IN_TOP_LEFT;
|
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_TOP_RIGHT : LV_ALIGN_IN_TOP_LEFT;
|
||||||
break;
|
break;
|
||||||
case LV_LAYOUT_ROW_M:
|
case LV_LAYOUT_ROW_M:
|
||||||
@ -407,7 +407,7 @@ static void lv_cont_layout_row(lv_obj_t * cont)
|
|||||||
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_RIGHT_MID: LV_ALIGN_IN_LEFT_MID;
|
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_RIGHT_MID: LV_ALIGN_IN_LEFT_MID;
|
||||||
break;
|
break;
|
||||||
case LV_LAYOUT_ROW_B:
|
case LV_LAYOUT_ROW_B:
|
||||||
vpad_corr = -lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_BOTTOM);;
|
vpad_corr = -lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_BOTTOM);;
|
||||||
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_BOTTOM_RIGHT: LV_ALIGN_IN_BOTTOM_LEFT;
|
align = base_dir == LV_BIDI_DIR_RTL ? LV_ALIGN_IN_BOTTOM_RIGHT: LV_ALIGN_IN_BOTTOM_LEFT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -422,10 +422,10 @@ static void lv_cont_layout_row(lv_obj_t * cont)
|
|||||||
|
|
||||||
/* Align the children */
|
/* Align the children */
|
||||||
lv_coord_t last_cord;
|
lv_coord_t last_cord;
|
||||||
if(base_dir == LV_BIDI_DIR_RTL) last_cord = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_RIGHT);
|
if(base_dir == LV_BIDI_DIR_RTL) last_cord = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_RIGHT);
|
||||||
else last_cord = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_LEFT);
|
else last_cord = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_LEFT);
|
||||||
|
|
||||||
lv_coord_t inner = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_INNER);
|
lv_coord_t inner = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_INNER);
|
||||||
|
|
||||||
LV_LL_READ_BACK(cont->child_ll, child)
|
LV_LL_READ_BACK(cont->child_ll, child)
|
||||||
{
|
{
|
||||||
@ -450,7 +450,7 @@ static void lv_cont_layout_center(lv_obj_t * cont)
|
|||||||
uint32_t obj_num = 0;
|
uint32_t obj_num = 0;
|
||||||
lv_coord_t h_tot = 0;
|
lv_coord_t h_tot = 0;
|
||||||
|
|
||||||
lv_coord_t inner = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_INNER);
|
lv_coord_t inner = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_INNER);
|
||||||
LV_LL_READ(cont->child_ll, child)
|
LV_LL_READ(cont->child_ll, child)
|
||||||
{
|
{
|
||||||
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||||
@ -490,7 +490,7 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
|||||||
lv_obj_t * child_rc; /* Row closer child */
|
lv_obj_t * child_rc; /* Row closer child */
|
||||||
lv_obj_t * child_tmp; /* Temporary child */
|
lv_obj_t * child_tmp; /* Temporary child */
|
||||||
lv_coord_t w_obj = lv_obj_get_width(cont);
|
lv_coord_t w_obj = lv_obj_get_width(cont);
|
||||||
lv_coord_t act_y = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_TOP);
|
lv_coord_t act_y = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_TOP);
|
||||||
/* Disable child change action because the children will be moved a lot
|
/* Disable child change action because the children will be moved a lot
|
||||||
* an unnecessary child change signals could be sent*/
|
* an unnecessary child change signals could be sent*/
|
||||||
|
|
||||||
@ -498,9 +498,9 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
|||||||
if(child_rs == NULL) return; /*Return if no child*/
|
if(child_rs == NULL) return; /*Return if no child*/
|
||||||
|
|
||||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||||
lv_coord_t left = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_LEFT);
|
lv_coord_t left = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_LEFT);
|
||||||
lv_coord_t right = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_RIGHT);
|
lv_coord_t right = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_RIGHT);
|
||||||
lv_coord_t inner = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_INNER);
|
lv_coord_t inner = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_INNER);
|
||||||
|
|
||||||
child_rc = child_rs; /*Initially the the row starter and closer is the same*/
|
child_rc = child_rs; /*Initially the the row starter and closer is the same*/
|
||||||
while(child_rs != NULL) {
|
while(child_rs != NULL) {
|
||||||
@ -588,7 +588,7 @@ static void lv_cont_layout_grid(lv_obj_t * cont)
|
|||||||
lv_coord_t w_obj = lv_obj_get_width(lv_obj_get_child(cont, NULL));
|
lv_coord_t w_obj = lv_obj_get_width(lv_obj_get_child(cont, NULL));
|
||||||
lv_coord_t w_fit = lv_obj_get_width_fit(cont);
|
lv_coord_t w_fit = lv_obj_get_width_fit(cont);
|
||||||
lv_coord_t h_obj = lv_obj_get_height(lv_obj_get_child(cont, NULL));
|
lv_coord_t h_obj = lv_obj_get_height(lv_obj_get_child(cont, NULL));
|
||||||
lv_coord_t inner = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_INNER);
|
lv_coord_t inner = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_INNER);
|
||||||
uint16_t obj_row = (w_fit) / (w_obj + inner); /*Obj. num. in a row*/
|
uint16_t obj_row = (w_fit) / (w_obj + inner); /*Obj. num. in a row*/
|
||||||
lv_coord_t x_ofs;
|
lv_coord_t x_ofs;
|
||||||
if(obj_row > 1) {
|
if(obj_row > 1) {
|
||||||
@ -603,9 +603,9 @@ static void lv_cont_layout_grid(lv_obj_t * cont)
|
|||||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||||
|
|
||||||
/* Align the children */
|
/* Align the children */
|
||||||
lv_coord_t left = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_LEFT);
|
lv_coord_t left = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_LEFT);
|
||||||
lv_coord_t act_x = left;
|
lv_coord_t act_x = left;
|
||||||
lv_coord_t act_y = lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_TOP);
|
lv_coord_t act_y = lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_TOP);
|
||||||
uint16_t obj_cnt = 0;
|
uint16_t obj_cnt = 0;
|
||||||
LV_LL_READ_BACK(cont->child_ll, child)
|
LV_LL_READ_BACK(cont->child_ll, child)
|
||||||
{
|
{
|
||||||
@ -653,10 +653,10 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
|||||||
lv_obj_t * par = lv_obj_get_parent(cont);
|
lv_obj_t * par = lv_obj_get_parent(cont);
|
||||||
lv_area_t flood_area;
|
lv_area_t flood_area;
|
||||||
lv_area_copy(&flood_area, &par->coords);
|
lv_area_copy(&flood_area, &par->coords);
|
||||||
flood_area.x1 += lv_obj_get_style_value(par, LV_OBJ_STYLE_MAIN, LV_STYLE_PAD_LEFT);
|
flood_area.x1 += lv_obj_get_style_value(par, LV_OBJ_PART_MAIN, LV_STYLE_PAD_LEFT);
|
||||||
flood_area.x2 -= lv_obj_get_style_value(par, LV_OBJ_STYLE_MAIN, LV_STYLE_PAD_RIGHT);
|
flood_area.x2 -= lv_obj_get_style_value(par, LV_OBJ_PART_MAIN, LV_STYLE_PAD_RIGHT);
|
||||||
flood_area.y1 += lv_obj_get_style_value(par, LV_OBJ_STYLE_MAIN, LV_STYLE_PAD_TOP);
|
flood_area.y1 += lv_obj_get_style_value(par, LV_OBJ_PART_MAIN, LV_STYLE_PAD_TOP);
|
||||||
flood_area.y2 -= lv_obj_get_style_value(par, LV_OBJ_STYLE_MAIN, LV_STYLE_PAD_BOTTOM);
|
flood_area.y2 -= lv_obj_get_style_value(par, LV_OBJ_PART_MAIN, LV_STYLE_PAD_BOTTOM);
|
||||||
|
|
||||||
/*Search the side coordinates of the children*/
|
/*Search the side coordinates of the children*/
|
||||||
lv_obj_get_coords(cont, &ori);
|
lv_obj_get_coords(cont, &ori);
|
||||||
@ -679,10 +679,10 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
|||||||
tight_area.y2 = LV_MATH_MAX(tight_area.y2, child_i->coords.y2);
|
tight_area.y2 = LV_MATH_MAX(tight_area.y2, child_i->coords.y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
tight_area.x1 -= lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_LEFT);
|
tight_area.x1 -= lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_LEFT);
|
||||||
tight_area.x2 += lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_RIGHT);
|
tight_area.x2 += lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_RIGHT);
|
||||||
tight_area.y1 -= lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_TOP);
|
tight_area.y1 -= lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_TOP);
|
||||||
tight_area.y2 += lv_obj_get_style_value(cont, LV_CONT_STYLE_MAIN, LV_STYLE_PAD_BOTTOM);
|
tight_area.y2 += lv_obj_get_style_value(cont, LV_CONT_PART_MAIN, LV_STYLE_PAD_BOTTOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
lv_area_t new_area;
|
lv_area_t new_area;
|
||||||
|
@ -69,9 +69,9 @@ typedef struct
|
|||||||
|
|
||||||
/*Styles*/
|
/*Styles*/
|
||||||
enum {
|
enum {
|
||||||
LV_CONT_STYLE_MAIN,
|
LV_CONT_PART_MAIN,
|
||||||
};
|
};
|
||||||
typedef uint8_t lv_cont_style_t;
|
typedef uint8_t lv_cont_part_t;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* GLOBAL PROTOTYPES
|
* GLOBAL PROTOTYPES
|
||||||
|
@ -591,9 +591,9 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_
|
|||||||
uint32_t line_start = 0;
|
uint32_t line_start = 0;
|
||||||
uint32_t new_line_start = 0;
|
uint32_t new_line_start = 0;
|
||||||
lv_coord_t max_w = lv_obj_get_width(label);
|
lv_coord_t max_w = lv_obj_get_width(label);
|
||||||
const lv_font_t * font = lv_obj_get_style_ptr(label, LV_LABEL_STYLE_MAIN, LV_STYLE_FONT);
|
const lv_font_t * font = lv_obj_get_style_ptr(label, LV_LABEL_PART_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 line_space = lv_obj_get_style_value(label, LV_LABEL_PART_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_style_value_t letter_space = lv_obj_get_style_value(label, LV_LABEL_PART_MAIN, LV_STYLE_LETTER_SPACE);
|
||||||
lv_coord_t letter_height = lv_font_get_line_height(font);
|
lv_coord_t letter_height = lv_font_get_line_height(font);
|
||||||
lv_coord_t y = 0;
|
lv_coord_t y = 0;
|
||||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||||
@ -695,9 +695,9 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
|||||||
uint32_t line_start = 0;
|
uint32_t line_start = 0;
|
||||||
uint32_t new_line_start = 0;
|
uint32_t new_line_start = 0;
|
||||||
lv_coord_t max_w = lv_obj_get_width(label);
|
lv_coord_t max_w = lv_obj_get_width(label);
|
||||||
const lv_font_t * font = lv_obj_get_style_ptr(label, LV_LABEL_STYLE_MAIN, LV_STYLE_FONT);
|
const lv_font_t * font = lv_obj_get_style_ptr(label, LV_LABEL_PART_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 line_space = lv_obj_get_style_value(label, LV_LABEL_PART_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_style_value_t letter_space = lv_obj_get_style_value(label, LV_LABEL_PART_MAIN, LV_STYLE_LETTER_SPACE);
|
||||||
lv_coord_t letter_height = lv_font_get_line_height(font);
|
lv_coord_t letter_height = lv_font_get_line_height(font);
|
||||||
lv_coord_t y = 0;
|
lv_coord_t y = 0;
|
||||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||||
@ -856,9 +856,9 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
|
|||||||
uint32_t line_start = 0;
|
uint32_t line_start = 0;
|
||||||
uint32_t new_line_start = 0;
|
uint32_t new_line_start = 0;
|
||||||
lv_coord_t max_w = lv_obj_get_width(label);
|
lv_coord_t max_w = lv_obj_get_width(label);
|
||||||
const lv_font_t * font = lv_obj_get_style_ptr(label, LV_LABEL_STYLE_MAIN, LV_STYLE_FONT);
|
const lv_font_t * font = lv_obj_get_style_ptr(label, LV_LABEL_PART_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 line_space = lv_obj_get_style_value(label, LV_LABEL_PART_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_style_value_t letter_space = lv_obj_get_style_value(label, LV_LABEL_PART_MAIN, LV_STYLE_LETTER_SPACE);
|
||||||
lv_coord_t letter_height = lv_font_get_line_height(font);
|
lv_coord_t letter_height = lv_font_get_line_height(font);
|
||||||
lv_coord_t y = 0;
|
lv_coord_t y = 0;
|
||||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||||
@ -938,7 +938,7 @@ lv_style_dsc_t * lv_label_get_style(lv_obj_t * label, uint8_t type)
|
|||||||
{
|
{
|
||||||
lv_style_dsc_t * style_dsc_p;
|
lv_style_dsc_t * style_dsc_p;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_LABEL_STYLE_MAIN:
|
case LV_LABEL_PART_MAIN:
|
||||||
style_dsc_p = &label->style_dsc;
|
style_dsc_p = &label->style_dsc;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1044,9 +1044,9 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_
|
|||||||
return LV_DESIGN_RES_NOT_COVER;
|
return LV_DESIGN_RES_NOT_COVER;
|
||||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||||
lv_area_t coords;
|
lv_area_t coords;
|
||||||
const lv_font_t * font = lv_obj_get_style_ptr(label, LV_LABEL_STYLE_MAIN, LV_STYLE_FONT);
|
const lv_font_t * font = lv_obj_get_style_ptr(label, LV_LABEL_PART_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 line_space = lv_obj_get_style_value(label, LV_LABEL_PART_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_style_value_t letter_space = lv_obj_get_style_value(label, LV_LABEL_PART_MAIN, LV_STYLE_LETTER_SPACE);
|
||||||
lv_obj_get_coords(label, &coords);
|
lv_obj_get_coords(label, &coords);
|
||||||
|
|
||||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||||
@ -1054,10 +1054,10 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_
|
|||||||
lv_area_t bg;
|
lv_area_t bg;
|
||||||
lv_obj_get_coords(label, &bg);
|
lv_obj_get_coords(label, &bg);
|
||||||
|
|
||||||
lv_coord_t left = lv_obj_get_style_value(label, LV_LABEL_STYLE_MAIN, LV_STYLE_PAD_LEFT);
|
lv_coord_t left = lv_obj_get_style_value(label, LV_LABEL_PART_MAIN, LV_STYLE_PAD_LEFT);
|
||||||
lv_coord_t right = lv_obj_get_style_value(label, LV_LABEL_STYLE_MAIN, LV_STYLE_PAD_RIGHT);
|
lv_coord_t right = lv_obj_get_style_value(label, LV_LABEL_PART_MAIN, LV_STYLE_PAD_RIGHT);
|
||||||
lv_coord_t top = lv_obj_get_style_value(label, LV_LABEL_STYLE_MAIN, LV_STYLE_PAD_TOP);
|
lv_coord_t top = lv_obj_get_style_value(label, LV_LABEL_PART_MAIN, LV_STYLE_PAD_TOP);
|
||||||
lv_coord_t bottom = lv_obj_get_style_value(label, LV_LABEL_STYLE_MAIN, LV_STYLE_PAD_BOTTOM);
|
lv_coord_t bottom = lv_obj_get_style_value(label, LV_LABEL_PART_MAIN, LV_STYLE_PAD_BOTTOM);
|
||||||
bg.x1 -= left;
|
bg.x1 -= left;
|
||||||
bg.x2 += right;
|
bg.x2 += right;
|
||||||
bg.y1 -= top;
|
bg.y1 -= top;
|
||||||
@ -1065,7 +1065,7 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_
|
|||||||
|
|
||||||
lv_draw_rect_dsc_t draw_rect_dsc;
|
lv_draw_rect_dsc_t draw_rect_dsc;
|
||||||
lv_draw_rect_dsc_init(&draw_rect_dsc);
|
lv_draw_rect_dsc_init(&draw_rect_dsc);
|
||||||
lv_obj_init_draw_rect_dsc(label, LV_LABEL_STYLE_MAIN, &draw_rect_dsc);
|
lv_obj_init_draw_rect_dsc(label, LV_LABEL_PART_MAIN, &draw_rect_dsc);
|
||||||
|
|
||||||
lv_draw_rect(&bg, clip_area, &draw_rect_dsc);
|
lv_draw_rect(&bg, clip_area, &draw_rect_dsc);
|
||||||
}
|
}
|
||||||
@ -1108,7 +1108,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_x = ext->offset.x;
|
||||||
label_draw_dsc.ofs_y = ext->offset.y;
|
label_draw_dsc.ofs_y = ext->offset.y;
|
||||||
label_draw_dsc.flag = flag;
|
label_draw_dsc.flag = flag;
|
||||||
lv_obj_init_draw_label_dsc(label, LV_LABEL_STYLE_MAIN, &label_draw_dsc);
|
lv_obj_init_draw_label_dsc(label, LV_LABEL_PART_MAIN, &label_draw_dsc);
|
||||||
|
|
||||||
lv_draw_label(&coords, clip_area, &label_draw_dsc, ext->text, hint);
|
lv_draw_label(&coords, clip_area, &label_draw_dsc, ext->text, hint);
|
||||||
|
|
||||||
@ -1182,10 +1182,10 @@ static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param
|
|||||||
}
|
}
|
||||||
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||||
if(ext->body_draw) {
|
if(ext->body_draw) {
|
||||||
lv_coord_t left = lv_obj_get_style_value(label, LV_LABEL_STYLE_MAIN, LV_STYLE_PAD_LEFT);
|
lv_coord_t left = lv_obj_get_style_value(label, LV_LABEL_PART_MAIN, LV_STYLE_PAD_LEFT);
|
||||||
lv_coord_t right = lv_obj_get_style_value(label, LV_LABEL_STYLE_MAIN, LV_STYLE_PAD_RIGHT);
|
lv_coord_t right = lv_obj_get_style_value(label, LV_LABEL_PART_MAIN, LV_STYLE_PAD_RIGHT);
|
||||||
lv_coord_t top = lv_obj_get_style_value(label, LV_LABEL_STYLE_MAIN, LV_STYLE_PAD_TOP);
|
lv_coord_t top = lv_obj_get_style_value(label, LV_LABEL_PART_MAIN, LV_STYLE_PAD_TOP);
|
||||||
lv_coord_t bottom = lv_obj_get_style_value(label, LV_LABEL_STYLE_MAIN, LV_STYLE_PAD_BOTTOM);
|
lv_coord_t bottom = lv_obj_get_style_value(label, LV_LABEL_PART_MAIN, LV_STYLE_PAD_BOTTOM);
|
||||||
label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, left);
|
label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, left);
|
||||||
label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, right);
|
label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, right);
|
||||||
label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, top);
|
label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, top);
|
||||||
@ -1222,9 +1222,9 @@ static void lv_label_refr_text(lv_obj_t * label)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
lv_coord_t max_w = lv_obj_get_width(label);
|
lv_coord_t max_w = lv_obj_get_width(label);
|
||||||
const lv_font_t * font = lv_obj_get_style_ptr(label, LV_LABEL_STYLE_MAIN, LV_STYLE_FONT);
|
const lv_font_t * font = lv_obj_get_style_ptr(label, LV_LABEL_PART_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 line_space = lv_obj_get_style_value(label, LV_LABEL_PART_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_style_value_t letter_space = lv_obj_get_style_value(label, LV_LABEL_PART_MAIN, LV_STYLE_LETTER_SPACE);
|
||||||
|
|
||||||
/*If the width will be expanded set the max length to very big */
|
/*If the width will be expanded set the max length to very big */
|
||||||
if(ext->long_mode == LV_LABEL_LONG_EXPAND) {
|
if(ext->long_mode == LV_LABEL_LONG_EXPAND) {
|
||||||
|
@ -103,10 +103,10 @@ typedef struct
|
|||||||
|
|
||||||
/** Label styles*/
|
/** Label styles*/
|
||||||
enum {
|
enum {
|
||||||
LV_LABEL_STYLE_MAIN,
|
LV_LABEL_PART_MAIN,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef uint8_t lv_label_style_t;
|
typedef uint8_t lv_label_part_t;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* GLOBAL PROTOTYPES
|
* GLOBAL PROTOTYPES
|
||||||
|
@ -45,8 +45,8 @@
|
|||||||
**********************/
|
**********************/
|
||||||
static void lv_page_sb_refresh(lv_obj_t * page);
|
static void lv_page_sb_refresh(lv_obj_t * page);
|
||||||
static lv_design_res_t lv_page_design(lv_obj_t * page, const lv_area_t * clip_area, lv_design_mode_t mode);
|
static lv_design_res_t lv_page_design(lv_obj_t * page, const lv_area_t * clip_area, lv_design_mode_t mode);
|
||||||
static lv_design_res_t lv_scrl_design(lv_obj_t * scrl, const lv_area_t * clisp_area, lv_design_mode_t mode);
|
|
||||||
static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param);
|
static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param);
|
||||||
|
static lv_style_dsc_t * lv_page_get_style(lv_obj_t * page, uint8_t type);
|
||||||
static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param);
|
static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param);
|
||||||
static void scrl_def_event_cb(lv_obj_t * scrl, lv_event_t event);
|
static void scrl_def_event_cb(lv_obj_t * scrl, lv_event_t event);
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
@ -97,7 +97,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
ext->scrl = NULL;
|
ext->scrl = NULL;
|
||||||
ext->sb.hor_draw = 0;
|
ext->sb.hor_draw = 0;
|
||||||
ext->sb.ver_draw = 0;
|
ext->sb.ver_draw = 0;
|
||||||
ext->sb.style = &lv_style_pretty;
|
// ext->sb.style = &lv_style_pretty;
|
||||||
ext->sb.mode = LV_SB_MODE_AUTO;
|
ext->sb.mode = LV_SB_MODE_AUTO;
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
ext->edge_flash.enabled = 0;
|
ext->edge_flash.enabled = 0;
|
||||||
@ -115,14 +115,13 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
/*Init the new page object*/
|
/*Init the new page object*/
|
||||||
if(copy == NULL) {
|
if(copy == NULL) {
|
||||||
ext->scrl = lv_cont_create(new_page, NULL);
|
ext->scrl = lv_cont_create(new_page, NULL);
|
||||||
lv_obj_set_signal_cb(ext->scrl, lv_page_scrollable_signal);
|
|
||||||
lv_obj_set_design_cb(ext->scrl, lv_scrl_design);
|
|
||||||
lv_obj_set_drag(ext->scrl, true);
|
lv_obj_set_drag(ext->scrl, true);
|
||||||
lv_obj_set_drag_throw(ext->scrl, true);
|
lv_obj_set_drag_throw(ext->scrl, true);
|
||||||
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST);
|
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST);
|
||||||
lv_cont_set_fit4(ext->scrl, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL);
|
lv_cont_set_fit4(ext->scrl, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL);
|
||||||
lv_obj_set_event_cb(ext->scrl, scrl_def_event_cb); /*Propagate some event to the background
|
lv_obj_set_event_cb(ext->scrl, scrl_def_event_cb); /*Propagate some event to the background
|
||||||
object by default for convenience */
|
object by default for convenience */
|
||||||
|
lv_obj_set_signal_cb(ext->scrl, lv_page_scrollable_signal);
|
||||||
|
|
||||||
/* Add the signal function only if 'scrolling' is created
|
/* Add the signal function only if 'scrolling' is created
|
||||||
+ * because everything has to be ready before any signal is received*/
|
+ * because everything has to be ready before any signal is received*/
|
||||||
@ -131,21 +130,23 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
|
|
||||||
lv_page_set_sb_mode(new_page, ext->sb.mode);
|
lv_page_set_sb_mode(new_page, ext->sb.mode);
|
||||||
|
|
||||||
|
lv_obj_refresh_style(new_page, LV_OBJ_PART_ALL);
|
||||||
|
|
||||||
/*Set the default styles*/
|
/*Set the default styles*/
|
||||||
lv_theme_t * th = lv_theme_get_current();
|
lv_theme_t * th = lv_theme_get_current();
|
||||||
if(th) {
|
if(th) {
|
||||||
if(par == NULL) { /*Different styles if it is screen*/
|
if(par == NULL) { /*Different styles if it is screen*/
|
||||||
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->style.bg);
|
// lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->style.bg);
|
||||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_transp);
|
// lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_transp);
|
||||||
} else {
|
} else {
|
||||||
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->style.page.bg);
|
// lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->style.page.bg);
|
||||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, th->style.page.scrl);
|
// lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, th->style.page.scrl);
|
||||||
}
|
}
|
||||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, th->style.page.sb);
|
// lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL_BAR, th->style.page.sb);
|
||||||
} else {
|
} else {
|
||||||
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, &lv_style_pretty_color);
|
// lv_page_set_style(new_page, LV_PAGE_STYLE_BG, &lv_style_pretty_color);
|
||||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_pretty);
|
// lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_pretty);
|
||||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, &lv_style_pretty_color);
|
// lv_page_set_style(new_page, LV_PAGE_STYLE_SB, &lv_style_pretty_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -158,16 +159,14 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
lv_obj_set_signal_cb(new_page, lv_page_signal);
|
lv_obj_set_signal_cb(new_page, lv_page_signal);
|
||||||
lv_obj_set_design_cb(new_page, lv_page_design);
|
lv_obj_set_design_cb(new_page, lv_page_design);
|
||||||
|
|
||||||
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, lv_page_get_style(copy, LV_PAGE_STYLE_BG));
|
// lv_page_set_style(new_page, LV_PAGE_STYLE_BG, lv_page_get_style(copy, LV_PAGE_STYLE_BG));
|
||||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, lv_page_get_style(copy, LV_PAGE_STYLE_SCRL));
|
// lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, lv_page_get_style(copy, LV_PAGE_STYLE_SCRL));
|
||||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, lv_page_get_style(copy, LV_PAGE_STYLE_SB));
|
// lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL_BAR, lv_page_get_style(copy, LV_PAGE_STYLE_SCRL_BAR));
|
||||||
|
|
||||||
lv_page_set_sb_mode(new_page, copy_ext->sb.mode);
|
lv_page_set_sb_mode(new_page, copy_ext->sb.mode);
|
||||||
|
|
||||||
/*Refresh the style with new signal function*/
|
|
||||||
lv_obj_refresh_style(new_page);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lv_page_sb_refresh(new_page);
|
lv_page_sb_refresh(new_page);
|
||||||
|
|
||||||
LV_LOG_INFO("page created");
|
LV_LOG_INFO("page created");
|
||||||
@ -274,35 +273,6 @@ void lv_page_set_edge_flash(lv_obj_t * page, bool en)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a style of a page
|
|
||||||
* @param page pointer to a page object
|
|
||||||
* @param type which style should be set
|
|
||||||
* @param style pointer to a style
|
|
||||||
* */
|
|
||||||
void lv_page_set_style(lv_obj_t * page, lv_page_style_t type, const lv_style_t * style)
|
|
||||||
{
|
|
||||||
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
|
||||||
|
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
|
||||||
|
|
||||||
switch(type) {
|
|
||||||
case LV_PAGE_STYLE_BG: lv_obj_set_style(page, style); break;
|
|
||||||
case LV_PAGE_STYLE_SCRL: lv_obj_set_style(ext->scrl, style); break;
|
|
||||||
case LV_PAGE_STYLE_SB:
|
|
||||||
ext->sb.style = style;
|
|
||||||
lv_area_set_height(&ext->sb.hor_area, ext->sb.style->body.padding.inner);
|
|
||||||
lv_area_set_width(&ext->sb.ver_area, ext->sb.style->body.padding.inner);
|
|
||||||
lv_page_sb_refresh(page);
|
|
||||||
lv_obj_refresh_ext_draw_pad(page);
|
|
||||||
lv_obj_invalidate(page);
|
|
||||||
break;
|
|
||||||
#if LV_USE_ANIMATION
|
|
||||||
case LV_PAGE_STYLE_EDGE_FLASH: ext->edge_flash.style = style; break;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*=====================
|
/*=====================
|
||||||
* Getter functions
|
* Getter functions
|
||||||
*====================*/
|
*====================*/
|
||||||
@ -392,11 +362,12 @@ lv_coord_t lv_page_get_fit_width(lv_obj_t * page)
|
|||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
lv_style_value_t bg_left = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_LEFT);
|
||||||
const lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
lv_style_value_t bg_right = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_RIGHT);
|
||||||
|
lv_style_value_t scrl_left = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL, LV_STYLE_PAD_LEFT);
|
||||||
|
lv_style_value_t scrl_right = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL, LV_STYLE_PAD_RIGHT);
|
||||||
|
|
||||||
return lv_obj_get_width(page) - bg_style->body.padding.left - bg_style->body.padding.right -
|
return lv_obj_get_width(page) - bg_left - bg_right - scrl_left - scrl_right;
|
||||||
scrl_style->body.padding.left - scrl_style->body.padding.right;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -408,37 +379,42 @@ lv_coord_t lv_page_get_fit_height(lv_obj_t * page)
|
|||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
lv_style_value_t bg_top = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_TOP);
|
||||||
const lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
lv_style_value_t bg_bottom = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_BOTTOM);
|
||||||
|
lv_style_value_t scrl_top = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL, LV_STYLE_PAD_TOP);
|
||||||
|
lv_style_value_t scrl_bottom = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL, LV_STYLE_PAD_BOTTOM);
|
||||||
|
|
||||||
return lv_obj_get_height(page) - bg_style->body.padding.top - bg_style->body.padding.bottom -
|
return lv_obj_get_height(page) - bg_top - bg_bottom - scrl_top - scrl_bottom;
|
||||||
scrl_style->body.padding.top - scrl_style->body.padding.bottom;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a style of a page
|
static lv_style_dsc_t * lv_page_get_style(lv_obj_t * page, uint8_t type)
|
||||||
* @param page pointer to page object
|
|
||||||
* @param type which style should be get
|
|
||||||
* @return style pointer to a style
|
|
||||||
* */
|
|
||||||
const lv_style_t * lv_page_get_style(const lv_obj_t * page, lv_page_style_t type)
|
|
||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
LV_ASSERT_OBJ(page, LV_OBJX_NAME);
|
||||||
|
|
||||||
const lv_style_t * style = NULL;
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_style_dsc_t * style_dsc_p;
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case LV_PAGE_STYLE_BG: style = lv_obj_get_style(page); break;
|
case LV_PAGE_PART_BG:
|
||||||
case LV_PAGE_STYLE_SCRL: style = lv_obj_get_style(ext->scrl); break;
|
style_dsc_p = &page->style_dsc;
|
||||||
case LV_PAGE_STYLE_SB: style = ext->sb.style; break;
|
break;
|
||||||
|
case LV_PAGE_PART_SCRL:
|
||||||
|
style_dsc_p = lv_obj_get_style(ext->scrl, LV_CONT_PART_MAIN);
|
||||||
|
break;
|
||||||
|
case LV_PAGE_PART_SCRL_BAR:
|
||||||
|
style_dsc_p = &ext->sb.style;
|
||||||
|
break;
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
case LV_PAGE_STYLE_EDGE_FLASH: style = ext->edge_flash.style; break;
|
case LV_PAGE_STYLE_EDGE_FLASH:
|
||||||
|
style_dsc_p = &ext->edge_flash.style;
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
default: style = NULL; break;
|
default:
|
||||||
|
style_dsc_p = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return style;
|
return style_dsc_p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*=====================
|
/*=====================
|
||||||
@ -453,7 +429,6 @@ const lv_style_t * lv_page_get_style(const lv_obj_t * page, lv_page_style_t type
|
|||||||
*/
|
*/
|
||||||
bool lv_page_on_edge(lv_obj_t * page, lv_page_edge_t edge)
|
bool lv_page_on_edge(lv_obj_t * page, lv_page_edge_t edge)
|
||||||
{
|
{
|
||||||
const lv_style_t * page_style = lv_obj_get_style(page);
|
|
||||||
lv_obj_t * scrl = lv_page_get_scrl(page);
|
lv_obj_t * scrl = lv_page_get_scrl(page);
|
||||||
lv_area_t page_coords;
|
lv_area_t page_coords;
|
||||||
lv_area_t scrl_coords;
|
lv_area_t scrl_coords;
|
||||||
@ -461,10 +436,15 @@ bool lv_page_on_edge(lv_obj_t * page, lv_page_edge_t edge)
|
|||||||
lv_obj_get_coords(scrl, &scrl_coords);
|
lv_obj_get_coords(scrl, &scrl_coords);
|
||||||
lv_obj_get_coords(page, &page_coords);
|
lv_obj_get_coords(page, &page_coords);
|
||||||
|
|
||||||
if((edge & LV_PAGE_EDGE_TOP) && scrl_coords.y1 == page_coords.y1 + page_style->body.padding.top) return true;
|
lv_style_value_t left = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_LEFT);
|
||||||
if((edge & LV_PAGE_EDGE_BOTTOM) && scrl_coords.y2 == page_coords.y2 - page_style->body.padding.bottom) return true;
|
lv_style_value_t right = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_RIGHT);
|
||||||
if((edge & LV_PAGE_EDGE_LEFT) && scrl_coords.x1 == page_coords.x1 + page_style->body.padding.left) return true;
|
lv_style_value_t top = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_TOP);
|
||||||
if((edge & LV_PAGE_EDGE_RIGHT) && scrl_coords.x2 == page_coords.x2 - page_style->body.padding.right) return true;
|
lv_style_value_t bottom = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_BOTTOM);
|
||||||
|
|
||||||
|
if((edge & LV_PAGE_EDGE_TOP) && scrl_coords.y1 == page_coords.y1 + top) return true;
|
||||||
|
if((edge & LV_PAGE_EDGE_BOTTOM) && scrl_coords.y2 == page_coords.y2 - bottom) return true;
|
||||||
|
if((edge & LV_PAGE_EDGE_LEFT) && scrl_coords.x1 == page_coords.x1 + left) return true;
|
||||||
|
if((edge & LV_PAGE_EDGE_RIGHT) && scrl_coords.x2 == page_coords.x2 - right) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -499,8 +479,6 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_
|
|||||||
lv_anim_del(ext->scrl, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
lv_anim_del(ext->scrl, (lv_anim_exec_xcb_t)lv_obj_set_y);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
|
||||||
const lv_style_t * style_scrl = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
|
||||||
|
|
||||||
/*If obj is higher then the page focus where the "error" is smaller*/
|
/*If obj is higher then the page focus where the "error" is smaller*/
|
||||||
lv_coord_t obj_y = obj->coords.y1 - ext->scrl->coords.y1;
|
lv_coord_t obj_y = obj->coords.y1 - ext->scrl->coords.y1;
|
||||||
@ -511,20 +489,26 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_
|
|||||||
lv_coord_t top_err = -(scrlable_y + obj_y);
|
lv_coord_t top_err = -(scrlable_y + obj_y);
|
||||||
lv_coord_t bot_err = scrlable_y + obj_y + obj_h - page_h;
|
lv_coord_t bot_err = scrlable_y + obj_y + obj_h - page_h;
|
||||||
|
|
||||||
|
lv_style_value_t bg_top = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_TOP);
|
||||||
|
lv_style_value_t bg_bottom = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_BOTTOM);
|
||||||
|
lv_style_value_t scrl_top = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL, LV_STYLE_PAD_TOP);
|
||||||
|
lv_style_value_t scrl_bottom = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL, LV_STYLE_PAD_BOTTOM);
|
||||||
|
|
||||||
/*Out of the page on the top*/
|
/*Out of the page on the top*/
|
||||||
if((obj_h <= page_h && top_err > 0) || (obj_h > page_h && top_err < bot_err)) {
|
if((obj_h <= page_h && top_err > 0) || (obj_h > page_h && top_err < bot_err)) {
|
||||||
/*Calculate a new position and let some space above*/
|
/*Calculate a new position and let some space above*/
|
||||||
scrlable_y = -(obj_y - style_scrl->body.padding.top - style->body.padding.top);
|
scrlable_y = -(obj_y - scrl_top - bg_top);
|
||||||
scrlable_y += style_scrl->body.padding.top;
|
scrlable_y += scrl_top;
|
||||||
}
|
}
|
||||||
/*Out of the page on the bottom*/
|
/*Out of the page on the bottom*/
|
||||||
else if((obj_h <= page_h && bot_err > 0) || (obj_h > page_h && top_err >= bot_err)) {
|
else if((obj_h <= page_h && bot_err > 0) || (obj_h > page_h && top_err >= bot_err)) {
|
||||||
/*Calculate a new position and let some space below*/
|
/*Calculate a new position and let some space below*/
|
||||||
scrlable_y = -(obj_y + style_scrl->body.padding.bottom + style->body.padding.bottom);
|
scrlable_y = -(obj_y + scrl_bottom + bg_bottom);
|
||||||
scrlable_y -= style_scrl->body.padding.bottom;
|
scrlable_y -= scrl_bottom;
|
||||||
scrlable_y += page_h - obj_h;
|
scrlable_y += page_h - obj_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*If obj is wider then the page focus where the "error" is smaller*/
|
/*If obj is wider then the page focus where the "error" is smaller*/
|
||||||
lv_coord_t obj_x = obj->coords.x1 - ext->scrl->coords.x1;
|
lv_coord_t obj_x = obj->coords.x1 - ext->scrl->coords.x1;
|
||||||
lv_coord_t obj_w = lv_obj_get_width(obj);
|
lv_coord_t obj_w = lv_obj_get_width(obj);
|
||||||
@ -534,17 +518,22 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_
|
|||||||
lv_coord_t left_err = -(scrlable_x + obj_x);
|
lv_coord_t left_err = -(scrlable_x + obj_x);
|
||||||
lv_coord_t right_err = scrlable_x + obj_x + obj_w - page_w;
|
lv_coord_t right_err = scrlable_x + obj_x + obj_w - page_w;
|
||||||
|
|
||||||
|
lv_style_value_t bg_left = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_LEFT);
|
||||||
|
lv_style_value_t bg_right = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_RIGHT);
|
||||||
|
lv_style_value_t scrl_left = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL, LV_STYLE_PAD_LEFT);
|
||||||
|
lv_style_value_t scrl_right = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL, LV_STYLE_PAD_RIGHT);
|
||||||
|
|
||||||
/*Out of the page on the left*/
|
/*Out of the page on the left*/
|
||||||
if((obj_w <= page_w && left_err > 0) || (obj_w > page_w && left_err < right_err)) {
|
if((obj_w <= page_w && left_err > 0) || (obj_w > page_w && left_err < right_err)) {
|
||||||
/*Calculate a new position and let some space above*/
|
/*Calculate a new position and let some space on the side*/
|
||||||
scrlable_x = -(obj_x - style_scrl->body.padding.left - style->body.padding.left);
|
scrlable_x = -(obj_x - scrl_left - bg_left);
|
||||||
scrlable_x += style_scrl->body.padding.left;
|
scrlable_x += scrl_left;
|
||||||
}
|
}
|
||||||
/*Out of the page on the rigth*/
|
/*Out of the page on the rigth*/
|
||||||
else if((obj_w <= page_w && right_err > 0) || (obj_w > page_w && left_err >= right_err)) {
|
else if((obj_w <= page_w && right_err > 0) || (obj_w > page_w && left_err >= right_err)) {
|
||||||
/*Calculate a new position and let some space below*/
|
/*Calculate a new position and let some space on teh side*/
|
||||||
scrlable_x = -(obj_x + style_scrl->body.padding.right + style->body.padding.right);
|
scrlable_x = -(obj_x + scrl_right + bg_right);
|
||||||
scrlable_x -= style_scrl->body.padding.right;
|
scrlable_x -= scrl_right;
|
||||||
scrlable_x += page_w - obj_w;
|
scrlable_x += page_w - obj_w;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,32 +686,40 @@ static lv_design_res_t lv_page_design(lv_obj_t * page, const lv_area_t * clip_ar
|
|||||||
if(mode == LV_DESIGN_COVER_CHK) {
|
if(mode == LV_DESIGN_COVER_CHK) {
|
||||||
return ancestor_design(page, clip_area, mode);
|
return ancestor_design(page, clip_area, mode);
|
||||||
}
|
}
|
||||||
/*Cache page bg style for temporary modification*/
|
|
||||||
const lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
|
||||||
lv_style_t style_tmp;
|
|
||||||
lv_style_copy(&style_tmp, style);
|
|
||||||
|
|
||||||
if(mode == LV_DESIGN_DRAW_MAIN) {
|
if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||||
/*Draw without border*/
|
lv_draw_rect_dsc_t draw_dsc;
|
||||||
style_tmp.body.border.width = 0;
|
lv_draw_rect_dsc_init(&draw_dsc);
|
||||||
lv_draw_rect(&page->coords, clip_area, &style_tmp, lv_obj_get_opa_scale(page));
|
lv_obj_init_draw_rect_dsc(page, LV_PAGE_PART_BG, &draw_dsc);
|
||||||
|
|
||||||
if(style->body.corner_mask) {
|
/*Draw without border first*/
|
||||||
style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
draw_dsc.border_width = 0;
|
||||||
lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));;
|
|
||||||
lv_draw_mask_radius_init(mp, &page->coords, style->body.radius, false);
|
lv_draw_rect(&page->coords, clip_area, &draw_dsc);
|
||||||
|
|
||||||
|
if(lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_BG_CLIP_CORNER)) {
|
||||||
|
lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
|
||||||
|
|
||||||
|
lv_coord_t r = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_RADIUS);
|
||||||
|
|
||||||
|
lv_draw_mask_radius_init(mp, &page->coords, r, false);
|
||||||
/*Add the mask and use `page+8` as custom id. Don't use `page` directly because it might be sued by the user*/
|
/*Add the mask and use `page+8` as custom id. Don't use `page` directly because it might be sued by the user*/
|
||||||
lv_draw_mask_add(mp, page + 8);
|
lv_draw_mask_add(mp, page + 8);
|
||||||
}
|
}
|
||||||
} else if(mode == LV_DESIGN_DRAW_POST) {
|
} else if(mode == LV_DESIGN_DRAW_POST) {
|
||||||
/*Draw only a border*/
|
lv_draw_rect_dsc_t draw_dsc;
|
||||||
style_tmp.body.shadow.width = 0;
|
lv_draw_rect_dsc_init(&draw_dsc);
|
||||||
style_tmp.body.opa = LV_OPA_TRANSP;
|
lv_obj_init_draw_rect_dsc(page, LV_PAGE_PART_BG, &draw_dsc);
|
||||||
lv_draw_rect(&page->coords, clip_area, &style_tmp, lv_obj_get_opa_scale(page));
|
|
||||||
|
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
/*Draw only a border. It ensures that the page looks "closed" even with overflowing scrollable*/
|
||||||
|
draw_dsc.shadow_blur = 0;
|
||||||
|
draw_dsc.bg_opa = LV_OPA_TRANSP;
|
||||||
|
lv_draw_rect(&page->coords, clip_area, &draw_dsc);
|
||||||
|
|
||||||
/*Draw the scrollbars*/
|
/*Draw the scrollbars*/
|
||||||
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
|
lv_draw_rect_dsc_init(&draw_dsc);
|
||||||
|
lv_obj_init_draw_rect_dsc(page, LV_PAGE_PART_SCRL_BAR, &draw_dsc);
|
||||||
lv_area_t sb_area;
|
lv_area_t sb_area;
|
||||||
if(ext->sb.hor_draw && (ext->sb.mode & LV_SB_MODE_HIDE) == 0) {
|
if(ext->sb.hor_draw && (ext->sb.mode & LV_SB_MODE_HIDE) == 0) {
|
||||||
/*Convert the relative coordinates to absolute*/
|
/*Convert the relative coordinates to absolute*/
|
||||||
@ -731,7 +728,7 @@ static lv_design_res_t lv_page_design(lv_obj_t * page, const lv_area_t * clip_ar
|
|||||||
sb_area.y1 += page->coords.y1;
|
sb_area.y1 += page->coords.y1;
|
||||||
sb_area.x2 += page->coords.x1;
|
sb_area.x2 += page->coords.x1;
|
||||||
sb_area.y2 += page->coords.y1;
|
sb_area.y2 += page->coords.y1;
|
||||||
lv_draw_rect(&sb_area, clip_area, ext->sb.style, lv_obj_get_opa_scale(page));
|
lv_draw_rect(&sb_area, clip_area, &draw_dsc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ext->sb.ver_draw && (ext->sb.mode & LV_SB_MODE_HIDE) == 0) {
|
if(ext->sb.ver_draw && (ext->sb.mode & LV_SB_MODE_HIDE) == 0) {
|
||||||
@ -741,7 +738,7 @@ static lv_design_res_t lv_page_design(lv_obj_t * page, const lv_area_t * clip_ar
|
|||||||
sb_area.y1 += page->coords.y1;
|
sb_area.y1 += page->coords.y1;
|
||||||
sb_area.x2 += page->coords.x1;
|
sb_area.x2 += page->coords.x1;
|
||||||
sb_area.y2 += page->coords.y1;
|
sb_area.y2 += page->coords.y1;
|
||||||
lv_draw_rect(&sb_area, clip_area, ext->sb.style, lv_obj_get_opa_scale(page));
|
lv_draw_rect(&sb_area, clip_area, &draw_dsc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
@ -794,57 +791,6 @@ static lv_design_res_t lv_page_design(lv_obj_t * page, const lv_area_t * clip_ar
|
|||||||
return LV_DESIGN_RES_OK;
|
return LV_DESIGN_RES_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle the drawing related tasks of the scrollable object
|
|
||||||
* @param scrl pointer to an object
|
|
||||||
* @param clisp_area the object will be drawn only in this area
|
|
||||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
|
||||||
* (return 'true' if yes)
|
|
||||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
|
||||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
|
||||||
* @param return an element of `lv_design_res_t`
|
|
||||||
*/
|
|
||||||
static lv_design_res_t lv_scrl_design(lv_obj_t * scrl, const lv_area_t * clisp_area, lv_design_mode_t mode)
|
|
||||||
{
|
|
||||||
if(mode == LV_DESIGN_COVER_CHK) {
|
|
||||||
return ancestor_design(scrl, clisp_area, mode);
|
|
||||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
|
||||||
#if LV_USE_GROUP
|
|
||||||
/* If the page is focused in a group and
|
|
||||||
* the background object is not visible (transparent)
|
|
||||||
* then "activate" the style of the scrollable*/
|
|
||||||
const lv_style_t * style_scrl_ori = lv_obj_get_style(scrl);
|
|
||||||
lv_obj_t * page = lv_obj_get_parent(scrl);
|
|
||||||
const lv_style_t * style_page = lv_obj_get_style(page);
|
|
||||||
lv_group_t * g = lv_obj_get_group(page);
|
|
||||||
if((style_page->body.opa == LV_OPA_TRANSP) &&
|
|
||||||
style_page->body.border.width == 0) { /*Is the background visible?*/
|
|
||||||
if(lv_group_get_focused(g) == page) {
|
|
||||||
lv_style_t * style_mod;
|
|
||||||
style_mod = lv_group_mod_style(g, style_scrl_ori);
|
|
||||||
/*If still not visible modify the style a littel bit*/
|
|
||||||
if((style_mod->body.opa == LV_OPA_TRANSP) && style_mod->body.border.width == 0) {
|
|
||||||
style_mod->body.opa = LV_OPA_50;
|
|
||||||
style_mod->body.border.width = 1;
|
|
||||||
style_mod = lv_group_mod_style(g, style_mod);
|
|
||||||
}
|
|
||||||
|
|
||||||
scrl->style_p = style_mod; /*Temporally change the style to the activated */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ancestor_design(scrl, clisp_area, mode);
|
|
||||||
|
|
||||||
#if LV_USE_GROUP
|
|
||||||
scrl->style_p = style_scrl_ori; /*Revert the style*/
|
|
||||||
#endif
|
|
||||||
} else if(mode == LV_DESIGN_DRAW_POST) {
|
|
||||||
ancestor_design(scrl, clisp_area, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
return LV_DESIGN_RES_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signal function of the page
|
* Signal function of the page
|
||||||
* @param page pointer to a page object
|
* @param page pointer to a page object
|
||||||
@ -855,6 +801,12 @@ static lv_design_res_t lv_scrl_design(lv_obj_t * scrl, const lv_area_t * clisp_a
|
|||||||
static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||||
{
|
{
|
||||||
lv_res_t res;
|
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_page_get_style(page, **type_p);
|
||||||
|
return LV_RES_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
res = ancestor_signal(page, sign, param);
|
res = ancestor_signal(page, sign, param);
|
||||||
@ -875,12 +827,15 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
|||||||
/*Automatically move children to the scrollable object*/
|
/*Automatically move children to the scrollable object*/
|
||||||
else if(sign == LV_SIGNAL_CHILD_CHG) {
|
else if(sign == LV_SIGNAL_CHILD_CHG) {
|
||||||
lv_obj_t * child;
|
lv_obj_t * child;
|
||||||
const lv_style_t * style_scrl = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
|
||||||
lv_fit_t fit_left = lv_page_get_scrl_fit_left(page);
|
lv_fit_t fit_left = lv_page_get_scrl_fit_left(page);
|
||||||
lv_fit_t fit_right = lv_page_get_scrl_fit_right(page);
|
lv_fit_t fit_right = lv_page_get_scrl_fit_right(page);
|
||||||
lv_fit_t fit_top = lv_page_get_scrl_fit_top(page);
|
lv_fit_t fit_top = lv_page_get_scrl_fit_top(page);
|
||||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(page);
|
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(page);
|
||||||
|
|
||||||
|
lv_style_value_t scrl_left = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL, LV_STYLE_PAD_LEFT);
|
||||||
|
lv_style_value_t scrl_right = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL, LV_STYLE_PAD_RIGHT);
|
||||||
|
lv_style_value_t scrl_top = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL, LV_STYLE_PAD_TOP);
|
||||||
|
|
||||||
child = lv_obj_get_child(page, NULL);
|
child = lv_obj_get_child(page, NULL);
|
||||||
while(child != NULL) {
|
while(child != NULL) {
|
||||||
if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) {
|
if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) {
|
||||||
@ -892,18 +847,18 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
|||||||
if((tmp->coords.x1 == page->coords.x1) &&
|
if((tmp->coords.x1 == page->coords.x1) &&
|
||||||
(fit_left == LV_FIT_TIGHT || fit_left == LV_FIT_FILL) &&
|
(fit_left == LV_FIT_TIGHT || fit_left == LV_FIT_FILL) &&
|
||||||
base_dir != LV_BIDI_DIR_RTL) {
|
base_dir != LV_BIDI_DIR_RTL) {
|
||||||
tmp->coords.x1 += style_scrl->body.padding.left;
|
tmp->coords.x1 += scrl_left;
|
||||||
tmp->coords.x2 += style_scrl->body.padding.left;
|
tmp->coords.x2 += scrl_left;
|
||||||
}
|
}
|
||||||
else if((tmp->coords.x2 == page->coords.x2) &&
|
else if((tmp->coords.x2 == page->coords.x2) &&
|
||||||
(fit_right == LV_FIT_TIGHT || fit_right == LV_FIT_FILL)
|
(fit_right == LV_FIT_TIGHT || fit_right == LV_FIT_FILL)
|
||||||
&& base_dir == LV_BIDI_DIR_RTL) {
|
&& base_dir == LV_BIDI_DIR_RTL) {
|
||||||
tmp->coords.x1 -= style_scrl->body.padding.right;
|
tmp->coords.x1 -= scrl_right;
|
||||||
tmp->coords.x2 -= style_scrl->body.padding.right;
|
tmp->coords.x2 -= scrl_right;
|
||||||
}
|
}
|
||||||
if((tmp->coords.y1 == page->coords.y1) && (fit_top == LV_FIT_TIGHT || fit_top == LV_FIT_FILL)) {
|
if((tmp->coords.y1 == page->coords.y1) && (fit_top == LV_FIT_TIGHT || fit_top == LV_FIT_FILL)) {
|
||||||
tmp->coords.y1 += style_scrl->body.padding.top;
|
tmp->coords.y1 += scrl_top;
|
||||||
tmp->coords.y2 += style_scrl->body.padding.top;
|
tmp->coords.y2 += scrl_top;
|
||||||
}
|
}
|
||||||
lv_obj_set_parent(tmp, ext->scrl);
|
lv_obj_set_parent(tmp, ext->scrl);
|
||||||
} else {
|
} else {
|
||||||
@ -913,6 +868,10 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
|||||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||||
ext->scrl->signal_cb(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
|
ext->scrl->signal_cb(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
|
||||||
|
|
||||||
|
lv_style_value_t sb_width = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL_BAR, LV_STYLE_SCROLLBAR_WIDTH);
|
||||||
|
lv_area_set_height(&ext->sb.hor_area, sb_width);
|
||||||
|
lv_area_set_width(&ext->sb.ver_area, sb_width);
|
||||||
|
|
||||||
/*The scrollbars are important only if they are visible now*/
|
/*The scrollbars are important only if they are visible now*/
|
||||||
if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
|
if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
|
||||||
|
|
||||||
@ -929,11 +888,13 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
|||||||
if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
|
if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
|
||||||
}
|
}
|
||||||
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||||
|
|
||||||
|
lv_style_value_t sb_bottom = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL_BAR, LV_STYLE_PAD_BOTTOM);
|
||||||
|
lv_style_value_t sb_right = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL_BAR, LV_STYLE_PAD_RIGHT);
|
||||||
|
|
||||||
/*Ensure ext. size for the scrollbars if they are out of the page*/
|
/*Ensure ext. size for the scrollbars if they are out of the page*/
|
||||||
if(page->ext_draw_pad < (-ext->sb.style->body.padding.right))
|
if(page->ext_draw_pad < (-sb_right)) page->ext_draw_pad = -sb_right;
|
||||||
page->ext_draw_pad = -ext->sb.style->body.padding.right;
|
if(page->ext_draw_pad < (-sb_bottom)) page->ext_draw_pad = -sb_bottom;
|
||||||
if(page->ext_draw_pad < (-ext->sb.style->body.padding.bottom))
|
|
||||||
page->ext_draw_pad = -ext->sb.style->body.padding.bottom;
|
|
||||||
} else if(sign == LV_SIGNAL_CONTROL) {
|
} else if(sign == LV_SIGNAL_CONTROL) {
|
||||||
uint32_t c = *((uint32_t *)param);
|
uint32_t c = *((uint32_t *)param);
|
||||||
|
|
||||||
@ -973,6 +934,11 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
|||||||
*/
|
*/
|
||||||
static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
|
static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||||
|
return ancestor_signal(scrl, sign, param);
|
||||||
|
}
|
||||||
|
|
||||||
lv_res_t res;
|
lv_res_t res;
|
||||||
|
|
||||||
/* Include the ancient signal function */
|
/* Include the ancient signal function */
|
||||||
@ -981,7 +947,6 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
|||||||
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, "");
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, "");
|
||||||
|
|
||||||
lv_obj_t * page = lv_obj_get_parent(scrl);
|
lv_obj_t * page = lv_obj_get_parent(scrl);
|
||||||
const lv_style_t * page_style = lv_obj_get_style(page);
|
|
||||||
lv_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_CORD_CHG) {
|
if(sign == LV_SIGNAL_CORD_CHG) {
|
||||||
@ -996,8 +961,6 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
|||||||
lv_obj_get_coords(scrl, &scrl_coords);
|
lv_obj_get_coords(scrl, &scrl_coords);
|
||||||
lv_obj_get_coords(page, &page_coords);
|
lv_obj_get_coords(page, &page_coords);
|
||||||
|
|
||||||
lv_coord_t hpad = page_style->body.padding.left + page_style->body.padding.right;
|
|
||||||
lv_coord_t vpad = page_style->body.padding.top + page_style->body.padding.bottom;
|
|
||||||
lv_obj_t * page_parent = lv_obj_get_parent(page);
|
lv_obj_t * page_parent = lv_obj_get_parent(page);
|
||||||
|
|
||||||
/*Handle scroll propagation*/
|
/*Handle scroll propagation*/
|
||||||
@ -1027,41 +990,44 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lv_style_value_t left = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_LEFT);
|
||||||
|
lv_style_value_t right = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_RIGHT);
|
||||||
|
lv_style_value_t top = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_TOP);
|
||||||
|
lv_style_value_t bottom = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_BOTTOM);
|
||||||
|
|
||||||
/*scrollable width smaller then page width? -> align to left*/
|
/*scrollable width smaller then page width? -> align to left*/
|
||||||
if(lv_area_get_width(&scrl_coords) + hpad <= lv_area_get_width(&page_coords)) {
|
if(lv_area_get_width(&scrl_coords) + left +right <= lv_area_get_width(&page_coords)) {
|
||||||
if(scrl_coords.x1 != page_coords.x1 + page_style->body.padding.left) {
|
if(scrl_coords.x1 != page_coords.x1 + left) {
|
||||||
new_x = page_style->body.padding.left;
|
new_x = left;
|
||||||
refr_x = true;
|
refr_x = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*The edges of the scrollable can not be in the page (minus hpad) */
|
/*The edges of the scrollable can not be in the page (minus hpad) */
|
||||||
if(scrl_coords.x2 < page_coords.x2 - page_style->body.padding.right) {
|
if(scrl_coords.x2 < page_coords.x2 - right) {
|
||||||
new_x = lv_area_get_width(&page_coords) - lv_area_get_width(&scrl_coords) -
|
new_x = lv_area_get_width(&page_coords) - lv_area_get_width(&scrl_coords) - right; /* Right align */
|
||||||
page_style->body.padding.right; /* Right align */
|
|
||||||
refr_x = true;
|
refr_x = true;
|
||||||
lv_page_start_edge_flash(page, LV_PAGE_EDGE_RIGHT);
|
lv_page_start_edge_flash(page, LV_PAGE_EDGE_RIGHT);
|
||||||
} else if(scrl_coords.x1 > page_coords.x1 + page_style->body.padding.left) {
|
} else if(scrl_coords.x1 > page_coords.x1 + left) {
|
||||||
new_x = page_style->body.padding.left; /*Left align*/
|
new_x = left; /*Left align*/
|
||||||
refr_x = true;
|
refr_x = true;
|
||||||
lv_page_start_edge_flash(page, LV_PAGE_EDGE_LEFT);
|
lv_page_start_edge_flash(page, LV_PAGE_EDGE_LEFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*scrollable height smaller then page height? -> align to top*/
|
/*scrollable height smaller then page height? -> align to top*/
|
||||||
if(lv_area_get_height(&scrl_coords) + vpad <= lv_area_get_height(&page_coords)) {
|
if(lv_area_get_height(&scrl_coords) + top + bottom <= lv_area_get_height(&page_coords)) {
|
||||||
if(scrl_coords.y1 != page_coords.y1 + page_style->body.padding.top) {
|
if(scrl_coords.y1 != page_coords.y1 + top) {
|
||||||
new_y = page_style->body.padding.top;
|
new_y = top;
|
||||||
refr_y = true;
|
refr_y = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*The edges of the scrollable can not be in the page (minus vpad) */
|
/*The edges of the scrollable can not be in the page (minus vpad) */
|
||||||
if(scrl_coords.y2 < page_coords.y2 - page_style->body.padding.bottom) {
|
if(scrl_coords.y2 < page_coords.y2 - bottom) {
|
||||||
new_y = lv_area_get_height(&page_coords) - lv_area_get_height(&scrl_coords) -
|
new_y = lv_area_get_height(&page_coords) - lv_area_get_height(&scrl_coords) - bottom; /* Bottom align */
|
||||||
page_style->body.padding.bottom; /* Bottom align */
|
|
||||||
refr_y = true;
|
refr_y = true;
|
||||||
lv_page_start_edge_flash(page, LV_PAGE_EDGE_BOTTOM);
|
lv_page_start_edge_flash(page, LV_PAGE_EDGE_BOTTOM);
|
||||||
} else if(scrl_coords.y1 > page_coords.y1 + page_style->body.padding.top) {
|
} else if(scrl_coords.y1 > page_coords.y1 + top) {
|
||||||
new_y = page_style->body.padding.top; /*Top align*/
|
new_y = top; /*Top align*/
|
||||||
refr_y = true;
|
refr_y = true;
|
||||||
lv_page_start_edge_flash(page, LV_PAGE_EDGE_TOP);
|
lv_page_start_edge_flash(page, LV_PAGE_EDGE_TOP);
|
||||||
}
|
}
|
||||||
@ -1149,7 +1115,6 @@ static void scrl_def_event_cb(lv_obj_t * scrl, lv_event_t event)
|
|||||||
static void lv_page_sb_refresh(lv_obj_t * page)
|
static void lv_page_sb_refresh(lv_obj_t * page)
|
||||||
{
|
{
|
||||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||||
const lv_style_t * style = lv_obj_get_style(page);
|
|
||||||
lv_obj_t * scrl = ext->scrl;
|
lv_obj_t * scrl = ext->scrl;
|
||||||
lv_coord_t size_tmp;
|
lv_coord_t size_tmp;
|
||||||
lv_coord_t scrl_w = lv_obj_get_width(scrl);
|
lv_coord_t scrl_w = lv_obj_get_width(scrl);
|
||||||
@ -1157,12 +1122,21 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
|||||||
lv_coord_t obj_w = lv_obj_get_width(page);
|
lv_coord_t obj_w = lv_obj_get_width(page);
|
||||||
lv_coord_t obj_h = lv_obj_get_height(page);
|
lv_coord_t obj_h = lv_obj_get_height(page);
|
||||||
|
|
||||||
|
lv_style_value_t sb_width = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL_BAR, LV_STYLE_SCROLLBAR_WIDTH);
|
||||||
|
lv_style_value_t sb_right = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL_BAR, LV_STYLE_PAD_RIGHT);
|
||||||
|
lv_style_value_t sb_bottom = lv_obj_get_style_value(page, LV_PAGE_PART_SCRL_BAR, LV_STYLE_PAD_BOTTOM);
|
||||||
|
|
||||||
|
lv_style_value_t bg_left = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_LEFT);
|
||||||
|
lv_style_value_t bg_right = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_RIGHT);
|
||||||
|
lv_style_value_t bg_top = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_TOP);
|
||||||
|
lv_style_value_t bg_bottom = lv_obj_get_style_value(page, LV_PAGE_PART_BG, LV_STYLE_PAD_BOTTOM);
|
||||||
|
|
||||||
/*Always let 'scrollbar width' padding above, under, left and right to the scrollbars
|
/*Always let 'scrollbar width' padding above, under, left and right to the scrollbars
|
||||||
* else:
|
* else:
|
||||||
* - horizontal and vertical scrollbars can overlap on the corners
|
* - horizontal and vertical scrollbars can overlap on the corners
|
||||||
* - if the page has radius the scrollbar can be out of the radius */
|
* - if the page has radius the scrollbar can be out of the radius */
|
||||||
lv_coord_t sb_hor_pad = LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.right);
|
lv_coord_t sb_hor_pad = LV_MATH_MAX(sb_width, sb_right);
|
||||||
lv_coord_t sb_ver_pad = LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.bottom);
|
lv_coord_t sb_ver_pad = LV_MATH_MAX(sb_width, sb_bottom);
|
||||||
|
|
||||||
if(ext->sb.mode == LV_SB_MODE_OFF) return;
|
if(ext->sb.mode == LV_SB_MODE_OFF) return;
|
||||||
|
|
||||||
@ -1198,47 +1172,47 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*Full sized horizontal scrollbar*/
|
/*Full sized horizontal scrollbar*/
|
||||||
if(scrl_w <= obj_w - style->body.padding.left - style->body.padding.right) {
|
if(scrl_w <= obj_w - bg_left - bg_right) {
|
||||||
lv_area_set_width(&ext->sb.hor_area, obj_w - 2 * sb_hor_pad);
|
lv_area_set_width(&ext->sb.hor_area, obj_w - 2 * sb_hor_pad);
|
||||||
lv_area_set_pos(&ext->sb.hor_area, sb_hor_pad,
|
lv_area_set_pos(&ext->sb.hor_area, sb_hor_pad,
|
||||||
obj_h - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.bottom);
|
obj_h - sb_width - sb_bottom);
|
||||||
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.hor_draw = 0;
|
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.hor_draw = 0;
|
||||||
}
|
}
|
||||||
/*Smaller horizontal scrollbar*/
|
/*Smaller horizontal scrollbar*/
|
||||||
else {
|
else {
|
||||||
size_tmp =
|
size_tmp =
|
||||||
(obj_w * (obj_w - (2 * sb_hor_pad))) / (scrl_w + style->body.padding.left + style->body.padding.right);
|
(obj_w * (obj_w - (2 * sb_hor_pad))) / (scrl_w + bg_left + bg_right);
|
||||||
if(size_tmp < LV_PAGE_SB_MIN_SIZE) size_tmp = LV_PAGE_SB_MIN_SIZE;
|
if(size_tmp < LV_PAGE_SB_MIN_SIZE) size_tmp = LV_PAGE_SB_MIN_SIZE;
|
||||||
lv_area_set_width(&ext->sb.hor_area, size_tmp);
|
lv_area_set_width(&ext->sb.hor_area, size_tmp);
|
||||||
|
|
||||||
lv_area_set_pos(&ext->sb.hor_area,
|
lv_area_set_pos(&ext->sb.hor_area,
|
||||||
sb_hor_pad +
|
sb_hor_pad +
|
||||||
(-(lv_obj_get_x(scrl) - style->body.padding.left) * (obj_w - size_tmp - 2 * sb_hor_pad)) /
|
(-(lv_obj_get_x(scrl) -bg_left) * (obj_w - size_tmp - 2 * sb_hor_pad)) /
|
||||||
(scrl_w + style->body.padding.left + style->body.padding.right - obj_w),
|
(scrl_w + bg_left + sb_right - obj_w),
|
||||||
obj_h - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.bottom);
|
obj_h - sb_width - sb_bottom);
|
||||||
|
|
||||||
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.hor_draw = 1;
|
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.hor_draw = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Full sized vertical scroll bar*/
|
/*Full sized vertical scroll bar*/
|
||||||
if(scrl_h <= obj_h - style->body.padding.top - style->body.padding.bottom) {
|
if(scrl_h <= obj_h - bg_top - bg_bottom) {
|
||||||
lv_area_set_height(&ext->sb.ver_area, obj_h - 2 * sb_ver_pad);
|
lv_area_set_height(&ext->sb.ver_area, obj_h - 2 * sb_ver_pad);
|
||||||
lv_area_set_pos(&ext->sb.ver_area,
|
lv_area_set_pos(&ext->sb.ver_area,
|
||||||
obj_w - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.right, sb_ver_pad);
|
obj_w - sb_width - sb_right, sb_ver_pad);
|
||||||
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.ver_draw = 0;
|
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.ver_draw = 0;
|
||||||
}
|
}
|
||||||
/*Smaller vertical scroll bar*/
|
/*Smaller vertical scroll bar*/
|
||||||
else {
|
else {
|
||||||
size_tmp =
|
size_tmp =
|
||||||
(obj_h * (obj_h - (2 * sb_ver_pad))) / (scrl_h + style->body.padding.top + style->body.padding.bottom);
|
(obj_h * (obj_h - (2 * sb_ver_pad))) / (scrl_h + bg_top + bg_bottom);
|
||||||
if(size_tmp < LV_PAGE_SB_MIN_SIZE) size_tmp = LV_PAGE_SB_MIN_SIZE;
|
if(size_tmp < LV_PAGE_SB_MIN_SIZE) size_tmp = LV_PAGE_SB_MIN_SIZE;
|
||||||
lv_area_set_height(&ext->sb.ver_area, size_tmp);
|
lv_area_set_height(&ext->sb.ver_area, size_tmp);
|
||||||
|
|
||||||
lv_area_set_pos(&ext->sb.ver_area,
|
lv_area_set_pos(&ext->sb.ver_area,
|
||||||
obj_w - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.right,
|
obj_w - sb_width - sb_right,
|
||||||
sb_ver_pad + (-(lv_obj_get_y(scrl) - ext->sb.style->body.padding.bottom) *
|
sb_ver_pad + (-(lv_obj_get_y(scrl) - sb_bottom) *
|
||||||
(obj_h - size_tmp - 2 * sb_ver_pad)) /
|
(obj_h - size_tmp - 2 * sb_ver_pad)) /
|
||||||
(scrl_h + style->body.padding.top + style->body.padding.bottom - obj_h));
|
(scrl_h + bg_top + bg_bottom - obj_h));
|
||||||
|
|
||||||
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.ver_draw = 1;
|
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.ver_draw = 1;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ typedef struct
|
|||||||
lv_obj_t * scrl; /*The scrollable object on the background*/
|
lv_obj_t * scrl; /*The scrollable object on the background*/
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
const lv_style_t * style; /*Style of scrollbars*/
|
lv_style_dsc_t style; /*Style of scrollbars*/
|
||||||
lv_area_t hor_area; /*Horizontal scrollbar area relative to the page. (Handled by the library) */
|
lv_area_t hor_area; /*Horizontal scrollbar area relative to the page. (Handled by the library) */
|
||||||
lv_area_t ver_area; /*Vertical scrollbar area relative to the page (Handled by the library)*/
|
lv_area_t ver_area; /*Vertical scrollbar area relative to the page (Handled by the library)*/
|
||||||
uint8_t hor_draw : 1; /*1: horizontal scrollbar is visible now (Handled by the library)*/
|
uint8_t hor_draw : 1; /*1: horizontal scrollbar is visible now (Handled by the library)*/
|
||||||
@ -68,7 +68,7 @@ typedef struct
|
|||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
lv_anim_value_t state; /*Store the current size of the edge flash effect*/
|
lv_anim_value_t state; /*Store the current size of the edge flash effect*/
|
||||||
const lv_style_t * style; /*Style of edge flash effect (usually homogeneous circle)*/
|
lv_style_dsc_t style; /*Style of edge flash effect (usually homogeneous circle)*/
|
||||||
uint8_t enabled : 1; /*1: Show a flash animation on the edge*/
|
uint8_t enabled : 1; /*1: Show a flash animation on the edge*/
|
||||||
uint8_t top_ip : 1; /*Used internally to show that top most position is reached (flash is In
|
uint8_t top_ip : 1; /*Used internally to show that top most position is reached (flash is In
|
||||||
Progress)*/
|
Progress)*/
|
||||||
@ -87,12 +87,12 @@ typedef struct
|
|||||||
} lv_page_ext_t;
|
} lv_page_ext_t;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
LV_PAGE_STYLE_BG,
|
LV_PAGE_PART_BG,
|
||||||
LV_PAGE_STYLE_SCRL,
|
LV_PAGE_PART_SCRL,
|
||||||
LV_PAGE_STYLE_SB,
|
LV_PAGE_PART_SCRL_BAR,
|
||||||
LV_PAGE_STYLE_EDGE_FLASH,
|
LV_PAGE_PART_EDGE_FLASH,
|
||||||
};
|
};
|
||||||
typedef uint8_t lv_page_style_t;
|
typedef uint8_t lv_part_style_t;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* GLOBAL PROTOTYPES
|
* GLOBAL PROTOTYPES
|
||||||
@ -228,14 +228,6 @@ static inline void lv_page_set_scrl_layout(lv_obj_t * page, lv_layout_t layout)
|
|||||||
lv_cont_set_layout(lv_page_get_scrl(page), layout);
|
lv_cont_set_layout(lv_page_get_scrl(page), layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a style of a page
|
|
||||||
* @param page pointer to a page object
|
|
||||||
* @param type which style should be set
|
|
||||||
* @param style pointer to a style
|
|
||||||
*/
|
|
||||||
void lv_page_set_style(lv_obj_t * page, lv_page_style_t type, const lv_style_t * style);
|
|
||||||
|
|
||||||
/*=====================
|
/*=====================
|
||||||
* Getter functions
|
* Getter functions
|
||||||
*====================*/
|
*====================*/
|
||||||
@ -345,14 +337,6 @@ static inline lv_fit_t lv_page_get_scrl_fit_bottom(const lv_obj_t * page)
|
|||||||
return lv_cont_get_fit_bottom(lv_page_get_scrl(page));
|
return lv_cont_get_fit_bottom(lv_page_get_scrl(page));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a style of a page
|
|
||||||
* @param page pointer to page object
|
|
||||||
* @param type which style should be get
|
|
||||||
* @return style pointer to a style
|
|
||||||
*/
|
|
||||||
const lv_style_t * lv_page_get_style(const lv_obj_t * page, lv_page_style_t type);
|
|
||||||
|
|
||||||
/*=====================
|
/*=====================
|
||||||
* Other functions
|
* Other functions
|
||||||
*====================*/
|
*====================*/
|
||||||
|
@ -69,11 +69,6 @@ typedef struct
|
|||||||
enum {
|
enum {
|
||||||
LV_TABVIEW_STYLE_BG,
|
LV_TABVIEW_STYLE_BG,
|
||||||
LV_TABVIEW_STYLE_INDIC,
|
LV_TABVIEW_STYLE_INDIC,
|
||||||
LV_TABVIEW_STYLE_BTN_BG,
|
|
||||||
LV_TABVIEW_STYLE_BTN_REL,
|
|
||||||
LV_TABVIEW_STYLE_BTN_PR,
|
|
||||||
LV_TABVIEW_STYLE_BTN_TGL_REL,
|
|
||||||
LV_TABVIEW_STYLE_BTN_TGL_PR,
|
|
||||||
};
|
};
|
||||||
typedef uint8_t lv_tabview_style_t;
|
typedef uint8_t lv_tabview_style_t;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user