mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-29 22:56:58 +08:00
slider and sw update
This commit is contained in:
+35
-47
@@ -34,9 +34,11 @@ extern "C" {
|
||||
/*Data of switch*/
|
||||
typedef struct
|
||||
{
|
||||
lv_slider_ext_t slider; /*Ext. of ancestor*/
|
||||
lv_slider_ext_t slider; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
uint8_t changed :1; /*Indicates the switch explicitly changed by drag*/
|
||||
lv_style_t *knob_off_style; /*Style of the knob when the switch is OFF*/
|
||||
lv_style_t *knob_on_style; /*Style of the knob when the switch is ON (NULL to use the same as OFF)*/
|
||||
uint8_t changed :1; /*Indicates the switch explicitly changed by drag*/
|
||||
}lv_sw_ext_t;
|
||||
|
||||
/**********************
|
||||
@@ -51,48 +53,44 @@ typedef struct
|
||||
*/
|
||||
lv_obj_t * lv_sw_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the switch
|
||||
* @param sw pointer to a switch object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param);
|
||||
|
||||
/******************************
|
||||
* TRANSPARENT API FUNCTIONS
|
||||
******************************/
|
||||
|
||||
/**
|
||||
* Set the styles of a switch
|
||||
* @param sw pointer to a switch object
|
||||
* @param bg pointer to the background's style
|
||||
* @param indic pointer to the indicator's style
|
||||
* @param knob pointer to the knob's style
|
||||
*/
|
||||
static inline void lv_sw_set_style(lv_obj_t * sw, lv_style_t *bg, lv_style_t *indic, lv_style_t *knob)
|
||||
{
|
||||
lv_slider_set_style(sw, bg, indic, knob);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn ON the switch
|
||||
* @param sw pointer to a switch object
|
||||
*/
|
||||
static inline void lv_sw_set_on(lv_obj_t *sw)
|
||||
{
|
||||
lv_bar_set_value(sw, 1);
|
||||
}
|
||||
void lv_sw_set_on(lv_obj_t *sw);
|
||||
|
||||
/**
|
||||
* Turn OFF the switch
|
||||
* @param sw pointer to a switch object
|
||||
*/
|
||||
static inline void lv_sw_set_off(lv_obj_t *sw)
|
||||
{
|
||||
lv_bar_set_value(sw, 0);
|
||||
}
|
||||
void lv_sw_set_off(lv_obj_t *sw);
|
||||
/**
|
||||
* Set the styles of a switch
|
||||
* @param sw pointer to a switch object
|
||||
* @param bg pointer to the background's style
|
||||
* @param indic pointer to the indicator's style
|
||||
* @param knob_off pointer to the knob's style when the switch is OFF
|
||||
* @param knob_on pointer to the knob's style when the switch is ON
|
||||
*/
|
||||
void lv_sw_set_style(lv_obj_t * sw, lv_style_t *bg, lv_style_t *indic, lv_style_t *knob_off, lv_style_t *knob_on);
|
||||
|
||||
/**
|
||||
* Get the style of the switch's knob when the switch is OFF
|
||||
* @param sw pointer to a switch object
|
||||
* @return pointer to the switch's knob OFF style
|
||||
*/
|
||||
lv_style_t * lv_sw_get_style_knob_off(lv_obj_t *sw);
|
||||
|
||||
/**
|
||||
* Get the style of the switch's knob when the switch is ON
|
||||
* @param sw pointer to a switch object
|
||||
* @return pointer to the switch's knob ON style
|
||||
*/
|
||||
lv_style_t * lv_sw_get_style_knob_on(lv_obj_t *sw);
|
||||
|
||||
/******************************
|
||||
* TRANSPARENT API FUNCTIONS
|
||||
******************************/
|
||||
|
||||
/**
|
||||
* Set a function which will be called when the switch is toggled by the user
|
||||
@@ -129,7 +127,7 @@ static inline lv_action_t lv_sw_get_action(lv_obj_t * slider)
|
||||
* @param sw pointer to a switch object
|
||||
* @return pointer to the switch's background style
|
||||
*/
|
||||
static inline bool lv_sw_get_style_bg(lv_obj_t *sw)
|
||||
static inline lv_style_t * lv_sw_get_style_bg(lv_obj_t *sw)
|
||||
{
|
||||
return lv_slider_get_style_bg(sw);
|
||||
}
|
||||
@@ -139,21 +137,11 @@ static inline bool lv_sw_get_style_bg(lv_obj_t *sw)
|
||||
* @param sw pointer to a switch object
|
||||
* @return pointer to the switch's indicator style
|
||||
*/
|
||||
static inline bool lv_sw_get_style_indicator(lv_obj_t *sw)
|
||||
static inline lv_style_t * lv_sw_get_style_indicator(lv_obj_t *sw)
|
||||
{
|
||||
return lv_slider_get_style_indicator(sw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the style of the switch's knob
|
||||
* @param sw pointer to a switch object
|
||||
* @return pointer to the switch's knob style
|
||||
*/
|
||||
static inline bool lv_sw_get_style_knob(lv_obj_t *sw)
|
||||
{
|
||||
return lv_slider_get_style_knob(sw);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
Reference in New Issue
Block a user