lv_sw.c: lv_sw_toggle_anim initial commit

This commit is contained in:
Brian Pugh
2019-01-25 20:17:43 -08:00
committed by Gabor Kiss-Vamosi
parent 514511c15a
commit 9cecebfe0a
2 changed files with 23 additions and 0 deletions

View File

@@ -189,6 +189,22 @@ void lv_sw_off_anim(lv_obj_t * sw)
lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_off);
}
/**
* Toggle the position of the switch with an animation
* @param sw pointer to a switch object
* @return resulting state of the switch.
*/
bool lv_sw_toggle_anim(lv_obj_t *sw) {
bool state = lv_sw_get_state(sw);
if(state) {
lv_sw_off_anim(sw);
}
else {
lv_sw_on_anim(sw);
}
return !state;
}
/**
* Set a style of a switch
* @param sw pointer to a switch object

View File

@@ -107,6 +107,13 @@ void lv_sw_on_anim(lv_obj_t * sw);
*/
void lv_sw_off_anim(lv_obj_t * sw);
/**
* Toggle the position of the switch with an animation
* @param sw pointer to a switch object
* @return resulting state of the switch.
*/
bool lv_sw_toggle_anim(lv_obj_t *sw);
/**
* Set a function which will be called when the switch is toggled by the user
* @param sw pointer to switch object