start to implement the new generic event system

This commit is contained in:
Gabor Kiss-Vamosi
2019-02-26 09:25:46 +01:00
parent cc3ef640da
commit 50e69bab6b
49 changed files with 403 additions and 806 deletions

View File

@@ -82,7 +82,7 @@ void lv_group_del(lv_group_t * group)
{
/*Defocus the the currently focused object*/
if(group->obj_focus != NULL) {
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
(*group->obj_focus)->signal_cb(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
lv_obj_invalidate(*group->obj_focus);
}
@@ -141,7 +141,7 @@ void lv_group_remove_obj(lv_obj_t * obj)
if(*g->obj_focus == obj) {
/*If this is the only object in the group then focus to nothing.*/
if(lv_ll_get_head(&g->obj_ll) == g->obj_focus && lv_ll_get_tail(&g->obj_ll) == g->obj_focus) {
(*g->obj_focus)->signal_func(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
(*g->obj_focus)->signal_cb(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
}
/*If there more objects in the group then focus to the next/prev object*/
else {
@@ -186,14 +186,14 @@ void lv_group_focus_obj(lv_obj_t * obj)
if(*i == obj) {
if(g->obj_focus == i) return; /*Don't focus the already focused object again*/
if(g->obj_focus != NULL) {
(*g->obj_focus)->signal_func(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
(*g->obj_focus)->signal_cb(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
lv_obj_invalidate(*g->obj_focus);
}
g->obj_focus = i;
if(g->obj_focus != NULL) {
(*g->obj_focus)->signal_func(*g->obj_focus, LV_SIGNAL_FOCUS, NULL);
(*g->obj_focus)->signal_cb(*g->obj_focus, LV_SIGNAL_FOCUS, NULL);
if(g->focus_cb) g->focus_cb(g);
lv_obj_invalidate(*g->obj_focus);
}
@@ -242,7 +242,7 @@ lv_res_t lv_group_send_data(lv_group_t * group, uint32_t c)
lv_obj_t * act = lv_group_get_focused(group);
if(act == NULL) return LV_RES_OK;
return act->signal_func(act, LV_SIGNAL_CONTROLL, &c);
return act->signal_cb(act, LV_SIGNAL_CONTROLL, &c);
}
/**
@@ -291,7 +291,7 @@ void lv_group_set_editing(lv_group_t * group, bool edit)
group->editing = en_val;
lv_obj_t * focused = lv_group_get_focused(group);
if(focused) focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave edit mode*/
if(focused) focused->signal_cb(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave edit mode*/
lv_obj_invalidate(focused);
}
@@ -568,13 +568,13 @@ static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *)
if(obj_next == group->obj_focus) return; /*There's only one visible object and it's already focused*/
if(group->obj_focus) {
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
(*group->obj_focus)->signal_cb(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
lv_obj_invalidate(*group->obj_focus);
}
group->obj_focus = obj_next;
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
(*group->obj_focus)->signal_cb(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
lv_obj_invalidate(*group->obj_focus);
if(group->focus_cb) group->focus_cb(group);

View File

@@ -382,13 +382,15 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
#if USE_LV_GROUP
if(i->group == NULL) return;
lv_obj_t * focused = lv_group_get_focused(i->group);
/*Key press happened*/
if(data->state == LV_INDEV_STATE_PR &&
i->proc.last_state == LV_INDEV_STATE_REL) {
i->proc.pr_timestamp = lv_tick_get();
lv_obj_t * focused = lv_group_get_focused(i->group);
if(focused && data->key == LV_GROUP_KEY_ENTER) {
focused->signal_func(focused, LV_SIGNAL_PRESSED, indev_act);
focused->signal_cb(focused, LV_SIGNAL_PRESSED, indev_act);
lv_obj_send_event(focused, LV_EVENT_PRESSED);
}
}
/*Pressing*/
@@ -399,8 +401,9 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
/*On enter long press leave edit mode.*/
lv_obj_t * focused = lv_group_get_focused(i->group);
if(focused) {
focused->signal_func(focused, LV_SIGNAL_LONG_PRESS, indev_act);
focused->signal_cb(focused, LV_SIGNAL_LONG_PRESS, indev_act);
i->proc.long_pr_sent = 1;
lv_obj_send_event(focused, LV_EVENT_LONG_PRESSED);
}
}
}
@@ -421,7 +424,9 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
lv_group_focus_prev(i->group);
} else if(data->key == LV_GROUP_KEY_ENTER) {
if(!i->proc.long_pr_sent) {
lv_group_send_data(i->group, data->key);
focused->signal_cb(focused, LV_SIGNAL_RELEASED, indev_act);
lv_obj_send_event(focused, LV_EVENT_RELEASED);
lv_obj_send_event(focused, LV_EVENT_CLICKED);
}
} else {
lv_group_send_data(i->group, data->key);
@@ -486,18 +491,18 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
lv_obj_t * focused = lv_group_get_focused(i->group);
bool editable = false;
if(focused) focused->signal_func(focused, LV_SIGNAL_GET_EDITABLE, &editable);
if(focused) focused->signal_cb(focused, LV_SIGNAL_GET_EDITABLE, &editable);
if(editable) {
if(i->group->obj_ll.head != i->group->obj_ll.tail)
lv_group_set_editing(i->group, lv_group_get_editing(i->group) ? false : true); /*Toggle edit mode on long press*/
else if(focused)
focused->signal_func(focused, LV_SIGNAL_LONG_PRESS, indev_act);
focused->signal_cb(focused, LV_SIGNAL_LONG_PRESS, indev_act);
}
/*If not editable then just send a long press signal*/
else {
if(focused)
focused->signal_func(focused, LV_SIGNAL_LONG_PRESS, indev_act);
focused->signal_cb(focused, LV_SIGNAL_LONG_PRESS, indev_act);
}
i->proc.long_pr_sent = 1;
}
@@ -506,7 +511,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
else if(data->state == LV_INDEV_STATE_REL && i->proc.last_state == LV_INDEV_STATE_PR) {
lv_obj_t * focused = lv_group_get_focused(i->group);
bool editable = false;
if(focused) focused->signal_func(focused, LV_SIGNAL_GET_EDITABLE, &editable);
if(focused) focused->signal_cb(focused, LV_SIGNAL_GET_EDITABLE, &editable);
/*The button was released on a non-editable object. Just send enter*/
if(!editable) {
@@ -600,7 +605,8 @@ static void indev_proc_press(lv_indev_proc_t * proc)
/*If a new object found the previous was lost, so send a signal*/
if(proc->act_obj != NULL) {
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
proc->act_obj->signal_cb(proc->act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
lv_obj_send_event(proc->act_obj, LV_EVENT_PRESS_LOST);
if(proc->reset_query != 0) return;
}
@@ -636,7 +642,8 @@ static void indev_proc_press(lv_indev_proc_t * proc)
}
/*Send a signal about the press*/
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_PRESSED, indev_act);
proc->act_obj->signal_cb(proc->act_obj, LV_SIGNAL_PRESSED, indev_act);
lv_obj_send_event(proc->act_obj, LV_EVENT_PRESSED);
if(proc->reset_query != 0) return;
}
}
@@ -647,7 +654,8 @@ static void indev_proc_press(lv_indev_proc_t * proc)
/*If there is active object and it can be dragged run the drag*/
if(proc->act_obj != NULL) {
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_PRESSING, indev_act);
proc->act_obj->signal_cb(proc->act_obj, LV_SIGNAL_PRESSING, indev_act);
lv_obj_send_event(proc->act_obj, LV_EVENT_PRESSING);
if(proc->reset_query != 0) return;
indev_drag(proc);
@@ -657,7 +665,8 @@ static void indev_proc_press(lv_indev_proc_t * proc)
if(proc->drag_in_prog == 0 && proc->long_pr_sent == 0) {
/*Send a signal about the long press if enough time elapsed*/
if(lv_tick_elaps(proc->pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) {
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS, indev_act);
pr_obj->signal_cb(pr_obj, LV_SIGNAL_LONG_PRESS, indev_act);
lv_obj_send_event(pr_obj, LV_EVENT_LONG_PRESSED);
if(proc->reset_query != 0) return;
/*Mark the signal sending to do not send it again*/
@@ -671,7 +680,8 @@ static void indev_proc_press(lv_indev_proc_t * proc)
if(proc->drag_in_prog == 0 && proc->long_pr_sent == 1) {
/*Send a signal about the long press repeate if enough time elapsed*/
if(lv_tick_elaps(proc->longpr_rep_timestamp) > LV_INDEV_LONG_PRESS_REP_TIME) {
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS_REP, indev_act);
pr_obj->signal_cb(pr_obj, LV_SIGNAL_LONG_PRESS_REP, indev_act);
lv_obj_send_event(pr_obj, LV_EVENT_LONG_PRESSED_REPEAT);
if(proc->reset_query != 0) return;
proc->longpr_rep_timestamp = lv_tick_get();
@@ -703,14 +713,27 @@ static void indev_proc_release(lv_indev_proc_t * proc)
/* Search the object on the current current coordinates.
* The start object is the object itself. If not ON it the the result will be NULL*/
lv_obj_t * obj_on = indev_search_obj(proc, proc->act_obj);
if(obj_on == proc->act_obj) proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_RELEASED, indev_act);
else proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
if(obj_on == proc->act_obj) {
proc->act_obj->signal_cb(proc->act_obj, LV_SIGNAL_RELEASED, indev_act);
lv_obj_send_event(proc->act_obj, LV_EVENT_RELEASED);
if(proc->long_pr_sent == 0 && proc->drag_in_prog == 0) {
lv_obj_send_event(proc->act_obj, LV_EVENT_CLICKED);
}
}
else {
proc->act_obj->signal_cb(proc->act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
lv_obj_send_event(proc->act_obj, LV_SIGNAL_PRESS_LOST);
}
}
/* The simple case: `act_obj` was not protected against press lost.
* If it is already not pressed then was handled in `indev_proc_press`*/
else {
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_RELEASED, indev_act);
proc->act_obj->signal_cb(proc->act_obj, LV_SIGNAL_RELEASED, indev_act);
lv_obj_send_event(proc->act_obj, LV_SIGNAL_RELEASED);
if(proc->long_pr_sent == 0 && proc->drag_in_prog == 0) {
lv_obj_send_event(proc->act_obj, LV_EVENT_CLICKED);
}
}
if(proc->reset_query != 0) return;
@@ -874,7 +897,7 @@ static void indev_drag(lv_indev_proc_t * state)
if(drag_obj->coords.x1 != prev_x || drag_obj->coords.y1 != prev_y) {
if(state->drag_range_out != 0) { /*Send the drag begin signal on first move*/
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_BEGIN, indev_act);
drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_BEGIN, indev_act);
if(state->reset_query != 0) return;
}
state->drag_in_prog = 1;
@@ -917,7 +940,7 @@ static void indev_drag_throw(lv_indev_proc_t * state)
/*Return if the drag throw is not enabled*/
if(lv_obj_get_drag_throw(drag_obj) == false) {
state->drag_in_prog = 0;
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
return;
}
@@ -943,14 +966,14 @@ static void indev_drag_throw(lv_indev_proc_t * state)
state->drag_in_prog = 0;
state->vect.x = 0;
state->vect.y = 0;
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
}
}
/*If the vectors become 0 -> drag_in_prog = 0 and send a drag end signal*/
else {
state->drag_in_prog = 0;
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
}
}
#endif

View File

@@ -165,8 +165,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
new_obj->style_p = &lv_style_scr;
}
/*Set virtual functions*/
lv_obj_set_signal_func(new_obj, lv_obj_signal);
lv_obj_set_design_func(new_obj, lv_obj_design);
lv_obj_set_signal_cb(new_obj, lv_obj_signal);
lv_obj_set_design_cb(new_obj, lv_obj_design);
/*Set free data*/
#ifdef LV_OBJ_FREE_NUM_TYPE
@@ -233,8 +233,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
}
/*Set virtual functions*/
lv_obj_set_signal_func(new_obj, lv_obj_signal);
lv_obj_set_design_func(new_obj, lv_obj_design);
lv_obj_set_signal_cb(new_obj, lv_obj_signal);
lv_obj_set_design_cb(new_obj, lv_obj_design);
/*Set free data*/
#ifdef LV_OBJ_FREE_NUM_TYPE
@@ -311,7 +311,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
/*Send a signal to the parent to notify it about the new child*/
if(parent != NULL) {
parent->signal_func(parent, LV_SIGNAL_CHILD_CHG, new_obj);
parent->signal_cb(parent, LV_SIGNAL_CHILD_CHG, new_obj);
/*Invalidate the area if not screen created*/
lv_obj_invalidate(new_obj);
@@ -375,7 +375,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
/* All children deleted.
* Now clean up the object specific data*/
obj->signal_func(obj, LV_SIGNAL_CLEANUP, NULL);
obj->signal_cb(obj, LV_SIGNAL_CLEANUP, NULL);
/*Delete the base objects*/
if(obj->ext_attr != NULL) lv_mem_free(obj->ext_attr);
@@ -383,7 +383,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
/*Send a signal to the parent to notify it about the child delete*/
if(par != NULL) {
par->signal_func(par, LV_SIGNAL_CHILD_CHG, NULL);
par->signal_cb(par, LV_SIGNAL_CHILD_CHG, NULL);
}
return LV_RES_INV;
@@ -485,10 +485,10 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
lv_obj_set_pos(obj, old_pos.x, old_pos.y);
/*Notify the original parent because one of its children is lost*/
old_par->signal_func(old_par, LV_SIGNAL_CHILD_CHG, NULL);
old_par->signal_cb(old_par, LV_SIGNAL_CHILD_CHG, NULL);
/*Notify the new parent about the child*/
parent->signal_func(parent, LV_SIGNAL_CHILD_CHG, obj);
parent->signal_cb(parent, LV_SIGNAL_CHILD_CHG, obj);
lv_obj_invalidate(obj);
}
@@ -535,10 +535,10 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
refresh_children_position(obj, diff.x, diff.y);
/*Inform the object about its new coordinates*/
obj->signal_func(obj, LV_SIGNAL_CORD_CHG, &ori);
obj->signal_cb(obj, LV_SIGNAL_CORD_CHG, &ori);
/*Send a signal to the parent too*/
par->signal_func(par, LV_SIGNAL_CHILD_CHG, obj);
par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj);
/*Invalidate the new area*/
lv_obj_invalidate(obj);
@@ -595,16 +595,16 @@ void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
/*Send a signal to the object with its new coordinates*/
obj->signal_func(obj, LV_SIGNAL_CORD_CHG, &ori);
obj->signal_cb(obj, LV_SIGNAL_CORD_CHG, &ori);
/*Send a signal to the parent too*/
lv_obj_t * par = lv_obj_get_parent(obj);
if(par != NULL) par->signal_func(par, LV_SIGNAL_CHILD_CHG, obj);
if(par != NULL) par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj);
/*Tell the children the parent's size has changed*/
lv_obj_t * i;
LL_READ(obj->child_ll, i) {
i->signal_func(i, LV_SIGNAL_PARENT_SIZE_CHG, NULL);
i->signal_cb(i, LV_SIGNAL_PARENT_SIZE_CHG, NULL);
}
/*Invalidate the new area*/
@@ -987,7 +987,7 @@ void lv_obj_set_style(lv_obj_t * obj, lv_style_t * style)
void lv_obj_refresh_style(lv_obj_t * obj)
{
lv_obj_invalidate(obj);
obj->signal_func(obj, LV_SIGNAL_STYLE_CHG, NULL);
obj->signal_cb(obj, LV_SIGNAL_STYLE_CHG, NULL);
lv_obj_invalidate(obj);
}
@@ -1032,7 +1032,7 @@ void lv_obj_set_hidden(lv_obj_t * obj, bool en)
if(!obj->hidden) lv_obj_invalidate(obj); /*Invalidate when not hidden (hidden objects are ignored) */
lv_obj_t * par = lv_obj_get_parent(obj);
par->signal_func(par, LV_SIGNAL_CHILD_CHG, obj);
par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj);
}
@@ -1132,24 +1132,55 @@ void lv_obj_clear_protect(lv_obj_t * obj, uint8_t prot)
}
/**
* Set the signal function of an object.
* Set a an event handler function for an object.
* Used by the user to react on event which happens with the object.
* @param obj pointer to an object
* @param cb the new event function
*/
void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t cb)
{
obj->event_cb = cb;
}
/**
* Send an event to the object
* @param obj pointer to an object
* @param event the type of the event from `lv_event_t`.
*/
void lv_obj_send_event(lv_obj_t * obj, lv_event_t event)
{
if(obj->event_cb) obj->event_cb(obj, event);
}
/**
* Set the a signal function of an object. Used internally by the library.
* Always call the previous signal function in the new.
* @param obj pointer to an object
* @param fp the new signal function
* @param cb the new signal function
*/
void lv_obj_set_signal_func(lv_obj_t * obj, lv_signal_func_t fp)
void lv_obj_set_signal_cb(lv_obj_t * obj, lv_signal_cb_t cb)
{
obj->signal_func = fp;
obj->signal_cb = cb;
}
/**
* Send an event to the object
* @param obj pointer to an object
* @param event the type of the event from `lv_event_t`.
*/
void lv_obj_send_signal(lv_obj_t * obj, lv_signal_t signal, void * param)
{
if(obj->signal_cb) obj->signal_cb(obj, signal, param);
}
/**
* Set a new design function for an object
* @param obj pointer to an object
* @param fp the new design function
* @param cb the new design function
*/
void lv_obj_set_design_func(lv_obj_t * obj, lv_design_func_t fp)
void lv_obj_set_design_cb(lv_obj_t * obj, lv_design_cb_t cb)
{
obj->design_func = fp;
obj->design_cb = cb;
}
/*----------------
@@ -1176,7 +1207,7 @@ void * lv_obj_allocate_ext_attr(lv_obj_t * obj, uint16_t ext_size)
void lv_obj_refresh_ext_size(lv_obj_t * obj)
{
obj->ext_size = 0;
obj->signal_func(obj, LV_SIGNAL_REFR_EXT_SIZE, NULL);
obj->signal_cb(obj, LV_SIGNAL_REFR_EXT_SIZE, NULL);
lv_obj_invalidate(obj);
}
@@ -1656,9 +1687,9 @@ bool lv_obj_is_protected(const lv_obj_t * obj, uint8_t prot)
* @param obj pointer to an object
* @return the signal function
*/
lv_signal_func_t lv_obj_get_signal_func(const lv_obj_t * obj)
lv_signal_cb_t lv_obj_get_signal_func(const lv_obj_t * obj)
{
return obj->signal_func;
return obj->signal_cb;
}
/**
@@ -1666,9 +1697,9 @@ lv_signal_func_t lv_obj_get_signal_func(const lv_obj_t * obj)
* @param obj pointer to an object
* @return the design function
*/
lv_design_func_t lv_obj_get_design_func(const lv_obj_t * obj)
lv_design_cb_t lv_obj_get_design_func(const lv_obj_t * obj)
{
return obj->design_func;
return obj->design_cb;
}
/*------------------
@@ -1699,7 +1730,7 @@ void lv_obj_get_type(lv_obj_t * obj, lv_obj_type_t * buf)
memset(buf, 0, sizeof(lv_obj_type_t));
memset(&tmp, 0, sizeof(lv_obj_type_t));
obj->signal_func(obj, LV_SIGNAL_GET_TYPE, &tmp);
obj->signal_cb(obj, LV_SIGNAL_GET_TYPE, &tmp);
uint8_t cnt;
for(cnt = 0; cnt < LV_MAX_ANCESTOR_NUM; cnt++) {
@@ -1956,7 +1987,7 @@ static void delete_children(lv_obj_t * obj)
lv_ll_rem(&(par->child_ll), obj);
/* Clean up the object specific data*/
obj->signal_func(obj, LV_SIGNAL_CLEANUP, NULL);
obj->signal_cb(obj, LV_SIGNAL_CLEANUP, NULL);
/*Delete the base objects*/
if(obj->ext_attr != NULL) lv_mem_free(obj->ext_attr);

