BigW Consortium Gitlab

Commit 659a641c by Kiss-Vamosi Gabor

lv_btn style loading bugfux

parent 35605d87
......@@ -25,7 +25,7 @@
* STATIC PROTOTYPES
**********************/
static bool lv_btn_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
static void lv_btn_style_load(lv_obj_t * obj_dp);
static void lv_btn_style_load(lv_obj_t * obj_dp, lv_rects_t * rects_p);
/**********************
* STATIC VARIABLES
......@@ -102,15 +102,15 @@ static lv_btns_t lv_btns_border =
*/
lv_obj_t* lv_btn_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
{
lv_obj_t* new_obj;
lv_obj_t* new_obj_dp;
new_obj = lv_rect_create(par_dp, copy_dp);
new_obj_dp = lv_rect_create(par_dp, copy_dp);
/*Allocate the extended data*/
lv_obj_alloc_ext(new_obj, sizeof(lv_btn_ext_t));
lv_obj_set_signal_f(new_obj, lv_btn_signal);
lv_obj_set_design_f(new_obj, lv_btn_design);
lv_obj_alloc_ext(new_obj_dp, sizeof(lv_btn_ext_t));
lv_obj_set_signal_f(new_obj_dp, lv_btn_signal);
lv_obj_set_design_f(new_obj_dp, lv_btn_design);
lv_btn_ext_t * btn_ext_dp = lv_obj_get_ext(new_obj);
lv_btn_ext_t * btn_ext_dp = lv_obj_get_ext(new_obj_dp);
btn_ext_dp->lpr_exec = 0;
/*If no copy do the basic initialization*/
......@@ -121,7 +121,7 @@ lv_obj_t* lv_btn_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
btn_ext_dp->rel_action = NULL;
btn_ext_dp->lpr_action = NULL;
btn_ext_dp->tgl = 0;
lv_obj_set_style(new_obj, &lv_btns_def);
lv_obj_set_style(new_obj_dp, &lv_btns_def);
}
/*Copy 'copy_dp'*/
else{
......@@ -133,7 +133,7 @@ lv_obj_t* lv_btn_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
btn_ext_dp->tgl = ori_btn_ext->tgl;
}
return new_obj;
return new_obj_dp;
}
/**
......@@ -146,11 +146,6 @@ bool lv_btn_signal(lv_obj_t * obj_dp, lv_signal_t sign, void* param)
{
bool valid;
/*Be sure the corresponding style is loaded*/
if(sign == LV_SIGNAL_STYLE_CHG) {
lv_btn_style_load(obj_dp);
}
/* Include the ancient signal function */
valid = lv_rect_signal(obj_dp, sign, param);
......@@ -222,10 +217,6 @@ bool lv_btn_signal(lv_obj_t * obj_dp, lv_signal_t sign, void* param)
btn_ext_dp->lpr_exec = 1;
valid = btn_ext_dp->lpr_action(obj_dp, param);
}
break;
case LV_SIGNAL_STYLE_CHG:
/*Load the currently active style*/
lv_btn_style_load(obj_dp);
break;
default:
/*Do nothing*/
......@@ -262,7 +253,6 @@ void lv_btn_set_state(lv_obj_t* obj_dp, lv_btn_state_t state)
lv_btn_ext_t * btn_p = lv_obj_get_ext(obj_dp);
btn_p->state = state;
lv_btn_style_load(obj_dp);
lv_obj_inv(obj_dp);
}
......@@ -403,8 +393,12 @@ static bool lv_btn_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
area_t area;
lv_obj_get_cords(obj_dp, &area);
lv_rects_t rects_tmp;
lv_btn_style_load(obj_dp, &rects_tmp);
/*Draw the rectangle*/
lv_draw_rect(&area, mask_p, &btns_p->rects, opa);
lv_draw_rect(&area, mask_p, &rects_tmp, opa);
return true;
}
......@@ -413,15 +407,16 @@ static bool lv_btn_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
* Load the corresponding style according to the state to 'rects' in 'lv_btns_t'
* @param obj_dp pointer to a button object
*/
static void lv_btn_style_load(lv_obj_t * obj_dp)
static void lv_btn_style_load(lv_obj_t * obj_dp, lv_rects_t * rects_p)
{
lv_btn_state_t state = lv_btn_get_state(obj_dp);
lv_btns_t * btns_p = lv_obj_get_style(obj_dp);
/*Init the style*/
btns_p->rects.objs.color = btns_p->mcolor[state];
btns_p->rects.gcolor = btns_p->gcolor[state];
btns_p->rects.bcolor = btns_p->bcolor[state];
/*Load the style*/
memcpy(rects_p, &btns_p->rects, sizeof(lv_rects_t));
rects_p->objs.color = btns_p->mcolor[state];
rects_p->gcolor = btns_p->gcolor[state];
rects_p->bcolor = btns_p->bcolor[state];
}
#endif
......@@ -22,7 +22,7 @@
*********************/
#define LVGL_VERSION_MAJOR 1
#define LVGL_VERSION_MINOR 1
#define LVGL_VERSION_BUGFIX 1
#define LVGL_VERSION_BUGFIX 2
/**********************
* TYPEDEFS
......
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