mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
lv_sw: lv_sw_toggle initial commit
This commit is contained in:
parent
a3f50c61f9
commit
d962e36dbb
@ -147,6 +147,22 @@ void lv_sw_off(lv_obj_t * sw)
|
||||
lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_off);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function which will be called when the switch is toggled by the user
|
||||
* @param sw pointer to switch object
|
||||
* @param action a callback function
|
||||
*/
|
||||
bool lv_sw_toggle(lv_obj_t *sw) {
|
||||
bool state = lv_sw_get_state(sw);
|
||||
if(state) {
|
||||
lv_sw_off(sw);
|
||||
}
|
||||
else {
|
||||
lv_sw_on(sw);
|
||||
}
|
||||
return !state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn ON the switch with an animation
|
||||
* @param sw pointer to a switch object
|
||||
|
@ -88,6 +88,13 @@ void lv_sw_on(lv_obj_t *sw);
|
||||
*/
|
||||
void lv_sw_off(lv_obj_t *sw);
|
||||
|
||||
/**
|
||||
* Toggle the position of the switch
|
||||
* @param sw pointer to a switch object
|
||||
* @return resulting state of the switch.
|
||||
*/
|
||||
bool lv_sw_toggle(lv_obj_t *sw);
|
||||
|
||||
/**
|
||||
* Turn ON the switch with an animation
|
||||
* @param sw pointer to a switch object
|
||||
|
Loading…
x
Reference in New Issue
Block a user