lv_obj: protect field added (opa_protect and child_chg_off moved here)

This commit is contained in:
Gabor
2017-01-03 17:09:35 +01:00
parent cb250fa5c0
commit 64dd00b823
4 changed files with 83 additions and 49 deletions

View File

@@ -48,10 +48,10 @@ static ll_dsc_t scr_ll;
static lv_objs_t lv_objs_def = {.color = COLOR_MAKE(0xa0, 0xc0, 0xe0), .transp = 0};
static lv_objs_t lv_objs_scr = {.color = LV_OBJ_DEF_SCR_COLOR, .transp = 0};
static lv_objs_t lv_objs_transp = {.transp = 1};
/*
#ifdef LV_IMG_DEF_WALLPAPER
LV_IMG_DECLARE(LV_IMG_DEF_WALLPAPER);
#endif
#endif*/
/**********************
* MACROS
@@ -80,10 +80,10 @@ void lv_init(void)
/*Create the default screen*/
ll_init(&scr_ll, sizeof(lv_obj_t));
#ifdef LV_IMG_DEF_WALLPAPER
lv_img_create_file("def_wp", LV_IMG_DEF_WALLPAPER);
// lv_img_create_file("def_wp", LV_IMG_DEF_WALLPAPER);
def_scr = lv_img_create(NULL, NULL);
lv_img_set_auto_size(def_scr, false);
lv_img_set_file(def_scr, "U:/def_wp");
lv_img_set_file(def_scr, LV_IMG_DEF_WALLPAPER);
#else
def_scr = lv_obj_create(NULL, NULL);
#endif
@@ -206,8 +206,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
new_obj->style_iso = 0;
new_obj->hidden = 0;
new_obj->top_en = 0;
new_obj->child_chg_off = 0;
new_obj->opa_protect = 0;
new_obj->protect = LV_OBJ_PROT_NONE;
new_obj->ext = NULL;
}
@@ -215,7 +214,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
else
{
new_obj = ll_ins_head(&(parent)->child_ll);
new_obj->par = parent; /*Set the parent*/
ll_init(&(new_obj->child_ll), sizeof(lv_obj_t));
@@ -244,8 +243,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
new_obj->style_iso = 0;
new_obj->hidden = 0;
new_obj->top_en = 0;
new_obj->child_chg_off = 0;
new_obj->opa_protect = 0;
new_obj->protect = LV_OBJ_PROT_NONE;
new_obj->ext = NULL;
@@ -265,7 +263,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
new_obj->hidden = copy->hidden;
new_obj->style_iso = copy->style_iso;
new_obj->top_en = copy->top_en;
new_obj->opa_protect = copy->opa_protect;
new_obj->protect = copy->protect;
if(copy->style_iso == 0) {
new_obj->style_p = copy->style_p;
@@ -356,7 +354,7 @@ bool lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
switch(sign) {
case LV_SIGNAL_CHILD_CHG:
/*Return 'invalid' if the child change signal is not enabled*/
if(obj->child_chg_off != 0) valid = false;
if(lv_obj_is_protected(obj, LV_OBJ_PROT_CHILD_CHG) != false) valid = false;
break;
default:
break;
@@ -875,7 +873,8 @@ void lv_obj_set_opar(lv_obj_t * obj, uint8_t opa)
lv_obj_set_opar(i, opa);
}
if(obj->opa_protect == 0) obj->opa = opa;
/*Set the opacity is the object is not protected*/
if(lv_obj_is_protected(obj, LV_OBJ_PROT_OPA) == false) obj->opa = opa;
lv_obj_inv(obj);
}
@@ -953,14 +952,26 @@ void lv_obj_set_drag_parent(lv_obj_t * obj, bool en)
}
/**
* Do not let 'lv_obj_set_opar' to set the opacity
* Set a bit or bits in the protect filed
* @param obj pointer to an object
* @param en true: enable the 'opa_protect' for the object
* @param prot 'OR'-ed values from lv_obj_prot_t
*/
void lv_obj_set_opa_protect(lv_obj_t * obj, bool en)
void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot)
{
obj->opa_protect = (en == true ? 1 : 0);
obj->protect |= prot;
}
/**
* Clear a bit or bits in the protect filed
* @param obj pointer to an object
* @param prot 'OR'-ed values from lv_obj_prot_t
*/
void lv_obj_clr_protect(lv_obj_t * obj, uint8_t prot)
{
prot = (~prot) & 0xFF;
obj->protect &= prot;
}
/**
* Set the signal function of an object.
* Always call the previous signal function in the new.
@@ -1373,13 +1384,24 @@ bool lv_obj_get_style_iso(lv_obj_t * obj)
}
/**
* Get the opa_protect attribute of an object
* Get the protect field of an object
* @param obj pointer to an object
* @return true: opa_protect is enabled
* @return protect field ('OR'ed values of lv_obj_prot_t)
*/
bool lv_obj_get_opa_protect(lv_obj_t * obj)
uint8_t lv_obj_get_protect(lv_obj_t * obj)
{
return obj->opa_protect == 0 ? false : true;
return obj->protect ;
}
/**
* Check at least one bit of a given protect bitfield is set
* @param obj pointer to an object
* @param prot protect bits to test ('OR'ed values of lv_obj_prot_t)
* @return false: none of the given bits are set, true: at least one bit is set
*/
bool lv_obj_is_protected(lv_obj_t * obj, uint8_t prot)
{
return (obj->protect & prot) == 0 ? false : true ;
}
/**