1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-02-04 07:13:00 +08:00

chore(anim): define anim on/off as true/false

Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
Neo Xu 2024-12-21 11:18:20 +08:00 committed by Gabor Kiss-Vamosi
parent 17b76773a3
commit 2d8ff35bfb
2 changed files with 6 additions and 7 deletions

View File

@ -306,7 +306,7 @@ void lv_obj_scroll_by_bounded(lv_obj_t * obj, int32_t dx, int32_t dy, lv_anim_en
void lv_obj_scroll_by(lv_obj_t * obj, int32_t dx, int32_t dy, lv_anim_enable_t anim_en) void lv_obj_scroll_by(lv_obj_t * obj, int32_t dx, int32_t dy, lv_anim_enable_t anim_en)
{ {
if(dx == 0 && dy == 0) return; if(dx == 0 && dy == 0) return;
if(anim_en == LV_ANIM_ON) { if(anim_en) {
lv_display_t * d = lv_obj_get_display(obj); lv_display_t * d = lv_obj_get_display(obj);
lv_anim_t a; lv_anim_t a;
lv_anim_init(&a); lv_anim_init(&a);
@ -801,7 +801,7 @@ static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_p
if((scroll_dir & LV_DIR_TOP) == 0 && y_scroll < 0) y_scroll = 0; if((scroll_dir & LV_DIR_TOP) == 0 && y_scroll < 0) y_scroll = 0;
if((scroll_dir & LV_DIR_BOTTOM) == 0 && y_scroll > 0) y_scroll = 0; if((scroll_dir & LV_DIR_BOTTOM) == 0 && y_scroll > 0) y_scroll = 0;
scroll_value->x += anim_en == LV_ANIM_OFF ? 0 : x_scroll; scroll_value->x += anim_en ? x_scroll : 0;
scroll_value->y += anim_en == LV_ANIM_OFF ? 0 : y_scroll; scroll_value->y += anim_en ? y_scroll : 0;
lv_obj_scroll_by(parent, x_scroll, y_scroll, anim_en); lv_obj_scroll_by(parent, x_scroll, y_scroll, anim_en);
} }

View File

@ -80,10 +80,9 @@ LV_EXPORT_CONST_INT(LV_ANIM_PLAYTIME_INFINITE);
**********************/ **********************/
/** Can be used to indicate if animations are enabled or disabled in a case*/ /** Can be used to indicate if animations are enabled or disabled in a case*/
typedef enum { #define LV_ANIM_OFF false
LV_ANIM_OFF, #define LV_ANIM_ON true
LV_ANIM_ON, typedef bool lv_anim_enable_t;
} lv_anim_enable_t;
/** Get the current value during an animation*/ /** Get the current value during an animation*/
typedef int32_t (*lv_anim_path_cb_t)(const lv_anim_t *); typedef int32_t (*lv_anim_path_cb_t)(const lv_anim_t *);