mirror of
https://github.com/lvgl/lvgl.git
synced 2026-08-20 22:31:20 +08:00
Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
37 lines
1.4 KiB
C
37 lines
1.4 KiB
C
#include "../lv_examples.h"
|
|
#if LV_BUILD_EXAMPLES && LV_USE_IMAGE
|
|
|
|
/**
|
|
* @title Slider indicator part and pressed state
|
|
* @brief Style a slider's indicator differently when it is pressed.
|
|
*
|
|
* One style gives the slider's `LV_PART_INDICATOR` a horizontal red
|
|
* gradient, and a second style adds a red shadow with `shadow_width = 10`
|
|
* and `shadow_spread = 3` on `LV_PART_INDICATOR | LV_STATE_PRESSED`. The
|
|
* slider is created with value 70 and centered on the active screen, so
|
|
* pressing the indicator reveals the shadow.
|
|
*/
|
|
void lv_example_style_14(void)
|
|
{
|
|
static lv_style_t style_indic;
|
|
lv_style_init(&style_indic);
|
|
lv_style_set_bg_color(&style_indic, lv_palette_lighten(LV_PALETTE_RED, 3));
|
|
lv_style_set_bg_grad_color(&style_indic, lv_palette_main(LV_PALETTE_RED));
|
|
lv_style_set_bg_grad_dir(&style_indic, LV_GRAD_DIR_HOR);
|
|
|
|
static lv_style_t style_indic_pr;
|
|
lv_style_init(&style_indic_pr);
|
|
lv_style_set_shadow_color(&style_indic_pr, lv_palette_main(LV_PALETTE_RED));
|
|
lv_style_set_shadow_width(&style_indic_pr, 10);
|
|
lv_style_set_shadow_spread(&style_indic_pr, 3);
|
|
|
|
/*Create an object with the new style_pr*/
|
|
lv_obj_t * obj = lv_slider_create(lv_screen_active());
|
|
lv_obj_add_style(obj, &style_indic, LV_PART_INDICATOR);
|
|
lv_obj_add_style(obj, &style_indic_pr, LV_PART_INDICATOR | LV_STATE_PRESSED);
|
|
lv_slider_set_value(obj, 70, LV_ANIM_OFF);
|
|
lv_obj_center(obj);
|
|
}
|
|
|
|
#endif
|