add style examples

This commit is contained in:
Gabor Kiss-Vamosi
2021-02-19 14:47:32 +01:00
parent f04dc72c4a
commit fb27f59479
11 changed files with 266 additions and 296 deletions

View File

@@ -1,28 +1,29 @@
//#include "../../lv_examples.h" #include "../../lvgl.h"
// #if LV_BUILD_EXAMPLES
///**
// * Using the background style properties /**
// */ * Using the background style properties
//void lv_example_style_1(void) */
//{ void lv_example_style_1(void)
// static lv_style_t style; {
// lv_style_init(&style); static lv_style_t style;
// lv_style_set_radius(&style, LV_STATE_DEFAULT, 5); lv_style_init(&style);
// lv_style_set_radius(&style, 5);
// /*Make a gradient*/
// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); /*Make a gradient*/
// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); lv_style_set_bg_opa(&style, LV_OPA_COVER);
// lv_style_set_bg_grad_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); lv_style_set_bg_color(&style, LV_COLOR_SILVER);
// lv_style_set_bg_grad_dir(&style, LV_STATE_DEFAULT, LV_GRAD_DIR_VER); 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, LV_STATE_DEFAULT, 128); /*Shift the gradient to the bottom*/
// lv_style_set_bg_grad_stop(&style, LV_STATE_DEFAULT, 192); lv_style_set_bg_main_stop(&style, 128);
// lv_style_set_bg_grad_stop(&style, 192);
//
// /*Create an object with the new style*/ /*Create an object with the new style*/
// lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL);
// lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &style); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
//} }
//
#endif

View File

@@ -1,36 +1,22 @@
//#include "../../lv_examples.h" #include "../../lvgl.h"
// #if LV_BUILD_EXAMPLES && LV_USE_ARC
///**
// * Using the scale style properties /**
// */ * Using the Arc style properties
//void lv_example_style_11(void) */
//{ void lv_example_style_11(void)
// static lv_style_t style; {
// lv_style_init(&style); 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_arc_color(&style, LV_COLOR_RED);
// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_arc_width(&style, 4);
// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER);
//
// /*Set some paddings*/ /*Create an object with the new style*/
// lv_style_set_pad_top(&style, LV_STATE_DEFAULT, 20); lv_obj_t * obj = lv_arc_create(lv_scr_act(), NULL);
// lv_style_set_pad_left(&style, LV_STATE_DEFAULT, 5); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
// lv_style_set_pad_right(&style, LV_STATE_DEFAULT, 5); lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
// }
// lv_style_set_scale_end_color(&style, LV_STATE_DEFAULT, LV_COLOR_RED); #endif
// 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
//}
//

View File

@@ -1,27 +1,29 @@
//#include "../../lv_examples.h" #include "../../lvgl.h"
// #if LV_BUILD_EXAMPLES
///**
// * Using the border style properties /**
// */ * Using the border style properties
//void lv_example_style_2(void) */
//{ void lv_example_style_2(void)
// static lv_style_t style; {
// lv_style_init(&style); 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); /*Set a background color and a radius*/
// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_radius(&style, 10);
// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); 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_STATE_DEFAULT, LV_COLOR_BLUE); /*Add border to the bottom+right*/
// lv_style_set_border_width(&style, LV_STATE_DEFAULT, 5); lv_style_set_border_color(&style, LV_COLOR_BLUE);
// lv_style_set_border_opa(&style, LV_STATE_DEFAULT, LV_OPA_50); lv_style_set_border_width(&style, 5);
// lv_style_set_border_side(&style, LV_STATE_DEFAULT, LV_BORDER_SIDE_BOTTOM | LV_BORDER_SIDE_RIGHT); 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); /*Create an object with the new style*/
// lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &style); lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL);
// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
//} lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
// }
#endif

View File

