mirror of
https://github.com/lvgl/lvgl.git
synced 2025-02-04 07:13:00 +08:00
lv_sw.c: lv_sw_toggle_anim initial commit
This commit is contained in:
parent
6af285adb8
commit
64c87e0e4a
@ -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);
|
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
|
* Set a style of a switch
|
||||||
* @param sw pointer to a switch object
|
* @param sw pointer to a switch object
|
||||||
|
@ -107,6 +107,13 @@ void lv_sw_on_anim(lv_obj_t * sw);
|
|||||||
*/
|
*/
|
||||||
void lv_sw_off_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
|
* Set a function which will be called when the switch is toggled by the user
|
||||||
* @param sw pointer to switch object
|
* @param sw pointer to switch object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user