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

unify lv_obj_..._ext_click_area... API

This commit is contained in:
Gabor Kiss-Vamosi 2019-05-24 06:26:56 +02:00
parent 0f1e260155
commit d3d9fde245
2 changed files with 70 additions and 46 deletions

View File

@ -1081,9 +1081,10 @@ void lv_obj_set_ext_click_area(lv_obj_t * obj, uint8_t w, uint8_t h)
}
#endif
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
/**
* Set the size of an extended clickable area
* If TINY mode is used, only the largest of the horizontal and vertical padding
* values are considered.
* @param obj pointer to an object
* @param left extended clickable are on the left [px]
* @param right extended clickable are on the right [px]
@ -1092,12 +1093,16 @@ void lv_obj_set_ext_click_area(lv_obj_t * obj, uint8_t w, uint8_t h)
*/
void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right, lv_coord_t top, lv_coord_t bottom)
{
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
obj->ext_click_pad.x1 = left;
obj->ext_click_pad.x2 = right;
obj->ext_click_pad.y1 = top;
obj->ext_click_pad.y2 = bottom;
}
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
obj->ext_click_pad_hor = LV_MATH_MAX(left, right);
obj->ext_click_pad_ver = LV_MATH_MAX(top, bottom);
#endif
}
/*---------------------
* Appearance set
@ -1674,39 +1679,69 @@ bool lv_obj_get_auto_realign(lv_obj_t * obj)
#endif
}
/**
* Get the left padding of extended clickable area
* @param obj pointer to an object
* @return the extended left padding
*/
lv_coord_t lv_obj_get_ext_click_pad_left(const lv_obj_t * obj)
{
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
/**
* Get the horizontal padding of extended clickable area
* @param obj pointer to an object
* @return the horizontal padding
*/
uint8_t lv_obj_get_ext_click_pad_hor(const lv_obj_t * obj)
{
return obj->ext_click_pad_hor;
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
return obj->ext_click_pad.x1;
#else
return 0;
#endif
}
/**
* Get the vertical padding of extended clickable area
* Get the right padding of extended clickable area
* @param obj pointer to an object
* @return the vertical padding
* @return the extended right padding
*/
uint8_t lv_obj_get_ext_click_pad_ver(const lv_obj_t * obj)
lv_coord_t lv_obj_get_ext_click_pad_right(const lv_obj_t * obj)
{
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
return obj->ext_click_pad_hor;
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
return obj->ext_click_pad.x2;
#else
return 0;
#endif
}
/**
* Get the top padding of extended clickable area
* @param obj pointer to an object
* @return the extended top padding
*/
lv_coord_t lv_obj_get_ext_click_pad_top(const lv_obj_t * obj)
{
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
return obj->ext_click_pad_ver;
}
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
return obj->ext_click_pad.y1;
#else
return 0;
#endif
}
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
/**
* Get the horizontal padding of extended clickable area
* Get the bottom padding of extended clickable area
* @param obj pointer to an object
* @return the horizontal padding
* @return the extended bottom padding
*/
const lv_area_t * lv_obj_get_ext_click_pad(const lv_obj_t * obj)
lv_coord_t lv_obj_get_ext_click_pad_bottom(const lv_obj_t * obj)
{
return &obj->ext_click_pad;
}
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
return obj->ext_click_pad_ver
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
return obj->ext_click_pad.y2;
#else
return 0;
#endif
}
/**
* Get the extended size attribute of an object

View File

@ -398,17 +398,6 @@ void lv_obj_realign(lv_obj_t * obj);
*/
void lv_obj_set_auto_realign(lv_obj_t * obj, bool en);
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
/**
* Set the size of an extended clickable area
* @param obj pointer to an object
* @param w extended width to both sides
* @param h extended height to both sides
*/
void lv_obj_set_ext_click_area(lv_obj_t * obj, uint8_t w, uint8_t h);
#endif
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
/**
* Set the size of an extended clickable area
* @param obj pointer to an object
@ -418,7 +407,6 @@ void lv_obj_set_ext_click_area(lv_obj_t * obj, uint8_t w, uint8_t h);
* @param bottom extended clickable are on the bottom [px]
*/
void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right, lv_coord_t top, lv_coord_t bottom);
#endif
/*---------------------
* Appearance set
@ -727,32 +715,33 @@ lv_coord_t lv_obj_get_height_fit(lv_obj_t * obj);
*/
bool lv_obj_get_auto_realign(lv_obj_t * obj);
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
/**
* Get the horizontal padding of extended clickable area
* Get the left padding of extended clickable area
* @param obj pointer to an object
* @return the horizontal padding
* @return the extended left padding
*/
uint8_t lv_obj_get_ext_click_pad_hor(const lv_obj_t * obj);
lv_coord_t lv_obj_get_ext_click_pad_left(const lv_obj_t * obj);
/**
* Get the vertical padding of extended clickable area
* Get the right padding of extended clickable area
* @param obj pointer to an object
* @return the vertical padding
* @return the extended right padding
*/
uint8_t lv_obj_get_ext_click_pad_ver(const lv_obj_t * obj);
lv_coord_t lv_obj_get_ext_click_pad_right(const lv_obj_t * obj);
#endif
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
/**
* Get the horizontal padding of extended clickable area
* Get the top padding of extended clickable area
* @param obj pointer to an object
* @return the horizontal padding
* @return the extended top padding
*/
const lv_area_t * lv_obj_get_ext_click_pad(const lv_obj_t * obj);
#endif
lv_coord_t lv_obj_get_ext_click_pad_top(const lv_obj_t * obj);
/**
* Get the bottom padding of extended clickable area
* @param obj pointer to an object
* @return the extended bottom padding
*/
lv_coord_t lv_obj_get_ext_click_pad_bottom(const lv_obj_t * obj);
/**
* Get the extended size attribute of an object