mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
Merge b2d201dba779abe710e0704a86c77932e0b46acb into dev
This commit is contained in:
commit
2f7369e771
@ -737,6 +737,7 @@ static void lv_bar_set_value_with_anim(lv_obj_t * bar, int16_t new_value, int16_
|
||||
anim_info->anim_start = anim_info->anim_end;
|
||||
anim_info->anim_end = new_value;
|
||||
}
|
||||
*value_ptr = new_value;
|
||||
/* Stop the previous animation if it exists */
|
||||
lv_anim_del(anim_info, NULL);
|
||||
|
||||
|
@ -126,8 +126,8 @@ void lv_switch_on(lv_obj_t * sw, lv_anim_enable_t anim)
|
||||
#if LV_USE_ANIMATION == 0
|
||||
anim = LV_ANIM_OFF;
|
||||
#endif
|
||||
lv_switch_ext_t * ext = lv_obj_get_ext_attr(sw);
|
||||
ext->state = 1;
|
||||
if(lv_bar_get_value(sw) == 1)
|
||||
return;
|
||||
lv_bar_set_value(sw, 1, anim);
|
||||
lv_obj_add_state(sw, LV_STATE_CHECKED);
|
||||
}
|
||||
@ -144,8 +144,8 @@ void lv_switch_off(lv_obj_t * sw, lv_anim_enable_t anim)
|
||||
#if LV_USE_ANIMATION == 0
|
||||
anim = LV_ANIM_OFF;
|
||||
#endif
|
||||
lv_switch_ext_t * ext = lv_obj_get_ext_attr(sw);
|
||||
ext->state = 0;
|
||||
if(lv_bar_get_value(sw) == 0)
|
||||
return;
|
||||
lv_bar_set_value(sw, 0, anim);
|
||||
lv_obj_clear_state(sw, LV_STATE_CHECKED);
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ typedef struct {
|
||||
lv_bar_ext_t bar; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_style_list_t style_knob; /*Style of the knob*/
|
||||
uint8_t state : 1; /*The current state*/
|
||||
} lv_switch_ext_t;
|
||||
|
||||
/**
|
||||
@ -112,8 +111,7 @@ static inline void lv_switch_set_anim_time(lv_obj_t * sw, uint16_t anim_time)
|
||||
*/
|
||||
static inline bool lv_switch_get_state(const lv_obj_t * sw)
|
||||
{
|
||||
lv_switch_ext_t * ext = (lv_switch_ext_t *)lv_obj_get_ext_attr(sw);
|
||||
return ext->state ? true : false;
|
||||
return lv_bar_get_value(sw) == 1 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user