1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

add LV_PROTECT_PRESS_LOST

This commit is contained in:
Gabor Kiss-Vamosi 2018-02-24 11:26:06 +01:00
parent 6e6a7de1a8
commit 7310a2c6cc
5 changed files with 14 additions and 11 deletions

View File

@ -346,12 +346,13 @@ static void indev_proc_press(lv_indev_proc_t * info)
pr_obj = indev_search_obj(info, lv_layer_top()); pr_obj = indev_search_obj(info, lv_layer_top());
if(pr_obj == NULL) pr_obj = indev_search_obj(info, lv_scr_act()); if(pr_obj == NULL) pr_obj = indev_search_obj(info, lv_scr_act());
} }
/*If there is last object but it is not dragged also search*/ /*If there is last object but it is not dragged and not protected also search*/
else if(info->drag_in_prog == 0) {/*Now act_obj != NULL*/ else if(info->drag_in_prog == 0 &&
lv_obj_is_protected(info->act_obj, LV_PROTECT_PRESS_LOST) == false) {/*Now act_obj != NULL*/
pr_obj = indev_search_obj(info, lv_layer_top()); pr_obj = indev_search_obj(info, lv_layer_top());
if(pr_obj == NULL) pr_obj = indev_search_obj(info, lv_scr_act()); if(pr_obj == NULL) pr_obj = indev_search_obj(info, lv_scr_act());
} }
/*If a dragable object was the last then keep it*/ /*If a dragable or a protected object was the last then keep it*/
else { else {
} }

View File

@ -117,8 +117,9 @@ typedef struct _lv_obj_t
void * free_ptr; /*Application specific pointer (set it freely)*/ void * free_ptr; /*Application specific pointer (set it freely)*/
#endif #endif
void * group_p; /*Pointer to the group of the object*/ #if USE_LV_GROUP != 0
void * group_p; /*Pointer to the group of the object*/
#endif
/*Attributes and states*/ /*Attributes and states*/
uint8_t click :1; /*1: Can be pressed by an input device*/ uint8_t click :1; /*1: Can be pressed by an input device*/
uint8_t drag :1; /*1: Enable the dragging*/ uint8_t drag :1; /*1: Enable the dragging*/
@ -147,6 +148,7 @@ typedef enum
LV_PROTECT_PARENT = 0x02, /*Prevent automatic parent change (e.g. in lv_page)*/ LV_PROTECT_PARENT = 0x02, /*Prevent automatic parent change (e.g. in lv_page)*/
LV_PROTECT_POS = 0x04, /*Prevent automatic positioning (e.g. in lv_cont layout)*/ LV_PROTECT_POS = 0x04, /*Prevent automatic positioning (e.g. in lv_cont layout)*/
LV_PROTECT_FOLLOW = 0x08, /*Prevent the object be followed in automatic ordering (e.g. in lv_cont PRETTY layout)*/ LV_PROTECT_FOLLOW = 0x08, /*Prevent the object be followed in automatic ordering (e.g. in lv_cont PRETTY layout)*/
LV_PROTECT_PRESS_LOST= 0x10, /*TODO */
}lv_protect_t; }lv_protect_t;
typedef enum typedef enum

View File

@ -1755,7 +1755,7 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
bool line_ready; bool line_ready;
for(line = 1; line <= radius + swidth; line++) { /*Check all rows and make the 1D blur to 2D*/ for(line = 1; line <= radius + swidth; line++) { /*Check all rows and make the 1D blur to 2D*/
line_ready = false; line_ready = false;
for(col = 1; col < radius + swidth + 1; col++) { /*Check all pixels in a 1D blur line (from the origo to last shadow pixel (radius + swidth))*/ for(col = 1; col < radius + swidth + 10; col++) { /*Check all pixels in a 1D blur line (from the origo to last shadow pixel (radius + swidth))*/
/*Sum the opacities from the lines above and below this 'row'*/ /*Sum the opacities from the lines above and below this 'row'*/
int16_t line_rel; int16_t line_rel;

View File

@ -81,7 +81,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_set_design_func(ext->scrl, lv_scrl_design); lv_obj_set_design_func(ext->scrl, lv_scrl_design);
lv_obj_set_drag(ext->scrl, true); lv_obj_set_drag(ext->scrl, true);
lv_obj_set_drag_throw(ext->scrl, true); lv_obj_set_drag_throw(ext->scrl, true);
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT); lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST);
lv_cont_set_fit(ext->scrl, false, true); lv_cont_set_fit(ext->scrl, false, true);
/* Add the signal function only if 'scrolling' is created /* Add the signal function only if 'scrolling' is created

View File

@ -1,3 +1,4 @@
/** /**
* @file lv_slider.c * @file lv_slider.c
* *
@ -77,6 +78,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy)
/*Init the new slider slider*/ /*Init the new slider slider*/
if(copy == NULL) { if(copy == NULL) {
lv_obj_set_click(new_slider, true); lv_obj_set_click(new_slider, true);
lv_obj_set_protect(new_slider, LV_PROTECT_PRESS_LOST);
/*Set the default styles*/ /*Set the default styles*/
lv_theme_t *th = lv_theme_get_current(); lv_theme_t *th = lv_theme_get_current();
@ -421,14 +423,12 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
lv_style_t *knob_style = lv_slider_get_style(slider, LV_SLIDER_STYLE_KNOB); lv_style_t *knob_style = lv_slider_get_style(slider, LV_SLIDER_STYLE_KNOB);
lv_coord_t shadow_w = knob_style->body.shadow.width; lv_coord_t shadow_w = knob_style->body.shadow.width;
if(ext->knob_in == 0) { if(ext->knob_in == 0) {
/* The smaller size is the knob diameter /* The smaller size is the knob diameter*/
* +2 for the possible rounding error*/ lv_coord_t x = LV_MATH_MIN(w / 2 + 1 + shadow_w, h / 2 + 1 + shadow_w);
lv_coord_t x = LV_MATH_MIN(w / 2 + 2 + shadow_w, h / 2 + 2 + shadow_w);
if(slider->ext_size < x) slider->ext_size = x; if(slider->ext_size < x) slider->ext_size = x;
} else { } else {
lv_coord_t pad = LV_MATH_MIN(style->body.padding.hor, style->body.padding.ver); lv_coord_t pad = LV_MATH_MIN(style->body.padding.hor, style->body.padding.ver);
if(pad < 0) pad = -pad; if(pad < 0) pad = -pad;
if(pad < 1) pad = 1; /*For possible rounding errors*/
if(slider->ext_size < pad) slider->ext_size = pad; if(slider->ext_size < pad) slider->ext_size = pad;
if(slider->ext_size < shadow_w) slider->ext_size = shadow_w; if(slider->ext_size < shadow_w) slider->ext_size = shadow_w;