mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
lv_roller: fix misalignment when an other obj is cliked while rolling
This commit is contained in:
parent
71e950614f
commit
bbb0d2f60e
@ -687,12 +687,14 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
if(proc->wait_until_release != 0) return;
|
||||
|
||||
lv_disp_t * disp = indev_act->driver.disp;
|
||||
bool new_obj_searched = false;
|
||||
|
||||
/*If there is no last object then search*/
|
||||
if(indev_obj_act == NULL) {
|
||||
indev_obj_act = indev_search_obj(proc, lv_disp_get_layer_sys(disp));
|
||||
if(indev_obj_act == NULL) indev_obj_act = indev_search_obj(proc, lv_disp_get_layer_top(disp));
|
||||
if(indev_obj_act == NULL) indev_obj_act = indev_search_obj(proc, lv_disp_get_scr_act(disp));
|
||||
new_obj_searched = true;
|
||||
}
|
||||
/*If there is last object but it is not dragged and not protected also search*/
|
||||
else if(proc->types.pointer.drag_in_prog == 0 &&
|
||||
@ -700,14 +702,21 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
indev_obj_act = indev_search_obj(proc, lv_disp_get_layer_sys(disp));
|
||||
if(indev_obj_act == NULL) indev_obj_act = indev_search_obj(proc, lv_disp_get_layer_top(disp));
|
||||
if(indev_obj_act == NULL) indev_obj_act = indev_search_obj(proc, lv_disp_get_scr_act(disp));
|
||||
new_obj_searched = true;
|
||||
}
|
||||
/*If a dragable or a protected object was the last then keep it*/
|
||||
else {
|
||||
}
|
||||
|
||||
/*The last object might have drag throw. Stop it manually*/
|
||||
if(new_obj_searched && proc->types.pointer.last_obj) {
|
||||
proc->types.pointer.drag_throw_vect.x = 0;
|
||||
proc->types.pointer.drag_throw_vect.y = 0;
|
||||
indev_drag_throw(proc);
|
||||
}
|
||||
|
||||
/*If a new object was found reset some variables and send a pressed signal*/
|
||||
if(indev_obj_act != proc->types.pointer.act_obj) {
|
||||
|
||||
proc->types.pointer.last_point.x = proc->types.pointer.act_point.x;
|
||||
proc->types.pointer.last_point.y = proc->types.pointer.act_point.y;
|
||||
|
||||
@ -720,6 +729,7 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
if(indev_reset_check(proc)) return;
|
||||
lv_event_send(last_obj, LV_EVENT_PRESS_LOST, NULL);
|
||||
if(indev_reset_check(proc)) return;
|
||||
|
||||
}
|
||||
|
||||
proc->types.pointer.act_obj = indev_obj_act; /*Save the pressed object*/
|
||||
@ -1108,9 +1118,6 @@ static void indev_drag(lv_indev_proc_t * state)
|
||||
lv_obj_set_y(drag_obj, act_y + state->types.pointer.vect.y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*If the object didn't moved then clear the invalidated areas*/
|
||||
if(drag_obj->coords.x1 == prev_x && drag_obj->coords.y1 == prev_y) {
|
||||
// state->types.pointer.drag_in_prog = 0;
|
||||
|
@ -232,6 +232,7 @@ void lv_ddlist_set_fix_height(lv_obj_t * ddlist, lv_coord_t h)
|
||||
*/
|
||||
void lv_ddlist_set_fix_width(lv_obj_t * ddlist, lv_coord_t w)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
if(w == 0) {
|
||||
lv_cont_set_fit2(ddlist, LV_FIT_TIGHT, lv_cont_get_fit_bottom(ddlist));
|
||||
} else {
|
||||
@ -239,6 +240,12 @@ void lv_ddlist_set_fix_width(lv_obj_t * ddlist, lv_coord_t w)
|
||||
lv_obj_set_width(ddlist, w);
|
||||
}
|
||||
|
||||
switch(lv_label_get_align(ext->label)) {
|
||||
case LV_LABEL_ALIGN_LEFT: lv_obj_align(ext->label, NULL, LV_ALIGN_IN_LEFT_MID, 0, 0); break;
|
||||
case LV_LABEL_ALIGN_CENTER: lv_obj_align(ext->label, NULL, LV_ALIGN_CENTER, 0, 0); break;
|
||||
case LV_LABEL_ALIGN_RIGHT: lv_obj_align(ext->label, NULL, LV_ALIGN_IN_RIGHT_MID, 0, 0); break;
|
||||
}
|
||||
|
||||
lv_ddlist_refr_size(ddlist, false);
|
||||
}
|
||||
|
||||
|
@ -176,9 +176,17 @@ void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mo
|
||||
void lv_roller_set_align(lv_obj_t * roller, lv_label_align_t align)
|
||||
{
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||
lv_mem_assert(ext);
|
||||
if(ext->ddlist.label == NULL) return; /*Probably the roller is being deleted if the label is NULL.*/
|
||||
lv_label_set_align(ext->ddlist.label, align);
|
||||
|
||||
lv_obj_t * label = ext->ddlist.label;
|
||||
|
||||
if(label == NULL) return; /*Probably the roller is being deleted if the label is NULL.*/
|
||||
lv_label_set_align(label, align);
|
||||
|
||||
switch(lv_label_get_align(label)) {
|
||||
case LV_LABEL_ALIGN_LEFT: lv_obj_align(label, NULL, LV_ALIGN_IN_LEFT_MID, 0, 0); break;
|
||||
case LV_LABEL_ALIGN_CENTER: lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); break;
|
||||
case LV_LABEL_ALIGN_RIGHT: lv_obj_align(label, NULL, LV_ALIGN_IN_RIGHT_MID, 0, 0); break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user