@@ -1,26 +1,29 @@
//#include "../../lv_examples.h" #include "../../lvgl.h"
// #if LV_BUILD_EXAMPLES
///**
// * Using the outline style properties /**
// */ * Using the outline style properties
//void lv_example_style_3(void) */
//{ void lv_example_style_3(void)
// static lv_style_t style; {
// lv_style_init(&style); 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); /*Set a background color and a radius*/
// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_radius(&style, 5);
// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); 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, LV_STATE_DEFAULT, 2); /*Add outline*/
// lv_style_set_outline_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); lv_style_set_outline_width(&style, 2);
// lv_style_set_outline_pad(&style, LV_STATE_DEFAULT, 8); 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); /*Create an object with the new style*/
// lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &style); lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL);
// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
//} lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
// }
#endif

View File

@@ -1,27 +1,29 @@
//#include "../../lv_examples.h" #include "../../lvgl.h"
// #if LV_BUILD_EXAMPLES
///**
// * Using the Shadow style properties /**
// */ * Using the Shadow style properties
//void lv_example_style_4(void) */
//{ void lv_example_style_4(void)
// static lv_style_t style; {
// lv_style_init(&style); 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); /*Set a background color and a radius*/
// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_radius(&style, 5);
// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); 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, LV_STATE_DEFAULT, 8); /*Add a shadow*/
// lv_style_set_shadow_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); lv_style_set_shadow_width(&style, 8);
// lv_style_set_shadow_ofs_x(&style, LV_STATE_DEFAULT, 10); lv_style_set_shadow_color(&style, LV_COLOR_BLUE);
// lv_style_set_shadow_ofs_y(&style, LV_STATE_DEFAULT, 20); 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); /*Create an object with the new style*/
// lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &style); lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL);
// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
//} lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
// }
#endif

View File

@@ -1,27 +1,32 @@
//#include "../../lv_examples.h" #include "../../lvgl.h"
// #if LV_BUILD_EXAMPLES
///**
// * Using the pattern style properties /**
// */ * Using the content style properties
//void lv_example_style_5(void) */
//{ void lv_example_style_6(void)
// static lv_style_t style; {
// lv_style_init(&style); 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); /*Set a background color and a radius*/
// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_radius(&style, 5);
// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); lv_style_set_bg_opa(&style, LV_OPA_COVER);
// lv_style_set_bg_color(&style, LV_COLOR_SILVER);
// /*Add a repeating pattern*/
// lv_style_set_pattern_image(&style, LV_STATE_DEFAULT, LV_SYMBOL_OK); /*Add a value text properties*/
// lv_style_set_pattern_recolor(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); lv_style_set_content_color(&style, LV_COLOR_BLUE);
// lv_style_set_pattern_opa(&style, LV_STATE_DEFAULT, LV_OPA_50); lv_style_set_content_align(&style, LV_ALIGN_IN_BOTTOM_RIGHT);
// lv_style_set_pattern_repeat(&style, LV_STATE_DEFAULT, true); 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); /*Create an object with the new style*/
// lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &style); lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL);
// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); 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

View File

@@ -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");
//}
//

View File

