mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
Limit extra button click area of button matrix's buttons. Fixes #1712
This commit is contained in:
parent
c8cc9db7f0
commit
1815ff4b99
@ -13,7 +13,9 @@
|
||||
- Fix setting local style property multiple times
|
||||
- Add missing background drawing and radius handling to image button
|
||||
- Allow adding extra label to list buttons
|
||||
- Fix crash if `lv_table_set_col_cnt` is called before `lv_table_set_row_cnt` for the first time
|
||||
- Fix overflow in large image transformations
|
||||
- Limit extra button click area of button matrix's buttons. With large paddings it was counter intuitive. (Gaps are mapped to button when clicked).
|
||||
|
||||
## v7.3.0 (04.08.2020)
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_OBJX_NAME "lv_btnmatrix"
|
||||
#define BTN_EXTRA_CLICK_AREA_MAX (LV_DPI / 4)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -1203,18 +1204,23 @@ static uint16_t get_button_from_point(lv_obj_t * btnm, lv_point_t * p)
|
||||
/*Get the half inner padding. Button look larger with this value. (+1 for rounding error)*/
|
||||
pinner = (pinner / 2) + 1 + (pinner & 1);
|
||||
|
||||
pinner = LV_MATH_MIN(pinner, BTN_EXTRA_CLICK_AREA_MAX);
|
||||
pright = LV_MATH_MIN(pright, BTN_EXTRA_CLICK_AREA_MAX);
|
||||
ptop = LV_MATH_MIN(ptop, BTN_EXTRA_CLICK_AREA_MAX);
|
||||
pbottom = LV_MATH_MIN(pbottom, BTN_EXTRA_CLICK_AREA_MAX);
|
||||
|
||||
for(i = 0; i < ext->btn_cnt; i++) {
|
||||
lv_area_copy(&btn_area, &ext->button_areas[i]);
|
||||
if(btn_area.x1 <= pleft) btn_area.x1 = btnm_cords.x1;
|
||||
if(btn_area.x1 <= pleft) btn_area.x1 += btnm_cords.x1 - LV_MATH_MIN(pleft, BTN_EXTRA_CLICK_AREA_MAX);
|
||||
else btn_area.x1 += btnm_cords.x1 - pinner;
|
||||
|
||||
if(btn_area.y1 <= ptop) btn_area.y1 = btnm_cords.y1;
|
||||
if(btn_area.y1 <= ptop) btn_area.y1 += btnm_cords.y1 - LV_MATH_MIN(ptop, BTN_EXTRA_CLICK_AREA_MAX);
|
||||
else btn_area.y1 += btnm_cords.y1 - pinner;
|
||||
|
||||
if(btn_area.x2 >= w - pright - 2) btn_area.x2 = btnm_cords.x2; /*-2 for rounding error*/
|
||||
if(btn_area.x2 >= w - pright - 2) btn_area.x2 += btnm_cords.x1 + LV_MATH_MIN(pright, BTN_EXTRA_CLICK_AREA_MAX); /*-2 for rounding error*/
|
||||
else btn_area.x2 += btnm_cords.x1 + pinner;
|
||||
|
||||
if(btn_area.y2 >= h - pbottom - 2) btn_area.y2 = btnm_cords.y2; /*-2 for rounding error*/
|
||||
if(btn_area.y2 >= h - pbottom - 2) btn_area.y2 += btnm_cords.y1 + LV_MATH_MIN(pbottom, BTN_EXTRA_CLICK_AREA_MAX); /*-2 for rounding error*/
|
||||
else btn_area.y2 += btnm_cords.y1 + pinner;
|
||||
|
||||
if(_lv_area_is_point_on(&btn_area, p, 0) != false) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user