feat(event) rework the prototype of lv_event_cb

It encapsulates all event related parameters into a single lv_event_t obejct.
This commit is contained in:
Gabor Kiss-Vamosi
2021-04-14 15:31:54 +02:00
parent c090af0f26
commit 422c9e5bd6
67 changed files with 688 additions and 506 deletions

View File

@@ -30,7 +30,7 @@
* STATIC PROTOTYPES
**********************/
static void lv_led_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
static void lv_led_event(lv_obj_t * obj, lv_event_t e);
static void lv_led_event(lv_event_t * e);
/**********************
* STATIC VARIABLES
@@ -156,15 +156,17 @@ static void lv_led_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
led->bright = LV_LED_BRIGHT_MAX;
}
static void lv_led_event(lv_obj_t * obj, lv_event_t e)
static void lv_led_event(lv_event_t * e)
{
lv_res_t res;
/* Call the ancestor's event handler */
res = lv_obj_event_base(MY_CLASS, obj, e);
res = lv_obj_event_base(MY_CLASS, e);
if(res != LV_RES_OK) return;
if(e == LV_EVENT_DRAW_MAIN) {
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t * obj = lv_event_get_target(e);
if(code == LV_EVENT_DRAW_MAIN) {
/*Make darker colors in a temporary style according to the brightness*/
lv_led_t * led = (lv_led_t *)obj;
@@ -193,7 +195,7 @@ static void lv_led_event(lv_obj_t * obj, lv_event_t e)
rect_dsc.shadow_spread = ((led->bright - LV_LED_BRIGHT_MIN) * rect_dsc.shadow_spread) /
(LV_LED_BRIGHT_MAX - LV_LED_BRIGHT_MIN);
const lv_area_t * clip_area = lv_event_get_param();
const lv_area_t * clip_area = lv_event_get_param(e);
lv_draw_rect(&obj->coords, clip_area, &rect_dsc);
}
}