View File

@@ -62,7 +62,7 @@ enum
};
typedef uint8_t lv_design_mode_t;
typedef bool (* lv_design_func_t) (struct _lv_obj_t * obj, const lv_area_t * mask_p, lv_design_mode_t mode);
typedef bool (* lv_design_cb_t) (struct _lv_obj_t * obj, const lv_area_t * mask_p, lv_design_mode_t mode);
enum
{
@@ -71,6 +71,30 @@ enum
};
typedef uint8_t lv_res_t;
typedef enum {
LV_EVENT_PRESSED,
LV_EVENT_PRESSING,
LV_EVENT_PRESS_LOST,
LV_EVENT_RELEASED,
LV_EVENT_CLICKED,
LV_EVENT_LONG_PRESSED,
LV_EVENT_LONG_PRESSED_REPEAT,
LV_EVENT_LONG_HOVER_IN,
LV_EVENT_LONG_HOVER_OUT,
LV_EVENT_DRAG_BEGIN,
LV_EVENT_DRAG_END,
LV_EVENT_DRAG_THROW_BEGIN,
LV_EVENT_FOCUSED,
LV_EVENT_DEFOCUSED,
LV_EVENT_VALUE_CHANGED,
LV_EVENT_REFRESH,
LV_EVENT_APPLY, /*"Ok", "Apply" or similar specific button has clicked*/
LV_EVENT_CANCEL, /*"Close", "Cancel" or similar specific button has clicked*/
}lv_event_t;
typedef void (*lv_event_cb_t)(struct _lv_obj_t * obj, lv_event_t event);
enum
{
/*General signals*/
@@ -102,7 +126,7 @@ enum
};
typedef uint8_t lv_signal_t;
typedef lv_res_t (* lv_signal_func_t) (struct _lv_obj_t * obj, lv_signal_t sign, void * param);
typedef lv_res_t (* lv_signal_cb_t) (struct _lv_obj_t * obj, lv_signal_t sign, void * param);
enum
{
@@ -149,8 +173,9 @@ typedef struct _lv_obj_t
lv_area_t coords; /*Coordinates of the object (x1, y1, x2, y2)*/
lv_signal_func_t signal_func; /*Object type specific signal function*/
lv_design_func_t design_func; /*Object type specific design function*/
lv_event_cb_t event_cb;
lv_signal_cb_t signal_cb; /*Object type specific signal function*/
lv_design_cb_t design_cb; /*Object type specific design function*/
void * ext_attr; /*Object type specific extended data*/
lv_style_t * style_p; /*Pointer to the object's style*/
@@ -183,8 +208,6 @@ typedef struct _lv_obj_t
#endif
} lv_obj_t;
typedef lv_res_t (*lv_action_t) (struct _lv_obj_t * obj);
/*Protect some attributes (max. 8 bit)*/
enum
{
@@ -462,19 +485,41 @@ void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot);
void lv_obj_clear_protect(lv_obj_t * obj, uint8_t prot);
/**
* Set the signal function of an object.
* Set a an event handler function for an object.
* Used by the user to react on event which happens with the object.
* @param obj pointer to an object
* @param cb the new event function
*/
void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t cb);
/**
* Send an event to the object
* @param obj pointer to an object
* @param event the type of the event from `lv_event_t`.
*/
void lv_obj_send_event(lv_obj_t * obj, lv_event_t event);
/**
* Set the a signal function of an object. Used internally by the library.
* Always call the previous signal function in the new.
* @param obj pointer to an object
* @param fp the new signal function
* @param cb the new signal function
*/
void lv_obj_set_signal_func(lv_obj_t * obj, lv_signal_func_t fp);
void lv_obj_set_signal_cb(lv_obj_t * obj, lv_signal_cb_t cb);
/**
* Send an event to the object
* @param obj pointer to an object
* @param event the type of the event from `lv_event_t`.
*/
void lv_obj_send_signal(lv_obj_t * obj, lv_signal_t signal, void * param);
/**
* Set a new design function for an object
* @param obj pointer to an object
* @param fp the new design function
* @param cb the new design function
*/
void lv_obj_set_design_func(lv_obj_t * obj, lv_design_func_t fp);
void lv_obj_set_design_cb(lv_obj_t * obj, lv_design_cb_t cb);
/*----------------
* Other set
@@ -725,14 +770,14 @@ bool lv_obj_is_protected(const lv_obj_t * obj, uint8_t prot);
* @param obj pointer to an object
* @return the signal function
*/
lv_signal_func_t lv_obj_get_signal_func(const lv_obj_t * obj);
lv_signal_cb_t lv_obj_get_signal_func(const lv_obj_t * obj);
/**
* Get the design function of an object
* @param obj pointer to an object
* @return the design function
*/
lv_design_func_t lv_obj_get_design_func(const lv_obj_t * obj);
lv_design_cb_t lv_obj_get_design_func(const lv_obj_t * obj);
/*------------------
* Other get

View File

@@ -401,7 +401,7 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
if(found_p == NULL) {
lv_style_t * style = lv_obj_get_style(obj);
if(style->body.opa == LV_OPA_COVER &&
obj->design_func(obj, area_p, LV_DESIGN_COVER_CHK) != false &&
obj->design_cb(obj, area_p, LV_DESIGN_COVER_CHK) != false &&
lv_obj_get_opa_scale(obj) == LV_OPA_COVER) {
found_p = obj;
}
@@ -454,7 +454,7 @@ static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p)
/*Call the post draw design function of the parents of the to object*/
par = lv_obj_get_parent(top_p);
while(par != NULL) {
par->design_func(par, mask_p, LV_DESIGN_DRAW_POST);
par->design_cb(par, mask_p, LV_DESIGN_DRAW_POST);
par = lv_obj_get_parent(par);
}
}
@@ -487,7 +487,7 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
if(union_ok != false) {
/* Redraw the object */
obj->design_func(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
obj->design_cb(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
//usleep(5 * 1000); /*DEBUG: Wait after every object draw to see the order of drawing*/
@@ -518,7 +518,7 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
}
/* If all the children are redrawn make 'post draw' design */
obj->design_func(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST);
obj->design_cb(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST);
}
}