BigW Consortium Gitlab

Commit 932c10e5 by Gabor

ext_size attribute added

parent 07ece605
......@@ -98,7 +98,12 @@ void lv_obj_inv(lv_obj_t * obj)
lv_obj_t * par = lv_obj_get_parent(obj);
bool union_ok = true;
/*Start with the original coordinates*/
cord_t ext_size = obj->ext_size;
area_cpy(&area_trunc, &obj->cords);
area_trunc.x1 -= ext_size;
area_trunc.y1 -= ext_size;
area_trunc.x2 += ext_size;
area_trunc.y2 += ext_size;
/*Check through all parents*/
while(par != NULL) {
......@@ -163,6 +168,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
new_obj->cords.y1 = 0;
new_obj->cords.x2 = LV_HOR_RES - 1;
new_obj->cords.y2 = LV_VER_RES - 1;
new_obj->ext_size = 0;
/*Set appearance*/
new_obj->style_p = lv_objs_get(LV_OBJS_SCR, NULL);
......@@ -182,7 +188,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
new_obj->top_en = 0;
new_obj->ext = NULL;
}
/*parent != NULL create normal obj. on parent*/
/*parent != NULL create normal obj. on a parent*/
else
{
new_obj = ll_ins_head(&(parent)->child_ll);
......@@ -197,6 +203,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
LV_OBJ_DEF_WIDTH;
new_obj->cords.y2 = parent->cords.y1 +
LV_OBJ_DEF_HEIGHT;
new_obj->ext_size = 0;
/*Set appearance*/
new_obj->style_p = lv_objs_get(LV_OBJS_DEF, NULL);
......@@ -221,7 +228,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
if(copy != NULL) {
area_cpy(&new_obj->cords, &copy->cords);
new_obj->ext_size = copy->ext_size;
/*Set attributes*/
new_obj->click_en = copy->click_en;
new_obj->drag_en = copy->drag_en;
......@@ -752,6 +759,18 @@ void lv_obj_align_us(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_
lv_obj_align(obj, base, align, x_mod * LV_DOWNSCALE, y_mod * LV_DOWNSCALE);
}
/**
* Set the extended size of an object
* @param obj pointer to an object
* @param ext_size the extended size
*/
void lv_obj_set_ext_size(lv_obj_t * obj, cord_t ext_size)
{
obj->ext_size = ext_size;
lv_obj_inv(obj);
}
/*---------------------
* Appearance set
*--------------------*/
......@@ -937,6 +956,18 @@ void * lv_obj_alloc_ext(lv_obj_t * obj, uint16_t ext_size)
}
/**
* Send a 'LV_SIGNAL_REFR_EXT_SIZE' signal to the object
* @param obj pointer to an object
*/
void lv_obj_ext_size_refr(lv_obj_t * obj)
{
obj->ext_size = 0;
obj->signal_f(obj, LV_SIGNAL_REFR_EXT_SIZE, NULL);
lv_obj_inv(obj);
}
/**
* Set an application specific number for an object.
* It can help to identify objects in the application.
* @param obj pointer to an object
......@@ -1173,6 +1204,16 @@ cord_t lv_obj_get_height(lv_obj_t * obj)
return area_get_height(&obj->cords);
}
/**
* Get the extended size attribute of an object
* @param obj pointer to an object
* @return the extended size attribute
*/
cord_t lv_obj_getext_size(lv_obj_t * obj)
{
return obj->ext_size;
}
/*-----------------
* Appearance get
*---------------*/
......
......@@ -73,6 +73,7 @@ typedef enum
LV_SIGNAL_CHILD_CHG,
LV_SIGNAL_CORD_CHG,
LV_SIGNAL_STYLE_CHG,
LV_SIGNAL_REFR_EXT_SIZE,
}lv_signal_t;
typedef bool (* lv_signal_f_t) (struct __LV_OBJ_T * obj, lv_signal_t sign, void * param);
......@@ -102,11 +103,13 @@ typedef struct __LV_OBJ_T
uint8_t style_iso :1; /*1: The object has got an own style*/
uint8_t hidden :1; /*1: Object is hidden*/
uint8_t top_en :1; /*1: If the object or its children is clicked it goes to the foreground*/
uint8_t child_chg_off:1; /*1: Disable the child change signal. Useful when moving the children*/
uint8_t child_chg_off:1; /*1: Disable the child change signal. Used by the library*/
opa_t opa;
cord_t ext_size; /*EXTtend the size of the object in every direction. Used to draw shadow, shine etc.*/
uint8_t free_num; /*Application specific identifier (set it freely)*/
opa_t opa;
}lv_obj_t;
......@@ -194,6 +197,7 @@ void lv_obj_set_height(lv_obj_t * obj, cord_t h);
void lv_obj_set_height_us(lv_obj_t * obj, cord_t h);
void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
void lv_obj_align_us(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
void lv_obj_set_ext_size(lv_obj_t * obj, cord_t ext_size);;
/*Appearance set*/
void lv_obj_set_hidden(lv_obj_t * obj, bool hidden_en);
void lv_obj_set_opa(lv_obj_t * obj, opa_t opa);
......@@ -208,6 +212,7 @@ void lv_obj_set_signal_f(lv_obj_t * obj, lv_signal_f_t fp);
void lv_obj_set_design_f(lv_obj_t * obj, lv_design_f_t fp);
/*Other set*/
void * lv_obj_alloc_ext(lv_obj_t * obj, uint16_t ext_size);
void lv_obj_ext_size_refr(lv_obj_t * obj);
void lv_obj_set_style(lv_obj_t * obj, void * style_p);
void * lv_obj_iso_style(lv_obj_t * obj, uint32_t style_size);
void lv_obj_set_free_num(lv_obj_t * obj, uint8_t free_num);
......
......@@ -391,24 +391,38 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
bool union_ok; /* Store the return value of area_union */
/* Truncate the original mask to the coordinates of the parent
* because the parent and its children are visible only here */
area_t mask_parent;
union_ok = area_union(&mask_parent, mask_ori_p, &obj->cords);
area_t obj_mask;
area_t obj_area;
cord_t ext_size = obj->ext_size;
lv_obj_get_cords(obj, &obj_area);
obj_area.x1 -= ext_size;
obj_area.y1 -= ext_size;
obj_area.x2 += ext_size;
obj_area.y2 += ext_size;
union_ok = area_union(&obj_mask, mask_ori_p, &obj_area);
/*Draw the parent and its children only if they ore on 'mask_parent'*/
if(union_ok != false) {
/* Redraw the object */
if(obj->opa != OPA_TRANSP && LV_SA(obj, lv_objs_t)->transp == 0) {
obj->design_f(obj, &mask_parent, LV_DESIGN_DRAW_MAIN);
obj->design_f(obj, &obj_mask, LV_DESIGN_DRAW_MAIN);
}
area_t mask_child; /*Mask from obj and its child*/
lv_obj_t * child_p;
area_t child_area;
LL_READ_BACK(obj->child_ll, child_p)
{
lv_obj_get_cords(child_p, &child_area);
ext_size = child_p->ext_size;
child_area.x1 -= ext_size;
child_area.y1 -= ext_size;
child_area.x2 += ext_size;
child_area.y2 += ext_size;
/* Get the union (common parts) of original mask (from obj)
* and its child */
union_ok = area_union(&mask_child, &mask_parent, &child_p->cords);
union_ok = area_union(&mask_child, &obj_mask, &child_area);
/*If the parent and the child has common area then refresh the child */
if(union_ok) {
......@@ -419,7 +433,7 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
/* If all the children are redrawn call make 'post draw' design */
if(obj->opa != OPA_TRANSP && LV_SA(obj, lv_objs_t)->transp == 0) {
obj->design_f(obj, &mask_parent, LV_DESIGN_DRAW_POST);
obj->design_f(obj, &obj_mask, LV_DESIGN_DRAW_POST);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment