api(style) remove content style proeprties

This commit is contained in:
Gabor Kiss-Vamosi
2021-03-25 13:36:50 +01:00
parent b7becbbb22
commit 53f3cc1827
158 changed files with 701 additions and 1364 deletions
@@ -19,12 +19,12 @@ static void btn_event_cb(lv_obj_t * btn, lv_event_t event)
*/
void lv_example_get_started_1(void)
{
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL); /*Add a button the current screen*/
lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
lv_obj_set_size(btn, 120, 50); /*Set its size*/
lv_obj_add_event_cb(btn, btn_event_cb, NULL); /*Assign a callback to the button*/
lv_obj_t * label = lv_label_create(btn, NULL); /*Add a label to the button*/
lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/
lv_label_set_text(label, "Button"); /*Set the labels text*/
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
}
@@ -37,19 +37,19 @@ void lv_example_get_started_2(void)
lv_style_set_bg_grad_color(&style_btn_red, lv_color_blue_darken_3());
/*Create a button and use the new styles*/
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL); /*Add a button the current screen*/
lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
lv_obj_set_size(btn, 120, 50); /*Set its size*/
lv_obj_remove_style(btn, LV_PART_ANY, LV_STATE_ANY, NULL); /*Remove the styles coming from the theme*/
lv_obj_add_style(btn, LV_PART_MAIN, LV_STATE_DEFAULT, &style_btn);
lv_obj_add_style(btn, LV_PART_MAIN, LV_STATE_PRESSED, &style_btn_pressed);
lv_obj_t * label = lv_label_create(btn, NULL); /*Add a label to the button*/
lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/
lv_label_set_text(label, "Button"); /*Set the labels text*/
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
/*Create an other button and use the red style too*/
lv_obj_t * btn2 = lv_btn_create(lv_scr_act(), NULL);
lv_obj_t * btn2 = lv_btn_create(lv_scr_act());
lv_obj_set_pos(btn2, 10, 80);
lv_obj_set_size(btn2, 120, 50); /*Set its size*/
lv_obj_remove_style(btn2, LV_PART_ANY, LV_STATE_ANY, NULL); /*Remove the styles coming from the theme*/
@@ -58,7 +58,7 @@ void lv_example_get_started_2(void)
lv_obj_add_style(btn2, LV_PART_MAIN, LV_STATE_PRESSED, &style_btn_pressed);
lv_obj_set_style_radius(btn2, LV_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); /*Add a local style*/
label = lv_label_create(btn2, NULL); /*Add a label to the button*/
label = lv_label_create(btn2); /*Add a label to the button*/
lv_label_set_text(label, "Button 2"); /*Set the labels text*/
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
}
@@ -18,13 +18,13 @@ static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
void lv_example_get_started_3(void)
{
/*Create a slider in the center of the display*/
lv_obj_t * slider = lv_slider_create(lv_scr_act(), NULL);
lv_obj_t * slider = lv_slider_create(lv_scr_act());
lv_obj_set_width(slider, 200); /*Set the width*/
lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0); /*Align to the center of the parent (screen)*/
lv_obj_add_event_cb(slider, slider_event_cb, NULL); /*Assign an event function*/
/*Create a label below the slider*/
label = lv_label_create(lv_scr_act(), NULL);
label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "0");
lv_obj_align(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align below the slider*/
}
+6 -6
View File
@@ -7,13 +7,13 @@
void lv_example_flex_1(void)
{
/*Create a container with ROW flex direction*/
lv_obj_t * cont_row = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * cont_row = lv_obj_create(lv_scr_act());
lv_obj_set_size(cont_row, 300, 75);
lv_obj_align(cont_row, NULL, LV_ALIGN_IN_TOP_MID, 0, 5);
lv_obj_set_flex_flow(cont_row, LV_FLEX_FLOW_ROW);
/*Create a container with COLUMN flex direction*/
lv_obj_t * cont_col = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * cont_col = lv_obj_create(lv_scr_act());
lv_obj_set_size(cont_col, 200, 150);
lv_obj_align(cont_col, cont_row, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
lv_obj_set_flex_flow(cont_col, LV_FLEX_FLOW_COLUMN);
@@ -24,18 +24,18 @@ void lv_example_flex_1(void)
lv_obj_t * label;
/*Add items to the row*/
obj= lv_obj_create(cont_row, NULL);
obj= lv_obj_create(cont_row);
lv_obj_set_size(obj, 100, LV_SIZE_PCT(100));
label = lv_label_create(obj, NULL);
label = lv_label_create(obj);
lv_label_set_text_fmt(label, "Item: %d", i);
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
/*Add items to the column*/
obj = lv_obj_create(cont_col, NULL);
obj = lv_obj_create(cont_col);
lv_obj_set_size(obj, LV_SIZE_PCT(100), LV_SIZE_CONTENT);
label = lv_label_create(obj, NULL);
label = lv_label_create(obj);
lv_label_set_text_fmt(label, "Item: %d", i);
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
}
+3 -3
View File
@@ -12,17 +12,17 @@ void lv_example_flex_2(void)
lv_style_set_flex_main_place(&style, LV_FLEX_PLACE_SPACE_EVENLY);
lv_style_set_layout(&style, LV_LAYOUT_FLEX);
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_size(cont, 300, 220);
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_style(cont, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
uint32_t i;
for(i = 0; i < 8; i++) {
lv_obj_t * obj = lv_obj_create(cont, NULL);
lv_obj_t * obj = lv_obj_create(cont);
lv_obj_set_size(obj, 70, LV_SIZE_CONTENT);
lv_obj_t * label = lv_label_create(obj, NULL);
lv_obj_t * label = lv_label_create(obj);
lv_label_set_text_fmt(label, "%d", i);
}
}
+5 -5
View File
@@ -6,24 +6,24 @@
*/
void lv_example_flex_3(void)
{
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_size(cont, 300, 220);
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW);
lv_obj_t * obj;
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
lv_obj_set_size(obj, 40, 40); /*Fix size*/
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
lv_obj_set_height(obj, 40);
lv_obj_set_flex_grow(obj, 1); /*1 portion from the free space*/
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
lv_obj_set_height(obj, 40);
lv_obj_set_flex_grow(obj, 2); /*2 portion from the free space*/
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
lv_obj_set_size(obj, 40, 40); /*Fix size. It is flushed to the right by the "grow" items*/
}
+3 -3
View File
@@ -7,17 +7,17 @@
void lv_example_flex_4(void)
{
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_size(cont, 300, 220);
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_COLUMN_REVERSE);
uint32_t i;
for(i = 0; i < 6; i++) {
lv_obj_t * obj = lv_obj_create(cont, NULL);
lv_obj_t * obj = lv_obj_create(cont);
lv_obj_set_size(obj, 100, 50);
lv_obj_t * label = lv_label_create(obj, NULL);
lv_obj_t * label = lv_label_create(obj);
lv_label_set_text_fmt(label, "Item: %d", i);
}
}
+3 -3
View File
@@ -16,17 +16,17 @@ static void column_gap_anim(void * obj, int32_t v)
*/
void lv_example_flex_5(void)
{
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_size(cont, 300, 220);
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW_WRAP);
uint32_t i;
for(i = 0; i < 9; i++) {
lv_obj_t * obj = lv_obj_create(cont, NULL);
lv_obj_t * obj = lv_obj_create(cont);
lv_obj_set_size(obj, 70, LV_SIZE_CONTENT);
lv_obj_t * label = lv_label_create(obj, NULL);
lv_obj_t * label = lv_label_create(obj);
lv_label_set_text_fmt(label, "%d", i);
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
}
+3 -3
View File
@@ -7,7 +7,7 @@
*/
void lv_example_flex_6(void)
{
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_base_dir(cont, LV_BIDI_DIR_RTL);
lv_obj_set_size(cont, 300, 220);
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
@@ -15,10 +15,10 @@ void lv_example_flex_6(void)
uint32_t i;
for(i = 0; i < 20; i++) {
lv_obj_t * obj = lv_obj_create(cont, NULL);
lv_obj_t * obj = lv_obj_create(cont);
lv_obj_set_size(obj, 70, LV_SIZE_CONTENT);
lv_obj_t * label = lv_label_create(obj, NULL);
lv_obj_t * label = lv_label_create(obj);
lv_label_set_text_fmt(label, "%d", i);
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
}
+3 -3
View File
@@ -10,7 +10,7 @@ void lv_example_grid_1(void)
static lv_coord_t row_dsc[] = {50, 50, 50, LV_COORD_MAX};
/*Create a container with grid*/
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_style_grid_column_template(cont, LV_PART_MAIN, LV_STATE_DEFAULT, col_dsc);
lv_obj_set_style_grid_row_template(cont, LV_PART_MAIN, LV_STATE_DEFAULT, row_dsc);
lv_obj_set_size(cont, 300, 220);
@@ -25,13 +25,13 @@ void lv_example_grid_1(void)
uint8_t col = i % 3;
uint8_t row = i / 3;
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
/*Stretch the cell horizontally and vertically too
*Set span to 1 to make the cell 1 column/row sized*/
lv_obj_set_grid_cell(obj, LV_GRID_STRETCH, col, 1,
LV_GRID_STRETCH, row, 1);
label = lv_label_create(obj, NULL);
label = lv_label_create(obj);
lv_label_set_text_fmt(label, "c%d, r%d", col, row);
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
}
+11 -11
View File
@@ -11,7 +11,7 @@ void lv_example_grid_2(void)
static lv_coord_t row_dsc[] = {50, 50, 50, LV_GRID_TEMPLATE_LAST};
/*Create a container with grid*/
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_grid_template(cont, col_dsc, row_dsc);
lv_obj_set_size(cont, 300, 220);
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
@@ -20,43 +20,43 @@ void lv_example_grid_2(void)
lv_obj_t * obj;
/*Cell to 0;0 and align to to the start (left/top) horizontally and vertically too*/
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_grid_cell(obj, LV_GRID_START, 0, 1,
LV_GRID_START, 0, 1);
label = lv_label_create(obj, NULL);
label = lv_label_create(obj);
lv_label_set_text(label, "c0, r0");
/*Cell to 1;0 and align to to the start (left) horizontally and center vertically too*/
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_grid_cell(obj, LV_GRID_START, 1, 1,
LV_GRID_CENTER, 0, 1);
label = lv_label_create(obj, NULL);
label = lv_label_create(obj);
lv_label_set_text(label, "c1, r0");
/*Cell to 2;0 and align to to the start (left) horizontally and end (bottom) vertically too*/
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_grid_cell(obj, LV_GRID_START, 2, 1,
LV_GRID_END, 0, 1);
label = lv_label_create(obj, NULL);
label = lv_label_create(obj);
lv_label_set_text(label, "c2, r0");
/*Cell to 1;1 but 2 column wide (span = 2).Set width and height to stretched.*/
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_grid_cell(obj, LV_GRID_STRETCH, 1, 2,
LV_GRID_STRETCH, 1, 1);
label = lv_label_create(obj, NULL);
label = lv_label_create(obj);
lv_label_set_text(label, "c1-2, r1");
/*Cell to 0;1 but 2 rows tall (span = 2).Set width and height to stretched.*/
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_grid_cell(obj, LV_GRID_STRETCH, 0, 1,
LV_GRID_STRETCH, 1, 2);
label = lv_label_create(obj, NULL);
label = lv_label_create(obj);
lv_label_set_text(label, "c0\nr1-2");
}
+3 -3
View File
@@ -17,7 +17,7 @@ void lv_example_grid_3(void)
static lv_coord_t row_dsc[] = {40, LV_GRID_FR(1), 40, LV_GRID_TEMPLATE_LAST};
/*Create a container with grid*/
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_size(cont, 300, 220);
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_grid_template(cont, col_dsc, row_dsc);
@@ -29,13 +29,13 @@ void lv_example_grid_3(void)
uint8_t col = i % 3;
uint8_t row = i / 3;
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
/*Stretch the cell horizontally and vertically too
*Set span to 1 to make the cell 1 column/row sized*/
lv_obj_set_grid_cell(obj, LV_GRID_STRETCH, col, 1,
LV_GRID_STRETCH, row, 1);
label = lv_label_create(obj, NULL);
label = lv_label_create(obj);
lv_label_set_text_fmt(label, "%d,%d", col, row);
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
}
+3 -3
View File
@@ -13,7 +13,7 @@ void lv_example_grid_4(void)
/*Add space between the columns and move the rows to the bottom (end)*/
/*Create a container with grid*/
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_grid_place(cont, LV_GRID_SPACE_BETWEEN, LV_GRID_END);
lv_obj_set_grid_template(cont, col_dsc, row_dsc);
lv_obj_set_size(cont, 300, 220);
@@ -26,13 +26,13 @@ void lv_example_grid_4(void)
uint8_t col = i % 3;
uint8_t row = i / 3;
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
/*Stretch the cell horizontally and vertically too
*Set span to 1 to make the cell 1 column/row sized*/
lv_obj_set_grid_cell(obj, LV_GRID_STRETCH, col, 1,
LV_GRID_STRETCH, row, 1);
label = lv_label_create(obj, NULL);
label = lv_label_create(obj);
lv_label_set_text_fmt(label, "%d,%d", col, row);
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
}
+3 -3
View File
@@ -22,7 +22,7 @@ void lv_example_grid_5(void)
static lv_coord_t row_dsc[] = {40, 40, 40, LV_GRID_TEMPLATE_LAST};
/*Create a container with grid*/
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_size(cont, 300, 220);
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_grid_template(cont, col_dsc, row_dsc);
@@ -34,10 +34,10 @@ void lv_example_grid_5(void)
uint8_t col = i % 3;
uint8_t row = i / 3;
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
lv_obj_set_grid_cell(obj, LV_GRID_STRETCH, col, 1,
LV_GRID_STRETCH, row, 1);
label = lv_label_create(obj, NULL);
label = lv_label_create(obj);
lv_label_set_text_fmt(label, "%d,%d", col, row);
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
}
+3 -3
View File
@@ -11,7 +11,7 @@ void lv_example_grid_6(void)
static lv_coord_t row_dsc[] = {40, 40, 40, LV_GRID_TEMPLATE_LAST};
/*Create a container with grid*/
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_size(cont, 300, 220);
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_base_dir(cont, LV_BIDI_DIR_RTL);
@@ -24,13 +24,13 @@ void lv_example_grid_6(void)
uint8_t col = i % 3;
uint8_t row = i / 3;
obj = lv_obj_create(cont, NULL);
obj = lv_obj_create(cont);
/*Stretch the cell horizontally and vertically too
*Set span to 1 to make the cell 1 column/row sized*/
lv_obj_set_grid_cell(obj, LV_GRID_STRETCH, col, 1,
LV_GRID_STRETCH, row, 1);
label = lv_label_create(obj, NULL);
label = lv_label_create(obj);
lv_label_set_text_fmt(label, "%d,%d", col, row);
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
}
+11 -11
View File
@@ -7,40 +7,40 @@
void lv_example_scroll_1(void)
{
/*Create an object with the new style*/
lv_obj_t * panel = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * panel = lv_obj_create(lv_scr_act());
lv_obj_set_size(panel, 200, 200);
lv_obj_center(panel);
lv_obj_t * child;
lv_obj_t * label;
child = lv_obj_create(panel, NULL);
child = lv_obj_create(panel);
lv_obj_set_pos(child, 0, 0);
label = lv_label_create(child, NULL);
label = lv_label_create(child);
lv_label_set_text(label, "Zero");
lv_obj_center(label);
child = lv_obj_create(panel, NULL);
child = lv_obj_create(panel);
lv_obj_set_pos(child, -40, 100);
label = lv_label_create(child, NULL);
label = lv_label_create(child);
lv_label_set_text(label, "Left");
lv_obj_center(label);
child = lv_obj_create(panel, NULL);
child = lv_obj_create(panel);
lv_obj_set_pos(child, 90, -30);
label = lv_label_create(child, NULL);
label = lv_label_create(child);
lv_label_set_text(label, "Top");
lv_obj_center(label);
child = lv_obj_create(panel, NULL);
child = lv_obj_create(panel);
lv_obj_set_pos(child, 150, 80);
label = lv_label_create(child, NULL);
label = lv_label_create(child);
lv_label_set_text(label, "Right");
lv_obj_center(label);
child = lv_obj_create(panel, NULL);
child = lv_obj_create(panel);
lv_obj_set_pos(child, 60, 170);
label = lv_label_create(child, NULL);
label = lv_label_create(child);
lv_label_set_text(label, "Bottom");
lv_obj_center(label);
}
+5 -5
View File
@@ -16,7 +16,7 @@ static void sw_event_cb(lv_obj_t * sw, lv_event_t e)
*/
void lv_example_scroll_2(void)
{
lv_obj_t * panel = lv_obj_create(lv_scr_act(), NULL);
lv_obj_t * panel = lv_obj_create(lv_scr_act());
lv_obj_set_size(panel, 280, 150);
lv_obj_set_scroll_snap_x(panel, LV_SCROLL_SNAP_CENTER);
lv_obj_set_flex_flow(panel, LV_FLEX_FLOW_ROW);
@@ -24,10 +24,10 @@ void lv_example_scroll_2(void)
uint32_t i;
for(i = 0; i < 10; i++) {
lv_obj_t * btn = lv_btn_create(panel, NULL);
lv_obj_t * btn = lv_btn_create(panel);
lv_obj_set_size(btn, 150, 100);
lv_obj_t * label = lv_label_create(btn, NULL);
lv_obj_t * label = lv_label_create(btn);
if(i == 3) {
lv_label_set_text_fmt(label, "Panel %d\nno snap", i);
lv_obj_clear_flag(btn, LV_OBJ_FLAG_SNAPABLE);
@@ -41,10 +41,10 @@ void lv_example_scroll_2(void)
#if LV_USE_SWITCH
/*Switch between "One scroll" and "Normal scroll" mode*/
lv_obj_t * sw = lv_switch_create(lv_scr_act(), NULL);
lv_obj_t * sw = lv_switch_create(lv_scr_act());
lv_obj_align(sw, NULL, LV_ALIGN_IN_TOP_RIGHT, -20, 10);
lv_obj_add_event_cb(sw, sw_event_cb, panel);
lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);
lv_obj_t * label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "One scroll");
lv_obj_align(label, sw, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
#endif
+3 -3
View File
@@ -33,14 +33,14 @@ void lv_example_scroll_3(void)
lv_list_add_btn(list, LV_SYMBOL_AUDIO, buf, NULL);
}
lv_obj_t * float_btn = lv_btn_create(list, NULL);
lv_obj_t * float_btn = lv_btn_create(list);
lv_obj_set_size(float_btn, 50, 50);
lv_obj_add_flag(float_btn, LV_OBJ_FLAG_FLOATING);
lv_obj_align(float_btn, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, -lv_obj_get_style_pad_right(list, LV_PART_MAIN));
lv_obj_add_event_cb(float_btn, float_btn_event_cb, list);
lv_obj_set_style_radius(float_btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_obj_set_style_content_text(float_btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_PLUS);
lv_obj_set_style_content_font(float_btn, LV_PART_MAIN, LV_STATE_DEFAULT, lv_theme_get_font_large(float_btn));
lv_obj_set_style_bg_img_src(float_btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_PLUS);
lv_obj_set_style_text_font(float_btn, LV_PART_MAIN, LV_STATE_DEFAULT, lv_theme_get_font_large(float_btn));
}
#endif
+1 -1
View File
@@ -21,7 +21,7 @@ void lv_example_style_1(void)
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_t * obj = lv_obj_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
}
+1 -1
View File
@@ -29,7 +29,7 @@ typedef int _keep_pedantic_happy;
// lv_style_set_transition_prop_1(&style, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR);
//
// /*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());
// lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &style);
// lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
//}
+1 -1
View File
@@ -14,7 +14,7 @@ void lv_example_style_11(void)
/*Create an object with the new style*/
lv_obj_t * obj = lv_arc_create(lv_scr_act(), NULL);
lv_obj_t * obj = lv_arc_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
}
+1 -1
View File
@@ -21,7 +21,7 @@ void lv_example_style_2(void)
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_t * obj = lv_obj_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
}
+1 -1
View File
@@ -20,7 +20,7 @@ void lv_example_style_3(void)
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_t * obj = lv_obj_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
}
+1 -1
View File
@@ -21,7 +21,7 @@ void lv_example_style_4(void)
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_t * obj = lv_obj_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0);
}
-32
View File
@@ -1,32 +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_grey_lighten_3());
/*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
+1 -1
View File
@@ -22,7 +22,7 @@ void lv_example_style_7(void)
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_t * obj = lv_label_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_label_set_text(obj, "Text of\n"
"a label");
+1 -1
View File
@@ -14,7 +14,7 @@ void lv_example_style_8(void)
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_t * obj = lv_line_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
static lv_point_t p[] = {{10, 30}, {30, 50}, {100, 0}};
+1 -1
View File
@@ -23,7 +23,7 @@ void lv_example_style_9(void)
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_t * obj = lv_img_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
LV_IMG_DECLARE(img_cogwheel_argb);
+1 -1
View File
@@ -5,7 +5,7 @@
void lv_example_arc_1(void)
{
/*Create an Arc*/
lv_obj_t * arc = lv_arc_create(lv_scr_act(), NULL);
lv_obj_t * arc = lv_arc_create(lv_scr_act());
lv_arc_set_end_angle(arc, 200);
lv_obj_set_size(arc, 150, 150);
lv_obj_align(arc, NULL, LV_ALIGN_CENTER, 0, 0);
+1 -1
View File
@@ -26,7 +26,7 @@ static void arc_loader(lv_timer_t * t)
void lv_example_arc_2(void)
{
/*Create an Arc*/
lv_obj_t * arc = lv_arc_create(lv_scr_act(), NULL);
lv_obj_t * arc = lv_arc_create(lv_scr_act());
lv_arc_set_bg_angles(arc, 0, 360);
lv_arc_set_angles(arc, 270, 270);
lv_obj_align(arc, NULL, LV_ALIGN_CENTER, 0, 0);
+1 -1
View File
@@ -3,7 +3,7 @@
void lv_example_bar_1(void)
{
lv_obj_t * bar1 = lv_bar_create(lv_scr_act(), NULL);
lv_obj_t * bar1 = lv_bar_create(lv_scr_act());
lv_obj_set_size(bar1, 200, 20);
lv_obj_align(bar1, NULL, LV_ALIGN_CENTER, 0, 0);
lv_bar_set_value(bar1, 70, LV_ANIM_OFF);
+1 -1
View File
@@ -21,7 +21,7 @@ void lv_example_bar_2(void)
lv_style_set_bg_color(&style_indic, lv_color_blue());
lv_style_set_radius(&style_indic, 3);
lv_obj_t * bar = lv_bar_create(lv_scr_act(), NULL);
lv_obj_t * bar = lv_bar_create(lv_scr_act());
lv_obj_remove_style(bar, LV_PART_ANY, LV_STATE_ANY, NULL); /*To have a clean start*/
lv_obj_add_style(bar, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
lv_obj_add_style(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, &style_indic);
+5 -5
View File
@@ -7,7 +7,7 @@ static void set_temp(void * bar, int32_t temp)
static char buf[10]; /*Only the pointer t saved so must be static*/
lv_snprintf(buf, sizeof(buf), "%d°C", temp);
lv_obj_set_style_content_text(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, buf);
// lv_obj_set_style_content_text(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, buf);
}
/**
@@ -22,11 +22,11 @@ void lv_example_bar_3(void)
lv_style_set_bg_color(&style_indic, lv_color_red());
lv_style_set_bg_grad_color(&style_indic, lv_color_blue());
lv_style_set_bg_grad_dir(&style_indic, LV_GRAD_DIR_VER);
lv_style_set_content_align(&style_indic, LV_ALIGN_OUT_LEFT_TOP);
lv_style_set_content_ofs_x(&style_indic, -3);
lv_style_set_content_color(&style_indic, lv_color_grey());
// lv_style_set_content_align(&style_indic, LV_ALIGN_OUT_LEFT_TOP);
// lv_style_set_content_ofs_x(&style_indic, -3);
// lv_style_set_content_color(&style_indic, lv_color_grey());
lv_obj_t * bar = lv_bar_create(lv_scr_act(), NULL);
lv_obj_t * bar = lv_bar_create(lv_scr_act());
lv_obj_add_style(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, &style_indic);
lv_obj_set_size(bar, 20, 200);
lv_obj_align(bar, NULL, LV_ALIGN_CENTER, 0, 0);
+1 -1
View File
@@ -14,7 +14,7 @@ void lv_example_bar_4(void)
lv_style_set_bg_img_tiled(&style_indic, true);
lv_style_set_bg_img_opa(&style_indic, LV_OPA_30);
lv_obj_t * bar = lv_bar_create(lv_scr_act(), NULL);
lv_obj_t * bar = lv_bar_create(lv_scr_act());
lv_obj_add_style(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, &style_indic);
lv_obj_set_size(bar, 260, 20);
+6 -11
View File
@@ -6,25 +6,20 @@
*/
void lv_example_bar_5(void)
{
static lv_style_t style_bg;
lv_style_init(&style_bg);
lv_style_set_content_ofs_y(&style_bg, -3);
lv_style_set_content_align(&style_bg, LV_ALIGN_OUT_TOP_MID);
lv_obj_t * bar_ltr = lv_bar_create(lv_scr_act(), NULL);
lv_obj_t * bar_ltr = lv_bar_create(lv_scr_act());
lv_obj_set_size(bar_ltr, 200, 20);
lv_bar_set_value(bar_ltr, 70, LV_ANIM_OFF);
lv_obj_align(bar_ltr, NULL, LV_ALIGN_CENTER, 0, -30);
lv_obj_add_style(bar_ltr, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
lv_obj_set_style_content_text(bar_ltr, LV_PART_MAIN, LV_STATE_DEFAULT, "Left to Right base direction");
// lv_obj_add_style(bar_ltr, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
// lv_obj_set_style_content_text(bar_ltr, LV_PART_MAIN, LV_STATE_DEFAULT, "Left to Right base direction");
lv_obj_t * bar_rtl = lv_bar_create(lv_scr_act(), NULL);
lv_obj_t * bar_rtl = lv_bar_create(lv_scr_act());
lv_obj_set_base_dir(bar_rtl, LV_BIDI_DIR_RTL);
lv_obj_set_size(bar_rtl, 200, 20);
lv_bar_set_value(bar_rtl, 70, LV_ANIM_OFF);
lv_obj_align(bar_rtl, NULL, LV_ALIGN_CENTER, 0, 30);
lv_obj_add_style(bar_rtl, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
lv_obj_set_style_content_text(bar_rtl, LV_PART_MAIN, LV_STATE_DEFAULT, "Right to Left base direction");
// lv_obj_add_style(bar_rtl, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
// lv_obj_set_style_content_text(bar_rtl, LV_PART_MAIN, LV_STATE_DEFAULT, "Right to Left base direction");
}
#endif
+73 -73
View File
@@ -1,73 +1,73 @@
#include "../../../lvgl.h"
#if LV_USE_BAR && LV_BUILD_EXAMPLES
static void set_value(void *bar, int32_t v)
{
lv_bar_set_value(bar, v, LV_ANIM_OFF);
}
static void event_cb(lv_obj_t * obj, lv_event_t e)
{
if(e == LV_EVENT_DRAW_POST_END) {
lv_bar_t * bar = (lv_bar_t *)obj;
lv_draw_label_dsc_t dsc;
lv_draw_label_dsc_init(&dsc);
dsc.font = LV_FONT_DEFAULT;
char buf[8];
lv_snprintf(buf, sizeof(buf), "%d", lv_bar_get_value(obj));
lv_point_t txt_size;
lv_txt_get_size(&txt_size, buf, dsc.font, dsc.letter_space, dsc.line_space, LV_COORD_MAX, dsc.flag);
lv_area_t txt_area;
/*If the indicator is long enough put the text inside on the right*/
if(lv_area_get_width(&bar->indic_area) > txt_size.x + 20) {
txt_area.x2 = bar->indic_area.x2 - 5;
txt_area.x1 = txt_area.x2 - txt_size.x + 1;
dsc.color = lv_color_white();
}
/*If the indicator is still short put the text out of it on the right*/
else {
txt_area.x1 = bar->indic_area.x2 + 5;
txt_area.x2 = txt_area.x1 + txt_size.x - 1;
dsc.color = lv_color_black();
}
txt_area.y1 = bar->indic_area.y1 + (lv_area_get_height(&bar->indic_area) - txt_size.y) / 2;
txt_area.y2 = txt_area.y1 + txt_size.y - 1;
const lv_area_t * clip_area = lv_event_get_param();
lv_draw_label(&txt_area, clip_area, &dsc, buf, NULL);
}
}
/**
* Custom drawer on bar to display the current value
*/
void lv_example_bar_6(void)
{
static lv_style_t style_bg;
lv_style_init(&style_bg);
lv_style_set_content_ofs_y(&style_bg, -3);
lv_style_set_content_align(&style_bg, LV_ALIGN_OUT_TOP_MID);
lv_obj_t * bar = lv_bar_create(lv_scr_act(), NULL);
lv_obj_add_event_cb(bar, event_cb, NULL);
lv_obj_set_size(bar, 200, 20);
lv_obj_align(bar, NULL, LV_ALIGN_CENTER, 0, 0);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, bar);
lv_anim_set_values(&a, 0, 100);
lv_anim_set_exec_cb(&a, set_value);
lv_anim_set_time(&a, 2000);
lv_anim_set_playback_time(&a, 2000);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);
}
#endif
//#include "../../../lvgl.h"
//#if LV_USE_BAR && LV_BUILD_EXAMPLES
//
//static void set_value(void *bar, int32_t v)
//{
// lv_bar_set_value(bar, v, LV_ANIM_OFF);
//}
//
//static void event_cb(lv_obj_t * obj, lv_event_t e)
//{
// if(e == LV_EVENT_DRAW_POST_END) {
// lv_bar_t * bar = (lv_bar_t *)obj;
//
// lv_draw_label_dsc_t dsc;
// lv_draw_label_dsc_init(&dsc);
// dsc.font = LV_FONT_DEFAULT;
//
// char buf[8];
// lv_snprintf(buf, sizeof(buf), "%d", lv_bar_get_value(obj));
//
// lv_point_t txt_size;
// lv_txt_get_size(&txt_size, buf, dsc.font, dsc.letter_space, dsc.line_space, LV_COORD_MAX, dsc.flag);
//
// lv_area_t txt_area;
// /*If the indicator is long enough put the text inside on the right*/
// if(lv_area_get_width(&bar->indic_area) > txt_size.x + 20) {
// txt_area.x2 = bar->indic_area.x2 - 5;
// txt_area.x1 = txt_area.x2 - txt_size.x + 1;
// dsc.color = lv_color_white();
// }
// /*If the indicator is still short put the text out of it on the right*/
// else {
// txt_area.x1 = bar->indic_area.x2 + 5;
// txt_area.x2 = txt_area.x1 + txt_size.x - 1;
// dsc.color = lv_color_black();
// }
//
// txt_area.y1 = bar->indic_area.y1 + (lv_area_get_height(&bar->indic_area) - txt_size.y) / 2;
// txt_area.y2 = txt_area.y1 + txt_size.y - 1;
//
// const lv_area_t * clip_area = lv_event_get_param();
// lv_draw_label(&txt_area, clip_area, &dsc, buf, NULL);
// }
//}
//
///**
// * Custom drawer on bar to display the current value
// */
//void lv_example_bar_6(void)
//{
// static lv_style_t style_bg;
// lv_style_init(&style_bg);
// lv_style_set_content_ofs_y(&style_bg, -3);
// lv_style_set_content_align(&style_bg, LV_ALIGN_OUT_TOP_MID);
//
// lv_obj_t * bar = lv_bar_create(lv_scr_act());
// lv_obj_add_event_cb(bar, event_cb, NULL);
// lv_obj_set_size(bar, 200, 20);
// lv_obj_align(bar, NULL, LV_ALIGN_CENTER, 0, 0);
//
// lv_anim_t a;
// lv_anim_init(&a);
// lv_anim_set_var(&a, bar);
// lv_anim_set_values(&a, 0, 100);
// lv_anim_set_exec_cb(&a, set_value);
// lv_anim_set_time(&a, 2000);
// lv_anim_set_playback_time(&a, 2000);
// lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
// lv_anim_start(&a);
//
//}
//
//#endif
+10 -13
View File
@@ -16,24 +16,21 @@ void lv_example_btn_1(void)
{
lv_obj_t * label;
//
// lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL);
// lv_obj_add_event_cb(btn1, event_handler, NULL);
// lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, -40);
//
// label = lv_label_create(btn1, NULL);
// lv_label_set_text(label, "Button");
// lv_obj_center(label);
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
lv_obj_add_event_cb(btn1, event_handler, NULL);
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, -40);
lv_obj_t * btn2 = lv_btn_create(lv_scr_act(), NULL);
label = lv_label_create(btn1);
lv_label_set_text(label, "Button");
lv_obj_center(label);
lv_obj_t * btn2 = lv_btn_create(lv_scr_act());
lv_obj_add_event_cb(btn2, event_handler, NULL);
lv_obj_align(btn2, NULL, LV_ALIGN_CENTER, 0, 40);
lv_obj_add_flag(btn2, LV_OBJ_FLAG_CHECKABLE);
// lv_obj_set_height(btn2, LV_SIZE_CONTENT);
lv_obj_set_height(btn2, LV_SIZE_CONTENT);
label = lv_label_create(btn2, NULL);
label = lv_label_create(btn2);
lv_label_set_text(label, "Toggle");
// lv_obj_update_layout(btn2);
// lv_obj_update_layout(cont);
}
#endif
+2 -2
View File
@@ -37,13 +37,13 @@ void lv_example_btn_2(void)
lv_style_set_bg_color(&style_pr, lv_color_blue_darken_2());
lv_style_set_bg_grad_color(&style_pr, lv_color_blue_darken_4());
lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL);
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
lv_obj_remove_style(btn1, LV_PART_ANY, LV_STATE_ANY, NULL);
lv_obj_add_style(btn1, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_add_style(btn1, LV_PART_MAIN, LV_STATE_PRESSED, &style_pr);
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_t * label = lv_label_create(btn1, NULL);
lv_obj_t * label = lv_label_create(btn1);
lv_label_set_text(label, "Button");
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
+6 -7
View File
@@ -1,6 +1,6 @@
#include "../../../lvgl.h"
#include <stdio.h>
#if LV_USE_BTN
#if LV_BUILD_EXAMPLES && LV_USE_BTN
/**
* Create a style transition on a button to act like a gum when clicked
@@ -9,7 +9,7 @@ void lv_example_btn_3(void)
{
/*Properties to transition*/
static lv_style_prop_t props[] = {
LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT, LV_STYLE_CONTENT_LETTER_SPACE, 0
LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT, LV_STYLE_TEXT_LETTER_SPACE, 0
};
/*Define animation paths*/
@@ -42,16 +42,15 @@ void lv_example_btn_3(void)
lv_style_init(&style_pr);
lv_style_set_transform_width(&style_pr, 10);
lv_style_set_transform_height(&style_pr, -10);
lv_style_set_content_letter_space(&style_pr, 10);
lv_style_set_text_letter_space(&style_pr, 10);
lv_style_set_transition(&style_pr, &transition_dsc_pr);
lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL);
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, -80);
lv_obj_add_style(btn1, LV_PART_MAIN, LV_STATE_PRESSED, &style_pr);
lv_obj_add_style(btn1, LV_PART_MAIN, LV_STATE_DEFAULT, &style_def);
/*Instead of creating a label add a values string*/
lv_obj_set_style_content_text(btn1, LV_PART_MAIN, LV_STATE_DEFAULT, "Gum");
lv_obj_t * label = lv_label_create(btn1);
lv_label_set_text(label, "Gum");
}
#endif
@@ -18,7 +18,7 @@ static const char * btnm_map[] = {"1", "2", "3", "4", "5", "\n",
void lv_example_btnmatrix_1(void)
{
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act(), NULL);
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
lv_btnmatrix_set_map(btnm1, btnm_map);
lv_btnmatrix_set_btn_width(btnm1, 10, 2); /*Make "Action1" twice as wide as "Action2"*/
lv_btnmatrix_set_btn_ctrl(btnm1, 10, LV_BTNMATRIX_CTRL_CHECKABLE);
@@ -62,7 +62,7 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
*/
void lv_example_btnmatrix_2(void)
{
lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act(), NULL);
lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act());
lv_obj_add_event_cb(btnm, event_cb, NULL);
lv_obj_align(btnm, NULL, LV_ALIGN_CENTER, 0, 0);
}
@@ -47,7 +47,7 @@ void lv_example_btnmatrix_3(void)
static const char * map[] = {LV_SYMBOL_LEFT, "1", "2", "3", "4", "5", LV_SYMBOL_RIGHT, ""};
lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act(), NULL);
lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act());
lv_btnmatrix_set_map(btnm, map);
lv_obj_add_style(btnm, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
lv_obj_add_style(btnm, LV_PART_ITEMS, LV_STATE_DEFAULT, &style_btn);
@@ -27,7 +27,7 @@ void lv_example_canvas_1(void)
static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
lv_obj_t * canvas = lv_canvas_create(lv_scr_act(), NULL);
lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_TRUE_COLOR);
lv_obj_align(canvas, NULL, LV_ALIGN_CENTER, 0, 0);
lv_canvas_fill_bg(canvas, lv_color_grey_lighten_3(), LV_OPA_COVER);
@@ -10,13 +10,13 @@
void lv_example_canvas_2(void)
{
/*Create a button to better see the transparency*/
lv_btn_create(lv_scr_act(), NULL);
lv_btn_create(lv_scr_act());
/*Create a buffer for the canvas*/
static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_INDEXED_1BIT(CANVAS_WIDTH, CANVAS_HEIGHT)];
/*Create a canvas and initialize its the palette*/
lv_obj_t * canvas = lv_canvas_create(lv_scr_act(), NULL);
lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_INDEXED_1BIT);
lv_canvas_set_palette(canvas, 0, LV_COLOR_CHROMA_KEY);
lv_canvas_set_palette(canvas, 1, lv_color_red());
+1 -1
View File
@@ -5,7 +5,7 @@ void lv_example_chart_1(void)
{
/*Create a chart*/
lv_obj_t * chart;
chart = lv_chart_create(lv_scr_act(), NULL);
chart = lv_chart_create(lv_scr_act());
lv_obj_set_size(chart, 200, 150);
lv_obj_align(chart, NULL, LV_ALIGN_CENTER, 0, 0);
lv_chart_set_type(chart, LV_CHART_TYPE_LINE); /*Show lines and points too*/
+1 -1
View File
@@ -60,7 +60,7 @@ static void add_data(lv_timer_t * timer)
void lv_example_chart_2(void)
{
/*Create a chart1*/
chart1 = lv_chart_create(lv_scr_act(), NULL);
chart1 = lv_chart_create(lv_scr_act());
lv_obj_set_size(chart1, 200, 150);
lv_obj_align(chart1, NULL, LV_ALIGN_CENTER, 0, 0);
lv_chart_set_type(chart1, LV_CHART_TYPE_LINE); /*Show lines and points too*/
+1 -1
View File
@@ -20,7 +20,7 @@ void lv_example_chart_3(void)
{
/*Create a chart*/
lv_obj_t * chart;
chart = lv_chart_create(lv_scr_act(), NULL);
chart = lv_chart_create(lv_scr_act());
lv_obj_set_size(chart, 200, 150);
lv_obj_align(chart, NULL, LV_ALIGN_CENTER, 0, 0);
lv_chart_set_type(chart, LV_CHART_TYPE_BAR);
+4 -4
View File
@@ -26,15 +26,15 @@ static void event_cb(lv_obj_t * chart, lv_event_t e)
lv_coord_t value = y_array[id];
char buf[16];
lv_snprintf(buf, sizeof(buf), "$%d", value);
lv_snprintf(buf, sizeof(buf), LV_SYMBOL_DUMMY"$%d", value);
lv_draw_rect_dsc_t draw_rect_dsc;
lv_draw_rect_dsc_init(&draw_rect_dsc);
draw_rect_dsc.bg_color = lv_color_black();
draw_rect_dsc.bg_opa = LV_OPA_50;
draw_rect_dsc.radius = 3;
draw_rect_dsc.content_text = buf;
draw_rect_dsc.content_color = lv_color_white();
draw_rect_dsc.bg_img_src = buf;
draw_rect_dsc.bg_img_recolor = lv_color_white();
lv_area_t a;
a.x1 = chart->coords.x1 + p.x - 20;
@@ -57,7 +57,7 @@ void lv_example_chart_4(void)
{
/*Create a chart*/
lv_obj_t * chart;
chart = lv_chart_create(lv_scr_act(), NULL);
chart = lv_chart_create(lv_scr_act());
lv_obj_set_size(chart, 200, 150);
lv_obj_align(chart, NULL, LV_ALIGN_CENTER, 0, 0);
+3 -3
View File
@@ -69,7 +69,7 @@ static void slider_y_event_cb(lv_obj_t * obj, lv_event_t e)
void lv_example_chart_5(void)
{
/*Create a chart*/
chart = lv_chart_create(lv_scr_act(), NULL);
chart = lv_chart_create(lv_scr_act());
lv_obj_set_size(chart, 200, 150);
lv_obj_align(chart, NULL, LV_ALIGN_CENTER, -30, -30);
lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_Y, -1000, 1000);
@@ -84,13 +84,13 @@ void lv_example_chart_5(void)
lv_chart_set_ext_array(chart, ser, (lv_coord_t *)ecg_sample);
lv_obj_t * slider;
slider = lv_slider_create(lv_scr_act(), NULL);
slider = lv_slider_create(lv_scr_act());
lv_slider_set_range(slider, LV_IMG_ZOOM_NONE, LV_IMG_ZOOM_NONE * 10);
lv_obj_add_event_cb(slider, slider_x_event_cb, NULL);
lv_obj_set_size(slider, lv_obj_get_width(chart), 10);
lv_obj_align(slider, chart, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
slider = lv_slider_create(lv_scr_act(), NULL);
slider = lv_slider_create(lv_scr_act());
lv_slider_set_range(slider, LV_IMG_ZOOM_NONE, LV_IMG_ZOOM_NONE * 10);
lv_obj_add_event_cb(slider, slider_y_event_cb, NULL);
lv_obj_set_size(slider, 10, lv_obj_get_height(chart));
+2 -2
View File
@@ -57,7 +57,7 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
*/
void lv_example_chart_6(void)
{
chart = lv_chart_create(lv_scr_act(), NULL);
chart = lv_chart_create(lv_scr_act());
lv_obj_set_size(chart, 200, 150);
lv_obj_align(chart, NULL, LV_ALIGN_CENTER, 0, -10);
@@ -77,7 +77,7 @@ void lv_example_chart_6(void)
lv_chart_set_zoom_x(chart, 500);
lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);
lv_obj_t * label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "Click on a point");
lv_obj_align(label, chart, LV_ALIGN_OUT_TOP_MID, 0, -5);

Some files were not shown because too many files have changed in this diff Show More