@@ -1,34 +1,33 @@
//#include "../../lv_examples.h" #include "../../lvgl.h"
// #if LV_BUILD_EXAMPLES && LV_USE_LABEL
///**
// * Using the text style properties /**
// */ * Using the text style properties
//void lv_example_style_7(void) */
//{ void lv_example_style_7(void)
// static lv_style_t style; {
// lv_style_init(&style); 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_radius(&style, 5);
// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); lv_style_set_bg_opa(&style, LV_OPA_COVER);
// lv_style_set_border_width(&style, LV_STATE_DEFAULT, 2); lv_style_set_bg_color(&style, LV_COLOR_SILVER);
// lv_style_set_border_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); lv_style_set_border_width(&style, 2);
// lv_style_set_border_color(&style, LV_COLOR_BLUE);
// lv_style_set_pad_top(&style, LV_STATE_DEFAULT, 10); lv_style_set_pad_all(&style, 10);
// lv_style_set_pad_bottom(&style, LV_STATE_DEFAULT, 10);
// lv_style_set_pad_left(&style, LV_STATE_DEFAULT, 10); lv_style_set_text_color(&style, LV_COLOR_BLUE);
// lv_style_set_pad_right(&style, LV_STATE_DEFAULT, 10); lv_style_set_text_letter_space(&style, 5);
// lv_style_set_text_line_space(&style, 20);
// lv_style_set_text_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); lv_style_set_text_decor(&style, LV_TEXT_DECOR_UNDERLINE);
// lv_style_set_text_letter_space(&style, LV_STATE_DEFAULT, 5);
// lv_style_set_text_line_space(&style, LV_STATE_DEFAULT, 20); /*Create an object with the new style*/
// lv_style_set_text_decor(&style, LV_STATE_DEFAULT, LV_TEXT_DECOR_UNDERLINE); lv_obj_t * obj = lv_label_create(lv_scr_act(), NULL);
// lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
// /*Create an object with the new style*/ lv_label_set_text(obj, "Text of\n"
// lv_obj_t * obj = lv_label_create(lv_scr_act(), NULL); "a label");
// lv_obj_add_style(obj, LV_LABEL_PART_MAIN, &style);
// lv_label_set_text(obj, "Text of\n" lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
// "a label"); }
// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
//} #endif
//

View File

@@ -1,24 +1,26 @@
//#include "../../lv_examples.h" #include "../../lvgl.h"
// #if LV_BUILD_EXAMPLES && LV_USE_LINE
///**
// * Using the line style properties /**
// */ * Using the line style properties
//void lv_example_style_8(void) */
//{ void lv_example_style_8(void)
// static lv_style_t style; {
// lv_style_init(&style); 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_color(&style, LV_COLOR_GRAY);
// lv_style_set_line_rounded(&style, LV_STATE_DEFAULT, true); lv_style_set_line_width(&style, 6);
//#if LV_USE_LINE 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); /*Create an object with the new style*/
// lv_obj_add_style(obj, LV_LINE_PART_MAIN, &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); 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 lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
//} }
#endif

View File

@@ -1,35 +1,36 @@
//#include "../../lv_examples.h" #include "../../lvgl.h"
// #if LV_BUILD_EXAMPLES && LV_USE_IMG
///**
// * Using the image style properties /**
// */ * Using the Image style properties
//void lv_example_style_9(void) */
//{ void lv_example_style_9(void)
// static lv_style_t style; {
// lv_style_init(&style); 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); /*Set a background color and a radius*/
// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_radius(&style, 5);
// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER); lv_style_set_bg_opa(&style, LV_OPA_COVER);
// lv_style_set_border_width(&style, LV_STATE_DEFAULT, 2); lv_style_set_bg_color(&style, LV_COLOR_SILVER);
// lv_style_set_border_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); lv_style_set_border_width(&style, 2);
// lv_style_set_border_color(&style, 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_all(&style, 10);
// lv_style_set_pad_left(&style, LV_STATE_DEFAULT, 10);
// lv_style_set_pad_right(&style, LV_STATE_DEFAULT, 10); lv_style_set_img_recolor(&style, LV_COLOR_BLUE);
// lv_style_set_img_recolor_opa(&style, LV_OPA_50);
// lv_style_set_image_recolor(&style, LV_STATE_DEFAULT, LV_COLOR_BLUE); lv_style_set_transform_angle(&style, 300);
// lv_style_set_image_recolor_opa(&style, LV_STATE_DEFAULT, LV_OPA_50);
// /*Create an object with the new style*/
//#if LV_USE_IMG lv_obj_t * obj = lv_img_create(lv_scr_act(), NULL);
// /*Create an object with the new style*/ lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &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_DECLARE(img_cogwheel_argb); lv_img_set_src(obj, &img_cogwheel_argb);
// lv_img_set_src(obj, &img_cogwheel_argb); lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
//#endif // lv_obj_set_width(obj, 200);
//} }
//
#endif

View File

@@ -7,8 +7,7 @@ static lv_style_t style_pr;
static lv_style_t style_def; 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) void lv_example_slider_2(void)
{ {