lv_example: add screenshots

This commit is contained in:
Gabor
2017-08-17 10:41:48 +02:00
parent b8080ef1db
commit 7fdd633561
10 changed files with 71 additions and 99 deletions

View File

@@ -1,5 +1,5 @@
/**
* @file style_usage.c
* @file lv_ex_styles.h
*
*/
@@ -27,7 +27,7 @@
/*********************
* INCLUDES
*********************/
#include "style_usage.h"
#include "lv_ex_styles.h"
#if USE_LV_EXAMPLE != 0
@@ -60,66 +60,65 @@
/**
* Create a simple 'Hello world!' label
*/
void style_usage_init(void)
void lv_ex_styles(void)
{
/************************************
* BUTTON + LABEL WITH DEFAULT STYLE
************************************/
/****************************************
* BASE OBJECT + LABEL WITH DEFAULT STYLE
****************************************/
lv_obj_t * btn1;
btn1 = lv_btn_create(lv_scr_act(), NULL); /*Create a simple button*/
lv_obj_set_pos(btn1, 10, 10);
lv_obj_t * label = lv_label_create(btn1, NULL); /*Add a lebel tothe button*/
lv_obj_t * obj1;
obj1 = lv_obj_create(lv_scr_act(), NULL); /*Create a simple objects*/
lv_obj_set_pos(obj1, 10, 10);
lv_obj_t * label = lv_label_create(obj1, NULL);
/*Add a label to the object*/
lv_label_set_text(label, "Default");
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
/************************
* BUTTON WITH NEW STYLE
************************/
/****************************************
* BASE OBJECT WITH PRETTY COLOR STYLE
****************************************/
/* Create a new style
* Don't forget a style can describe any object type
* like buttons and labels */
static lv_style_t style_btn2; /*Styles can't be local variables*/
lv_style_get(LV_STYLE_PRETTY_COLOR, &style_btn2); /*Copy a built-in style as a starting point*/
style_btn2.swidth = 10; /*10 px shadow*/
style_btn2.bwidth = 5; /*5 px border width*/
style_btn2.mcolor = COLOR_ORANGE; /*Orange main color*/
style_btn2.gcolor = COLOR_RED; /*Red gradient color*/
style_btn2.letter_space = 10; /*10 px letter space*/
style_btn2.txt_align = LV_TXT_ALIGN_MID; /*Text align: middle*/
lv_obj_t * obj2;
obj2 = lv_obj_create(lv_scr_act(), NULL);
lv_obj_align(obj2, obj1, LV_ALIGN_OUT_RIGHT_MID, 20, 0); /*Align next to the previous object*/
lv_obj_set_style(obj2, lv_style_get(LV_STYLE_PRETTY_COLOR, NULL)); /*Set built in style*/
label = lv_label_create(obj2, NULL);
/*Create a button and apply the new style*/
lv_obj_t * btn2;
btn2 = lv_btn_create(lv_scr_act(), NULL);
lv_obj_align(btn2, btn1, LV_ALIGN_OUT_RIGHT_MID, 20, 0);
lv_obj_set_style(btn2, &style_btn2);
/* Add a label to the object.
* Labels by default inherit the parent's style */
lv_label_set_text(label, "Pretty\ncolor");
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
/* Add a label to the button.
* Label by default inherits the parent's style */
label = lv_label_create(btn2, NULL);
/*****************************
* BASE OBJECT WITH NEW STYLE
*****************************/
/* Create a new style */
static lv_style_t style_new; /*Styles can't be local variables*/
lv_style_get(LV_STYLE_PRETTY_COLOR, &style_new); /*Copy a built-in style as a starting point*/
style_new.radius = LV_RADIUS_CIRCLE; /*Fully round corners*/
style_new.swidth = 8; /*8 px shadow*/
style_new.bwidth = 2; /*2 px border width*/
style_new.mcolor = COLOR_WHITE; /*White main color*/
style_new.gcolor = color_mix(COLOR_BLUE, COLOR_WHITE, OPA_40); /*light blue gradient color*/
style_new.scolor = COLOR_MAKE(0xa0, 0xa0, 0xa0); /*Light gray shadow color*/
style_new.ccolor = color_mix(COLOR_BLUE, COLOR_WHITE, OPA_90); /*Blue content color (text color)*/
style_new.letter_space = 10; /*10 px letter space*/
style_new.txt_align = LV_TXT_ALIGN_MID; /*Middel text align*/
/*Create a base object and apply the new style*/
lv_obj_t * obj3;
obj3 = lv_obj_create(lv_scr_act(), NULL);
lv_obj_align(obj3, obj2, LV_ALIGN_OUT_RIGHT_MID, 20, 0);
lv_obj_set_style(obj3, &style_new);
/* Add a label to the object.
* Labels by default inherit the parent's style */
label = lv_label_create(obj3, NULL);
lv_label_set_text(label, "New\nstyle");
/************************
* LABEL WITH NEW STYLE
************************/
/*Create new style for the label*/
static lv_style_t style_label;
lv_style_get(LV_STYLE_PRETTY_COLOR, &style_label); /*Use a built-in style*/
style_label.ccolor = color_mix(COLOR_BLUE, COLOR_WHITE, OPA_70);/*Light blue content color (text color) */
style_label.letter_space = 4; /*4 px letter space*/
style_label.txt_align = LV_TXT_ALIGN_MID; /*Text align: middle*/
/*Copy 'btn2'. It will use the same style as 'btn2'*/
lv_obj_t * btn3;
btn3 = lv_btn_create(lv_scr_act(), btn2);
lv_obj_align(btn3, btn2, LV_ALIGN_OUT_RIGHT_MID, 20, 0);
/*Create a label and apply the new style */
label = lv_label_create(btn3, NULL);
lv_label_set_text(label, "Label\nstyle");
lv_obj_set_style(label, &style_label);
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
/************************
@@ -131,7 +130,7 @@ void style_usage_init(void)
lv_style_get(LV_STYLE_PRETTY_COLOR, &style_led);
style_led.swidth = 15;
style_led.radius = LV_RADIUS_CIRCLE;
style_led.bwidth = 5;
style_led.bwidth = 3;
style_led.bopa = OPA_30;
style_led.mcolor = COLOR_MAKE(0xb5, 0x0f, 0x04);
style_led.gcolor = COLOR_MAKE(0x50, 0x07, 0x02);
@@ -141,17 +140,17 @@ void style_usage_init(void)
/*Create a LED and switch it ON*/
lv_obj_t * led1 = lv_led_create(lv_scr_act(), NULL);
lv_obj_set_style(led1, &style_led);
lv_obj_align_us(led1, btn1, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
lv_obj_align_us(led1, obj1, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
lv_led_on(led1);
/*Copy the previous LED and set a brightness*/
lv_obj_t * led2 = lv_led_create(lv_scr_act(), led1);
lv_obj_align_us(led2, btn2, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
lv_obj_align_us(led2, obj2, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
lv_led_set_bright(led2, 190);
/*Copy the previous LED and switch it OFF*/
lv_obj_t * led3 = lv_led_create(lv_scr_act(), led1);
lv_obj_align_us(led3, btn3, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
lv_obj_align_us(led3, obj3, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
lv_led_off(led3);
}