mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-21 06:53:01 +08:00
arc: handle out of bounds start/end values
This commit is contained in:
parent
5c1eaf7a3a
commit
291545224c
@ -132,6 +132,7 @@ void lv_arc_set_start_angle(lv_obj_t * arc, int16_t start)
|
||||
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
||||
|
||||
if(start > 360) start -= 360;
|
||||
if(start < 0) start += 360;
|
||||
|
||||
/*Too large move, the whole arc need to be invalidated anyway*/
|
||||
if(LV_MATH_ABS(start - ext->arc_angle_start) >= 180) {
|
||||
@ -164,6 +165,9 @@ void lv_arc_set_end_angle(lv_obj_t * arc, int16_t end)
|
||||
|
||||
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
||||
|
||||
if(end > 360) end -= 360;
|
||||
if(end < 0) end += 360;
|
||||
|
||||
/*Too large move, the whole arc need to be invalidated anyway*/
|
||||
if(LV_MATH_ABS(end - ext->arc_angle_end) >= 180) {
|
||||
lv_obj_invalidate(arc);
|
||||
@ -191,14 +195,17 @@ void lv_arc_set_end_angle(lv_obj_t * arc, int16_t end)
|
||||
* @param start the start angle
|
||||
* @param end the end angle
|
||||
*/
|
||||
void lv_arc_set_angles(lv_obj_t * arc, uint16_t start, uint16_t end)
|
||||
void lv_arc_set_angles(lv_obj_t * arc, int16_t start, int16_t end)
|
||||
{
|
||||
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
|
||||
|
||||
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
||||
|
||||
if(end > 360) end -= 360;
|
||||
if(end < 0) end += 360;
|
||||
|
||||
if(start > 360) start -= 360;
|
||||
if(start < 0) start += 360;
|
||||
|
||||
inv_arc_area(arc, ext->arc_angle_start, ext->arc_angle_end);
|
||||
|
||||
@ -220,6 +227,7 @@ void lv_arc_set_bg_start_angle(lv_obj_t * arc, int16_t start)
|
||||
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
||||
|
||||
if(start > 360) start -= 360;
|
||||
if(start < 0) start += 360;
|
||||
|
||||
/*Too large move, the whole arc need to be invalidated anyway*/
|
||||
if(LV_MATH_ABS(start - ext->bg_angle_start) >= 180) {
|
||||
@ -253,6 +261,7 @@ void lv_arc_set_bg_end_angle(lv_obj_t * arc, int16_t end)
|
||||
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
||||
|
||||
if(end > 360) end -= 360;
|
||||
if(end < 0) end += 360;
|
||||
|
||||
/*Too large move, the whole arc need to be invalidated anyway*/
|
||||
if(LV_MATH_ABS(end - ext->bg_angle_end) >= 180) {
|
||||
@ -280,14 +289,17 @@ void lv_arc_set_bg_end_angle(lv_obj_t * arc, int16_t end)
|
||||
* @param start the start angle
|
||||
* @param end the end angle
|
||||
*/
|
||||
void lv_arc_set_bg_angles(lv_obj_t * arc, uint16_t start, uint16_t end)
|
||||
void lv_arc_set_bg_angles(lv_obj_t * arc, int16_t start, int16_t end)
|
||||
{
|
||||
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
|
||||
|
||||
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
||||
|
||||
if(end > 360) end -= 360;
|
||||
if(end < 0) end += 360;
|
||||
|
||||
if(start > 360) start -= 360;
|
||||
if(start < 0) start += 360;
|
||||
|
||||
inv_arc_area(arc, ext->bg_angle_start, ext->bg_angle_end);
|
||||
|
||||
|
@ -86,7 +86,7 @@ void lv_arc_set_end_angle(lv_obj_t * arc, int16_t end);
|
||||
* @param start the start angle
|
||||
* @param end the end angle
|
||||
*/
|
||||
void lv_arc_set_angles(lv_obj_t * arc, uint16_t start, uint16_t end);
|
||||
void lv_arc_set_angles(lv_obj_t * arc, int16_t start, int16_t end);
|
||||
|
||||
/**
|
||||
* Set the start angle of an arc background. 0 deg: right, 90 bottom, etc.
|
||||
@ -108,7 +108,7 @@ void lv_arc_set_bg_end_angle(lv_obj_t * arc, int16_t end);
|
||||
* @param start the start angle
|
||||
* @param end the end angle
|
||||
*/
|
||||
void lv_arc_set_bg_angles(lv_obj_t * arc, uint16_t start, uint16_t end);
|
||||
void lv_arc_set_bg_angles(lv_obj_t * arc, int16_t start, int16_t end);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
|
Loading…
x
Reference in New Issue
Block a user