diff --git a/lv_core/lv_indev.c b/lv_core/lv_indev.c index fa2bab6fd..a5f2c9a0d 100644 --- a/lv_core/lv_indev.c +++ b/lv_core/lv_indev.c @@ -145,7 +145,7 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj) indev->cursor = cur_obj; lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp)); - lv_obj_set_pos(indev->cursor, indev->proc.act_point.x, indev->proc.act_point.y); + lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y); } #if USE_LV_GROUP @@ -192,8 +192,8 @@ void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point) point->x = -1; point->y = -1; } else { - point->x = indev->proc.act_point.x; - point->y = indev->proc.act_point.y; + point->x = indev->proc.types.pointer.act_point.x; + point->y = indev->proc.types.pointer.act_point.y; } } @@ -205,7 +205,7 @@ void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point) uint32_t lv_indev_get_key(const lv_indev_t * indev) { if(indev->driver.type != LV_INDEV_TYPE_KEYPAD) return 0; - else return indev->proc.last_key; + else return indev->proc.types.keypad.last_key; } /** @@ -217,13 +217,13 @@ bool lv_indev_is_dragging(const lv_indev_t * indev) { if(indev == NULL) return false; if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON) return false; - return indev->proc.drag_in_prog == 0 ? false : true; + return indev->proc.types.pointer.drag_in_prog == 0 ? false : true; } /** - * Get the vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON) + * Get the types.pointer.vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON) * @param indev pointer to an input device - * @param point pointer to a point to store the vector + * @param point pointer to a point to store the types.pointer.vector */ void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point) { @@ -237,8 +237,8 @@ void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point) point->x = 0; point->y = 0; } else { - point->x = indev->proc.vect.x; - point->y = indev->proc.vect.y; + point->x = indev->proc.types.pointer.vect.x; + point->y = indev->proc.types.pointer.vect.y; } } @@ -281,7 +281,7 @@ lv_indev_feedback_t lv_indev_get_feedback(const lv_indev_t *indev) */ void lv_indev_wait_release(lv_indev_t * indev) { - indev->proc.wait_unil_release = 1; + indev->proc.types.pointer.wait_unil_release = 1; } /********************** @@ -354,13 +354,13 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data) { /*Move the cursor if set and moved*/ if(i->cursor != NULL && - (i->proc.last_point.x != data->point.x || - i->proc.last_point.y != data->point.y)) { + (i->proc.types.pointer.last_point.x != data->point.x || + i->proc.types.pointer.last_point.y != data->point.y)) { lv_obj_set_pos(i->cursor, data->point.x, data->point.y); } - i->proc.act_point.x = data->point.x; - i->proc.act_point.y = data->point.y; + i->proc.types.pointer.act_point.x = data->point.x; + i->proc.types.pointer.act_point.y = data->point.y; if(i->proc.state == LV_INDEV_STATE_PR) { indev_proc_press(&i->proc); @@ -368,8 +368,8 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data) indev_proc_release(&i->proc); } - i->proc.last_point.x = i->proc.act_point.x; - i->proc.last_point.y = i->proc.act_point.y; + i->proc.types.pointer.last_point.x = i->proc.types.pointer.act_point.x; + i->proc.types.pointer.last_point.y = i->proc.types.pointer.act_point.y; } /** @@ -386,7 +386,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) /*Key press happened*/ if(data->state == LV_INDEV_STATE_PR && - i->proc.last_state == LV_INDEV_STATE_REL) { + i->proc.types.keypad.last_state == LV_INDEV_STATE_REL) { i->proc.pr_timestamp = lv_tick_get(); if(focused && data->key == LV_GROUP_KEY_ENTER) { focused->signal_cb(focused, LV_SIGNAL_PRESSED, indev_act); @@ -394,7 +394,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) } } /*Pressing*/ - else if(data->state == LV_INDEV_STATE_PR && i->proc.last_state == LV_INDEV_STATE_PR) { + else if(data->state == LV_INDEV_STATE_PR && i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) { if(data->key == LV_GROUP_KEY_ENTER && i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) { @@ -408,9 +408,9 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) } } /*Release happened*/ - else if(data->state == LV_INDEV_STATE_REL && i->proc.last_state == LV_INDEV_STATE_PR) { + else if(data->state == LV_INDEV_STATE_REL && i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) { /*The user might clear the key when it was released. Always release the pressed key*/ - data->key = i->proc.last_key; + data->key = i->proc.types.keypad.last_key; /* Edit mode is not used by KEYPAD devices. * So leave edit mode if we are in it before focusing on the next/prev object*/ @@ -437,8 +437,8 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) i->proc.long_pr_sent = 0; } - i->proc.last_state = data->state; - i->proc.last_key = data->key; + i->proc.types.keypad.last_state = data->state; + i->proc.types.keypad.last_key = data->key; #else (void)data; /*Unused*/ (void)i; /*Unused*/ @@ -479,11 +479,11 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) /*Key press happened*/ if(data->state == LV_INDEV_STATE_PR && - i->proc.last_state == LV_INDEV_STATE_REL) { + i->proc.types.keypad.last_state == LV_INDEV_STATE_REL) { i->proc.pr_timestamp = lv_tick_get(); } /*Pressing*/ - else if(data->state == LV_INDEV_STATE_PR && i->proc.last_state == LV_INDEV_STATE_PR) { + else if(data->state == LV_INDEV_STATE_PR && i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) { if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) { /*On enter long press leave edit mode.*/ @@ -507,7 +507,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) } } /*Release happened*/ - else if(data->state == LV_INDEV_STATE_REL && i->proc.last_state == LV_INDEV_STATE_PR) { + else if(data->state == LV_INDEV_STATE_REL && i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) { lv_obj_t * focused = lv_group_get_focused(i->group); bool editable = false; if(focused) focused->signal_cb(focused, LV_SIGNAL_GET_EDITABLE, &editable); @@ -532,8 +532,8 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) i->proc.long_pr_sent = 0; } - i->proc.last_state = data->state; - i->proc.last_key = data->key; + i->proc.types.keypad.last_state = data->state; + i->proc.types.keypad.last_key = data->key; #else (void)data; /*Unused*/ (void)i; /*Unused*/ @@ -548,12 +548,12 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) */ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data) { - i->proc.act_point.x = i->btn_points[data->btn_id].x; - i->proc.act_point.y = i->btn_points[data->btn_id].y; + i->proc.types.pointer.act_point.x = i->btn_points[data->btn_id].x; + i->proc.types.pointer.act_point.y = i->btn_points[data->btn_id].y; /*Still the same point is pressed*/ - if(i->proc.last_point.x == i->proc.act_point.x && - i->proc.last_point.y == i->proc.act_point.y && + if(i->proc.types.pointer.last_point.x == i->proc.types.pointer.act_point.x && + i->proc.types.pointer.last_point.y == i->proc.types.pointer.act_point.y && data->state == LV_INDEV_STATE_PR) { indev_proc_press(&i->proc); @@ -562,8 +562,8 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data) indev_proc_release(&i->proc); } - i->proc.last_point.x = i->proc.act_point.x; - i->proc.last_point.y = i->proc.act_point.y; + i->proc.types.pointer.last_point.x = i->proc.types.pointer.act_point.x; + i->proc.types.pointer.last_point.y = i->proc.types.pointer.act_point.y; } /** @@ -572,21 +572,21 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data) */ static void indev_proc_press(lv_indev_proc_t * proc) { - lv_obj_t * pr_obj = proc->act_obj; + lv_obj_t * pr_obj = proc->types.pointer.act_obj; - if(proc->wait_unil_release != 0) return; + if(proc->types.pointer.wait_unil_release != 0) return; lv_disp_t * disp = indev_act->driver.disp; /*If there is no last object then search*/ - if(proc->act_obj == NULL) { + if(proc->types.pointer.act_obj == NULL) { pr_obj = indev_search_obj(proc, lv_disp_get_layer_sys(disp)); if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_layer_top(disp)); if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_scr_act(disp)); } /*If there is last object but it is not dragged and not protected also search*/ - else if(proc->drag_in_prog == 0 && - lv_obj_is_protected(proc->act_obj, LV_PROTECT_PRESS_LOST) == false) {/*Now act_obj != NULL*/ + else if(proc->types.pointer.drag_in_prog == 0 && + lv_obj_is_protected(proc->types.pointer.act_obj, LV_PROTECT_PRESS_LOST) == false) {/*Now types.pointer.act_obj != NULL*/ pr_obj = indev_search_obj(proc, lv_disp_get_layer_sys(disp)); if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_layer_top(disp)); if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_scr_act(disp)); @@ -597,35 +597,35 @@ static void indev_proc_press(lv_indev_proc_t * proc) } /*If a new object was found reset some variables and send a pressed signal*/ - if(pr_obj != proc->act_obj) { + if(pr_obj != proc->types.pointer.act_obj) { - proc->last_point.x = proc->act_point.x; - proc->last_point.y = proc->act_point.y; + proc->types.pointer.last_point.x = proc->types.pointer.act_point.x; + proc->types.pointer.last_point.y = proc->types.pointer.act_point.y; /*If a new object found the previous was lost, so send a signal*/ - if(proc->act_obj != NULL) { - 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->types.pointer.act_obj != NULL) { + proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_PRESS_LOST, indev_act); + lv_obj_send_event(proc->types.pointer.act_obj, LV_EVENT_PRESS_LOST); if(proc->reset_query != 0) return; } - proc->act_obj = pr_obj; /*Save the pressed object*/ - proc->last_obj = proc->act_obj; /*Refresh the last_obj*/ + proc->types.pointer.act_obj = pr_obj; /*Save the pressed object*/ + proc->types.pointer.last_obj = proc->types.pointer.act_obj; /*Refresh the types.pointer.last_obj*/ - if(proc->act_obj != NULL) { + if(proc->types.pointer.act_obj != NULL) { /* Save the time when the obj pressed. * It is necessary to count the long press time.*/ proc->pr_timestamp = lv_tick_get(); proc->long_pr_sent = 0; - proc->drag_limit_out = 0; - proc->drag_in_prog = 0; - proc->drag_sum.x = 0; - proc->drag_sum.y = 0; - proc->vect.x = 0; - proc->vect.y = 0; + proc->types.pointer.drag_limit_out = 0; + proc->types.pointer.drag_in_prog = 0; + proc->types.pointer.drag_sum.x = 0; + proc->types.pointer.drag_sum.y = 0; + proc->types.pointer.vect.x = 0; + proc->types.pointer.vect.y = 0; /*Search for 'top' attribute*/ - lv_obj_t * i = proc->act_obj; + lv_obj_t * i = proc->types.pointer.act_obj; lv_obj_t * last_top = NULL; while(i != NULL) { if(i->top != 0) last_top = i; @@ -641,42 +641,42 @@ static void indev_proc_press(lv_indev_proc_t * proc) } /*Send a signal about the press*/ - proc->act_obj->signal_cb(proc->act_obj, LV_SIGNAL_PRESSED, indev_act); - lv_obj_send_event(proc->act_obj, LV_EVENT_PRESSED); + proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_PRESSED, indev_act); + lv_obj_send_event(proc->types.pointer.act_obj, LV_EVENT_PRESSED); if(proc->reset_query != 0) return; } } - /*Calculate the vector*/ - proc->vect.x = proc->act_point.x - proc->last_point.x; - proc->vect.y = proc->act_point.y - proc->last_point.y; + /*Calculate the types.pointer.vector*/ + proc->types.pointer.vect.x = proc->types.pointer.act_point.x - proc->types.pointer.last_point.x; + proc->types.pointer.vect.y = proc->types.pointer.act_point.y - proc->types.pointer.last_point.y; - proc->drawg_throw_vect.x = (proc->drawg_throw_vect.x * 5) >> 3; - proc->drawg_throw_vect.y = (proc->drawg_throw_vect.y * 5) >> 3; + proc->types.pointer.drag_throw_vect.x = (proc->types.pointer.drag_throw_vect.x * 5) >> 3; + proc->types.pointer.drag_throw_vect.y = (proc->types.pointer.drag_throw_vect.y * 5) >> 3; - if(proc->drawg_throw_vect.x < 0) proc->drawg_throw_vect.x++; - else if(proc->drawg_throw_vect.x > 0) proc->drawg_throw_vect.x--; + if(proc->types.pointer.drag_throw_vect.x < 0) proc->types.pointer.drag_throw_vect.x++; + else if(proc->types.pointer.drag_throw_vect.x > 0) proc->types.pointer.drag_throw_vect.x--; - if(proc->drawg_throw_vect.y < 0) proc->drawg_throw_vect.y++; - else if(proc->drawg_throw_vect.y > 0) proc->drawg_throw_vect.y--; + if(proc->types.pointer.drag_throw_vect.y < 0) proc->types.pointer.drag_throw_vect.y++; + else if(proc->types.pointer.drag_throw_vect.y > 0) proc->types.pointer.drag_throw_vect.y--; - proc->drawg_throw_vect.x += (proc->vect.x * 4) >> 3; - proc->drawg_throw_vect.y += (proc->vect.y * 4) >> 3; + proc->types.pointer.drag_throw_vect.x += (proc->types.pointer.vect.x * 4) >> 3; + proc->types.pointer.drag_throw_vect.y += (proc->types.pointer.vect.y * 4) >> 3; - printf("dtv:%d\n", proc->drawg_throw_vect.y); + printf("dtv:%d\n", proc->types.pointer.drag_throw_vect.y); /*If there is active object and it can be dragged run the drag*/ - if(proc->act_obj != NULL) { - 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->types.pointer.act_obj != NULL) { + proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_PRESSING, indev_act); + lv_obj_send_event(proc->types.pointer.act_obj, LV_EVENT_PRESSING); if(proc->reset_query != 0) return; indev_drag(proc); if(proc->reset_query != 0) return; /*If there is no drag then check for long press time*/ - if(proc->drag_in_prog == 0 && proc->long_pr_sent == 0) { + if(proc->types.pointer.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_cb(pr_obj, LV_SIGNAL_LONG_PRESS, indev_act); @@ -691,7 +691,7 @@ static void indev_proc_press(lv_indev_proc_t * proc) } } /*Send long press repeated signal*/ - if(proc->drag_in_prog == 0 && proc->long_pr_sent == 1) { + if(proc->types.pointer.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_cb(pr_obj, LV_SIGNAL_LONG_PRESS_REP, indev_act); @@ -710,46 +710,45 @@ static void indev_proc_press(lv_indev_proc_t * proc) */ static void indev_proc_release(lv_indev_proc_t * proc) { - if(proc->wait_unil_release != 0) { - proc->act_obj = NULL; - proc->last_obj = NULL; + if(proc->types.pointer.wait_unil_release != 0) { + proc->types.pointer.act_obj = NULL; + proc->types.pointer.last_obj = NULL; proc->pr_timestamp = 0; proc->longpr_rep_timestamp = 0; - proc->wait_unil_release = 0; + proc->types.pointer.wait_unil_release = 0; } /*Forgot the act obj and send a released signal */ - if(proc->act_obj != NULL) { + if(proc->types.pointer.act_obj != NULL) { /* If the object was protected against press lost then it possible that - * the object is already not pressed but still it is the `act_obj`. - * In this case send the `LV_SIGNAL_RELEASED` if the indev is ON the `act_obj` */ - if(lv_obj_is_protected(proc->act_obj, LV_PROTECT_PRESS_LOST)) { + * the object is already not pressed but still it is the `types.pointer.act_obj`. + * In this case send the `LV_SIGNAL_RELEASED` if the indev is ON the `types.pointer.act_obj` */ + if(lv_obj_is_protected(proc->types.pointer.act_obj, LV_PROTECT_PRESS_LOST)) { /* 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_cb(proc->act_obj, LV_SIGNAL_RELEASED, indev_act); - if(proc->long_pr_sent == 0 && proc->drag_in_prog == 0) { - lv_obj_send_event(proc->act_obj, LV_EVENT_CLICKED); + lv_obj_t * obj_on = indev_search_obj(proc, proc->types.pointer.act_obj); + if(obj_on == proc->types.pointer.act_obj) { + proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_RELEASED, indev_act); + if(proc->long_pr_sent == 0 && proc->types.pointer.drag_in_prog == 0) { + lv_obj_send_event(proc->types.pointer.act_obj, LV_EVENT_CLICKED); } else { - lv_obj_send_event(proc->act_obj, LV_EVENT_RELEASED); + lv_obj_send_event(proc->types.pointer.act_obj, LV_EVENT_RELEASED); } } 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); + proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_PRESS_LOST, indev_act); + lv_obj_send_event(proc->types.pointer.act_obj, LV_SIGNAL_PRESS_LOST); } - } - /* The simple case: `act_obj` was not protected against press lost. + /* The simple case: `types.pointer.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_cb(proc->act_obj, LV_SIGNAL_RELEASED, indev_act); + proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_RELEASED, indev_act); - if(proc->long_pr_sent == 0 && proc->drag_in_prog == 0) { - lv_obj_send_event(proc->act_obj, LV_EVENT_CLICKED); + if(proc->long_pr_sent == 0 && proc->types.pointer.drag_in_prog == 0) { + lv_obj_send_event(proc->types.pointer.act_obj, LV_EVENT_CLICKED); } else { - lv_obj_send_event(proc->act_obj, LV_SIGNAL_RELEASED); + lv_obj_send_event(proc->types.pointer.act_obj, LV_SIGNAL_RELEASED); } } @@ -758,15 +757,15 @@ static void indev_proc_release(lv_indev_proc_t * proc) /*Handle click focus*/ #if USE_LV_GROUP /*Edit mode is not used by POINTER devices. So leave edit mode if we are in it*/ - lv_group_t * act_g = lv_obj_get_group(proc->act_obj); + lv_group_t * act_g = lv_obj_get_group(proc->types.pointer.act_obj); if(lv_group_get_editing(act_g)) { lv_group_set_editing(act_g, false); } /*Check, if the parent is in a group focus on it.*/ - if(lv_obj_is_protected(proc->act_obj, LV_PROTECT_CLICK_FOCUS) == false) { /*Respect the click protection*/ - lv_group_t * g = lv_obj_get_group(proc->act_obj); - lv_obj_t * parent = proc->act_obj; + if(lv_obj_is_protected(proc->types.pointer.act_obj, LV_PROTECT_CLICK_FOCUS) == false) { /*Respect the click protection*/ + lv_group_t * g = lv_obj_get_group(proc->types.pointer.act_obj); + lv_obj_t * parent = proc->types.pointer.act_obj; while(g == NULL) { parent = lv_obj_get_parent(parent); @@ -786,14 +785,14 @@ static void indev_proc_release(lv_indev_proc_t * proc) #endif if(proc->reset_query != 0) return; - proc->act_obj = NULL; + proc->types.pointer.act_obj = NULL; proc->pr_timestamp = 0; proc->longpr_rep_timestamp = 0; } /*The reset can be set in the signal function. * In case of reset query ignore the remaining parts.*/ - if(proc->last_obj != NULL && proc->reset_query == 0) { + if(proc->types.pointer.last_obj != NULL && proc->reset_query == 0) { indev_drag_throw(proc); if(proc->reset_query != 0) return; } @@ -809,15 +808,17 @@ static void indev_proc_release(lv_indev_proc_t * proc) static void indev_proc_reset_query_handler(lv_indev_t * indev) { if(indev->proc.reset_query) { - indev->proc.act_obj = NULL; - indev->proc.last_obj = NULL; - indev->proc.drag_limit_out = 0; - indev->proc.drag_in_prog = 0; + indev->proc.types.pointer.act_obj = NULL; + indev->proc.types.pointer.last_obj = NULL; + indev->proc.types.pointer.drag_limit_out = 0; + indev->proc.types.pointer.drag_in_prog = 0; indev->proc.long_pr_sent = 0; indev->proc.pr_timestamp = 0; indev->proc.longpr_rep_timestamp = 0; - indev->proc.drag_sum.x = 0; - indev->proc.drag_sum.y = 0; + indev->proc.types.pointer.drag_sum.x = 0; + indev->proc.types.pointer.drag_sum.y = 0; + indev->proc.types.pointer.drag_throw_vect.x = 0; + indev->proc.types.pointer.drag_throw_vect.y = 0; indev->proc.reset_query = 0; } } @@ -833,7 +834,7 @@ static lv_obj_t * indev_search_obj(const lv_indev_proc_t * proc, lv_obj_t * obj) /*If the point is on this object*/ /*Check its children too*/ - if(lv_area_is_point_on(&obj->coords, &proc->act_point)) { + if(lv_area_is_point_on(&obj->coords, &proc->types.pointer.act_point)) { lv_obj_t * i; LL_READ(obj->child_ll, i) { @@ -863,12 +864,12 @@ static lv_obj_t * indev_search_obj(const lv_indev_proc_t * proc, lv_obj_t * obj) } /** - * Handle the dragging of indev_proc_p->act_obj + * Handle the dragging of indev_proc_p->types.pointer.act_obj * @param indev pointer to a input device state */ static void indev_drag(lv_indev_proc_t * state) { - lv_obj_t * drag_obj = state->act_obj; + lv_obj_t * drag_obj = state->types.pointer.act_obj; /*If drag parent is active check recursively the drag_parent attribute*/ while(lv_obj_get_drag_parent(drag_obj) != false && @@ -881,24 +882,25 @@ static void indev_drag(lv_indev_proc_t * state) if(lv_obj_get_drag(drag_obj) == false) return; /*Count the movement by drag*/ - state->drag_sum.x += state->vect.x; - state->drag_sum.y += state->vect.y; + state->types.pointer.drag_sum.x += state->types.pointer.vect.x; + state->types.pointer.drag_sum.y += state->types.pointer.vect.y; /*Enough move?*/ - if(state->drag_limit_out == 0) { + if(state->types.pointer.drag_limit_out == 0) { /*If a move is greater then LV_DRAG_LIMIT then begin the drag*/ - if(LV_MATH_ABS(state->drag_sum.x) >= LV_INDEV_DRAG_LIMIT || - LV_MATH_ABS(state->drag_sum.y) >= LV_INDEV_DRAG_LIMIT) { - state->drag_limit_out = 1; + if(LV_MATH_ABS(state->types.pointer.drag_sum.x) >= LV_INDEV_DRAG_LIMIT || + LV_MATH_ABS(state->types.pointer.drag_sum.y) >= LV_INDEV_DRAG_LIMIT) { + state->types.pointer.drag_limit_out = 1; } } /*If the drag limit is exceeded handle the dragging*/ - if(state->drag_limit_out != 0) { + if(state->types.pointer.drag_limit_out != 0) { /*Set new position if the vector is not zero*/ - if(state->vect.x != 0 || - state->vect.y != 0) + if(state->types.pointer.vect.x != 0 || + state->types.pointer.vect.y != 0) { + /*Get the coordinates of the object and modify them*/ lv_coord_t act_x = lv_obj_get_x(drag_obj); lv_coord_t act_y = lv_obj_get_y(drag_obj); @@ -909,15 +911,16 @@ static void indev_drag(lv_indev_proc_t * state) lv_coord_t prev_par_w = lv_obj_get_width(lv_obj_get_parent(drag_obj)); lv_coord_t prev_par_h = lv_obj_get_height(lv_obj_get_parent(drag_obj)); - lv_obj_set_pos(drag_obj, act_x + state->vect.x, act_y + state->vect.y); + lv_obj_set_pos(drag_obj, act_x + state->types.pointer.vect.x, act_y + state->types.pointer.vect.y); /*Set the drag in progress flag if the object is really moved*/ if(drag_obj->coords.x1 != prev_x || drag_obj->coords.y1 != prev_y) { - if(state->drag_in_prog != 0) { /*Send the drag begin signal on first move*/ + if(state->types.pointer.drag_in_prog != 0) { /*Send the drag begin signal on first move*/ drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_BEGIN, indev_act); + if(state->reset_query != 0) return; } - state->drag_in_prog = 1; + state->types.pointer.drag_in_prog = 1; } /*If the object didn't moved then clear the invalidated areas*/ else { @@ -941,11 +944,10 @@ static void indev_drag(lv_indev_proc_t * state) */ static void indev_drag_throw(lv_indev_proc_t * proc) { - if(proc->drag_in_prog == 0) return; + if(proc->types.pointer.drag_in_prog == 0) return; /*Set new position if the vector is not zero*/ - lv_obj_t * drag_obj = proc->last_obj; - + lv_obj_t * drag_obj = proc->types.pointer.last_obj; /*If drag parent is active check recursively the drag_parent attribute*/ while(lv_obj_get_drag_parent(drag_obj) != false && @@ -959,42 +961,42 @@ static void indev_drag_throw(lv_indev_proc_t * proc) /*Return if the drag throw is not enabled*/ if(lv_obj_get_drag_throw(drag_obj) == false) { - proc->drag_in_prog = 0; + proc->types.pointer.drag_in_prog = 0; drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_END, indev_act); return; } /*Reduce the vectors*/ - proc->drawg_throw_vect.x = proc->drawg_throw_vect.x * (100 - LV_INDEV_DRAG_THROW) / 100; - proc->drawg_throw_vect.y = proc->drawg_throw_vect.y * (100 - LV_INDEV_DRAG_THROW) / 100; + proc->types.pointer.drag_throw_vect.x = proc->types.pointer.drag_throw_vect.x * (100 - LV_INDEV_DRAG_THROW) / 100; + proc->types.pointer.drag_throw_vect.y = proc->types.pointer.drag_throw_vect.y * (100 - LV_INDEV_DRAG_THROW) / 100; - if(proc->drawg_throw_vect.x != 0 || - proc->drawg_throw_vect.y != 0) { + if(proc->types.pointer.drag_throw_vect.x != 0 || + proc->types.pointer.drag_throw_vect.y != 0) { /*Get the coordinates and modify them*/ lv_area_t coords_ori; lv_obj_get_coords(drag_obj, &coords_ori); - lv_coord_t act_x = lv_obj_get_x(drag_obj) + proc->drawg_throw_vect.x; - lv_coord_t act_y = lv_obj_get_y(drag_obj) + proc->drawg_throw_vect.y; + lv_coord_t act_x = lv_obj_get_x(drag_obj) + proc->types.pointer.drag_throw_vect.x; + lv_coord_t act_y = lv_obj_get_y(drag_obj) + proc->types.pointer.drag_throw_vect.y; lv_obj_set_pos(drag_obj, act_x, act_y); lv_area_t coord_new; lv_obj_get_coords(drag_obj, &coord_new); /*If non of the coordinates are changed then do not continue throwing*/ - if((coords_ori.x1 == coord_new.x1 || proc->drawg_throw_vect.x == 0) && - (coords_ori.y1 == coord_new.y1 || proc->drawg_throw_vect.y == 0)) { - proc->drag_in_prog = 0; - proc->vect.x = 0; - proc->vect.y = 0; - proc->drawg_throw_vect.x = 0; - proc->drawg_throw_vect.y = 0; + if((coords_ori.x1 == coord_new.x1 || proc->types.pointer.drag_throw_vect.x == 0) && + (coords_ori.y1 == coord_new.y1 || proc->types.pointer.drag_throw_vect.y == 0)) { + proc->types.pointer.drag_in_prog = 0; + proc->types.pointer.vect.x = 0; + proc->types.pointer.vect.y = 0; + proc->types.pointer.drag_throw_vect.x = 0; + proc->types.pointer.drag_throw_vect.y = 0; 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*/ + /*If the types.pointer.vectors become 0 -> types.pointer.drag_in_prog = 0 and send a drag end signal*/ else { - proc->drag_in_prog = 0; + proc->types.pointer.drag_in_prog = 0; drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_END, indev_act); } diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index c8eb0c9c9..e63d43b2d 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -367,7 +367,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj) * the currently pressed object is deleted*/ lv_indev_t * indev = lv_indev_next(NULL); while(indev) { - if(indev->proc.act_obj == obj || indev->proc.last_obj == obj) { + if(indev->proc.types.pointer.act_obj == obj || indev->proc.types.pointer.last_obj == obj) { lv_indev_reset(indev); } indev = lv_indev_next(indev); @@ -1980,7 +1980,7 @@ static void delete_children(lv_obj_t * obj) * the currently pressed object is deleted*/ lv_indev_t * indev = lv_indev_next(NULL); while(indev) { - if(indev->proc.act_obj == obj || indev->proc.last_obj == obj) { + if(indev->proc.types.pointer.act_obj == obj || indev->proc.types.pointer.last_obj == obj) { lv_indev_reset(indev); } indev = lv_indev_next(indev); diff --git a/lv_hal/lv_hal_indev.h b/lv_hal/lv_hal_indev.h index 0391fb528..6c8101cf8 100644 --- a/lv_hal/lv_hal_indev.h +++ b/lv_hal/lv_hal_indev.h @@ -93,7 +93,7 @@ typedef struct _lv_indev_proc_t { lv_point_t last_point; lv_point_t vect; lv_point_t drag_sum; /*Count the dragged pixels to check LV_INDEV_DRAG_LIMIT*/ - lv_point_t drawg_throw_vect; + lv_point_t drag_throw_vect; struct _lv_obj_t * act_obj; struct _lv_obj_t * last_obj; @@ -101,12 +101,12 @@ typedef struct _lv_indev_proc_t { uint8_t drag_limit_out :1; uint8_t drag_in_prog :1; uint8_t wait_unil_release :1; - }; + }pointer; struct { /*Keypad data*/ lv_indev_state_t last_state; uint32_t last_key; - }; - }; + }keypad; + }types; uint32_t pr_timestamp; /*Pressed time stamp*/ uint32_t longpr_rep_timestamp; /*Long press repeat time stamp*/ diff --git a/lv_objx/lv_tileview.c b/lv_objx/lv_tileview.c index 094827229..33c1ac1ea 100644 --- a/lv_objx/lv_tileview.c +++ b/lv_objx/lv_tileview.c @@ -343,14 +343,14 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void /*Set horizontal drag constraint if no vertical constraint an dragged to valid x direction */ if(ext->drag_ver == 0 && - ((ext->drag_right_en && indev->proc.drag_sum.x <= -LV_INDEV_DRAG_LIMIT) || - (ext->drag_left_en && indev->proc.drag_sum.x >= LV_INDEV_DRAG_LIMIT))) { + ((ext->drag_right_en && indev->proc.types.pointer.drag_sum.x <= -LV_INDEV_DRAG_LIMIT) || + (ext->drag_left_en && indev->proc.types.pointer.drag_sum.x >= LV_INDEV_DRAG_LIMIT))) { ext->drag_hor = 1; } /*Set vertical drag constraint if no horizontal constraint an dragged to valid y direction */ if(ext->drag_hor == 0 && - ((ext->drag_bottom_en && indev->proc.drag_sum.y <= -LV_INDEV_DRAG_LIMIT) || - (ext->drag_top_en && indev->proc.drag_sum.y >= LV_INDEV_DRAG_LIMIT))) { + ((ext->drag_bottom_en && indev->proc.types.pointer.drag_sum.y <= -LV_INDEV_DRAG_LIMIT) || + (ext->drag_top_en && indev->proc.types.pointer.drag_sum.y >= LV_INDEV_DRAG_LIMIT))) { ext->drag_ver = 1; } @@ -369,7 +369,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void lv_coord_t h = lv_obj_get_height(tileview); lv_coord_t w = lv_obj_get_width(tileview); if(ext->drag_top_en == 0) { - if(y > -(ext->act_id.y * h) && indev->proc.vect.y > 0 && ext->drag_hor == 0) { + if(y > -(ext->act_id.y * h) && indev->proc.types.pointer.vect.y > 0 && ext->drag_hor == 0) { if(ext->page.edge_flash.enabled && ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 && ext->page.edge_flash.top_ip == 0 && ext->page.edge_flash.bottom_ip == 0) { @@ -380,7 +380,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void lv_obj_set_y(scrl, -ext->act_id.y * h); } } - if(ext->drag_bottom_en == 0 && indev->proc.vect.y < 0 && ext->drag_hor == 0) { + if(ext->drag_bottom_en == 0 && indev->proc.types.pointer.vect.y < 0 && ext->drag_hor == 0) { if(y < -(ext->act_id.y * h)) { if(ext->page.edge_flash.enabled && ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 && @@ -393,7 +393,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void lv_obj_set_y(scrl, -ext->act_id.y * h); } if(ext->drag_left_en == 0) { - if(x > -(ext->act_id.x * w) && indev->proc.vect.x > 0 && ext->drag_ver == 0) { + if(x > -(ext->act_id.x * w) && indev->proc.types.pointer.vect.x > 0 && ext->drag_ver == 0) { if(ext->page.edge_flash.enabled && ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 && ext->page.edge_flash.top_ip == 0 && ext->page.edge_flash.bottom_ip == 0) { @@ -404,7 +404,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void lv_obj_set_x(scrl, -ext->act_id.x * w); } } - if(ext->drag_right_en == 0 && indev->proc.vect.x < 0 && ext->drag_ver == 0) { + if(ext->drag_right_en == 0 && indev->proc.types.pointer.vect.x < 0 && ext->drag_ver == 0) { if(x < -(ext->act_id.x * w)) { if(ext->page.edge_flash.enabled && ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 && @@ -475,14 +475,15 @@ static lv_res_t element_signal_func(lv_obj_t * element, lv_signal_t sign, void * * let the tileview to finish the move.*/ lv_indev_t * indev = lv_indev_get_act(); lv_tileview_ext_t * ext = lv_obj_get_ext_attr(tileview); - if(indev->proc.drag_in_prog && (ext->drag_hor || ext->drag_ver)) { + if(lv_indev_is_dragging(indev) && (ext->drag_hor || ext->drag_ver)) { lv_obj_t * drag_obj = element; while(lv_obj_get_drag_parent(drag_obj)) { drag_obj = lv_obj_get_parent(drag_obj); if(drag_obj == NULL) break; } - indev->proc.drag_in_prog = 0; + + indev->proc.types.pointer.drag_in_prog = 0; if(drag_obj) drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_END, NULL); }