예제 #1
0
파일: lv_slider.c 프로젝트: databuser/lvgl
/**
 * Set a style of a slider
 * @param slider pointer to a slider object
 * @param type which style should be set
 * @param style pointer to a style
 */
void lv_slider_set_style(lv_obj_t *slider, lv_slider_style_t type, lv_style_t *style)
{
    lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);

    switch (type) {
        case LV_SLIDER_STYLE_BG:
            lv_bar_set_style(slider, LV_BAR_STYLE_BG, style);
            break;
        case LV_SLIDER_STYLE_INDIC:
            lv_bar_set_style(slider, LV_BAR_STYLE_INDIC, style);
            break;
        case LV_SLIDER_STYLE_KNOB:
            ext->style_knob = style;
            lv_obj_refresh_ext_size(slider);
            break;
    }
}
예제 #2
0
/**
 * Set a style of a switch
 * @param sw pointer to a switch object
 * @param type which style should be set
 * @param style pointer to a style
 */
void lv_sw_set_style(lv_obj_t *sw, lv_sw_style_t type, lv_style_t *style)
{
    lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);

    switch (type) {
        case LV_SLIDER_STYLE_BG:
            lv_slider_set_style(sw, LV_SLIDER_STYLE_BG, style);
            break;
        case LV_SLIDER_STYLE_INDIC:
            lv_bar_set_style(sw, LV_SLIDER_STYLE_INDIC, style);
            break;
        case LV_SW_STYLE_KNOB_OFF:
            ext->style_knob_off = style;
            if(lv_sw_get_state(sw) == 0) lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, style);
            break;
        case LV_SW_STYLE_KNOB_ON:
            ext->style_knob_on = style;
            if(lv_sw_get_state(sw) != 0) lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, style);
            break;
    }
}