diff --git a/examples/styles/lv_example_style_1.c b/examples/styles/lv_example_style_1.c index 13b825f22..f14218d35 100644 --- a/examples/styles/lv_example_style_1.c +++ b/examples/styles/lv_example_style_1.c @@ -1,28 +1,29 @@ -//#include "../../lv_examples.h" -// -///** -// * Using the background style properties -// */ -//void lv_example_style_1(void) -//{ -// static lv_style_t style; -// lv_style_init(&style); -// lv_style_set_radius(&style, LV_STATE_DEFAULT, 5); -// -// /*Make a gradient*/ -// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); -// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); -// lv_style_set_bg_grad_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); -// lv_style_set_bg_grad_dir(&style, LV_STATE_DEFAULT, LV_GRAD_DIR_VER); -// -// /*Shift the gradient to the bottom*/ -// lv_style_set_bg_main_stop(&style, LV_STATE_DEFAULT, 128); -// lv_style_set_bg_grad_stop(&style, LV_STATE_DEFAULT, 192); -// -// -// /*Create an object with the new style*/ -// lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); -// lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &style); -// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); -//} -// +#include "../../lvgl.h" +#if LV_BUILD_EXAMPLES + +/** + * Using the background style properties + */ +void lv_example_style_1(void) +{ + static lv_style_t style; + lv_style_init(&style); + lv_style_set_radius(&style, 5); + + /*Make a gradient*/ + lv_style_set_bg_opa(&style, LV_OPA_COVER); + lv_style_set_bg_color(&style, LV_COLOR_SILVER); + lv_style_set_bg_grad_color(&style, LV_COLOR_BLUE); + lv_style_set_bg_grad_dir(&style, LV_GRAD_DIR_VER); + + /*Shift the gradient to the bottom*/ + lv_style_set_bg_main_stop(&style, 128); + lv_style_set_bg_grad_stop(&style, 192); + + /*Create an object with the new style*/ + lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style); + lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); +} + +#endif diff --git a/examples/styles/lv_example_style_11.c b/examples/styles/lv_example_style_11.c index a415584b7..5fe759134 100644 --- a/examples/styles/lv_example_style_11.c +++ b/examples/styles/lv_example_style_11.c @@ -1,36 +1,22 @@ -//#include "../../lv_examples.h" -// -///** -// * Using the scale style properties -// */ -//void lv_example_style_11(void) -//{ -// static lv_style_t style; -// lv_style_init(&style); -// -// /*Set a background color and a radius*/ -// lv_style_set_radius(&style, LV_STATE_DEFAULT, 5); -// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); -// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); -// -// /*Set some paddings*/ -// lv_style_set_pad_top(&style, LV_STATE_DEFAULT, 20); -// lv_style_set_pad_left(&style, LV_STATE_DEFAULT, 5); -// lv_style_set_pad_right(&style, LV_STATE_DEFAULT, 5); -// -// lv_style_set_scale_end_color(&style, LV_STATE_DEFAULT, LV_COLOR_RED); -// lv_style_set_line_color(&style, LV_STATE_DEFAULT, LV_COLOR_WHITE); -// lv_style_set_scale_grad_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); -// lv_style_set_line_width(&style, LV_STATE_DEFAULT, 2); -// lv_style_set_scale_end_line_width(&style, LV_STATE_DEFAULT, 4); -// lv_style_set_scale_end_border_width(&style, LV_STATE_DEFAULT, 4); -// -// /*Gauge has a needle but for simplicity its style is not initialized here*/ -//#if LV_USE_GAUGE -// /*Create an object with the new style*/ -// lv_obj_t * obj = lv_gauge_create(lv_scr_act(), NULL); -// lv_obj_add_style(obj, LV_GAUGE_PART_MAIN, &style); -// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); -//#endif -//} -// +#include "../../lvgl.h" +#if LV_BUILD_EXAMPLES && LV_USE_ARC + +/** + * Using the Arc style properties + */ +void lv_example_style_11(void) +{ + static lv_style_t style; + lv_style_init(&style); + + lv_style_set_arc_color(&style, LV_COLOR_RED); + lv_style_set_arc_width(&style, 4); + + + /*Create an object with the new style*/ + lv_obj_t * obj = lv_arc_create(lv_scr_act(), NULL); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style); + lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); +} +#endif + diff --git a/examples/styles/lv_example_style_2.c b/examples/styles/lv_example_style_2.c index 10419a141..5eb374316 100644 --- a/examples/styles/lv_example_style_2.c +++ b/examples/styles/lv_example_style_2.c @@ -1,27 +1,29 @@ -//#include "../../lv_examples.h" -// -///** -// * Using the border style properties -// */ -//void lv_example_style_2(void) -//{ -// static lv_style_t style; -// lv_style_init(&style); -// -// /*Set a background color and a radius*/ -// lv_style_set_radius(&style, LV_STATE_DEFAULT, 20); -// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); -// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); -// -// /*Add border to the bottom+right*/ -// lv_style_set_border_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); -// lv_style_set_border_width(&style, LV_STATE_DEFAULT, 5); -// lv_style_set_border_opa(&style, LV_STATE_DEFAULT, LV_OPA_50); -// lv_style_set_border_side(&style, LV_STATE_DEFAULT, LV_BORDER_SIDE_BOTTOM | LV_BORDER_SIDE_RIGHT); -// -// /*Create an object with the new style*/ -// lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); -// lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &style); -// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); -//} -// +#include "../../lvgl.h" +#if LV_BUILD_EXAMPLES + +/** + * Using the border style properties + */ +void lv_example_style_2(void) +{ + static lv_style_t style; + lv_style_init(&style); + + /*Set a background color and a radius*/ + lv_style_set_radius(&style, 10); + lv_style_set_bg_opa(&style, LV_OPA_COVER); + lv_style_set_bg_color(&style, LV_COLOR_SILVER); + + /*Add border to the bottom+right*/ + lv_style_set_border_color(&style, LV_COLOR_BLUE); + lv_style_set_border_width(&style, 5); + lv_style_set_border_opa(&style, LV_OPA_50); + lv_style_set_border_side(&style, LV_BORDER_SIDE_BOTTOM | LV_BORDER_SIDE_RIGHT); + + /*Create an object with the new style*/ + lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style); + lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); +} + +#endif diff --git a/examples/styles/lv_example_style_3.c b/examples/styles/lv_example_style_3.c index 9e16cd071..1e966d61a 100644 --- a/examples/styles/lv_example_style_3.c +++ b/examples/styles/lv_example_style_3.c @@ -1,26 +1,29 @@ -//#include "../../lv_examples.h" -// -///** -// * Using the outline style properties -// */ -//void lv_example_style_3(void) -//{ -// static lv_style_t style; -// lv_style_init(&style); -// -// /*Set a background color and a radius*/ -// lv_style_set_radius(&style, LV_STATE_DEFAULT, 5); -// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); -// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); -// -// /*Add outline*/ -// lv_style_set_outline_width(&style, LV_STATE_DEFAULT, 2); -// lv_style_set_outline_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); -// lv_style_set_outline_pad(&style, LV_STATE_DEFAULT, 8); -// -// /*Create an object with the new style*/ -// lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); -// lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &style); -// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); -//} -// +#include "../../lvgl.h" +#if LV_BUILD_EXAMPLES + +/** + * Using the outline style properties + */ +void lv_example_style_3(void) +{ + static lv_style_t style; + lv_style_init(&style); + + /*Set a background color and a radius*/ + lv_style_set_radius(&style, 5); + lv_style_set_bg_opa(&style, LV_OPA_COVER); + lv_style_set_bg_color(&style, LV_COLOR_SILVER); + + /*Add outline*/ + lv_style_set_outline_width(&style, 2); + lv_style_set_outline_color(&style, LV_COLOR_BLUE); + lv_style_set_outline_pad(&style, 8); + + /*Create an object with the new style*/ + lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style); + lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); +} + +#endif + diff --git a/examples/styles/lv_example_style_4.c b/examples/styles/lv_example_style_4.c index 70e945d10..ee1afaa77 100644 --- a/examples/styles/lv_example_style_4.c +++ b/examples/styles/lv_example_style_4.c @@ -1,27 +1,29 @@ -//#include "../../lv_examples.h" -// -///** -// * Using the Shadow style properties -// */ -//void lv_example_style_4(void) -//{ -// static lv_style_t style; -// lv_style_init(&style); -// -// /*Set a background color and a radius*/ -// lv_style_set_radius(&style, LV_STATE_DEFAULT, 5); -// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); -// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); -// -// /*Add a shadow*/ -// lv_style_set_shadow_width(&style, LV_STATE_DEFAULT, 8); -// lv_style_set_shadow_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); -// lv_style_set_shadow_ofs_x(&style, LV_STATE_DEFAULT, 10); -// lv_style_set_shadow_ofs_y(&style, LV_STATE_DEFAULT, 20); -// -// /*Create an object with the new style*/ -// lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); -// lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &style); -// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); -//} -// +#include "../../lvgl.h" +#if LV_BUILD_EXAMPLES + +/** + * Using the Shadow style properties + */ +void lv_example_style_4(void) +{ + static lv_style_t style; + lv_style_init(&style); + + /*Set a background color and a radius*/ + lv_style_set_radius(&style, 5); + lv_style_set_bg_opa(&style, LV_OPA_COVER); + lv_style_set_bg_color(&style, LV_COLOR_SILVER); + + /*Add a shadow*/ + lv_style_set_shadow_width(&style, 8); + lv_style_set_shadow_color(&style, LV_COLOR_BLUE); + lv_style_set_shadow_ofs_x(&style, 10); + lv_style_set_shadow_ofs_y(&style, 20); + + /*Create an object with the new style*/ + lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style); + lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); +} + +#endif diff --git a/examples/styles/lv_example_style_5.c b/examples/styles/lv_example_style_5.c index 98b3d8937..e6a8e6344 100644 --- a/examples/styles/lv_example_style_5.c +++ b/examples/styles/lv_example_style_5.c @@ -1,27 +1,32 @@ -//#include "../../lv_examples.h" -// -///** -// * Using the pattern style properties -// */ -//void lv_example_style_5(void) -//{ -// static lv_style_t style; -// lv_style_init(&style); -// -// /*Set a background color and a radius*/ -// lv_style_set_radius(&style, LV_STATE_DEFAULT, 5); -// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); -// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); -// -// /*Add a repeating pattern*/ -// lv_style_set_pattern_image(&style, LV_STATE_DEFAULT, LV_SYMBOL_OK); -// lv_style_set_pattern_recolor(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); -// lv_style_set_pattern_opa(&style, LV_STATE_DEFAULT, LV_OPA_50); -// lv_style_set_pattern_repeat(&style, LV_STATE_DEFAULT, true); -// -// /*Create an object with the new style*/ -// lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); -// lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &style); -// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); -//} -// +#include "../../lvgl.h" +#if LV_BUILD_EXAMPLES + +/** + * Using the content style properties + */ +void lv_example_style_6(void) +{ + static lv_style_t style; + lv_style_init(&style); + + /*Set a background color and a radius*/ + lv_style_set_radius(&style, 5); + lv_style_set_bg_opa(&style, LV_OPA_COVER); + lv_style_set_bg_color(&style, LV_COLOR_SILVER); + + /*Add a value text properties*/ + lv_style_set_content_color(&style, LV_COLOR_BLUE); + lv_style_set_content_align(&style, LV_ALIGN_IN_BOTTOM_RIGHT); + lv_style_set_content_ofs_x(&style, -5); + lv_style_set_content_ofs_y(&style, -5); + + /*Create an object with the new style*/ + lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style); + lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); + + /*Add a value text to the local style. This way every object can have different text*/ + lv_obj_set_style_content_text(obj, LV_PART_MAIN, LV_STATE_DEFAULT, "Text"); +} + +#endif diff --git a/examples/styles/lv_example_style_6.c b/examples/styles/lv_example_style_6.c index 87c765965..e69de29bb 100644 --- a/examples/styles/lv_example_style_6.c +++ b/examples/styles/lv_example_style_6.c @@ -1,30 +0,0 @@ -//#include "../../lv_examples.h" -// -///** -// * Using the value style properties -// */ -//void lv_example_style_6(void) -//{ -// static lv_style_t style; -// lv_style_init(&style); -// -// /*Set a background color and a radius*/ -// lv_style_set_radius(&style, LV_STATE_DEFAULT, 5); -// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); -// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); -// -// /*Add a value text properties*/ -// lv_style_set_value_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); -// lv_style_set_value_align(&style, LV_STATE_DEFAULT, LV_ALIGN_IN_BOTTOM_RIGHT); -// lv_style_set_value_ofs_x(&style, LV_STATE_DEFAULT, 10); -// lv_style_set_value_ofs_y(&style, LV_STATE_DEFAULT, 10); -// -// /*Create an object with the new style*/ -// lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); -// lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &style); -// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); -// -// /*Add a value text to the local style. This way every object can have different text*/ -// lv_obj_set_style_local_value_str(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, "Text"); -//} -// diff --git a/examples/styles/lv_example_style_7.c b/examples/styles/lv_example_style_7.c index 995e664fa..54b124cca 100644 --- a/examples/styles/lv_example_style_7.c +++ b/examples/styles/lv_example_style_7.c @@ -1,34 +1,33 @@ -//#include "../../lv_examples.h" -// -///** -// * Using the text style properties -// */ -//void lv_example_style_7(void) -//{ -// static lv_style_t style; -// lv_style_init(&style); -// -// lv_style_set_radius(&style, LV_STATE_DEFAULT, 5); -// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); -// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); -// lv_style_set_border_width(&style, LV_STATE_DEFAULT, 2); -// lv_style_set_border_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); -// -// lv_style_set_pad_top(&style, LV_STATE_DEFAULT, 10); -// lv_style_set_pad_bottom(&style, LV_STATE_DEFAULT, 10); -// lv_style_set_pad_left(&style, LV_STATE_DEFAULT, 10); -// lv_style_set_pad_right(&style, LV_STATE_DEFAULT, 10); -// -// lv_style_set_text_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); -// lv_style_set_text_letter_space(&style, LV_STATE_DEFAULT, 5); -// lv_style_set_text_line_space(&style, LV_STATE_DEFAULT, 20); -// lv_style_set_text_decor(&style, LV_STATE_DEFAULT, LV_TEXT_DECOR_UNDERLINE); -// -// /*Create an object with the new style*/ -// lv_obj_t * obj = lv_label_create(lv_scr_act(), NULL); -// lv_obj_add_style(obj, LV_LABEL_PART_MAIN, &style); -// lv_label_set_text(obj, "Text of\n" -// "a label"); -// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); -//} -// +#include "../../lvgl.h" +#if LV_BUILD_EXAMPLES && LV_USE_LABEL + +/** + * Using the text style properties + */ +void lv_example_style_7(void) +{ + static lv_style_t style; + lv_style_init(&style); + + lv_style_set_radius(&style, 5); + lv_style_set_bg_opa(&style, LV_OPA_COVER); + lv_style_set_bg_color(&style, LV_COLOR_SILVER); + lv_style_set_border_width(&style, 2); + lv_style_set_border_color(&style, LV_COLOR_BLUE); + lv_style_set_pad_all(&style, 10); + + lv_style_set_text_color(&style, LV_COLOR_BLUE); + lv_style_set_text_letter_space(&style, 5); + lv_style_set_text_line_space(&style, 20); + lv_style_set_text_decor(&style, LV_TEXT_DECOR_UNDERLINE); + + /*Create an object with the new style*/ + lv_obj_t * obj = lv_label_create(lv_scr_act(), NULL); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style); + lv_label_set_text(obj, "Text of\n" + "a label"); + + lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); +} + +#endif diff --git a/examples/styles/lv_example_style_8.c b/examples/styles/lv_example_style_8.c index b3582f27e..c9b5b87d4 100644 --- a/examples/styles/lv_example_style_8.c +++ b/examples/styles/lv_example_style_8.c @@ -1,24 +1,26 @@ -//#include "../../lv_examples.h" -// -///** -// * Using the line style properties -// */ -//void lv_example_style_8(void) -//{ -// static lv_style_t style; -// lv_style_init(&style); -// -// lv_style_set_line_color(&style, LV_STATE_DEFAULT, LV_COLOR_GRAY); -// lv_style_set_line_width(&style, LV_STATE_DEFAULT, 6); -// lv_style_set_line_rounded(&style, LV_STATE_DEFAULT, true); -//#if LV_USE_LINE -// /*Create an object with the new style*/ -// lv_obj_t * obj = lv_line_create(lv_scr_act(), NULL); -// lv_obj_add_style(obj, LV_LINE_PART_MAIN, &style); -// -// static lv_point_t p[] = {{10, 30}, {30, 50}, {100, 0}}; -// lv_line_set_points(obj, p, 3); -// -// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); -//#endif -//} +#include "../../lvgl.h" +#if LV_BUILD_EXAMPLES && LV_USE_LINE + +/** + * Using the line style properties + */ +void lv_example_style_8(void) +{ + static lv_style_t style; + lv_style_init(&style); + + lv_style_set_line_color(&style, LV_COLOR_GRAY); + lv_style_set_line_width(&style, 6); + lv_style_set_line_rounded(&style, true); + + /*Create an object with the new style*/ + lv_obj_t * obj = lv_line_create(lv_scr_act(), NULL); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style); + + static lv_point_t p[] = {{10, 30}, {30, 50}, {100, 0}}; + lv_line_set_points(obj, p, 3); + + lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); +} + +#endif diff --git a/examples/styles/lv_example_style_9.c b/examples/styles/lv_example_style_9.c index a2c3a5ee1..e0b4b0d83 100644 --- a/examples/styles/lv_example_style_9.c +++ b/examples/styles/lv_example_style_9.c @@ -1,35 +1,36 @@ -//#include "../../lv_examples.h" -// -///** -// * Using the image style properties -// */ -//void lv_example_style_9(void) -//{ -// static lv_style_t style; -// lv_style_init(&style); -// -// /*Set a background color and a radius*/ -// lv_style_set_radius(&style, LV_STATE_DEFAULT, 5); -// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); -// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); -// lv_style_set_border_width(&style, LV_STATE_DEFAULT, 2); -// lv_style_set_border_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); -// -// lv_style_set_pad_top(&style, LV_STATE_DEFAULT, 10); -// lv_style_set_pad_bottom(&style, LV_STATE_DEFAULT, 10); -// lv_style_set_pad_left(&style, LV_STATE_DEFAULT, 10); -// lv_style_set_pad_right(&style, LV_STATE_DEFAULT, 10); -// -// lv_style_set_image_recolor(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); -// lv_style_set_image_recolor_opa(&style, LV_STATE_DEFAULT, LV_OPA_50); -// -//#if LV_USE_IMG -// /*Create an object with the new style*/ -// lv_obj_t * obj = lv_img_create(lv_scr_act(), NULL); -// lv_obj_add_style(obj, LV_IMG_PART_MAIN, &style); -// LV_IMG_DECLARE(img_cogwheel_argb); -// lv_img_set_src(obj, &img_cogwheel_argb); -// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); -//#endif -//} -// +#include "../../lvgl.h" +#if LV_BUILD_EXAMPLES && LV_USE_IMG + +/** + * Using the Image style properties + */ +void lv_example_style_9(void) +{ + static lv_style_t style; + lv_style_init(&style); + + /*Set a background color and a radius*/ + lv_style_set_radius(&style, 5); + lv_style_set_bg_opa(&style, LV_OPA_COVER); + lv_style_set_bg_color(&style, LV_COLOR_SILVER); + lv_style_set_border_width(&style, 2); + lv_style_set_border_color(&style, LV_COLOR_BLUE); + +// lv_style_set_pad_all(&style, 10); + + lv_style_set_img_recolor(&style, LV_COLOR_BLUE); + lv_style_set_img_recolor_opa(&style, LV_OPA_50); + lv_style_set_transform_angle(&style, 300); + + /*Create an object with the new style*/ + lv_obj_t * obj = lv_img_create(lv_scr_act(), NULL); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style); + + LV_IMG_DECLARE(img_cogwheel_argb); + lv_img_set_src(obj, &img_cogwheel_argb); + lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); + +// lv_obj_set_width(obj, 200); +} + +#endif diff --git a/examples/widgets/slider/lv_example_slider_2.c b/examples/widgets/slider/lv_example_slider_2.c index 463f59f55..28cfac723 100644 --- a/examples/widgets/slider/lv_example_slider_2.c +++ b/examples/widgets/slider/lv_example_slider_2.c @@ -7,8 +7,7 @@ static lv_style_t style_pr; static lv_style_t style_def; /** - * Show the current value when the slider if pressed (using only styles). - * + * Show the current value when the slider if pressed using a fancy style transition. */ void lv_example_slider_2(void) {