mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
start to implement the new generic event system
This commit is contained in:
parent
cc3ef640da
commit
50e69bab6b
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ static lv_res_t lv_arc_signal(lv_obj_t * arc, lv_signal_t sign, void * param);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_func_t ancestor_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -72,8 +72,8 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->angle_end = 315;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_arc, lv_arc_signal);
|
||||
lv_obj_set_design_func(new_arc, lv_arc_design);
|
||||
lv_obj_set_signal_cb(new_arc, lv_arc_signal);
|
||||
lv_obj_set_design_cb(new_arc, lv_arc_design);
|
||||
|
||||
/*Init the new arc arc*/
|
||||
if(copy == NULL) {
|
||||
|
@ -33,8 +33,8 @@ static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_func_t ancestor_design_f;
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design_f;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -73,8 +73,8 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->sym = 0;
|
||||
ext->style_indic = &lv_style_pretty_color;
|
||||
|
||||
lv_obj_set_signal_func(new_bar, lv_bar_signal);
|
||||
lv_obj_set_design_func(new_bar, lv_bar_design);
|
||||
lv_obj_set_signal_cb(new_bar, lv_bar_signal);
|
||||
lv_obj_set_design_cb(new_bar, lv_bar_design);
|
||||
|
||||
/*Init the new bar object*/
|
||||
if(copy == NULL) {
|
||||
|
@ -42,8 +42,8 @@ static void lv_btn_ink_effect_anim_ready(void * p);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_func_t ancestor_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design;
|
||||
|
||||
#if USE_LV_ANIMATION && LV_BTN_INK_EFFECT
|
||||
static lv_coord_t ink_act_value;
|
||||
@ -89,18 +89,12 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
ext->state = LV_BTN_STATE_REL;
|
||||
|
||||
ext->actions[LV_BTN_ACTION_PR] = NULL;
|
||||
ext->actions[LV_BTN_ACTION_CLICK] = NULL;
|
||||
ext->actions[LV_BTN_ACTION_LONG_PR] = NULL;
|
||||
ext->actions[LV_BTN_ACTION_LONG_PR_REPEAT] = NULL;
|
||||
|
||||
ext->styles[LV_BTN_STATE_REL] = &lv_style_btn_rel;
|
||||
ext->styles[LV_BTN_STATE_PR] = &lv_style_btn_pr;
|
||||
ext->styles[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_rel;
|
||||
ext->styles[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pr;
|
||||
ext->styles[LV_BTN_STATE_INA] = &lv_style_btn_ina;
|
||||
|
||||
ext->long_pr_action_executed = 0;
|
||||
ext->toggle = 0;
|
||||
#if USE_LV_ANIMATION && LV_BTN_INK_EFFECT
|
||||
ext->ink_in_time = 0;
|
||||
@ -108,8 +102,8 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->ink_out_time = 0;
|
||||
#endif
|
||||
|
||||
lv_obj_set_signal_func(new_btn, lv_btn_signal);
|
||||
lv_obj_set_design_func(new_btn, lv_btn_design);
|
||||
lv_obj_set_signal_cb(new_btn, lv_btn_signal);
|
||||
lv_obj_set_design_cb(new_btn, lv_btn_design);
|
||||
|
||||
/*If no copy do the basic initialization*/
|
||||
if(copy == NULL) {
|
||||
@ -142,7 +136,6 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->ink_wait_time = copy_ext->ink_wait_time;
|
||||
ext->ink_out_time = copy_ext->ink_out_time;
|
||||
#endif
|
||||
memcpy(ext->actions, copy_ext->actions, sizeof(ext->actions));
|
||||
memcpy(ext->styles, copy_ext->styles, sizeof(ext->styles));
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
@ -209,19 +202,6 @@ void lv_btn_toggle(lv_obj_t * btn)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to call when a button event happens
|
||||
* @param btn pointer to a button object
|
||||
* @param action type of event form 'lv_action_t' (press, release, long press, long press repeat)
|
||||
*/
|
||||
void lv_btn_set_action(lv_obj_t * btn, lv_btn_action_t type, lv_action_t action)
|
||||
{
|
||||
if(type >= LV_BTN_ACTION_NUM) return;
|
||||
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
ext->actions[type] = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set time of the ink effect (draw a circle on click to animate in the new state)
|
||||
* @param btn pointer to a button object
|
||||
@ -334,19 +314,6 @@ bool lv_btn_get_toggle(const lv_obj_t * btn)
|
||||
return ext->toggle != 0 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the release action of a button
|
||||
* @param btn pointer to a button object
|
||||
* @return pointer to the release action function
|
||||
*/
|
||||
lv_action_t lv_btn_get_action(const lv_obj_t * btn, lv_btn_action_t type)
|
||||
{
|
||||
if(type >= LV_BTN_ACTION_NUM) return NULL;
|
||||
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
return ext->actions[type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get time of the ink in effect (draw a circle on click to animate in the new state)
|
||||
* @param btn pointer to a button object
|
||||
@ -552,8 +519,6 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
#endif
|
||||
}
|
||||
|
||||
ext->long_pr_action_executed = 0;
|
||||
|
||||
#if USE_LV_ANIMATION && LV_BTN_INK_EFFECT
|
||||
/*Forget the old inked button*/
|
||||
if(ink_obj != NULL && ink_obj != btn) {
|
||||
@ -584,10 +549,6 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
lv_anim_create(&a);
|
||||
}
|
||||
#endif
|
||||
/*Call the press action, 'param' is the caller indev_proc*/
|
||||
if(ext->actions[LV_BTN_ACTION_PR] && state != LV_BTN_STATE_INA) {
|
||||
res = ext->actions[LV_BTN_ACTION_PR](btn);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_PRESS_LOST) {
|
||||
/*Refresh the state*/
|
||||
if(ext->state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
@ -601,7 +562,8 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
/*If not dragged and it was not long press action then
|
||||
*change state and run the action*/
|
||||
if(lv_indev_is_dragging(param) == false && ext->long_pr_action_executed == 0) {
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
if(lv_indev_is_dragging(param) == false && indev->proc.long_pr_sent == 0) {
|
||||
if(ext->state == LV_BTN_STATE_PR && tgl == false) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
} else if(ext->state == LV_BTN_STATE_TGL_PR && tgl == false) {
|
||||
@ -611,10 +573,6 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
} else if(ext->state == LV_BTN_STATE_TGL_PR && tgl == true) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
}
|
||||
|
||||
if(ext->actions[LV_BTN_ACTION_CLICK] && state != LV_BTN_STATE_INA) {
|
||||
res = ext->actions[LV_BTN_ACTION_CLICK](btn);
|
||||
}
|
||||
} else { /*If dragged change back the state*/
|
||||
if(ext->state == LV_BTN_STATE_PR) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
@ -650,29 +608,16 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
lv_anim_create(&a);
|
||||
}
|
||||
#endif
|
||||
} else if(sign == LV_SIGNAL_LONG_PRESS) {
|
||||
if(ext->actions[LV_BTN_ACTION_LONG_PR] && state != LV_BTN_STATE_INA) {
|
||||
ext->long_pr_action_executed = 1;
|
||||
res = ext->actions[LV_BTN_ACTION_LONG_PR](btn);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
|
||||
if(ext->actions[LV_BTN_ACTION_LONG_PR_REPEAT] && state != LV_BTN_STATE_INA) {
|
||||
res = ext->actions[LV_BTN_ACTION_LONG_PR_REPEAT](btn);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char *)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
|
||||
if(lv_btn_get_toggle(btn) != false) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
|
||||
if(ext->actions[LV_BTN_ACTION_CLICK] && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
|
||||
res = ext->actions[LV_BTN_ACTION_CLICK](btn);
|
||||
}
|
||||
if(lv_btn_get_toggle(btn)) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
|
||||
|
||||
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
|
||||
if(lv_btn_get_toggle(btn) != false) lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
if(ext->actions[LV_BTN_ACTION_CLICK] && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
|
||||
res = ext->actions[LV_BTN_ACTION_CLICK](btn);
|
||||
}
|
||||
if(lv_btn_get_toggle(btn)) lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
} else if(c == LV_GROUP_KEY_ENTER) {
|
||||
if(!ext->long_pr_action_executed) {
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
if(!indev->proc.long_pr_sent) {
|
||||
if(lv_btn_get_toggle(btn)) {
|
||||
if(state == LV_BTN_STATE_REL || state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
|
||||
else if(state == LV_BTN_STATE_TGL_REL || state == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
@ -680,12 +625,6 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
if(state == LV_BTN_STATE_REL || state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
else if(state == LV_BTN_STATE_TGL_REL || state == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
|
||||
}
|
||||
if(ext->actions[LV_BTN_ACTION_CLICK] && state != LV_BTN_STATE_INA) {
|
||||
res = ext->actions[LV_BTN_ACTION_CLICK](btn);
|
||||
}
|
||||
}
|
||||
if(res != LV_RES_INV) {
|
||||
ext->long_pr_action_executed = 0;
|
||||
}
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
|
@ -50,23 +50,11 @@ enum
|
||||
};
|
||||
typedef uint8_t lv_btn_state_t;
|
||||
|
||||
enum
|
||||
{
|
||||
LV_BTN_ACTION_CLICK,
|
||||
LV_BTN_ACTION_PR,
|
||||
LV_BTN_ACTION_LONG_PR,
|
||||
LV_BTN_ACTION_LONG_PR_REPEAT,
|
||||
LV_BTN_ACTION_NUM,
|
||||
};
|
||||
typedef uint8_t lv_btn_action_t;
|
||||
|
||||
|
||||
/*Data of button*/
|
||||
typedef struct
|
||||
{
|
||||
lv_cont_ext_t cont; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_action_t actions[LV_BTN_ACTION_NUM];
|
||||
lv_style_t * styles[LV_BTN_STATE_NUM]; /*Styles in each state*/
|
||||
lv_btn_state_t state; /*Current state of the button from 'lv_btn_state_t' enum*/
|
||||
#if LV_BTN_INK_EFFECT
|
||||
@ -75,7 +63,6 @@ typedef struct
|
||||
uint16_t ink_out_time; /*[ms] Time of ink disappearing*/
|
||||
#endif
|
||||
uint8_t toggle :1; /*1: Toggle enabled*/
|
||||
uint8_t long_pr_action_executed :1; /*1: Long press action executed (Handled by the library)*/
|
||||
} lv_btn_ext_t;
|
||||
|
||||
/*Styles*/
|
||||
@ -124,13 +111,6 @@ void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state);
|
||||
*/
|
||||
void lv_btn_toggle(lv_obj_t * btn);
|
||||
|
||||
/**
|
||||
* Set a function to call when a button event happens
|
||||
* @param btn pointer to a button object
|
||||
* @param action type of event form 'lv_action_t' (press, release, long press, long press repeat)
|
||||
*/
|
||||
void lv_btn_set_action(lv_obj_t * btn, lv_btn_action_t type, lv_action_t action);
|
||||
|
||||
/**
|
||||
* Set the layout on a button
|
||||
* @param btn pointer to a button object
|
||||
@ -225,13 +205,6 @@ lv_btn_state_t lv_btn_get_state(const lv_obj_t * btn);
|
||||
*/
|
||||
bool lv_btn_get_toggle(const lv_obj_t * btn);
|
||||
|
||||
/**
|
||||
* Get the release action of a button
|
||||
* @param btn pointer to a button object
|
||||
* @return pointer to the release action function
|
||||
*/
|
||||
lv_action_t lv_btn_get_action(const lv_obj_t * btn, lv_btn_action_t type);
|
||||
|
||||
/**
|
||||
* Get the layout of a button
|
||||
* @param btn pointer to button object
|
||||
|
@ -44,8 +44,8 @@ static const char * lv_btnm_def_map[] = {"Btn1", "Btn2", "Btn3", "\n",
|
||||
"\002Btn4", "Btn5", ""
|
||||
};
|
||||
|
||||
static lv_design_func_t ancestor_design_f;
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design_f;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -92,8 +92,8 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_btnm);
|
||||
|
||||
lv_obj_set_signal_func(new_btnm, lv_btnm_signal);
|
||||
lv_obj_set_design_func(new_btnm, lv_btnm_design);
|
||||
lv_obj_set_signal_cb(new_btnm, lv_btnm_signal);
|
||||
lv_obj_set_design_cb(new_btnm, lv_btnm_design);
|
||||
|
||||
/*Init the new button matrix object*/
|
||||
if(copy == NULL) {
|
||||
|
@ -52,8 +52,8 @@ static uint8_t is_leap_year(uint32_t year);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_func_t ancestor_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design;
|
||||
static const char * day_name[7] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};
|
||||
static const char * month_name[12] = {"January", "February", "March", "April",
|
||||
"May", "June", "July", "August",
|
||||
@ -107,10 +107,6 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->highlighted_dates_num = 0;
|
||||
ext->day_names = NULL;
|
||||
ext->month_names = NULL;
|
||||
ext->actions[LV_CALENDAR_ACTION_PR] = NULL;
|
||||
ext->actions[LV_CALENDAR_ACTION_CLICK] = NULL;
|
||||
ext->actions[LV_CALENDAR_ACTION_LONG_PR] = NULL;
|
||||
ext->actions[LV_CALENDAR_ACTION_LONG_PR_REPEAT] = NULL;
|
||||
ext->style_header = &lv_style_plain_color;
|
||||
ext->style_header_pr = &lv_style_pretty_color;
|
||||
ext->style_highlighted_days = &lv_style_plain_color;
|
||||
@ -120,8 +116,8 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->style_day_names = &lv_style_pretty;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_calendar, lv_calendar_signal);
|
||||
lv_obj_set_design_func(new_calendar, lv_calendar_design);
|
||||
lv_obj_set_signal_cb(new_calendar, lv_calendar_signal);
|
||||
lv_obj_set_design_cb(new_calendar, lv_calendar_design);
|
||||
|
||||
/*Init the new calendar calendar*/
|
||||
if(copy == NULL) {
|
||||
@ -147,9 +143,7 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, ext->style_today_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, ext->style_highlighted_days);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, ext->style_inactive_days);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/*Copy an existing calendar*/
|
||||
else {
|
||||
@ -166,8 +160,6 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->highlighted_dates_num = copy_ext->highlighted_dates_num;
|
||||
ext->day_names = copy_ext->day_names;
|
||||
|
||||
memcpy(ext->actions, copy_ext->actions, sizeof(ext->actions));
|
||||
|
||||
ext->month_names = copy_ext->month_names;
|
||||
ext->style_header = copy_ext->style_header;
|
||||
ext->style_header_pr = copy_ext->style_header_pr;
|
||||
@ -198,19 +190,6 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set a function to call when a calendar event happens
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param action type of event form 'lv_action_t' (press, release, long press, long press repeat)
|
||||
*/
|
||||
void lv_calendar_set_action(lv_obj_t * calendar, lv_calendar_action_t type, lv_action_t action)
|
||||
{
|
||||
if(type >= LV_CALENDAR_ACTION_NUM) return;
|
||||
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
ext->actions[type] = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the today's date
|
||||
* @param calendar pointer to a calendar object
|
||||
@ -327,19 +306,6 @@ void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, lv_sty
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the action of a calendar
|
||||
* @param calendar pointer to a calendar object
|
||||
* @return pointer to the action function
|
||||
*/
|
||||
lv_action_t lv_calendar_get_action(const lv_obj_t * calendar, lv_calendar_action_t type)
|
||||
{
|
||||
if(type >= LV_CALENDAR_ACTION_NUM) return NULL;
|
||||
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
return ext->actions[type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the today's date
|
||||
* @param calendar pointer to a calendar object
|
||||
@ -525,20 +491,6 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
|
||||
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||
} else if(sign == LV_SIGNAL_PRESSED) {
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
/*Call the press action, 'param' is the caller indev_proc*/
|
||||
if(ext->actions[LV_CALENDAR_ACTION_PR]) {
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
lv_point_t p;
|
||||
lv_indev_get_point(indev, &p);
|
||||
|
||||
if(calculate_touched_day(calendar, &p)){
|
||||
if(ext->btn_pressing != 0) lv_obj_invalidate(calendar);
|
||||
ext->btn_pressing = 0;
|
||||
res = ext->actions[LV_CALENDAR_ACTION_PR](calendar);
|
||||
}
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_PRESSING) {
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
lv_area_t header_area;
|
||||
@ -592,26 +544,12 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
|
||||
}
|
||||
else if(ext->pressed_date.year != 0)
|
||||
{
|
||||
if(ext->actions[LV_CALENDAR_ACTION_CLICK]) {
|
||||
res = ext->actions[LV_CALENDAR_ACTION_CLICK](calendar);
|
||||
}
|
||||
lv_obj_send_event(calendar, LV_EVENT_VALUE_CHANGED);
|
||||
}
|
||||
|
||||
ext->pressed_date.year = 0;
|
||||
ext->btn_pressing = 0;
|
||||
lv_obj_invalidate(calendar);
|
||||
|
||||
|
||||
} else if(sign == LV_SIGNAL_LONG_PRESS) {
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
if(ext->actions[LV_CALENDAR_ACTION_LONG_PR] && (ext->pressed_date.year != 0)) {
|
||||
res = ext->actions[LV_CALENDAR_ACTION_LONG_PR](calendar);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
if(ext->actions[LV_CALENDAR_ACTION_LONG_PR_REPEAT] && (ext->pressed_date.year != 0)) {
|
||||
res = ext->actions[LV_CALENDAR_ACTION_LONG_PR_REPEAT](calendar);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
uint8_t c = *((uint8_t *) param);
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
|
@ -37,16 +37,6 @@ typedef struct {
|
||||
int8_t day;
|
||||
} lv_calendar_date_t;
|
||||
|
||||
enum
|
||||
{
|
||||
LV_CALENDAR_ACTION_CLICK,
|
||||
LV_CALENDAR_ACTION_PR,
|
||||
LV_CALENDAR_ACTION_LONG_PR,
|
||||
LV_CALENDAR_ACTION_LONG_PR_REPEAT,
|
||||
LV_CALENDAR_ACTION_NUM,
|
||||
};
|
||||
typedef uint8_t lv_calendar_action_t;
|
||||
|
||||
/*Data of calendar*/
|
||||
typedef struct {
|
||||
/*None*/ /*Ext. of ancestor*/
|
||||
@ -59,7 +49,6 @@ typedef struct {
|
||||
lv_calendar_date_t pressed_date;
|
||||
const char ** day_names; /*Pointer to an array with the name of the days (NULL: use default names)*/
|
||||
const char ** month_names; /*Pointer to an array with the name of the month (NULL. use default names)*/
|
||||
lv_action_t actions[LV_CALENDAR_ACTION_NUM];
|
||||
|
||||
/*Styles*/
|
||||
lv_style_t * style_header;
|
||||
@ -107,12 +96,6 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
/**
|
||||
* Set a function to call when a calendar event happens
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param action type of event form 'lv_action_t' (press, release, long press, long press repeat)
|
||||
*/
|
||||
void lv_calendar_set_action(lv_obj_t * calendar, lv_calendar_action_t type, lv_action_t action);
|
||||
|
||||
/**
|
||||
* Set the today's date
|
||||
@ -164,12 +147,6 @@ void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, lv_sty
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
/**
|
||||
* Get the action of a calendar
|
||||
* @param calendar pointer to a calendar object
|
||||
* @return pointer to the action function
|
||||
*/
|
||||
lv_action_t lv_calendar_get_action(const lv_obj_t * calendar, lv_calendar_action_t type);
|
||||
|
||||
/**
|
||||
* Get the today's date
|
||||
|
@ -26,8 +26,8 @@ static lv_res_t lv_canvas_signal(lv_obj_t * canvas, lv_signal_t sign, void * par
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_func_t ancestor_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -70,7 +70,7 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_img_set_src(new_canvas, &ext->dsc);
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_canvas, lv_canvas_signal);
|
||||
lv_obj_set_signal_cb(new_canvas, lv_canvas_signal);
|
||||
|
||||
/*Init the new canvas canvas*/
|
||||
if(copy == NULL) {
|
||||
|
@ -30,9 +30,9 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_func_t ancestor_bg_design;
|
||||
static lv_design_func_t ancestor_bullet_design;
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_bg_design;
|
||||
static lv_design_cb_t ancestor_bullet_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -68,8 +68,8 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->bullet = NULL;
|
||||
ext->label = NULL;
|
||||
|
||||
lv_obj_set_signal_func(new_cb, lv_cb_signal);
|
||||
lv_obj_set_design_func(new_cb, lv_cb_design);
|
||||
lv_obj_set_signal_cb(new_cb, lv_cb_signal);
|
||||
lv_obj_set_design_cb(new_cb, lv_cb_design);
|
||||
|
||||
/*Init the new checkbox object*/
|
||||
if(copy == NULL) {
|
||||
@ -107,7 +107,7 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_refresh_style(new_cb);
|
||||
}
|
||||
|
||||
lv_obj_set_design_func(ext->bullet, lv_bullet_design);
|
||||
lv_obj_set_design_cb(ext->bullet, lv_bullet_design);
|
||||
|
||||
|
||||
LV_LOG_INFO("check box created");
|
||||
|
@ -103,16 +103,6 @@ static inline void lv_cb_set_inactive(lv_obj_t * cb)
|
||||
lv_btn_set_state(cb, LV_BTN_STATE_INA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to call when the check box is clicked
|
||||
* @param cb pointer to a check box object
|
||||
*/
|
||||
static inline void lv_cb_set_action(lv_obj_t * cb, lv_action_t action)
|
||||
{
|
||||
lv_btn_set_action(cb, LV_BTN_ACTION_CLICK, action);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a style of a check box
|
||||
* @param cb pointer to check box object
|
||||
@ -142,17 +132,6 @@ static inline bool lv_cb_is_checked(const lv_obj_t * cb)
|
||||
return lv_btn_get_state(cb) == LV_BTN_STATE_REL ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action of a check box
|
||||
* @param cb pointer to a button object
|
||||
* @return pointer to the action function
|
||||
*/
|
||||
static inline lv_action_t lv_cb_get_action(const lv_obj_t * cb)
|
||||
{
|
||||
return lv_btn_get_action(cb, LV_BTN_ACTION_CLICK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a style of a button
|
||||
* @param cb pointer to check box object
|
||||
|
@ -39,8 +39,8 @@ static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mas
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_func_t ancestor_design_f;
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design_f;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -85,8 +85,8 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_chart);
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_chart);
|
||||
|
||||
lv_obj_set_signal_func(new_chart, lv_chart_signal);
|
||||
lv_obj_set_design_func(new_chart, lv_chart_design);
|
||||
lv_obj_set_signal_cb(new_chart, lv_chart_signal);
|
||||
lv_obj_set_design_cb(new_chart, lv_chart_design);
|
||||
|
||||
/*Init the new chart background object*/
|
||||
if(copy == NULL) {
|
||||
|
@ -44,7 +44,7 @@ static void lv_cont_refr_autofit(lv_obj_t * cont);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -84,7 +84,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->fit_bottom = LV_FIT_NONE;
|
||||
ext->layout = LV_LAYOUT_OFF;
|
||||
|
||||
lv_obj_set_signal_func(new_cont, lv_cont_signal);
|
||||
lv_obj_set_signal_cb(new_cont, lv_cont_signal);
|
||||
|
||||
/*Init the new container*/
|
||||
if(copy == NULL) {
|
||||
@ -131,7 +131,7 @@ void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout)
|
||||
ext->layout = layout;
|
||||
|
||||
/*Send a signal to refresh the layout*/
|
||||
cont->signal_func(cont, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
cont->signal_cb(cont, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,7 +161,7 @@ void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t t
|
||||
ext->fit_bottom = bottom;
|
||||
|
||||
/*Send a signal to refresh the layout*/
|
||||
cont->signal_func(cont, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
cont->signal_cb(cont, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -705,16 +705,16 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
lv_obj_invalidate(cont);
|
||||
|
||||
/*Notify the object about its new coordinates*/
|
||||
cont->signal_func(cont, LV_SIGNAL_CORD_CHG, &ori);
|
||||
cont->signal_cb(cont, LV_SIGNAL_CORD_CHG, &ori);
|
||||
|
||||
/*Inform the parent about the new coordinates*/
|
||||
lv_obj_t * par = lv_obj_get_parent(cont);
|
||||
par->signal_func(par, LV_SIGNAL_CHILD_CHG, cont);
|
||||
par->signal_cb(par, LV_SIGNAL_CHILD_CHG, cont);
|
||||
|
||||
/*Tell the children the parent's size has changed*/
|
||||
lv_obj_t * i;
|
||||
LL_READ(cont->child_ll, i) {
|
||||
i->signal_func(i, LV_SIGNAL_PARENT_SIZE_CHG, NULL);
|
||||
i->signal_cb(i, LV_SIGNAL_PARENT_SIZE_CHG, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,16 +40,16 @@
|
||||
static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_design_mode_t mode);
|
||||
static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param);
|
||||
static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param);
|
||||
static lv_res_t lv_ddlist_release_action(lv_obj_t * ddlist);
|
||||
static lv_res_t release_handler(lv_obj_t * ddlist);
|
||||
static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en);
|
||||
static void lv_ddlist_pos_current_option(lv_obj_t * ddlist);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_func_t ancestor_scrl_signal;
|
||||
static lv_design_func_t ancestor_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_signal_cb_t ancestor_scrl_signal;
|
||||
static lv_design_cb_t ancestor_design;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -85,7 +85,6 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->label = NULL;
|
||||
ext->action = NULL;
|
||||
ext->opened = 0;
|
||||
ext->fix_height = 0;
|
||||
ext->sel_opt_id = 0;
|
||||
@ -96,9 +95,9 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->draw_arrow = 0; /*Do not draw arrow by default*/
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_ddlist, lv_ddlist_signal);
|
||||
lv_obj_set_signal_func(lv_page_get_scrl(new_ddlist), lv_ddlist_scrl_signal);
|
||||
lv_obj_set_design_func(new_ddlist, lv_ddlist_design);
|
||||
lv_obj_set_signal_cb(new_ddlist, lv_ddlist_signal);
|
||||
lv_obj_set_signal_cb(lv_page_get_scrl(new_ddlist), lv_ddlist_scrl_signal);
|
||||
lv_obj_set_design_cb(new_ddlist, lv_ddlist_design);
|
||||
|
||||
/*Init the new drop down list drop down list*/
|
||||
if(copy == NULL) {
|
||||
@ -108,7 +107,6 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
ext->label = lv_label_create(new_ddlist, NULL);
|
||||
lv_cont_set_fit2(new_ddlist, LV_FIT_TIGHT, LV_FIT_NONE);
|
||||
lv_page_set_rel_action(new_ddlist, lv_ddlist_release_action);
|
||||
lv_page_set_sb_mode(new_ddlist, LV_SB_MODE_DRAG);
|
||||
lv_page_set_sb_mode(new_ddlist, LV_SB_MODE_HIDE);
|
||||
lv_page_set_style(new_ddlist, LV_PAGE_STYLE_SCRL, &lv_style_transp_tight);
|
||||
@ -134,7 +132,6 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_label_set_text(ext->label, lv_label_get_text(copy_ext->label));
|
||||
ext->sel_opt_id = copy_ext->sel_opt_id;
|
||||
ext->fix_height = copy_ext->fix_height;
|
||||
ext->action = copy_ext->action;
|
||||
ext->option_cnt = copy_ext->option_cnt;
|
||||
ext->sel_style = copy_ext->sel_style;
|
||||
ext->anim_time = copy_ext->anim_time;
|
||||
@ -208,17 +205,6 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to call when a new option is chosen
|
||||
* @param ddlist pointer to a drop down list
|
||||
* @param action pointer to a call back function
|
||||
*/
|
||||
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t action)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
ext->action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fix height for the drop down list
|
||||
* If 0 then the opened ddlist will be auto. sized else the set height will be applied.
|
||||
@ -356,17 +342,6 @@ void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf)
|
||||
buf[c] = '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the "option selected" callback function
|
||||
* @param ddlist pointer to a drop down list
|
||||
* @return pointer to the call back function
|
||||
*/
|
||||
lv_action_t lv_ddlist_get_action(const lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
return ext->action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fix height value.
|
||||
* @param ddlist pointer to a drop down list object
|
||||
@ -652,7 +627,11 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
release_handler(ddlist);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
if(ext->opened) {
|
||||
ext->opened = false;
|
||||
ext->sel_opt_id = ext->sel_opt_id_ori;
|
||||
@ -685,8 +664,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
if(ext->opened) {
|
||||
ext->sel_opt_id_ori = ext->sel_opt_id;
|
||||
ext->opened = 0;
|
||||
if(ext->action) ext->action(ddlist);
|
||||
|
||||
lv_obj_send_event(ddlist, LV_EVENT_VALUE_CHANGED);
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(ddlist);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
@ -740,7 +718,11 @@ static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void *
|
||||
* In this way by dragging the scrollable part the wider rectangle area can be redrawn too*/
|
||||
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
||||
if(scrl->ext_size < style->body.padding.hor) scrl->ext_size = style->body.padding.hor;
|
||||
} else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
release_handler(ddlist);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
ext->label = NULL; /*The label is already deleted*/
|
||||
}
|
||||
@ -753,7 +735,7 @@ static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void *
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @return LV_ACTION_RES_INV if the ddlist it deleted in the user callback else LV_ACTION_RES_OK
|
||||
*/
|
||||
static lv_res_t lv_ddlist_release_action(lv_obj_t * ddlist)
|
||||
static lv_res_t release_handler(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
@ -785,9 +767,7 @@ static lv_res_t lv_ddlist_release_action(lv_obj_t * ddlist)
|
||||
|
||||
ext->sel_opt_id = new_opt;
|
||||
|
||||
if(ext->action != NULL) {
|
||||
ext->action(ddlist);
|
||||
}
|
||||
lv_obj_send_event(ddlist, LV_EVENT_VALUE_CHANGED);
|
||||
}
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
|
||||
|
@ -48,7 +48,6 @@ typedef struct
|
||||
/*New data for this type */
|
||||
lv_obj_t *label; /*Label for the options*/
|
||||
lv_style_t * sel_style; /*Style of the selected option*/
|
||||
lv_action_t action; /*Pointer to function to call when an option is selected*/
|
||||
uint16_t option_cnt; /*Number of options*/
|
||||
uint16_t sel_opt_id; /*Index of the current option*/
|
||||
uint16_t sel_opt_id_ori; /*Store the original index on focus*/
|
||||
@ -102,13 +101,6 @@ void lv_ddlist_set_options(lv_obj_t * ddlist, const char * options);
|
||||
*/
|
||||
void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt);
|
||||
|
||||
/**
|
||||
* Set a function to call when a new option is chosen
|
||||
* @param ddlist pointer to a drop down list
|
||||
* @param action pointer to a call back function
|
||||
*/
|
||||
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t action);
|
||||
|
||||
/**
|
||||
* Set the fix height for the drop down list
|
||||
* If 0 then the opened ddlist will be auto. sized else the set height will be applied.
|
||||
@ -189,12 +181,6 @@ uint16_t lv_ddlist_get_selected(const lv_obj_t * ddlist);
|
||||
*/
|
||||
void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf);
|
||||
|
||||
/**
|
||||
* Get the "option selected" callback function
|
||||
* @param ddlist pointer to a drop down list
|
||||
* @return pointer to the call back function
|
||||
*/
|
||||
lv_action_t lv_ddlist_get_action(const lv_obj_t * ddlist);
|
||||
|
||||
/**
|
||||
* Get the fix height value.
|
||||
|
@ -42,8 +42,8 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_func_t ancestor_design;
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -82,8 +82,8 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_func(new_gauge);
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_gauge, lv_gauge_signal);
|
||||
lv_obj_set_design_func(new_gauge, lv_gauge_design);
|
||||
lv_obj_set_signal_cb(new_gauge, lv_gauge_signal);
|
||||
lv_obj_set_design_cb(new_gauge, lv_gauge_design);
|
||||
|
||||
/*Init the new gauge gauge*/
|
||||
if(copy == NULL) {
|
||||
|
@ -38,7 +38,7 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -80,8 +80,8 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->auto_size = 1;
|
||||
|
||||
/*Init the new object*/
|
||||
lv_obj_set_signal_func(new_img, lv_img_signal);
|
||||
lv_obj_set_design_func(new_img, lv_img_design);
|
||||
lv_obj_set_signal_cb(new_img, lv_img_signal);
|
||||
lv_obj_set_design_cb(new_img, lv_img_design);
|
||||
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_click(new_img, false);
|
||||
|
@ -27,8 +27,8 @@ static void refr_img(lv_obj_t * imgbtn);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_func_t ancestor_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -72,8 +72,8 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->act_cf = LV_IMG_CF_UNKOWN;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_imgbtn, lv_imgbtn_signal);
|
||||
lv_obj_set_design_func(new_imgbtn, lv_imgbtn_design);
|
||||
lv_obj_set_signal_cb(new_imgbtn, lv_imgbtn_signal);
|
||||
lv_obj_set_design_cb(new_imgbtn, lv_imgbtn_design);
|
||||
|
||||
/*Init the new image button image button*/
|
||||
if(copy == NULL) {
|
||||
|
@ -134,16 +134,6 @@ static inline void lv_imgbtn_toggle(lv_obj_t * imgbtn)
|
||||
lv_btn_toggle(imgbtn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to call when a button event happens
|
||||
* @param imgbtn pointer to an image button object
|
||||
* @param action type of event form 'lv_action_t' (press, release, long press, long press repeat)
|
||||
*/
|
||||
static inline void lv_imgbtn_set_action(lv_obj_t * imgbtn, lv_btn_action_t type, lv_action_t action)
|
||||
{
|
||||
lv_btn_set_action(imgbtn, type, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a style of a image button.
|
||||
* @param imgbtn pointer to image button object
|
||||
@ -213,16 +203,6 @@ static inline bool lv_imgbtn_get_toggle(const lv_obj_t * imgbtn)
|
||||
return lv_btn_get_toggle(imgbtn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the release action of a image button
|
||||
* @param imgbtn pointer to a image button object
|
||||
* @return pointer to the release action function
|
||||
*/
|
||||
static inline lv_action_t lv_imgbtn_get_action(const lv_obj_t * imgbtn, lv_btn_action_t type)
|
||||
{
|
||||
return lv_btn_get_action(imgbtn, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get style of a image button.
|
||||
* @param imgbtn pointer to image button object
|
||||
|
@ -30,7 +30,7 @@ static lv_res_t lv_kb_def_action(lv_obj_t * kb, const char * txt);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
static const char * kb_map_lc[] = {
|
||||
"\2051#", "\204q", "\204w", "\204e", "\204r", "\204t", "\204y", "\204u", "\204i", "\204o", "\204p", "\207Bksp", "\n",
|
||||
@ -94,11 +94,9 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->ta = NULL;
|
||||
ext->mode = LV_KB_MODE_TEXT;
|
||||
ext->cursor_mng = 0;
|
||||
ext->hide_action = NULL;
|
||||
ext->ok_action = NULL;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_kb, lv_kb_signal);
|
||||
lv_obj_set_signal_cb(new_kb, lv_kb_signal);
|
||||
|
||||
/*Init the new keyboard keyboard*/
|
||||
if(copy == NULL) {
|
||||
@ -127,8 +125,6 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->ta = copy_ext->ta;
|
||||
ext->mode = copy_ext->mode;
|
||||
ext->cursor_mng = copy_ext->cursor_mng;
|
||||
ext->hide_action = copy_ext->hide_action;
|
||||
ext->ok_action = copy_ext->ok_action;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_kb);
|
||||
@ -210,28 +206,6 @@ void lv_kb_set_cursor_manage(lv_obj_t * kb, bool en)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set call back to call when the "Ok" button is pressed
|
||||
* @param kb pointer to Keyboard object
|
||||
* @param action a callback with 'lv_action_t' type
|
||||
*/
|
||||
void lv_kb_set_ok_action(lv_obj_t * kb, lv_action_t action)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
ext->ok_action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set call back to call when the "Hide" button is pressed
|
||||
* @param kb pointer to Keyboard object
|
||||
* @param action a callback with 'lv_action_t' type
|
||||
*/
|
||||
void lv_kb_set_hide_action(lv_obj_t * kb, lv_action_t action)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
ext->hide_action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a style of a keyboard
|
||||
* @param kb pointer to a keyboard object
|
||||
@ -300,28 +274,6 @@ bool lv_kb_get_cursor_manage(const lv_obj_t * kb)
|
||||
return ext->cursor_mng == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the callback to call when the "Ok" button is pressed
|
||||
* @param kb pointer to Keyboard object
|
||||
* @return the ok callback
|
||||
*/
|
||||
lv_action_t lv_kb_get_ok_action(const lv_obj_t * kb)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
return ext->ok_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the callback to call when the "Hide" button is pressed
|
||||
* @param kb pointer to Keyboard object
|
||||
* @return the close callback
|
||||
*/
|
||||
lv_action_t lv_kb_get_hide_action(const lv_obj_t * kb)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
return ext->hide_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a style of a keyboard
|
||||
* @param kb pointer to a keyboard object
|
||||
@ -414,14 +366,14 @@ static lv_res_t lv_kb_def_action(lv_obj_t * kb, const char * txt)
|
||||
lv_btnm_set_map(kb, kb_map_spec);
|
||||
return LV_RES_OK;
|
||||
} else if(strcmp(txt, SYMBOL_CLOSE) == 0) {
|
||||
if(ext->hide_action) res = ext->hide_action(kb);
|
||||
if(kb->event_cb) lv_obj_send_event(kb, LV_EVENT_CANCEL);
|
||||
else {
|
||||
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
|
||||
lv_obj_del(kb);
|
||||
}
|
||||
return res;
|
||||
} else if(strcmp(txt, SYMBOL_OK) == 0) {
|
||||
if(ext->ok_action) res = ext->ok_action(kb);
|
||||
if(kb->event_cb) lv_obj_send_event(kb, LV_EVENT_APPLY);
|
||||
else {
|
||||
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
|
||||
res = lv_obj_del(kb);
|
||||
|
@ -54,8 +54,6 @@ typedef struct {
|
||||
lv_obj_t *ta; /*Pointer to the assigned text area*/
|
||||
lv_kb_mode_t mode; /*Key map type*/
|
||||
uint8_t cursor_mng :1; /*1: automatically show/hide cursor when a text area is assigned or left*/
|
||||
lv_action_t ok_action; /*Called when the "Ok" button is clicked*/
|
||||
lv_action_t hide_action; /*Called when the "Hide" button is clicked*/
|
||||
} lv_kb_ext_t;
|
||||
|
||||
enum {
|
||||
@ -106,20 +104,6 @@ void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode);
|
||||
*/
|
||||
void lv_kb_set_cursor_manage(lv_obj_t * kb, bool en);
|
||||
|
||||
/**
|
||||
* Set call back to call when the "Ok" button is pressed
|
||||
* @param kb pointer to Keyboard object
|
||||
* @param action a callback with 'lv_action_t' type
|
||||
*/
|
||||
void lv_kb_set_ok_action(lv_obj_t * kb, lv_action_t action);
|
||||
|
||||
/**
|
||||
* Set call back to call when the "Hide" button is pressed
|
||||
* @param kb pointer to Keyboard object
|
||||
* @param action a callback with 'lv_action_t' type
|
||||
*/
|
||||
void lv_kb_set_hide_action(lv_obj_t * kb, lv_action_t action);
|
||||
|
||||
/**
|
||||
* Set a new map for the keyboard
|
||||
* @param kb pointer to a Keyboard object
|
||||
@ -164,20 +148,6 @@ lv_kb_mode_t lv_kb_get_mode(const lv_obj_t * kb);
|
||||
*/
|
||||
bool lv_kb_get_cursor_manage(const lv_obj_t * kb);
|
||||
|
||||
/**
|
||||
* Get the callback to call when the "Ok" button is pressed
|
||||
* @param kb pointer to Keyboard object
|
||||
* @return the ok callback
|
||||
*/
|
||||
lv_action_t lv_kb_get_ok_action(const lv_obj_t * kb);
|
||||
|
||||
/**
|
||||
* Get the callback to call when the "Hide" button is pressed
|
||||
* @param kb pointer to Keyboard object
|
||||
* @return the close callback
|
||||
*/
|
||||
lv_action_t lv_kb_get_hide_action(const lv_obj_t * kb);
|
||||
|
||||
/**
|
||||
* Get a style of a keyboard
|
||||
* @param kb pointer to a keyboard object
|
||||
|
@ -47,7 +47,7 @@ static void lv_label_set_offset_y(lv_obj_t * label, lv_coord_t y);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -91,8 +91,8 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->anim_speed = LV_LABEL_SCROLL_SPEED;
|
||||
ext->offset.x = 0;
|
||||
ext->offset.y = 0;
|
||||
lv_obj_set_design_func(new_label, lv_label_design);
|
||||
lv_obj_set_signal_func(new_label, lv_label_signal);
|
||||
lv_obj_set_design_cb(new_label, lv_label_design);
|
||||
lv_obj_set_signal_cb(new_label, lv_label_signal);
|
||||
|
||||
/*Init the new label*/
|
||||
if(copy == NULL) {
|
||||
|
@ -33,8 +33,8 @@ static lv_res_t lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_func_t ancestor_design_f;
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design_f;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -69,8 +69,8 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
ext->bright = LV_LED_BRIGHT_ON;
|
||||
|
||||
lv_obj_set_signal_func(new_led, lv_led_signal);
|
||||
lv_obj_set_design_func(new_led, lv_led_design);
|
||||
lv_obj_set_signal_cb(new_led, lv_led_signal);
|
||||
lv_obj_set_design_cb(new_led, lv_led_design);
|
||||
|
||||
/*Init the new led object*/
|
||||
if(copy == NULL) {
|
||||
|
@ -33,7 +33,7 @@ static lv_res_t lv_line_signal(lv_obj_t * line, lv_signal_t sign, void * param);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -69,8 +69,8 @@ lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->auto_size = 1;
|
||||
ext->y_inv = 0;
|
||||
|
||||
lv_obj_set_design_func(new_line, lv_line_design);
|
||||
lv_obj_set_signal_func(new_line, lv_line_signal);
|
||||
lv_obj_set_design_cb(new_line, lv_line_design);
|
||||
lv_obj_set_signal_cb(new_line, lv_line_signal);
|
||||
|
||||
/*Init the new line*/
|
||||
if(copy == NULL) {
|
||||
|
@ -44,11 +44,11 @@ static void lv_list_btn_single_selected(lv_obj_t *btn);
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
#if USE_LV_IMG
|
||||
static lv_signal_func_t img_signal;
|
||||
static lv_signal_cb_t img_signal;
|
||||
#endif
|
||||
static lv_signal_func_t label_signal;
|
||||
static lv_signal_func_t ancestor_page_signal;
|
||||
static lv_signal_func_t ancestor_btn_signal;
|
||||
static lv_signal_cb_t label_signal;
|
||||
static lv_signal_cb_t ancestor_page_signal;
|
||||
static lv_signal_cb_t ancestor_btn_signal;
|
||||
#if USE_LV_GROUP
|
||||
/*Used to make the last clicked button pressed (selected) when the list become focused and `click_focus == 1`*/
|
||||
static lv_obj_t * last_clicked_btn;
|
||||
@ -98,7 +98,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->selected_btn = NULL;
|
||||
#endif
|
||||
|
||||
lv_obj_set_signal_func(new_list, lv_list_signal);
|
||||
lv_obj_set_signal_cb(new_list, lv_list_signal);
|
||||
|
||||
/*Init the new list object*/
|
||||
if(copy == NULL) {
|
||||
@ -132,7 +132,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_t * copy_img = lv_list_get_btn_img(copy_btn);
|
||||
if(copy_img) img_src = lv_img_get_src(copy_img);
|
||||
#endif
|
||||
lv_list_add(new_list, img_src, lv_list_get_btn_text(copy_btn), lv_btn_get_action(copy_btn, LV_BTN_ACTION_CLICK));
|
||||
lv_list_add(new_list, img_src, lv_list_get_btn_text(copy_btn), copy_btn->event_cb);
|
||||
copy_btn = lv_list_get_next_btn(copy, copy_btn);
|
||||
}
|
||||
|
||||
@ -174,10 +174,10 @@ void lv_list_clean(lv_obj_t * obj)
|
||||
* @param list pointer to list object
|
||||
* @param img_fn file name of an image before the text (NULL if unused)
|
||||
* @param txt text of the list element (NULL if unused)
|
||||
* @param rel_action pointer to release action function (like with lv_btn)
|
||||
* @param event_cb specify the an event handler function. NULL if unused
|
||||
* @return pointer to the new list element which can be customized (a button)
|
||||
*/
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, lv_action_t rel_action)
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, lv_event_cb_t event_cb)
|
||||
{
|
||||
lv_style_t * style = lv_obj_get_style(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
@ -196,12 +196,12 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
|
||||
lv_btn_set_style(liste, LV_BTN_STYLE_TGL_PR, ext->styles_btn[LV_BTN_STATE_TGL_PR]);
|
||||
lv_btn_set_style(liste, LV_BTN_STYLE_INA, ext->styles_btn[LV_BTN_STATE_INA]);
|
||||
|
||||
lv_btn_set_action(liste, LV_BTN_ACTION_CLICK, rel_action);
|
||||
lv_obj_set_event_cb(liste, event_cb);
|
||||
lv_page_glue_obj(liste, true);
|
||||
lv_btn_set_layout(liste, LV_LAYOUT_ROW_M);
|
||||
lv_btn_set_fit2(liste, LV_FIT_FLOOD, LV_FIT_TIGHT);
|
||||
lv_obj_set_protect(liste, LV_PROTECT_PRESS_LOST);
|
||||
lv_obj_set_signal_func(liste, lv_list_btn_signal);
|
||||
lv_obj_set_signal_cb(liste, lv_list_btn_signal);
|
||||
|
||||
/*Make the size adjustment*/
|
||||
lv_coord_t w = lv_obj_get_width(list);
|
||||
@ -431,7 +431,7 @@ lv_obj_t * lv_list_get_btn_label(const lv_obj_t * btn)
|
||||
lv_obj_t * label = lv_obj_get_child(btn, NULL);
|
||||
if(label == NULL) return NULL;
|
||||
|
||||
while(label->signal_func != label_signal) {
|
||||
while(label->signal_cb != label_signal) {
|
||||
label = lv_obj_get_child(btn, label);
|
||||
if(label == NULL) break;
|
||||
}
|
||||
@ -450,7 +450,7 @@ lv_obj_t * lv_list_get_btn_img(const lv_obj_t * btn)
|
||||
lv_obj_t * img = lv_obj_get_child(btn, NULL);
|
||||
if(img == NULL) return NULL;
|
||||
|
||||
while(img->signal_func != img_signal) {
|
||||
while(img->signal_cb != img_signal) {
|
||||
img = lv_obj_get_child(btn, img);
|
||||
if(img == NULL) break;
|
||||
}
|
||||
@ -478,7 +478,7 @@ lv_obj_t * lv_list_get_prev_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
|
||||
btn = lv_obj_get_child(scrl, prev_btn);
|
||||
if(btn == NULL) return NULL;
|
||||
|
||||
while(btn->signal_func != lv_list_btn_signal) {
|
||||
while(btn->signal_cb != lv_list_btn_signal) {
|
||||
btn = lv_obj_get_child(scrl, btn);
|
||||
if(btn == NULL) break;
|
||||
}
|
||||
@ -505,7 +505,7 @@ lv_obj_t * lv_list_get_next_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
|
||||
btn = lv_obj_get_child_back(scrl, prev_btn);
|
||||
if(btn == NULL) return NULL;
|
||||
|
||||
while(btn->signal_func != lv_list_btn_signal) {
|
||||
while(btn->signal_cb != lv_list_btn_signal) {
|
||||
btn = lv_obj_get_child_back(scrl, btn);
|
||||
if(btn == NULL) break;
|
||||
}
|
||||
@ -846,9 +846,6 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
if(btn != NULL) {
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
ext->last_sel = btn;
|
||||
lv_action_t rel_action;
|
||||
rel_action = lv_btn_get_action(btn, LV_BTN_ACTION_CLICK);
|
||||
if(rel_action != NULL) rel_action(btn);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -105,10 +105,10 @@ void lv_list_clean(lv_obj_t *obj);
|
||||
* @param list pointer to list object
|
||||
* @param img_fn file name of an image before the text (NULL if unused)
|
||||
* @param txt text of the list element (NULL if unused)
|
||||
* @param rel_action pointer to release action function (like with lv_btn)
|
||||
* @param event_cb specify the an event handler function. NULL if unused
|
||||
* @return pointer to the new list element which can be customized (a button)
|
||||
*/
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, lv_action_t rel_action);
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, lv_event_cb_t event_cb);
|
||||
|
||||
/**
|
||||
* Remove the index of the button in the list
|
||||
|
@ -34,7 +34,7 @@ static lv_coord_t lv_lmeter_coord_round(int32_t x);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -74,8 +74,8 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->scale_angle = 240; /*(scale_num - 1) * N looks better */
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_lmeter, lv_lmeter_signal);
|
||||
lv_obj_set_design_func(new_lmeter, lv_lmeter_design);
|
||||
lv_obj_set_signal_cb(new_lmeter, lv_lmeter_signal);
|
||||
lv_obj_set_design_cb(new_lmeter, lv_lmeter_design);
|
||||
|
||||
/*Init the new line meter line meter*/
|
||||
if(copy == NULL) {
|
||||
|
@ -43,7 +43,7 @@ static void lv_mbox_close_end_cb(lv_obj_t * mbox);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -80,7 +80,7 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->anim_time = LV_MBOX_CLOSE_ANIM_TIME;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_mbox, lv_mbox_signal);
|
||||
lv_obj_set_signal_cb(new_mbox, lv_mbox_signal);
|
||||
|
||||
/*Init the new message box message box*/
|
||||
if(copy == NULL) {
|
||||
@ -431,7 +431,7 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
} else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS ||
|
||||
sign == LV_SIGNAL_CONTROLL || sign == LV_SIGNAL_GET_EDITABLE) {
|
||||
if(ext->btnm) {
|
||||
ext->btnm->signal_func(ext->btnm, sign, param);
|
||||
ext->btnm->signal_cb(ext->btnm, sign, param);
|
||||
}
|
||||
|
||||
/* The button matrix with ENCODER input supposes it's in a group but in this case it isn't (Only the message box's container)
|
||||
|
@ -39,12 +39,13 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param);
|
||||
static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param);
|
||||
static void edge_flash_anim(void * page, int32_t v);
|
||||
static void edge_flash_anim_end(void * page);
|
||||
static void scrl_def_event_cb(lv_obj_t * scrl, lv_event_t event);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_func_t ancestor_design;
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -78,8 +79,6 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
if(ext == NULL) return NULL;
|
||||
|
||||
ext->scrl = NULL;
|
||||
ext->pr_action = NULL;
|
||||
ext->rel_action = NULL;
|
||||
ext->sb.hor_draw = 0;
|
||||
ext->sb.ver_draw = 0;
|
||||
ext->sb.style = &lv_style_pretty;
|
||||
@ -98,17 +97,18 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Init the new page object*/
|
||||
if(copy == NULL) {
|
||||
ext->scrl = lv_cont_create(new_page, NULL);
|
||||
lv_obj_set_signal_func(ext->scrl, lv_page_scrollable_signal);
|
||||
lv_obj_set_design_func(ext->scrl, lv_scrl_design);
|
||||
lv_obj_set_signal_cb(ext->scrl, lv_page_scrollable_signal);
|
||||
lv_obj_set_design_cb(ext->scrl, lv_scrl_design);
|
||||
lv_obj_set_drag(ext->scrl, true);
|
||||
lv_obj_set_drag_throw(ext->scrl, true);
|
||||
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST);
|
||||
lv_cont_set_fit4(ext->scrl, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL);
|
||||
lv_obj_set_event_cb(ext->scrl, scrl_def_event_cb); /*Propagate some event to the background object by default for convenience */
|
||||
|
||||
/* Add the signal function only if 'scrolling' is created
|
||||
* because everything has to be ready before any signal is received*/
|
||||
lv_obj_set_signal_func(new_page, lv_page_signal);
|
||||
lv_obj_set_design_func(new_page, lv_page_design);
|
||||
lv_obj_set_signal_cb(new_page, lv_page_signal);
|
||||
lv_obj_set_design_cb(new_page, lv_page_design);
|
||||
|
||||
lv_page_set_sb_mode(new_page, ext->sb.mode);
|
||||
|
||||
@ -133,10 +133,8 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
} else {
|
||||
lv_page_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->scrl = lv_cont_create(new_page, copy_ext->scrl);
|
||||
lv_obj_set_signal_func(ext->scrl, lv_page_scrollable_signal);
|
||||
lv_obj_set_signal_cb(ext->scrl, lv_page_scrollable_signal);
|
||||
|
||||
lv_page_set_pr_action(new_page, copy_ext->pr_action);
|
||||
lv_page_set_rel_action(new_page, copy_ext->rel_action);
|
||||
lv_page_set_sb_mode(new_page, copy_ext->sb.mode);
|
||||
lv_page_set_arrow_scroll(new_page, copy_ext->arrow_scroll);
|
||||
|
||||
@ -147,8 +145,8 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/* Add the signal function only if 'scrolling' is created
|
||||
* because everything has to be ready before any signal is received*/
|
||||
lv_obj_set_signal_func(new_page, lv_page_signal);
|
||||
lv_obj_set_design_func(new_page, lv_page_design);
|
||||
lv_obj_set_signal_cb(new_page, lv_page_signal);
|
||||
lv_obj_set_design_cb(new_page, lv_page_design);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_page);
|
||||
@ -175,28 +173,6 @@ void lv_page_clean(lv_obj_t * obj)
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set a release action for the page
|
||||
* @param page pointer to a page object
|
||||
* @param rel_action a function to call when the page is release
|
||||
*/
|
||||
void lv_page_set_rel_action(lv_obj_t * page, lv_action_t rel_action)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
ext->rel_action = rel_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a press action for the page
|
||||
* @param page pointer to a page object
|
||||
* @param pr_action a function to call when the page is pressed
|
||||
*/
|
||||
void lv_page_set_pr_action(lv_obj_t * page, lv_action_t pr_action)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
ext->pr_action = pr_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the scroll bar mode on a page
|
||||
* @param page pointer to a page object
|
||||
@ -301,28 +277,6 @@ lv_obj_t * lv_page_get_scrl(const lv_obj_t * page)
|
||||
return ext->scrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the press action of the page
|
||||
* @param page pointer to a page object
|
||||
* @return a function to call when the page is pressed
|
||||
*/
|
||||
lv_action_t lv_page_get_pr_action(lv_obj_t * page)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
return ext->pr_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the release action of the page
|
||||
* @param page pointer to a page object
|
||||
* @return a function to call when the page is released
|
||||
*/
|
||||
lv_action_t lv_page_get_rel_action(lv_obj_t * page)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
return ext->rel_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the scroll bar mode on a page
|
||||
* @param page pointer to a page object
|
||||
@ -786,7 +740,7 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
}
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
ext->scrl->signal_func(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
|
||||
ext->scrl->signal_cb(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
|
||||
|
||||
/*The scrollbars are important only if they are visible now*/
|
||||
if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
|
||||
@ -798,21 +752,11 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
if(ext->scrl != NULL && (lv_obj_get_width(page) != lv_area_get_width(param) ||
|
||||
lv_obj_get_height(page) != lv_area_get_height(param))) {
|
||||
/*If no hor_fit enabled set the scrollable's width to the page's width*/
|
||||
ext->scrl->signal_func(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
|
||||
ext->scrl->signal_cb(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
|
||||
|
||||
/*The scrollbars are important only if they are visible now*/
|
||||
if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_PRESSED) {
|
||||
if(ext->pr_action != NULL) {
|
||||
res = ext->pr_action(page);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
if(lv_indev_is_dragging(lv_indev_get_act()) == false) {
|
||||
if(ext->rel_action != NULL) {
|
||||
res = ext->rel_action(page);
|
||||
}
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
/*Ensure ext. size for the scrollbars if they are out of the page*/
|
||||
if(page->ext_size < (-ext->sb.style->body.padding.hor)) page->ext_size = -ext->sb.style->body.padding.hor;
|
||||
@ -1019,22 +963,36 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
page_ext->sb.ver_draw = 0;
|
||||
}
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_PRESSED) {
|
||||
if(page_ext->pr_action != NULL) {
|
||||
res = page_ext->pr_action(page);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
if(lv_indev_is_dragging(lv_indev_get_act()) == false) {
|
||||
if(page_ext->rel_action != NULL) {
|
||||
res = page_ext->rel_action(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Propagate the input device related event of the scrollable to the parent page background
|
||||
* It is used by default if the scrollable's event is not specified
|
||||
* @param scrl pointer to the page's scrollable object
|
||||
* @param event type of the event
|
||||
*/
|
||||
static void scrl_def_event_cb(lv_obj_t * scrl, lv_event_t event)
|
||||
{
|
||||
lv_obj_t * page = lv_obj_get_parent(scrl);
|
||||
|
||||
if(event == LV_EVENT_PRESSED ||
|
||||
event == LV_EVENT_PRESSING ||
|
||||
event == LV_EVENT_PRESS_LOST ||
|
||||
event == LV_EVENT_RELEASED ||
|
||||
event == LV_EVENT_CLICKED ||
|
||||
event == LV_EVENT_LONG_PRESSED ||
|
||||
event == LV_EVENT_LONG_PRESSED_REPEAT ||
|
||||
event == LV_EVENT_LONG_HOVER_IN ||
|
||||
event == LV_EVENT_LONG_HOVER_OUT)
|
||||
{
|
||||
lv_obj_send_event(page, event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the position and size of the scroll bars.
|
||||
* @param page pointer to a page object
|
||||
|
@ -55,8 +55,6 @@ typedef struct
|
||||
lv_cont_ext_t bg; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * scrl; /*The scrollable object on the background*/
|
||||
lv_action_t rel_action; /*Function to call when the page is released*/
|
||||
lv_action_t pr_action; /*Function to call when the page is pressed*/
|
||||
struct {
|
||||
lv_style_t *style; /*Style of scrollbars*/
|
||||
lv_area_t hor_area; /*Horizontal scrollbar area relative to the page. (Handled by the library) */
|
||||
@ -106,20 +104,6 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
*/
|
||||
void lv_page_clean(lv_obj_t *obj);
|
||||
|
||||
/**
|
||||
* Get the press action of the page
|
||||
* @param page pointer to a page object
|
||||
* @return a function to call when the page is pressed
|
||||
*/
|
||||
lv_action_t lv_page_get_pr_action(lv_obj_t * page);
|
||||
|
||||
/**
|
||||
* Get the release action of the page
|
||||
* @param page pointer to a page object
|
||||
* @return a function to call when the page is released
|
||||
*/
|
||||
lv_action_t lv_page_get_rel_action(lv_obj_t * page);
|
||||
|
||||
/**
|
||||
* Get the scrollable object of a page
|
||||
* @param page pointer to a page object
|
||||
@ -131,20 +115,6 @@ lv_obj_t * lv_page_get_scrl(const lv_obj_t * page);
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set a release action for the page
|
||||
* @param page pointer to a page object
|
||||
* @param rel_action a function to call when the page is released
|
||||
*/
|
||||
void lv_page_set_rel_action(lv_obj_t * page, lv_action_t rel_action);
|
||||
|
||||
/**
|
||||
* Set a press action for the page
|
||||
* @param page pointer to a page object
|
||||
* @param pr_action a function to call when the page is pressed
|
||||
*/
|
||||
void lv_page_set_pr_action(lv_obj_t * page, lv_action_t pr_action);
|
||||
|
||||
/**
|
||||
* Set the scroll bar mode on a page
|
||||
* @param page pointer to a page object
|
||||
|
@ -43,8 +43,8 @@ static lv_res_t lv_preload_signal(lv_obj_t * preload, lv_signal_t sign, void * p
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_func_t ancestor_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -82,8 +82,8 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->anim_type = LV_PRELOAD_DEF_ANIM;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_preload, lv_preload_signal);
|
||||
lv_obj_set_design_func(new_preload, lv_preload_design);
|
||||
lv_obj_set_signal_cb(new_preload, lv_preload_signal);
|
||||
lv_obj_set_design_cb(new_preload, lv_preload_design);
|
||||
|
||||
|
||||
/*Init the new pre loader pre loader*/
|
||||
|
@ -41,8 +41,8 @@ static void draw_bg(lv_obj_t * roller, const lv_area_t * mask);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_func_t ancestor_scrl_signal;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_signal_cb_t ancestor_scrl_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -77,21 +77,20 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->ddlist.draw_arrow = 0; /*Do not draw arrow by default*/
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_roller, lv_roller_signal);
|
||||
lv_obj_set_design_func(new_roller, lv_roller_design);
|
||||
lv_obj_set_signal_cb(new_roller, lv_roller_signal);
|
||||
lv_obj_set_design_cb(new_roller, lv_roller_design);
|
||||
|
||||
/*Init the new roller roller*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_t * scrl = lv_page_get_scrl(new_roller);
|
||||
lv_obj_set_drag(scrl, true); /*In ddlist is might be disabled*/
|
||||
lv_page_set_rel_action(new_roller, NULL); /*Roller don't uses it (like ddlist)*/
|
||||
lv_obj_set_drag(scrl, true); /*In ddlist it might be disabled*/
|
||||
lv_page_set_scrl_fit2(new_roller, LV_FIT_TIGHT, LV_FIT_NONE); /*Height is specified directly*/
|
||||
lv_ddlist_open(new_roller, false);
|
||||
lv_ddlist_set_anim_time(new_roller, LV_ROLLER_ANIM_TIME);
|
||||
lv_roller_set_visible_row_count(new_roller, 3);
|
||||
lv_label_set_align(ext->ddlist.label, LV_LABEL_ALIGN_CENTER);
|
||||
|
||||
lv_obj_set_signal_func(scrl, lv_roller_scrl_signal);
|
||||
lv_obj_set_signal_cb(scrl, lv_roller_scrl_signal);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
@ -107,7 +106,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
else {
|
||||
lv_obj_t * scrl = lv_page_get_scrl(new_roller);
|
||||
lv_ddlist_open(new_roller, false);
|
||||
lv_obj_set_signal_func(scrl, lv_roller_scrl_signal);
|
||||
lv_obj_set_signal_cb(scrl, lv_roller_scrl_signal);
|
||||
|
||||
lv_obj_refresh_style(new_roller); /*Refresh the style with new signal function*/
|
||||
}
|
||||
@ -404,7 +403,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_ENTER) {
|
||||
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/
|
||||
if(ext->ddlist.action) ext->ddlist.action(roller);
|
||||
lv_obj_send_event(roller, LV_EVENT_VALUE_CHANGED);
|
||||
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(roller);
|
||||
@ -459,7 +458,7 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign,
|
||||
if(id < 0) id = 0;
|
||||
if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1;
|
||||
ext->ddlist.sel_opt_id = id;
|
||||
if(ext->ddlist.action) ext->ddlist.action(roller);
|
||||
lv_obj_send_event(roller, LV_EVENT_VALUE_CHANGED);
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
/*If picked an option by clicking then set it*/
|
||||
if(!lv_indev_is_dragging(indev)) {
|
||||
@ -470,7 +469,7 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign,
|
||||
if(id < 0) id = 0;
|
||||
if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1;
|
||||
ext->ddlist.sel_opt_id = id;
|
||||
if(ext->ddlist.action) ext->ddlist.action(roller);
|
||||
lv_obj_send_event(roller, LV_EVENT_VALUE_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,16 +90,6 @@ static inline void lv_roller_set_options(lv_obj_t * roller, const char * options
|
||||
*/
|
||||
void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en);
|
||||
|
||||
/**
|
||||
* Set a function to call when a new option is chosen
|
||||
* @param roller pointer to a roller
|
||||
* @param action pointer to a callback function
|
||||
*/
|
||||
static inline void lv_roller_set_action(lv_obj_t * roller, lv_action_t action)
|
||||
{
|
||||
lv_ddlist_set_action(roller, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the height to show the given number of rows (options)
|
||||
* @param roller pointer to a roller object
|
||||
@ -176,16 +166,6 @@ static inline void lv_roller_get_selected_str(const lv_obj_t * roller, char * bu
|
||||
lv_ddlist_get_selected_str(roller, buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the "option selected" callback function
|
||||
* @param roller pointer to a roller
|
||||
* @return pointer to the call back function
|
||||
*/
|
||||
static inline lv_action_t lv_roller_get_action(const lv_obj_t * roller)
|
||||
{
|
||||
return lv_ddlist_get_action(roller);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the open/close animation time.
|
||||
* @param roller pointer to a roller
|
||||
|
@ -34,8 +34,8 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_func_t ancestor_design_f;
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design_f;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -69,14 +69,13 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
if(ext == NULL) return NULL;
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->action = NULL;
|
||||
ext->drag_value = LV_SLIDER_NOT_PRESSED;
|
||||
ext->style_knob = &lv_style_pretty;
|
||||
ext->knob_in = 0;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_slider, lv_slider_signal);
|
||||
lv_obj_set_design_func(new_slider, lv_slider_design);
|
||||
lv_obj_set_signal_cb(new_slider, lv_slider_signal);
|
||||
lv_obj_set_design_cb(new_slider, lv_slider_design);
|
||||
|
||||
/*Init the new slider slider*/
|
||||
if(copy == NULL) {
|
||||
@ -97,7 +96,6 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
else {
|
||||
lv_slider_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->style_knob = copy_ext->style_knob;
|
||||
ext->action = copy_ext->action;
|
||||
ext->knob_in = copy_ext->knob_in;
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_slider);
|
||||
@ -114,17 +112,6 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set a function which will be called when a new value is set on the slider
|
||||
* @param slider pointer to slider object
|
||||
* @param action a callback function
|
||||
*/
|
||||
void lv_slider_set_action(lv_obj_t * slider, lv_action_t action)
|
||||
{
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||
ext->action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the 'knob in' attribute of a slider
|
||||
* @param slider pointer to slider object
|
||||
@ -181,17 +168,6 @@ int16_t lv_slider_get_value(const lv_obj_t * slider)
|
||||
else return lv_bar_get_value(slider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the slider action function
|
||||
* @param slider pointer to slider object
|
||||
* @return the callback function
|
||||
*/
|
||||
lv_action_t lv_slider_get_action(const lv_obj_t * slider)
|
||||
{
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||
return ext->action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the slider is being dragged or not
|
||||
* @param slider pointer to a slider object
|
||||
@ -454,18 +430,18 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
||||
if(tmp != ext->drag_value) {
|
||||
ext->drag_value = tmp;
|
||||
lv_obj_invalidate(slider);
|
||||
if(ext->action != NULL) res = ext->action(slider);
|
||||
lv_obj_send_event(slider, LV_EVENT_VALUE_CHANGED);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
|
||||
lv_slider_set_value(slider, ext->drag_value);
|
||||
ext->drag_value = LV_SLIDER_NOT_PRESSED;
|
||||
if(ext->action != NULL) res = ext->action(slider);
|
||||
lv_obj_send_event(slider, LV_EVENT_VALUE_CHANGED);
|
||||
} else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
/* The knob size depends on slider size.
|
||||
* During the drawing method the ext. size is used by the knob so refresh the ext. size.*/
|
||||
if(lv_obj_get_width(slider) != lv_area_get_width(param) ||
|
||||
lv_obj_get_height(slider) != lv_area_get_height(param)) {
|
||||
slider->signal_func(slider, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
slider->signal_cb(slider, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
lv_style_t * style = lv_slider_get_style(slider, LV_SLIDER_STYLE_BG);
|
||||
@ -498,10 +474,10 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
||||
#endif
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
|
||||
lv_slider_set_value(slider, lv_slider_get_value(slider) + 1);
|
||||
if(ext->action != NULL) res = ext->action(slider);
|
||||
lv_obj_send_event(slider, LV_EVENT_VALUE_CHANGED);
|
||||
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
|
||||
lv_slider_set_value(slider, lv_slider_get_value(slider) - 1);
|
||||
if(ext->action != NULL) res = ext->action(slider);
|
||||
lv_obj_send_event(slider, LV_EVENT_VALUE_CHANGED);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||
bool * editable = (bool *)param;
|
||||
|
@ -41,7 +41,6 @@ typedef struct
|
||||
{
|
||||
lv_bar_ext_t bar; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_action_t action; /*Function to call when a new value is set*/
|
||||
lv_style_t *style_knob; /*Style of the knob*/
|
||||
int16_t drag_value; /*Store a temporal value during press until release (Handled by the library)*/
|
||||
uint8_t knob_in :1; /*1: Draw the knob inside the bar*/
|
||||
@ -104,13 +103,6 @@ static inline void lv_slider_set_range(lv_obj_t *slider, int16_t min, int16_t ma
|
||||
lv_bar_set_range(slider, min, max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function which will be called when a new value is set on the slider
|
||||
* @param slider pointer to slider object
|
||||
* @param action a callback function
|
||||
*/
|
||||
void lv_slider_set_action(lv_obj_t * slider, lv_action_t action);
|
||||
|
||||
/**
|
||||
* Set the 'knob in' attribute of a slider
|
||||
* @param slider pointer to slider object
|
||||
@ -158,13 +150,6 @@ static inline int16_t lv_slider_get_max_value(const lv_obj_t * slider)
|
||||
return lv_bar_get_max_value(slider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the slider action function
|
||||
* @param slider pointer to slider object
|
||||
* @return the callback function
|
||||
*/
|
||||
lv_action_t lv_slider_get_action(const lv_obj_t * slider);
|
||||
|
||||
/**
|
||||
* Give the slider is being dragged or not
|
||||
* @param slider pointer to a slider object
|
||||
|
@ -29,8 +29,8 @@ static void lv_spinbox_updatevalue(lv_obj_t * spinbox);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_func_t ancestor_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -79,8 +79,8 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_ta_set_cursor_type(new_spinbox, LV_CURSOR_BLOCK | LV_CURSOR_HIDDEN); /*hidden by default*/
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_spinbox, lv_spinbox_signal);
|
||||
lv_obj_set_design_func(new_spinbox, ancestor_design); /*Leave the Text area's design function*/
|
||||
lv_obj_set_signal_cb(new_spinbox, lv_spinbox_signal);
|
||||
lv_obj_set_design_cb(new_spinbox, ancestor_design); /*Leave the Text area's design function*/
|
||||
|
||||
/*Init the new spinbox spinbox*/
|
||||
if(copy == NULL) {
|
||||
|
@ -35,7 +35,7 @@ static void lv_sw_anim_to_value(lv_obj_t * sw, int16_t value);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -76,7 +76,7 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->style_knob_on = ext->slider.style_knob;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_sw, lv_sw_signal);
|
||||
lv_obj_set_signal_cb(new_sw, lv_sw_signal);
|
||||
|
||||
/*Init the new switch switch*/
|
||||
if(copy == NULL) {
|
||||
@ -310,10 +310,6 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
|
||||
if(sign == LV_SIGNAL_PRESSING) old_val = ext->slider.drag_value;
|
||||
else old_val = lv_slider_get_value(sw);
|
||||
|
||||
/*Do not let the slider to call the callback. The Switch will do it if required*/
|
||||
lv_action_t slider_action = ext->slider.action;
|
||||
ext->slider.action = NULL;
|
||||
|
||||
lv_res_t res;
|
||||
/* Include the ancient signal function */
|
||||
res = ancestor_signal(sw, sign, param);
|
||||
@ -377,7 +373,7 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
|
||||
if(lv_sw_get_state(sw)) lv_sw_off_anim(sw);
|
||||
else lv_sw_on_anim(sw);
|
||||
|
||||
if(slider_action != NULL) res = slider_action(sw);
|
||||
lv_obj_send_event(sw, LV_EVENT_VALUE_CHANGED);
|
||||
}
|
||||
/*If the switch was dragged then calculate the new state based on the current position*/
|
||||
else {
|
||||
@ -385,7 +381,7 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
|
||||
if(v > LV_SWITCH_SLIDER_ANIM_MAX / 2) lv_sw_on_anim(sw);
|
||||
else lv_sw_off_anim(sw);
|
||||
|
||||
if(slider_action != NULL) res = slider_action(sw);
|
||||
lv_obj_send_event(sw, LV_EVENT_VALUE_CHANGED);
|
||||
}
|
||||
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
@ -395,13 +391,13 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
|
||||
if(old_val) lv_sw_off_anim(sw);
|
||||
else lv_sw_on_anim(sw);
|
||||
|
||||
if(slider_action) res = slider_action(sw);
|
||||
lv_obj_send_event(sw, LV_EVENT_VALUE_CHANGED);
|
||||
} else if(c == LV_GROUP_KEY_UP || c == LV_GROUP_KEY_RIGHT) {
|
||||
lv_sw_on_anim(sw);
|
||||
if(slider_action) res = slider_action(sw);
|
||||
lv_obj_send_event(sw, LV_EVENT_VALUE_CHANGED);
|
||||
} else if(c == LV_GROUP_KEY_DOWN || c == LV_GROUP_KEY_LEFT) {
|
||||
lv_sw_off_anim(sw);
|
||||
if(slider_action) res = slider_action(sw);
|
||||
lv_obj_send_event(sw, LV_EVENT_VALUE_CHANGED);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||
bool * editable = (bool *)param;
|
||||
@ -415,9 +411,6 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
|
||||
buf->type[i] = "lv_sw";
|
||||
}
|
||||
|
||||
/*Restore the callback*/
|
||||
if(res == LV_RES_OK) ext->slider.action = slider_action;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -114,16 +114,6 @@ void lv_sw_off_anim(lv_obj_t * sw);
|
||||
*/
|
||||
bool lv_sw_toggle_anim(lv_obj_t *sw);
|
||||
|
||||
/**
|
||||
* Set a function which will be called when the switch is toggled by the user
|
||||
* @param sw pointer to switch object
|
||||
* @param action a callback function
|
||||
*/
|
||||
static inline void lv_sw_set_action(lv_obj_t * sw, lv_action_t action)
|
||||
{
|
||||
lv_slider_set_action(sw, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a style of a switch
|
||||
* @param sw pointer to a switch object
|
||||
@ -156,16 +146,6 @@ static inline bool lv_sw_get_state(const lv_obj_t *sw)
|
||||
return lv_bar_get_value(sw) < LV_SWITCH_SLIDER_ANIM_MAX / 2 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the switch action function
|
||||
* @param slider pointer to a switch object
|
||||
* @return the callback function
|
||||
*/
|
||||
static inline lv_action_t lv_sw_get_action(const lv_obj_t * slider)
|
||||
{
|
||||
return lv_slider_get_action(slider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a style of a switch
|
||||
* @param sw pointer to a switch object
|
||||
|
@ -59,10 +59,10 @@ static void update_cursor_position_on_click(lv_obj_t * ta, lv_indev_t * click_so
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_func_t ancestor_design;
|
||||
static lv_design_func_t scrl_design;
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_func_t scrl_signal;
|
||||
static lv_design_cb_t ancestor_design;
|
||||
static lv_design_cb_t scrl_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_signal_cb_t scrl_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -110,9 +110,9 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->label = NULL;
|
||||
ext->placeholder = NULL;
|
||||
|
||||
lv_obj_set_signal_func(new_ta, lv_ta_signal);
|
||||
lv_obj_set_signal_func(lv_page_get_scrl(new_ta), lv_ta_scrollable_signal);
|
||||
lv_obj_set_design_func(new_ta, lv_ta_design);
|
||||
lv_obj_set_signal_cb(new_ta, lv_ta_signal);
|
||||
lv_obj_set_signal_cb(lv_page_get_scrl(new_ta), lv_ta_scrollable_signal);
|
||||
lv_obj_set_design_cb(new_ta, lv_ta_design);
|
||||
|
||||
/*Init the new text area object*/
|
||||
if(copy == NULL) {
|
||||
@ -120,7 +120,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
ext->label = lv_label_create(new_ta, NULL);
|
||||
|
||||
lv_obj_set_design_func(ext->page.scrl, lv_ta_scrollable_design);
|
||||
lv_obj_set_design_cb(ext->page.scrl, lv_ta_scrollable_design);
|
||||
|
||||
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_BREAK);
|
||||
lv_label_set_text(ext->label, "Text area");
|
||||
@ -140,7 +140,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_obj_set_design_func(ext->page.scrl, lv_ta_scrollable_design);
|
||||
lv_obj_set_design_cb(ext->page.scrl, lv_ta_scrollable_design);
|
||||
lv_ta_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->label = lv_label_create(new_ta, copy_ext->label);
|
||||
ext->pwd_mode = copy_ext->pwd_mode;
|
||||
@ -254,6 +254,8 @@ void lv_ta_add_char(lv_obj_t * ta, uint32_t c)
|
||||
lv_ta_set_edge_flash(ta, edge_flash_en);
|
||||
|
||||
placeholder_update(ta);
|
||||
|
||||
lv_obj_send_event(ta, LV_EVENT_VALUE_CHANGED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -319,6 +321,8 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt)
|
||||
lv_ta_set_edge_flash(ta, edge_flash_en);
|
||||
|
||||
placeholder_update(ta);
|
||||
|
||||
lv_obj_send_event(ta, LV_EVENT_VALUE_CHANGED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -360,6 +364,8 @@ void lv_ta_del_char(lv_obj_t * ta)
|
||||
lv_ta_set_cursor_pos(ta, ext->cursor.pos - 1);
|
||||
|
||||
placeholder_update(ta);
|
||||
|
||||
lv_obj_send_event(ta, LV_EVENT_VALUE_CHANGED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,16 +201,6 @@ void lv_ta_set_accepted_chars(lv_obj_t * ta, const char * list);
|
||||
*/
|
||||
void lv_ta_set_max_length(lv_obj_t * ta, uint16_t num);
|
||||
|
||||
/**
|
||||
* Set an action to call when the Text area is clicked
|
||||
* @param ta pointer to a Text area
|
||||
* @param action a function pointer
|
||||
*/
|
||||
static inline void lv_ta_set_action(lv_obj_t * ta, lv_action_t action)
|
||||
{
|
||||
lv_page_set_rel_action(ta, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the scroll bar mode of a text area
|
||||
* @param ta pointer to a text area object
|
||||
@ -323,16 +313,6 @@ const char * lv_ta_get_accepted_chars(lv_obj_t * ta);
|
||||
*/
|
||||
uint16_t lv_ta_get_max_length(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Set an action to call when the Text area is clicked
|
||||
* @param ta pointer to a Text area
|
||||
* @param action a function pointer
|
||||
*/
|
||||
static inline lv_action_t lv_ta_get_action(lv_obj_t * ta)
|
||||
{
|
||||
return lv_page_get_rel_action(ta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the scroll bar mode of a text area
|
||||
* @param ta pointer to a text area object
|
||||
|
@ -33,8 +33,8 @@ static void refr_size(lv_obj_t * table);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_func_t ancestor_scrl_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_scrl_design;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -81,8 +81,8 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
}
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_table, lv_table_signal);
|
||||
lv_obj_set_design_func(new_table, lv_table_design);
|
||||
lv_obj_set_signal_cb(new_table, lv_table_signal);
|
||||
lv_obj_set_design_cb(new_table, lv_table_design);
|
||||
|
||||
/*Init the new table table*/
|
||||
if(copy == NULL) {
|
||||
|
@ -45,9 +45,9 @@ static void tabview_realign(lv_obj_t * tabview);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_func_t page_signal;
|
||||
static lv_signal_func_t page_scrl_signal;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_signal_cb_t page_signal;
|
||||
static lv_signal_cb_t page_scrl_signal;
|
||||
static const char * tab_def[] = {""};
|
||||
|
||||
/**********************
|
||||
@ -96,7 +96,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_tabview, lv_tabview_signal);
|
||||
lv_obj_set_signal_cb(new_tabview, lv_tabview_signal);
|
||||
|
||||
/*Init the new tab tab*/
|
||||
if(copy == NULL) {
|
||||
@ -214,8 +214,8 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
||||
|
||||
if(page_signal == NULL) page_signal = lv_obj_get_signal_func(h);
|
||||
if(page_scrl_signal == NULL) page_scrl_signal = lv_obj_get_signal_func(lv_page_get_scrl(h));
|
||||
lv_obj_set_signal_func(h, tabpage_signal);
|
||||
lv_obj_set_signal_func(lv_page_get_scrl(h), tabpage_scrl_signal);
|
||||
lv_obj_set_signal_cb(h, tabpage_signal);
|
||||
lv_obj_set_signal_cb(lv_page_get_scrl(h), tabpage_scrl_signal);
|
||||
|
||||
/*Extend the button matrix map with the new name*/
|
||||
char * name_dm;
|
||||
@ -616,7 +616,7 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
||||
/* The button matrix is not in a group (the tab view is in it) but it should handle the group signals.
|
||||
* So propagate the related signals to the button matrix manually*/
|
||||
if(ext->btns) {
|
||||
ext->btns->signal_func(ext->btns, sign, param);
|
||||
ext->btns->signal_cb(ext->btns, sign, param);
|
||||
}
|
||||
if(sign == LV_SIGNAL_FOCUS) {
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
|
@ -41,9 +41,9 @@ static bool set_valid_drag_dirs(lv_obj_t * tileview);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_func_t ancestor_scrl_signal;
|
||||
static lv_design_func_t ancestor_design;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_signal_cb_t ancestor_scrl_signal;
|
||||
static lv_design_cb_t ancestor_design;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -84,8 +84,8 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->valid_pos = NULL;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_tileview, lv_tileview_signal);
|
||||
lv_obj_set_signal_func(lv_page_get_scrl(new_tileview), lv_tileview_scrl_signal);
|
||||
lv_obj_set_signal_cb(new_tileview, lv_tileview_signal);
|
||||
lv_obj_set_signal_cb(lv_page_get_scrl(new_tileview), lv_tileview_scrl_signal);
|
||||
|
||||
/*Init the new tileview*/
|
||||
if(copy == NULL) {
|
||||
@ -132,7 +132,7 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
void lv_tileview_add_element(lv_obj_t * element)
|
||||
{
|
||||
lv_obj_set_free_ptr(element, lv_obj_get_signal_func(element));
|
||||
lv_obj_set_signal_func(element, element_signal_func);
|
||||
lv_obj_set_signal_cb(element, element_signal_func);
|
||||
lv_obj_set_drag_parent(element, true);
|
||||
}
|
||||
|
||||
@ -439,7 +439,7 @@ static lv_res_t element_signal_func(lv_obj_t * element, lv_signal_t sign, void *
|
||||
lv_res_t res;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
lv_signal_func_t sign_func = lv_obj_get_free_ptr(element);
|
||||
lv_signal_cb_t sign_func = lv_obj_get_free_ptr(element);
|
||||
res = sign_func(element, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
@ -483,7 +483,7 @@ static lv_res_t element_signal_func(lv_obj_t * element, lv_signal_t sign, void *
|
||||
if(drag_obj == NULL) break;
|
||||
}
|
||||
indev->proc.drag_in_prog = 0;
|
||||
if(drag_obj) drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, NULL);
|
||||
if(drag_obj) drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_END, NULL);
|
||||
}
|
||||
|
||||
drag_end_handler(tileview);
|
||||
|
@ -29,7 +29,7 @@ static void lv_win_realign(lv_obj_t * win);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -110,7 +110,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_HEADER, &lv_style_plain_color);
|
||||
}
|
||||
|
||||
lv_obj_set_signal_func(new_win, lv_win_signal);
|
||||
lv_obj_set_signal_cb(new_win, lv_win_signal);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
@ -132,7 +132,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
child = lv_obj_get_child_back(copy_ext->header, child);
|
||||
}
|
||||
|
||||
lv_obj_set_signal_func(new_win, lv_win_signal);
|
||||
lv_obj_set_signal_cb(new_win, lv_win_signal);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_win);
|
||||
@ -163,10 +163,10 @@ void lv_win_clean(lv_obj_t * obj)
|
||||
* Add control button to the header of the window
|
||||
* @param win pointer to a window object
|
||||
* @param img_src an image source ('lv_img_t' variable, path to file or a symbol)
|
||||
* @param rel_action a function pointer to call when the button is released
|
||||
* @param event_cb specify the an event handler function. NULL if unused
|
||||
* @return pointer to the created button object
|
||||
*/
|
||||
lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src, lv_action_t rel_action)
|
||||
lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src, lv_event_cb_t event_cb)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
|
||||
@ -174,7 +174,7 @@ lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src, lv_action_t rel_
|
||||
lv_btn_set_style(btn, LV_BTN_STYLE_REL, ext->style_btn_rel);
|
||||
lv_btn_set_style(btn, LV_BTN_STYLE_PR, ext->style_btn_pr);
|
||||
lv_obj_set_size(btn, ext->btn_size, ext->btn_size);
|
||||
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, rel_action);
|
||||
lv_obj_set_event_cb(btn, event_cb);
|
||||
|
||||
lv_obj_t * img = lv_img_create(btn, NULL);
|
||||
lv_obj_set_click(img, false);
|
||||
@ -508,7 +508,7 @@ static lv_res_t lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param)
|
||||
ext->title = NULL;
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
/*Forward all the control signals to the page*/
|
||||
ext->page->signal_func(ext->page, sign, param);
|
||||
ext->page->signal_cb(ext->page, sign, param);
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
|
@ -105,10 +105,10 @@ void lv_win_clean(lv_obj_t *obj);
|
||||
* Add control button to the header of the window
|
||||
* @param win pointer to a window object
|
||||
* @param img_src an image source ('lv_img_t' variable, path to file or a symbol)
|
||||
* @param rel_action a function pointer to call when the button is released
|
||||
* @param event_cb specify the an event handler function. NULL if unused
|
||||
* @return pointer to the created button object
|
||||
*/
|
||||
lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src, lv_action_t rel_action);
|
||||
lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src, lv_event_cb_t event_cb);
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
|
Loading…
x
Reference in New Issue
Block a user