1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

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

View File

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

View File

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

View File

@ -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*/
}

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);
}

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);
}
}

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*/
}

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);
}
}

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);
}

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);
}

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);
}

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

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);
}

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);
}

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);
}

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);
}

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);
}

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

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

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);
}

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

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);
}

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);
}

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);
}

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);
}

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

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");

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}};

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);

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);

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);

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);

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);

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);

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);

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

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

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

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);

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

View File

@ -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);

View File

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

View File

@ -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);

View File

@ -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);

View File

@ -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());

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*/

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*/

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);

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);

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));

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);

View File

@ -16,21 +16,21 @@ void lv_example_checkbox_1(void)
lv_obj_set_flex_place(lv_scr_act(), LV_FLEX_PLACE_CENTER, LV_FLEX_PLACE_START, LV_FLEX_PLACE_CENTER);
lv_obj_t * cb;
cb = lv_checkbox_create(lv_scr_act(), NULL);
cb = lv_checkbox_create(lv_scr_act());
lv_checkbox_set_text(cb, "Apple");
lv_obj_add_event_cb(cb, event_handler, NULL);
cb = lv_checkbox_create(lv_scr_act(), NULL);
cb = lv_checkbox_create(lv_scr_act());
lv_checkbox_set_text(cb, "Banana");
lv_obj_add_state(cb, LV_STATE_CHECKED);
lv_obj_add_event_cb(cb, event_handler, NULL);
cb = lv_checkbox_create(lv_scr_act(), NULL);
cb = lv_checkbox_create(lv_scr_act());
lv_checkbox_set_text(cb, "Lemon");
lv_obj_add_state(cb, LV_STATE_DISABLED);
lv_obj_add_event_cb(cb, event_handler, NULL);
cb = lv_checkbox_create(lv_scr_act(), NULL);
cb = lv_checkbox_create(lv_scr_act());
lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED);
lv_checkbox_set_text(cb, "Melon");
lv_obj_add_event_cb(cb, event_handler, NULL);

View File

@ -16,7 +16,7 @@ void lv_example_dropdown_1(void)
{
/*Create a normal drop down list*/
lv_obj_t * dd = lv_dropdown_create(lv_scr_act(), NULL);
lv_obj_t * dd = lv_dropdown_create(lv_scr_act());
lv_dropdown_set_options(dd, "Apple\n"
"Banana\n"
"Orange\n"

View File

@ -15,23 +15,23 @@ void lv_example_dropdown_2(void)
"Raspberry";
lv_obj_t * dd;
dd = lv_dropdown_create(lv_scr_act(), NULL);
dd = lv_dropdown_create(lv_scr_act());
lv_dropdown_set_options_static(dd, opts);
lv_obj_align(dd, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
dd = lv_dropdown_create(lv_scr_act(), NULL);
dd = lv_dropdown_create(lv_scr_act());
lv_dropdown_set_options_static(dd, opts);
lv_dropdown_set_dir(dd, LV_DIR_BOTTOM);
lv_dropdown_set_symbol(dd, LV_SYMBOL_UP);
lv_obj_align(dd, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -10);
dd = lv_dropdown_create(lv_scr_act(), NULL);
dd = lv_dropdown_create(lv_scr_act());
lv_dropdown_set_options_static(dd, opts);
lv_dropdown_set_dir(dd, LV_DIR_RIGHT);
lv_dropdown_set_symbol(dd, LV_SYMBOL_RIGHT);
lv_obj_align(dd, NULL, LV_ALIGN_IN_LEFT_MID, 10, 0);
dd = lv_dropdown_create(lv_scr_act(), NULL);
dd = lv_dropdown_create(lv_scr_act());
lv_dropdown_set_options_static(dd, opts);
lv_dropdown_set_dir(dd, LV_DIR_LEFT);
lv_dropdown_set_symbol(dd, LV_SYMBOL_LEFT);

View File

@ -16,7 +16,7 @@ static void event_cb(lv_obj_t * dropdown, lv_event_t e)
void lv_example_dropdown_3(void)
{
/*Create a drop down list*/
lv_obj_t * dropdown = lv_dropdown_create(lv_scr_act(), NULL);
lv_obj_t * dropdown = lv_dropdown_create(lv_scr_act());
lv_obj_align(dropdown, NULL, LV_ALIGN_IN_TOP_LEFT, 10, 10);
lv_dropdown_set_options(dropdown, "New project\n"
"New file\n"

View File

@ -5,12 +5,12 @@
void lv_example_img_1(void)
{
LV_IMG_DECLARE(img_cogwheel_argb);
lv_obj_t * img1 = lv_img_create(lv_scr_act(), NULL);
lv_obj_t * img1 = lv_img_create(lv_scr_act());
lv_img_set_src(img1, &img_cogwheel_argb);
lv_obj_align(img1, NULL, LV_ALIGN_CENTER, 0, -20);
lv_obj_set_size(img1, 200, 200);
lv_obj_t * img2 = lv_img_create(lv_scr_act(), NULL);
lv_obj_t * img2 = lv_img_create(lv_scr_act());
lv_img_set_src(img2, LV_SYMBOL_OK "Accept");
lv_obj_align(img2, img1, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
}

View File

@ -31,7 +31,7 @@ void lv_example_img_2(void)
/*Now create the actual image*/
LV_IMG_DECLARE(img_cogwheel_argb)
img1 = lv_img_create(lv_scr_act(), NULL);
img1 = lv_img_create(lv_scr_act());
lv_img_set_src(img1, &img_cogwheel_argb);
lv_obj_align(img1, NULL, LV_ALIGN_IN_RIGHT_MID, -20, 0);
@ -53,7 +53,7 @@ static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
static lv_obj_t * create_slider(lv_color_t color)
{
lv_obj_t * slider = lv_slider_create(lv_scr_act(), NULL);
lv_obj_t * slider = lv_slider_create(lv_scr_act());
lv_slider_set_range(slider, 0, 255);
lv_obj_set_size(slider, 10, 200);
lv_obj_set_style_bg_color(slider, LV_PART_KNOB, LV_STATE_DEFAULT, color);

View File

@ -20,7 +20,7 @@ void lv_example_img_3(void)
LV_IMG_DECLARE(img_cogwheel_argb);
/*Now create the actual image*/
lv_obj_t * img = lv_img_create(lv_scr_act(), NULL);
lv_obj_t * img = lv_img_create(lv_scr_act());
lv_img_set_src(img, &img_cogwheel_argb);
lv_obj_align(img, NULL, LV_ALIGN_CENTER, 50, 50);
lv_img_set_pivot(img, 0, 0); /*Rotate around the top left corner*/

View File

@ -20,7 +20,7 @@ void lv_example_img_4(void)
lv_style_set_img_recolor_opa(&style, LV_OPA_COVER);
lv_style_set_img_recolor(&style, lv_color_black());
lv_obj_t * img = lv_img_create(lv_scr_act(), NULL);
lv_obj_t * img = lv_img_create(lv_scr_act());
lv_obj_add_style(img, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_img_set_src(img, &img_skew_strip);
lv_obj_set_size(img, 150, 100);

View File

@ -33,7 +33,7 @@ void lv_example_imgbtn_1(void)
lv_obj_align(imgbtn1, NULL, LV_ALIGN_CENTER, 0, 0);
/*Create a label on the image button*/
lv_obj_t * label = lv_label_create(imgbtn1, NULL);
lv_obj_t * label = lv_label_create(imgbtn1);
lv_label_set_text(label, "Button");
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, -4);
}

View File

@ -22,12 +22,12 @@ void lv_example_keyboard_1(void)
/*Create a text area. The keyboard will write here*/
lv_obj_t * ta;
ta = lv_textarea_create(lv_scr_act(), NULL);
ta = lv_textarea_create(lv_scr_act());
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_LEFT, 10, 10);
lv_obj_add_event_cb(ta, ta_event_cb, kb);
lv_textarea_set_placeholder_text(ta, "Hello");
ta = lv_textarea_create(lv_scr_act(), NULL);
ta = lv_textarea_create(lv_scr_act());
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_RIGHT, -10, 10);
lv_obj_add_event_cb(ta, ta_event_cb, kb);

View File

@ -6,7 +6,7 @@
*/
void lv_example_label_1(void)
{
lv_obj_t * label1 = lv_label_create(lv_scr_act(), NULL);
lv_obj_t * label1 = lv_label_create(lv_scr_act());
lv_label_set_long_mode(label1, LV_LABEL_LONG_WRAP); /*Break the long lines*/
lv_label_set_recolor(label1, true); /*Enable re-coloring by commands in the text*/
lv_label_set_text(label1, "#0000ff Re-color# #ff00ff words# #ff0000 of a# label, align the lines to the center"
@ -16,7 +16,7 @@ void lv_example_label_1(void)
lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, -40);
lv_obj_t * label2 = lv_label_create(lv_scr_act(), NULL);
lv_obj_t * label2 = lv_label_create(lv_scr_act());
lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR); /*Circular scroll*/
lv_obj_set_width(label2, 150);
lv_label_set_text(label2, "It is a circularly scrolling text. ");

View File

@ -13,11 +13,11 @@ void lv_example_label_2(void)
lv_style_set_text_color(&style_shadow, lv_color_black());
/*Create a label for the shadow first (it's in the background)*/
lv_obj_t * shadow_label = lv_label_create(lv_scr_act(), NULL);
lv_obj_t * shadow_label = lv_label_create(lv_scr_act());
lv_obj_add_style(shadow_label, LV_PART_MAIN, LV_STATE_DEFAULT, &style_shadow);
/*Create the main label*/
lv_obj_t * main_label = lv_label_create(lv_scr_act(), NULL);
lv_obj_t * main_label = lv_label_create(lv_scr_act());
lv_label_set_text(main_label, "A simple method to create\n"
"shadows on a text.\n"
"It even works with\n\n"

View File

@ -15,7 +15,7 @@ void lv_example_line_1(void)
/*Create a line and apply the new style*/
lv_obj_t * line1;
line1 = lv_line_create(lv_scr_act(), NULL);
line1 = lv_line_create(lv_scr_act());
lv_line_set_points(line1, line_points, 5); /*Set the points*/
lv_obj_add_style(line1, LV_PART_MAIN, LV_STATE_DEFAULT, &style_line); /*Set the points*/
lv_obj_align(line1, NULL, LV_ALIGN_CENTER, 0, 0);

View File

@ -19,7 +19,7 @@ void lv_example_list_1(void)
uint32_t t = lv_tick_get();
int i;
for(i = 0; i < 3; i++) {
// lv_btn_create(lv_scr_act(), NULL);
// lv_btn_create(lv_scr_act());
lv_list_add_btn(list1, LV_SYMBOL_FILE, "New", event_handler);
}

View File

@ -13,7 +13,7 @@ static void set_value(void * indic, int32_t v)
*/
void lv_example_meter_1(void)
{
meter = lv_meter_create(lv_scr_act(), NULL);
meter = lv_meter_create(lv_scr_act());
lv_obj_align(meter, NULL, LV_ALIGN_CENTER, 0, 0);
/*Add a scale first*/

View File

@ -14,7 +14,7 @@ static void set_value(void * indic, int32_t v)
*/
void lv_example_meter_2(void)
{
meter = lv_meter_create(lv_scr_act(), NULL);
meter = lv_meter_create(lv_scr_act());
lv_obj_align(meter, NULL, LV_ALIGN_CENTER, 0, 0);
/*Remove the circle from the middle*/

View File

@ -14,7 +14,7 @@ static void set_value(void * indic, int32_t v)
*/
void lv_example_meter_3(void)
{
meter = lv_meter_create(lv_scr_act(), NULL);
meter = lv_meter_create(lv_scr_act());
lv_obj_align(meter, NULL, LV_ALIGN_CENTER, 0, 0);
/*Create a scale for the minutes*/

View File

@ -6,7 +6,7 @@
*/
void lv_example_meter_4(void)
{
lv_obj_t * meter = lv_meter_create(lv_scr_act(), NULL);
lv_obj_t * meter = lv_meter_create(lv_scr_act());
lv_obj_align(meter, NULL, LV_ALIGN_CENTER, 0, 0);
/*Remove the background and the circle from the middle*/

View File

@ -4,7 +4,7 @@
void lv_example_obj_1(void)
{
lv_obj_t * obj1;
obj1 = lv_obj_create(lv_scr_act(), NULL);
obj1 = lv_obj_create(lv_scr_act());
lv_obj_set_size(obj1, 100, 50);
lv_obj_align(obj1, NULL, LV_ALIGN_CENTER, -60, -30);
@ -15,7 +15,7 @@ void lv_example_obj_1(void)
lv_style_set_shadow_color(&style_shadow, lv_color_blue());
lv_obj_t * obj3;
obj3 = lv_obj_create(lv_scr_act(), NULL);
obj3 = lv_obj_create(lv_scr_act());
lv_obj_add_style(obj3, LV_PART_MAIN, LV_STATE_DEFAULT, &style_shadow);
lv_obj_align(obj3, NULL, LV_ALIGN_CENTER, 60, 30);
}

View File

@ -15,7 +15,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event)
*/
void lv_example_roller_1(void)
{
lv_obj_t *roller1 = lv_roller_create(lv_scr_act(), NULL);
lv_obj_t *roller1 = lv_roller_create(lv_scr_act());
lv_roller_set_options(roller1,
"January\n"
"February\n"

View File

@ -24,7 +24,7 @@ void lv_example_roller_2(void)
lv_obj_t *roller;
/*A roller on the left with left aligned text, and custom width*/
roller = lv_roller_create(lv_scr_act(), NULL);
roller = lv_roller_create(lv_scr_act());
lv_roller_set_options(roller, opts, LV_ROLLER_MODE_NORMAL);
lv_roller_set_visible_row_count(roller, 2);
lv_obj_set_width(roller, 100);
@ -35,7 +35,7 @@ void lv_example_roller_2(void)
lv_roller_set_selected(roller, 2, LV_ANIM_OFF);
/*A roller on the middle with center aligned text, and auto (default) width*/
roller = lv_roller_create(lv_scr_act(), NULL);
roller = lv_roller_create(lv_scr_act());
lv_roller_set_options(roller, opts, LV_ROLLER_MODE_NORMAL);
lv_roller_set_visible_row_count(roller, 3);
lv_obj_add_style(roller, LV_PART_SELECTED, LV_STATE_DEFAULT, &style_sel);
@ -44,7 +44,7 @@ void lv_example_roller_2(void)
lv_roller_set_selected(roller, 5, LV_ANIM_OFF);
/*A roller on the right with right aligned text, and custom width*/
roller = lv_roller_create(lv_scr_act(), NULL);
roller = lv_roller_create(lv_scr_act());
lv_roller_set_options(roller, opts, LV_ROLLER_MODE_NORMAL);
lv_roller_set_visible_row_count(roller, 4);
lv_obj_set_width(roller, 80);

View File

@ -10,12 +10,12 @@ static lv_obj_t * slider_label;
void lv_example_slider_1(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_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_event_cb(slider, slider_event_cb, NULL);
/*Create a label below the slider*/
slider_label = lv_label_create(lv_scr_act(), NULL);
slider_label = lv_label_create(lv_scr_act());
lv_label_set_text(slider_label, "0%");
lv_obj_align(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);

View File

@ -1,41 +1,41 @@
#include "../../../lvgl.h"
#if LV_USE_SLIDER && LV_BUILD_EXAMPLES
static void slider_event_cb(lv_obj_t * slider, lv_event_t event);
static lv_style_t style_pr;
static lv_style_t style_def;
/**
* Show the current value when the slider if pressed using a fancy style transition.
*/
void lv_example_slider_2(void)
{
lv_style_init(&style_def);
lv_style_set_content_opa(&style_def, LV_OPA_TRANSP);
lv_style_set_content_align(&style_def, LV_ALIGN_OUT_TOP_MID);
lv_style_init(&style_pr);
lv_style_set_content_opa(&style_pr, LV_OPA_COVER);
lv_style_set_content_ofs_y(&style_pr, -15);
/*Create a slider in the center of the display*/
lv_obj_t * slider;
slider = lv_slider_create(lv_scr_act(), NULL);
lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_event_cb(slider, slider_event_cb, NULL);
lv_obj_add_style(slider, LV_PART_KNOB, LV_STATE_DEFAULT, &style_def);
lv_obj_add_style(slider, LV_PART_KNOB, LV_STATE_PRESSED, &style_pr);
}
static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
{
if(event == LV_EVENT_VALUE_CHANGED) {
static char buf[8];
lv_snprintf(buf, sizeof(buf), "%u", lv_slider_get_value(slider));
lv_obj_set_style_content_text(slider, LV_PART_KNOB, LV_STATE_DEFAULT, buf);
}
}
#endif
//#include "../../../lvgl.h"
//#if LV_USE_SLIDER && LV_BUILD_EXAMPLES
//
//static void slider_event_cb(lv_obj_t * slider, lv_event_t event);
//
//static lv_style_t style_pr;
//static lv_style_t style_def;
//
///**
// * Show the current value when the slider if pressed using a fancy style transition.
// */
//void lv_example_slider_2(void)
//{
// lv_style_init(&style_def);
// lv_style_set_content_opa(&style_def, LV_OPA_TRANSP);
// lv_style_set_content_align(&style_def, LV_ALIGN_OUT_TOP_MID);
//
// lv_style_init(&style_pr);
// lv_style_set_content_opa(&style_pr, LV_OPA_COVER);
// lv_style_set_content_ofs_y(&style_pr, -15);
//
// /*Create a slider in the center of the display*/
// lv_obj_t * slider;
// slider = lv_slider_create(lv_scr_act());
// lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);
// lv_obj_add_event_cb(slider, slider_event_cb, NULL);
//
// lv_obj_add_style(slider, LV_PART_KNOB, LV_STATE_DEFAULT, &style_def);
// lv_obj_add_style(slider, LV_PART_KNOB, LV_STATE_PRESSED, &style_pr);
//}
//
//static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
//{
// if(event == LV_EVENT_VALUE_CHANGED) {
// static char buf[8];
// lv_snprintf(buf, sizeof(buf), "%u", lv_slider_get_value(slider));
// lv_obj_set_style_content_text(slider, LV_PART_KNOB, LV_STATE_DEFAULT, buf);
// }
//}
//
//#endif

View File

@ -1,39 +1,39 @@
#include "../../../lvgl.h"
#if LV_USE_SLIDER && LV_BUILD_EXAMPLES
static void slider_event_cb(lv_obj_t * slider, lv_event_t event);
/**
* Show the current value when the slider if pressed (using only styles).
*
*/
void lv_example_slider_3(void)
{
/*Create a slider in the center of the display*/
lv_obj_t * slider;
slider = lv_slider_create(lv_scr_act(), NULL);
lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_event_cb(slider, slider_event_cb, NULL);
lv_slider_set_mode(slider, LV_SLIDER_MODE_RANGE);
lv_slider_set_value(slider, 70, LV_ANIM_OFF);
lv_slider_set_left_value(slider, 20, LV_ANIM_OFF);
/*Now use only a local style.*/
lv_obj_set_style_content_ofs_y(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, -20);
lv_obj_set_style_content_color(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, lv_color_grey_darken_3());
/*To update the value text*/
lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);
}
static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
{
if(event == LV_EVENT_VALUE_CHANGED) {
static char buf[8];
lv_snprintf(buf, sizeof(buf), "%d - %d", lv_slider_get_value(slider), lv_slider_get_left_value(slider));
lv_obj_set_style_content_text(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, buf);
}
}
#endif
//#include "../../../lvgl.h"
//#if LV_USE_SLIDER && LV_BUILD_EXAMPLES
//
//static void slider_event_cb(lv_obj_t * slider, lv_event_t event);
//
///**
// * Show the current value when the slider if pressed (using only styles).
// *
// */
//void lv_example_slider_3(void)
//{
// /*Create a slider in the center of the display*/
// lv_obj_t * slider;
// slider = lv_slider_create(lv_scr_act());
// lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);
// lv_obj_add_event_cb(slider, slider_event_cb, NULL);
// lv_slider_set_mode(slider, LV_SLIDER_MODE_RANGE);
//
// lv_slider_set_value(slider, 70, LV_ANIM_OFF);
// lv_slider_set_left_value(slider, 20, LV_ANIM_OFF);
//
// /*Now use only a local style.*/
// lv_obj_set_style_content_ofs_y(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, -20);
// lv_obj_set_style_content_color(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, lv_color_grey_darken_3());
//
// /*To update the value text*/
// lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);
//}
//
//static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
//{
// if(event == LV_EVENT_VALUE_CHANGED) {
// static char buf[8];
// lv_snprintf(buf, sizeof(buf), "%d - %d", lv_slider_get_value(slider), lv_slider_get_left_value(slider));
// lv_obj_set_style_content_text(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, buf);
// }
//}
//
//#endif

View File

@ -32,16 +32,16 @@ void lv_example_spinbox_1(void)
lv_coord_t h = lv_obj_get_height(spinbox);
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL);
lv_obj_t * btn = lv_btn_create(lv_scr_act());
lv_obj_set_size(btn, h, h);
lv_obj_align(btn, spinbox, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
lv_obj_set_style_content_text(btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_PLUS);
lv_obj_set_style_bg_img_src(btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_PLUS);
lv_obj_add_event_cb(btn, lv_spinbox_increment_event_cb, NULL);
btn = lv_btn_create(lv_scr_act(), NULL);
btn = lv_btn_create(lv_scr_act());
lv_obj_set_size(btn, h, h);
lv_obj_align(btn, spinbox, LV_ALIGN_OUT_LEFT_MID, -5, 0);
lv_obj_set_style_content_text(btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_MINUS);
lv_obj_set_style_bg_img_src(btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_MINUS);
lv_obj_add_event_cb(btn, lv_spinbox_decrement_event_cb, NULL);
}

View File

@ -15,18 +15,18 @@ void lv_example_switch_1(void)
lv_obj_t * sw;
sw = lv_switch_create(lv_scr_act(), NULL);
sw = lv_switch_create(lv_scr_act());
lv_obj_add_event_cb(sw, event_handler, NULL);
sw = lv_switch_create(lv_scr_act(), NULL);
sw = lv_switch_create(lv_scr_act());
lv_obj_add_state(sw, LV_STATE_CHECKED);
lv_obj_add_event_cb(sw, event_handler, NULL);
sw = lv_switch_create(lv_scr_act(), NULL);
sw = lv_switch_create(lv_scr_act());
lv_obj_add_state(sw, LV_STATE_DISABLED);
lv_obj_add_event_cb(sw, event_handler, NULL);
sw = lv_switch_create(lv_scr_act(), NULL);
sw = lv_switch_create(lv_scr_act());
lv_obj_add_state(sw, LV_STATE_CHECKED | LV_STATE_DISABLED);
lv_obj_add_event_cb(sw, event_handler, NULL);
}

View File

@ -33,7 +33,7 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
void lv_example_table_1(void)
{
lv_obj_t * table = lv_table_create(lv_scr_act(), NULL);
lv_obj_t * table = lv_table_create(lv_scr_act());
/*Fill the first column*/
lv_table_set_cell_value(table, 0, 0, "Name");

View File

@ -58,7 +58,7 @@ void lv_example_table_2(void)
uint32_t t = lv_tick_get();
lv_obj_t * table = lv_table_create(lv_scr_act(), NULL);
lv_obj_t * table = lv_table_create(lv_scr_act());
/*Set a smaller height to the table. It'll make it scrollable*/
lv_obj_set_size(table, 150, 200);
@ -87,7 +87,7 @@ void lv_example_table_2(void)
uint32_t elaps = lv_tick_elaps(t);
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_fmt(label, "%d bytes are used by the table\n"
"and %d items were added in %d ms",
mem_used, ITEM_CNT, elaps);

View File

@ -13,7 +13,7 @@ void lv_example_tabview_1(void)
lv_obj_t *tab3 = lv_tabview_add_tab(tabview, "Tab 3");
/*Add content to the tabs*/
lv_obj_t * label = lv_label_create(tab1, NULL);
lv_obj_t * label = lv_label_create(tab1);
lv_label_set_text(label, "This the first tab\n\n"
"If the content\n"
"of a tab\n"
@ -30,10 +30,10 @@ void lv_example_tabview_1(void)
"\n"
"Can you see it?");
label = lv_label_create(tab2, NULL);
label = lv_label_create(tab2);
lv_label_set_text(label, "Second tab");
label = lv_label_create(tab3, NULL);
label = lv_label_create(tab3);
lv_label_set_text(label, "Third tab");
lv_obj_scroll_to_view_recursive(label, LV_ANIM_ON);

View File

@ -17,7 +17,7 @@ static void btnm_event_handler(lv_obj_t * obj, lv_event_t event)
void lv_example_textarea_1(void)
{
lv_obj_t * ta = lv_textarea_create(lv_scr_act(), NULL);
lv_obj_t * ta = lv_textarea_create(lv_scr_act());
lv_textarea_set_one_line(ta, true);
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
lv_obj_add_state(ta, LV_STATE_FOCUSED); /*To be sure the cursor is visible*/
@ -27,7 +27,7 @@ void lv_example_textarea_1(void)
"7", "8", "9", "\n",
LV_SYMBOL_BACKSPACE, "0", LV_SYMBOL_NEW_LINE, ""};
lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act(), NULL);
lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act());
lv_obj_set_size(btnm, 200, 150);
lv_obj_align(btnm, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -10);
lv_obj_add_event_cb(btnm, btnm_event_handler, ta);

View File

@ -8,7 +8,7 @@ static lv_obj_t * kb;
void lv_example_textarea_2(void)
{
/*Create the password box*/
lv_obj_t * pwd_ta = lv_textarea_create(lv_scr_act(), NULL);
lv_obj_t * pwd_ta = lv_textarea_create(lv_scr_act());
lv_textarea_set_text(pwd_ta, "");
lv_textarea_set_password_mode(pwd_ta, true);
lv_textarea_set_one_line(pwd_ta, true);
@ -17,18 +17,18 @@ void lv_example_textarea_2(void)
lv_obj_add_event_cb(pwd_ta, ta_event_cb, NULL);
/*Create a label and position it above the text box*/
lv_obj_t * pwd_label = lv_label_create(lv_scr_act(), NULL);
lv_obj_t * pwd_label = lv_label_create(lv_scr_act());
lv_label_set_text(pwd_label, "Password:");
lv_obj_align(pwd_label, pwd_ta, LV_ALIGN_OUT_TOP_LEFT, 0, 0);
/*Create the one-line mode text area*/
lv_obj_t * oneline_ta = lv_textarea_create(lv_scr_act(), pwd_ta);
lv_obj_t * oneline_ta = lv_textarea_create(lv_scr_act());
lv_textarea_set_password_mode(oneline_ta, false);
lv_obj_align(oneline_ta, NULL, LV_ALIGN_IN_TOP_RIGHT, -5, 20);
/*Create a label and position it above the text box*/
lv_obj_t * oneline_label = lv_label_create(lv_scr_act(), NULL);
lv_obj_t * oneline_label = lv_label_create(lv_scr_act());
lv_label_set_text(oneline_label, "Text:");
lv_obj_align(oneline_label, oneline_ta, LV_ALIGN_OUT_TOP_LEFT, 0, 0);

View File

@ -12,7 +12,7 @@ static lv_obj_t * kb;
void lv_example_textarea_3(void)
{
/*Create the text area*/
lv_obj_t * ta = lv_textarea_create(lv_scr_act(), NULL);
lv_obj_t * ta = lv_textarea_create(lv_scr_act());
lv_obj_add_event_cb(ta, ta_event_cb, NULL);
lv_textarea_set_accepted_chars(ta, "0123456789:");
lv_textarea_set_max_length(ta, 5);

View File

@ -12,7 +12,7 @@ void lv_example_tileview_1(void)
/*Tile1: just a label*/
lv_obj_t * tile1 = lv_tileview_add_tile(tv, 0, 0, LV_DIR_BOTTOM);
lv_obj_t * label = lv_label_create(tile1, NULL);
lv_obj_t * label = lv_label_create(tile1);
lv_label_set_text(label, "Scroll down");
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
@ -20,9 +20,9 @@ void lv_example_tileview_1(void)
/*Tile2: a button*/
lv_obj_t * tile2 = lv_tileview_add_tile(tv, 0, 1, LV_DIR_TOP | LV_DIR_RIGHT);
lv_obj_t * btn = lv_btn_create(tile2, NULL);
lv_obj_t * btn = lv_btn_create(tile2);
label = lv_label_create(btn, NULL);
label = lv_label_create(btn);
lv_label_set_text(label, "Scroll up or right");
lv_obj_set_size(btn, LV_SIZE_CONTENT, LV_SIZE_CONTENT);

View File

@ -18,7 +18,7 @@ void lv_example_win_1(void)
lv_win_add_btn(win, LV_SYMBOL_CLOSE, 60, event_handler);
lv_obj_t * cont = lv_win_get_content(win); /*Content can be aded here*/
lv_obj_t * label = lv_label_create(cont, NULL);
lv_obj_t * label = lv_label_create(cont);
lv_label_set_text(label, "This is\n"
"a pretty\n"
"long text\n"

View File

@ -59,7 +59,7 @@ typedef struct {
/**********************
* STATIC PROTOTYPES
**********************/
static void lv_obj_constructor(lv_obj_t * obj, const lv_obj_t * copy);
static void lv_obj_constructor(lv_obj_t * obj);
static void lv_obj_destructor(lv_obj_t * obj);
static void lv_obj_draw(lv_obj_t * obj, lv_event_t e);
static void lv_obj_event_cb(lv_obj_t * obj, lv_event_t e);
@ -178,9 +178,9 @@ void lv_deinit(void)
}
#endif
lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
lv_obj_t * lv_obj_create(lv_obj_t * parent)
{
return lv_obj_create_from_class(&lv_obj_class, parent, copy);
return lv_obj_create_from_class(&lv_obj_class, parent);
}
/*---------------------
@ -606,7 +606,7 @@ bool lv_obj_is_valid(const lv_obj_t * obj)
* STATIC FUNCTIONS
**********************/
static void lv_obj_constructor(lv_obj_t * obj, const lv_obj_t * copy)
static void lv_obj_constructor(lv_obj_t * obj)
{
LV_TRACE_OBJ_CREATE("begin");
@ -751,7 +751,6 @@ static void lv_obj_draw(lv_obj_t * obj, lv_event_t e)
draw_dsc.bg_opa = LV_OPA_TRANSP;
draw_dsc.outline_opa = LV_OPA_TRANSP;
draw_dsc.shadow_opa = LV_OPA_TRANSP;
draw_dsc.content_opa = LV_OPA_TRANSP;
lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &draw_dsc);
lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);

View File

@ -283,11 +283,9 @@ void lv_deinit(void);
/**
* Create a base object (a rectangle)
* @param parent pointer to a parent object. If NULL then a screen will be created.
* @param copy DEPRECATED, will be removed in v9.
* Pointer to an other base object to copy.
* @return pointer to the new object
*/
lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy);
lv_obj_t * lv_obj_create(lv_obj_t * parent);
/*---------------------

View File

@ -24,7 +24,7 @@
/**********************
* STATIC PROTOTYPES
**********************/
static void lv_obj_construct(lv_obj_t * obj, const lv_obj_t * copy);
static void lv_obj_construct(lv_obj_t * obj);
static uint32_t get_instance_size(const lv_obj_class_t * class_p);
/**********************
@ -39,7 +39,7 @@ static uint32_t get_instance_size(const lv_obj_class_t * class_p);
* GLOBAL FUNCTIONS
**********************/
lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class_p, lv_obj_t * parent, const lv_obj_t * copy)
lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class_p, lv_obj_t * parent)
{
LV_TRACE_OBJ_CREATE("Creating object with %p class on %p parent", class_p, parent);
uint32_t s = get_instance_size(class_p);
@ -49,8 +49,53 @@ lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class_p, lv_obj_t * p
obj->class_p = class_p;
obj->parent = parent;
/*Create a screen*/
if(parent == NULL) {
LV_TRACE_OBJ_CREATE("creating a screen");
lv_disp_t * disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("No display created to so far. No place to assign the new screen");
return NULL;
}
if(disp->screens == NULL) {
disp->screens = lv_mem_alloc(sizeof(lv_obj_t *));
disp->screens[0] = obj;
disp->screen_cnt = 1;
} else {
disp->screen_cnt++;
disp->screens = lv_mem_realloc(disp->screens, sizeof(lv_obj_t *) * disp->screen_cnt);
disp->screens[disp->screen_cnt - 1] = obj;
}
/*Set coordinates to full screen size*/
obj->coords.x1 = 0;
obj->coords.y1 = 0;
obj->coords.x2 = lv_disp_get_hor_res(NULL) - 1;
obj->coords.y2 = lv_disp_get_ver_res(NULL) - 1;
}
/*Create a normal object*/
else {
LV_TRACE_OBJ_CREATE("creating normal object");
LV_ASSERT_OBJ(parent, MY_CLASS);
if(parent->spec_attr == NULL) {
lv_obj_allocate_spec_attr(parent);
}
if(parent->spec_attr->children == NULL) {
parent->spec_attr->children = lv_mem_alloc(sizeof(lv_obj_t *));
parent->spec_attr->children[0] = obj;
parent->spec_attr->child_cnt = 1;
} else {
parent->spec_attr->child_cnt++;
parent->spec_attr->children = lv_mem_realloc(parent->spec_attr->children, sizeof(lv_obj_t *) * parent->spec_attr->child_cnt);
parent->spec_attr->children[parent->spec_attr->child_cnt - 1] = obj;
}
}
lv_theme_apply(obj);
lv_obj_construct(obj, copy);
lv_obj_construct(obj);
if(parent) {
/*Call the ancestor's event handler to the parent to notify it about the new child.
@ -93,7 +138,7 @@ bool lv_obj_is_editable(struct _lv_obj_t * obj)
* STATIC FUNCTIONS
**********************/
static void lv_obj_construct(lv_obj_t * obj, const lv_obj_t * copy)
static void lv_obj_construct(lv_obj_t * obj)
{
const lv_obj_class_t * original_class_p = obj->class_p;
@ -102,13 +147,13 @@ static void lv_obj_construct(lv_obj_t * obj, const lv_obj_t * copy)
obj->class_p = obj->class_p->base_class;
/*Construct the base first*/
lv_obj_construct(obj, copy);
lv_obj_construct(obj);
}
/*Restore the original class*/
obj->class_p = original_class_p;
if(obj->class_p->constructor_cb) obj->class_p->constructor_cb(obj, copy);
if(obj->class_p->constructor_cb) obj->class_p->constructor_cb(obj);
}
static uint32_t get_instance_size(const lv_obj_class_t * class_p)

View File

@ -39,7 +39,7 @@ typedef enum {
*/
typedef struct _lv_obj_class_t {
const struct _lv_obj_class_t * base_class;
void (*constructor_cb)(struct _lv_obj_t * obj, const struct _lv_obj_t * copy);
void (*constructor_cb)(struct _lv_obj_t * obj);
void (*destructor_cb)(struct _lv_obj_t * obj);
lv_event_cb_t event_cb; /**< Object type specific event function*/
uint32_t editable : 2; /**< Value from ::lv_obj_class_editable_t*/
@ -54,10 +54,9 @@ typedef struct _lv_obj_class_t {
* Create an object form a class descriptor
* @param class_p pointer to a class
* @param parent pointer to an object where the new object should be created
* @param copy pointer to an other object with the same type to copy (DEPRECATED will be removed in v9)
* @return pointer to the created object
*/
struct _lv_obj_t * lv_obj_create_from_class(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * parent, const struct _lv_obj_t * copy);
struct _lv_obj_t * lv_obj_create_from_class(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * parent);
void _lv_obj_destruct(struct _lv_obj_t * obj);

View File

@ -94,26 +94,14 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
if(draw_dsc->bg_img_src) {
draw_dsc->bg_img_opa = lv_obj_get_style_bg_img_opa(obj, part);
if(draw_dsc->bg_img_opa > LV_OPA_MIN) {
draw_dsc->bg_img_recolor = lv_obj_get_style_bg_img_recolor(obj, part);
draw_dsc->bg_img_recolor_opa = lv_obj_get_style_bg_img_recolor_opa(obj, part);
draw_dsc->bg_img_tiled = lv_obj_get_style_bg_img_tiled(obj, part);
}
}
}
if(draw_dsc->content_opa != LV_OPA_TRANSP) {
draw_dsc->content_text = lv_obj_get_style_content_text(obj, part);
if(draw_dsc->content_text) {
draw_dsc->content_opa = lv_obj_get_style_content_opa(obj, part);
if(draw_dsc->content_opa > LV_OPA_MIN) {
draw_dsc->content_ofs_y = lv_obj_get_style_content_ofs_y(obj, part);
draw_dsc->content_ofs_x = lv_obj_get_style_content_ofs_x(obj, part);
draw_dsc->content_align = lv_obj_get_style_content_align(obj, part);
draw_dsc->content_font = lv_obj_get_style_content_font(obj, part);
draw_dsc->content_color = lv_obj_get_style_content_color_filtered(obj, part);
draw_dsc->content_letter_space = lv_obj_get_style_content_letter_space(obj, part);
draw_dsc->content_line_space = lv_obj_get_style_content_line_space(obj, part);
if(lv_img_src_get_type(draw_dsc->bg_img_src) == LV_IMG_SRC_SYMBOL) {
draw_dsc->bg_img_symbol_font= lv_obj_get_style_text_font(obj, part);
draw_dsc->bg_img_recolor = lv_obj_get_style_text_color(obj, part);
} else {
draw_dsc->bg_img_recolor = lv_obj_get_style_bg_img_recolor(obj, part);
draw_dsc->bg_img_recolor_opa = lv_obj_get_style_bg_img_recolor_opa(obj, part);
draw_dsc->bg_img_tiled = lv_obj_get_style_bg_img_tiled(obj, part);
}
}
}
}
@ -141,7 +129,6 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
draw_dsc->bg_opa = (uint16_t)((uint16_t)draw_dsc->bg_opa * opa) >> 8;
draw_dsc->border_opa = (uint16_t)((uint16_t)draw_dsc->border_opa * opa) >> 8;
draw_dsc->shadow_opa = (uint16_t)((uint16_t)draw_dsc->shadow_opa * opa) >> 8;
draw_dsc->content_opa = (uint16_t)((uint16_t)draw_dsc->content_opa * opa) >> 8;
draw_dsc->outline_opa = (uint16_t)((uint16_t)draw_dsc->outline_opa * opa) >> 8;
}
#else /*LV_DRAW_COMPLEX*/
@ -332,41 +319,6 @@ lv_coord_t lv_obj_calculate_ext_draw_size(lv_obj_t * obj, uint8_t part)
}
}
const void * content_text = lv_obj_get_style_content_text(obj, part);
if(content_text) {
lv_opa_t content_opa;
lv_point_t content_size;
content_opa = lv_obj_get_style_text_opa(obj, part);
if(content_opa > 0) {
lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, part);
lv_coord_t line_space = lv_obj_get_style_text_letter_space(obj, part);
const lv_font_t * font = lv_obj_get_style_text_font(obj, part);
lv_txt_get_size(&content_size, content_text, font, letter_space, line_space, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
lv_area_t content_area;
content_area.x1 = 0;
content_area.y1 = 0;
content_area.x2 = content_size.x - 1;
content_area.y2 = content_size.y - 1;
lv_align_t align = lv_obj_get_style_content_align(obj, part);
lv_coord_t xofs = lv_obj_get_style_content_ofs_x(obj, part);
lv_coord_t yofs = lv_obj_get_style_content_ofs_y(obj, part);
lv_point_t p_align;
_lv_area_align(&obj->coords, &content_area, align, &p_align);
content_area.x1 += p_align.x + xofs;
content_area.y1 += p_align.y + yofs;
content_area.x2 += p_align.x + xofs;
content_area.y2 += p_align.y + yofs;
s = LV_MAX(s, obj->coords.x1 - content_area.x1);
s = LV_MAX(s, obj->coords.y1 - content_area.y1);
s = LV_MAX(s, content_area.x2 - obj->coords.x2);
s = LV_MAX(s, content_area.y2 - obj->coords.y2);
}
}
lv_coord_t w = lv_obj_get_style_transform_width(obj, part);
lv_coord_t h = lv_obj_get_style_transform_height(obj, part);
lv_coord_t wh = LV_MAX(w, h);

View File

@ -360,14 +360,6 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_OFS_Y, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_SPREAD, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_LINE_WIDTH, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_TEXT, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_OFS_X, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_OFS_Y, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_ALIGN, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_FONT, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_LINE_SPACE, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_LETTER_SPACE, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_OPA, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else {
if(res != _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) {
if((obj->styles[i].part == LV_PART_MAIN || obj->styles[i].part == LV_PART_SCROLLBAR)) {

View File

@ -485,72 +485,6 @@ static inline const void * lv_obj_get_style_arc_img_src(const struct _lv_obj_t *
return (const void *)v.ptr;
}
static inline const char * lv_obj_get_style_content_text(const struct _lv_obj_t * obj, uint32_t part)
{
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_TEXT);
return (const char *)v.ptr;
}
static inline lv_align_t lv_obj_get_style_content_align(const struct _lv_obj_t * obj, uint32_t part)
{
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_ALIGN);
return (lv_align_t)v.num;
}
static inline lv_coord_t lv_obj_get_style_content_ofs_x(const struct _lv_obj_t * obj, uint32_t part)
{
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OFS_X);
return (lv_coord_t)v.num;
}
static inline lv_coord_t lv_obj_get_style_content_ofs_y(const struct _lv_obj_t * obj, uint32_t part)
{
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OFS_Y);
return (lv_coord_t)v.num;
}
static inline lv_opa_t lv_obj_get_style_content_opa(const struct _lv_obj_t * obj, uint32_t part)
{
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OPA);
return (lv_opa_t)v.num;
}
static inline const lv_font_t * lv_obj_get_style_content_font(const struct _lv_obj_t * obj, uint32_t part)
{
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_FONT);
return (const lv_font_t *)v.ptr;
}
static inline lv_color_t lv_obj_get_style_content_color(const struct _lv_obj_t * obj, uint32_t part)
{
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_COLOR);
return v.color;
}
static inline lv_color_t lv_obj_get_style_content_color_filtered(const struct _lv_obj_t * obj, uint32_t part)
{
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_COLOR_FILTERED);
return v.color;
}
static inline lv_coord_t lv_obj_get_style_content_letter_space(const struct _lv_obj_t * obj, uint32_t part)
{
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_LETTER_SPACE);
return (lv_coord_t)v.num;
}
static inline lv_coord_t lv_obj_get_style_content_line_space(const struct _lv_obj_t * obj, uint32_t part)
{
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_LINE_SPACE);
return (lv_coord_t)v.num;
}
static inline lv_text_decor_t lv_obj_get_style_content_decor(const struct _lv_obj_t * obj, uint32_t part)
{
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_DECOR);
return (lv_text_decor_t)v.num;
}
static inline void lv_obj_set_style_radius(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value)
{
lv_style_value_t v = {
@ -1199,91 +1133,3 @@ static inline void lv_obj_set_style_arc_img_src(struct _lv_obj_t * obj, uint32_t
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_ARC_IMG_SRC, v);
}
static inline void lv_obj_set_style_content_text(struct _lv_obj_t * obj, uint32_t part, uint32_t state, const char * value)
{
lv_style_value_t v = {
.ptr = value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_TEXT, v);
}
static inline void lv_obj_set_style_content_align(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_align_t value)
{
lv_style_value_t v = {
.num = (int32_t)value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_ALIGN, v);
}
static inline void lv_obj_set_style_content_ofs_x(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value)
{
lv_style_value_t v = {
.num = (int32_t)value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_OFS_X, v);
}
static inline void lv_obj_set_style_content_ofs_y(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value)
{
lv_style_value_t v = {
.num = (int32_t)value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_OFS_Y, v);
}
static inline void lv_obj_set_style_content_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value)
{
lv_style_value_t v = {
.num = (int32_t)value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_OPA, v);
}
static inline void lv_obj_set_style_content_font(struct _lv_obj_t * obj, uint32_t part, uint32_t state, const lv_font_t * value)
{
lv_style_value_t v = {
.ptr = value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_FONT, v);
}
static inline void lv_obj_set_style_content_color(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value)
{
lv_style_value_t v = {
.color = value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_COLOR, v);
}
static inline void lv_obj_set_style_content_color_filtered(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value)
{
lv_style_value_t v = {
.color = value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_COLOR_FILTERED, v);
}
static inline void lv_obj_set_style_content_letter_space(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value)
{
lv_style_value_t v = {
.num = (int32_t)value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_LETTER_SPACE, v);
}
static inline void lv_obj_set_style_content_line_space(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value)
{
lv_style_value_t v = {
.num = (int32_t)value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_LINE_SPACE, v);
}
static inline void lv_obj_set_style_content_decor(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_text_decor_t value)
{
lv_style_value_t v = {
.num = (int32_t)value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_DECOR, v);
}

View File

@ -32,20 +32,8 @@ struct _lv_obj_class_t;
* GLOBAL PROTOTYPES
**********************/
/**
* Create a basic object
* @param parent pointer to a parent object.
* If NULL then a screen will be created
* @param copy pointer to a base object, if not NULL then the new object will be copied from it
* @return pointer to the new object
*/
void lv_obj_del(struct _lv_obj_t * obj);
/**
* Delete 'obj' and all of its children
* @param obj pointer to an object to delete
* @return LV_RES_INV because the object is deleted
*/
void lv_obj_clean(struct _lv_obj_t * obj);
/**

View File

@ -45,8 +45,6 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coord
LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups_buf);
#endif
static void draw_content(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc);
static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip,
lv_coord_t radius, bool radius_is_in, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
#if LV_DRAW_COMPLEX
@ -76,16 +74,13 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
dsc->bg_color = lv_color_white();
dsc->bg_grad_color = lv_color_black();
dsc->border_color = lv_color_black();
dsc->content_color = lv_color_black();
dsc->shadow_color = lv_color_black();
dsc->bg_grad_color_stop = 0xFF;
dsc->bg_img_symbol_font = LV_FONT_DEFAULT;
dsc->bg_opa = LV_OPA_COVER;
dsc->bg_img_opa = LV_OPA_COVER;
dsc->outline_opa = LV_OPA_COVER;
dsc->border_opa = LV_OPA_COVER;
dsc->content_font = LV_FONT_DEFAULT;
dsc->content_opa = LV_OPA_COVER;
dsc->content_align = LV_ALIGN_CENTER;
dsc->shadow_opa = LV_OPA_COVER;
dsc->border_side = LV_BORDER_SIDE_FULL;
}
@ -108,8 +103,6 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_dra
draw_border(coords, clip, dsc);
draw_content(coords, clip, dsc);
draw_outline(coords, clip, dsc);
LV_ASSERT_MEM_INTEGRITY();
@ -344,44 +337,58 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg_img(const lv_area_t * coords, const lv
if(dsc->bg_img_opa <= LV_OPA_MIN) return;
lv_img_src_t src_type = lv_img_src_get_type(dsc->bg_img_src);
if(src_type != LV_IMG_SRC_VARIABLE && src_type != LV_IMG_SRC_FILE) {
LV_LOG_WARN("bg_img_src must be variable or path");
return;
}
lv_img_header_t header;
lv_res_t res = lv_img_decoder_get_info(dsc->bg_img_src, &header);
if(res != LV_RES_OK) {
LV_LOG_WARN("Coudn't read the background image");
return;
if(src_type == LV_IMG_SRC_SYMBOL) {
lv_point_t size;
lv_txt_get_size(&size, dsc->bg_img_src, dsc->bg_img_symbol_font, 0, 0, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
lv_area_t a;
a.x1 = coords->x1 + lv_area_get_width(coords) / 2 - size.x / 2;
a.x2 = a.x1 + size.x - 1;
a.y1 = coords->y1 + lv_area_get_height(coords) / 2 - size.y / 2;
a.y2 = a.y1 + size.y - 1;
lv_draw_label_dsc_t label_draw_dsc;
lv_draw_label_dsc_init(&label_draw_dsc);
label_draw_dsc.font = dsc->bg_img_symbol_font;
label_draw_dsc.color = dsc->bg_img_recolor;
label_draw_dsc.opa = dsc->bg_img_opa;
lv_draw_label(&a, clip, &label_draw_dsc, dsc->bg_img_src, NULL);
}
else {
lv_img_header_t header;
lv_res_t res = lv_img_decoder_get_info(dsc->bg_img_src, &header);
if(res != LV_RES_OK) {
LV_LOG_WARN("Coudn't read the background image");
return;
}
lv_draw_img_dsc_t img_dsc;
lv_draw_img_dsc_init(&img_dsc);
img_dsc.blend_mode = dsc->blend_mode;
img_dsc.recolor = dsc->bg_img_recolor;
img_dsc.recolor_opa = dsc->bg_img_recolor_opa;
img_dsc.opa = dsc->bg_img_opa;
lv_draw_img_dsc_t img_dsc;
lv_draw_img_dsc_init(&img_dsc);
img_dsc.blend_mode = dsc->blend_mode;
img_dsc.recolor = dsc->bg_img_recolor;
img_dsc.recolor_opa = dsc->bg_img_recolor_opa;
img_dsc.opa = dsc->bg_img_opa;
/*Center align*/
if(dsc->bg_img_tiled == false) {
lv_area_t area;
area.x1 = coords->x1 + lv_area_get_width(coords) / 2 - header.w / 2;
area.y1 = coords->y1 + lv_area_get_height(coords) / 2 - header.h / 2;
area.x2 = area.x1 + header.w - 1;
area.y2 = area.y1 + header.h - 1;
lv_draw_img(&area, clip, dsc->bg_img_src, &img_dsc);
} else {
lv_area_t area;
area.y1 = coords->y1;
area.y2 = area.y1 + header.h - 1;
for(; area.y1 <= coords->y2; area.y1 += header.h, area.y2 += header.h) {
area.x1 = coords->x1;
/*Center align*/
if(dsc->bg_img_tiled == false) {
lv_area_t area;
area.x1 = coords->x1 + lv_area_get_width(coords) / 2 - header.w / 2;
area.y1 = coords->y1 + lv_area_get_height(coords) / 2 - header.h / 2;
area.x2 = area.x1 + header.w - 1;
for(; area.x1 <= coords->x2; area.x1 += header.w, area.x2 += header.w) {
lv_draw_img(&area, clip, dsc->bg_img_src, &img_dsc);
area.y2 = area.y1 + header.h - 1;
lv_draw_img(&area, clip, dsc->bg_img_src, &img_dsc);
} else {
lv_area_t area;
area.y1 = coords->y1;
area.y2 = area.y1 + header.h - 1;
for(; area.y1 <= coords->y2; area.y1 += header.h, area.y2 += header.h) {
area.x1 = coords->x1;
area.x2 = area.x1 + header.w - 1;
for(; area.x1 <= coords->x2; area.x1 += header.w, area.x2 += header.w) {
lv_draw_img(&area, clip, dsc->bg_img_src, &img_dsc);
}
}
}
}
@ -603,7 +610,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
shadow_draw_corner_buf(&sh_rect_area, (uint16_t *)sh_buf, dsc->shadow_width, r_sh);
/*Cache the corner if it fits into the cache size*/
if(corner_size * corner_size < sizeof(sh_cache)) {
if((uint32_t)corner_size * corner_size < sizeof(sh_cache)) {
lv_memcpy(sh_cache, sh_buf, corner_size * corner_size);
sh_cache_size = corner_size;
sh_cache_r = r_sh;
@ -1196,58 +1203,6 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, const
dsc->blend_mode);
}
static void draw_content(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc)
{
if(dsc->content_text == NULL) return;
if(dsc->content_opa == LV_OPA_MIN) return;
lv_draw_label_dsc_t label_dsc;
#if LV_USE_ARABIC_PERSIAN_CHARS
size_t len = _lv_txt_ap_calc_bytes_cnt(dsc->content_text) + 1;
char * txt = txt = lv_mem_buf_get(len);
_lv_txt_ap_proc(dsc->content_text, txt);
#else
const char * txt = dsc->content_text;
#endif
lv_draw_label_dsc_init(&label_dsc);
label_dsc.color = dsc->content_color;
label_dsc.font = dsc->content_font;
label_dsc.opa = dsc->content_opa;
label_dsc.letter_space = dsc->content_letter_space;
label_dsc.line_space = dsc->content_line_space;
lv_point_t s;
lv_txt_get_size(&s, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
LV_TEXT_FLAG_NONE);
/*Can't draw zero sized images*/
if(s.x == 0 || s.y == 0) return;
lv_area_t coords_tmp;
coords_tmp.x1 = 0;
coords_tmp.y1 = 0;
coords_tmp.x2 = s.x - 1;
coords_tmp.y2 = s.y - 1;
lv_point_t p_align;
_lv_area_align(coords, &coords_tmp, dsc->content_align, &p_align);
coords_tmp.x1 += p_align.x + dsc->content_ofs_x;
coords_tmp.y1 += p_align.y + dsc->content_ofs_y;
coords_tmp.x2 += p_align.x + dsc->content_ofs_x;
coords_tmp.y2 += p_align.y + dsc->content_ofs_y;
lv_draw_label(&coords_tmp, clip, &label_dsc, dsc->content_text, NULL);
#if LV_USE_ARABIC_PERSIAN_CHARS
lv_mem_buf_release(txt);
#endif
}
static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip,
lv_coord_t radius, bool radius_is_in, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode)
{

View File

@ -41,6 +41,7 @@ typedef struct {
/*Background img*/
const void * bg_img_src;
const void * bg_img_symbol_font;
lv_color_t bg_img_recolor;
lv_opa_t bg_img_opa;
lv_opa_t bg_img_recolor_opa;
@ -66,18 +67,6 @@ typedef struct {
lv_coord_t shadow_ofs_y;
lv_coord_t shadow_spread;
lv_opa_t shadow_opa;
/*Content*/
const void * content_text;
const lv_font_t * content_font;
lv_coord_t content_letter_space;
lv_coord_t content_line_space;
lv_coord_t content_ofs_x;
lv_coord_t content_ofs_y;
lv_color_t content_color;
lv_opa_t content_opa;
lv_align_t content_align : 5;
} lv_draw_rect_dsc_t;
/**********************

View File

@ -185,10 +185,9 @@ static lv_color_t grey_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t col
static void style_init(void)
{
static const lv_style_prop_t trans_props[] = {
LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR, LV_STYLE_CONTENT_OPA,
LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR,
LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT,
LV_STYLE_TRANSFORM_ZOOM, LV_STYLE_TRANSFORM_ANGLE,
LV_STYLE_CONTENT_OFS_X, LV_STYLE_CONTENT_OFS_Y,
LV_STYLE_COLOR_FILTER_OPA, LV_STYLE_COLOR_FILTER_DSC,
0
};
@ -327,32 +326,27 @@ static void style_init(void)
style_init_reset(&styles->bg_color_primary);
lv_style_set_bg_color(&styles->bg_color_primary, color_primary_accent);
lv_style_set_text_color(&styles->bg_color_primary, lv_color_white());
lv_style_set_content_color(&styles->bg_color_primary, lv_color_white());
lv_style_set_bg_opa(&styles->bg_color_primary, LV_OPA_COVER);
style_init_reset(&styles->bg_color_primary_muted);
lv_style_set_bg_color(&styles->bg_color_primary_muted, color_primary_muted);
lv_style_set_text_color(&styles->bg_color_primary_muted, color_primary_accent);
lv_style_set_content_color(&styles->bg_color_primary_muted, color_primary_accent);
lv_style_set_bg_opa(&styles->bg_color_primary_muted, LV_OPA_COVER);
style_init_reset(&styles->bg_color_secondary);
lv_style_set_bg_color(&styles->bg_color_secondary, color_secondary_accent);
lv_style_set_text_color(&styles->bg_color_secondary, lv_color_white());
lv_style_set_content_color(&styles->bg_color_secondary, lv_color_white());
lv_style_set_bg_opa(&styles->bg_color_secondary, LV_OPA_COVER);
style_init_reset(&styles->bg_color_grey);
lv_style_set_bg_color(&styles->bg_color_grey, COLOR_GREY);
lv_style_set_bg_opa(&styles->bg_color_grey, LV_OPA_COVER);
lv_style_set_text_color(&styles->bg_color_grey, lv_color_grey_darken_4());
lv_style_set_content_color(&styles->bg_color_grey, lv_color_grey_darken_4());
style_init_reset(&styles->bg_color_white);
lv_style_set_bg_color(&styles->bg_color_white, lv_color_white());
lv_style_set_bg_opa(&styles->bg_color_white, LV_OPA_COVER);
lv_style_set_text_color(&styles->bg_color_white, lv_color_grey_darken_4());
lv_style_set_content_color(&styles->bg_color_white, lv_color_grey_darken_4());
style_init_reset(&styles->circle);
lv_style_set_radius(&styles->circle, LV_RADIUS_CIRCLE);
@ -395,9 +389,9 @@ static void style_init(void)
lv_style_set_radius(&styles->cb_marker, RADIUS_DEFAULT / 2);
style_init_reset(&styles->cb_marker_checked);
lv_style_set_content_text(&styles->cb_marker_checked, LV_SYMBOL_OK);
lv_style_set_content_color(&styles->cb_marker_checked, lv_color_white());
lv_style_set_content_font(&styles->cb_marker_checked, theme.font_small);
lv_style_set_bg_img_src(&styles->cb_marker_checked, LV_SYMBOL_OK);
lv_style_set_text_color(&styles->cb_marker_checked, lv_color_white());
lv_style_set_text_font(&styles->cb_marker_checked, theme.font_small);
style_init_reset(&styles->cb_bg_outline_pad);
lv_style_set_outline_pad(&styles->cb_bg_outline_pad, LV_DPX(5));

View File

@ -23,7 +23,7 @@
/**********************
* STATIC PROTOTYPES
**********************/
static void my_constructor(lv_obj_t * obj, const lv_obj_t * copy);
static void my_constructor(lv_obj_t * obj);
static void draw_event_cb(lv_obj_t * obj, lv_event_t e);
static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day);
@ -53,7 +53,7 @@ static const char * day_names_def[7] = LV_CALENDAR_DEFAULT_DAY_NAMES;
lv_obj_t * lv_calendar_create(lv_obj_t * parent)
{
lv_obj_t * obj = lv_obj_create_from_class(&lv_calendar_class, parent, NULL);
lv_obj_t * obj = lv_obj_create_from_class(&lv_calendar_class, parent);
return obj;
}
@ -204,9 +204,8 @@ bool lv_calendar_get_pressed_date(const lv_obj_t * obj, lv_calendar_date_t * dat
* STATIC FUNCTIONS
**********************/
static void my_constructor(lv_obj_t * obj, const lv_obj_t * copy)
static void my_constructor(lv_obj_t * obj)
{
LV_UNUSED(copy);
lv_calendar_t * calendar = (lv_calendar_t *)obj;
/*Initialize the allocated 'ext'*/

View File

@ -42,7 +42,7 @@ static const char * month_names_def[12] = LV_CALENDAR_DEFAULT_MONTH_NAMES;
lv_obj_t * lv_calendar_header_arrow_create(lv_obj_t * parent, lv_obj_t * calendar, lv_coord_t btn_size)
{
lv_obj_t * header = lv_obj_create(parent, NULL);
lv_obj_t * header = lv_obj_create(parent);
/*Use the same paddings as the calendar*/
lv_obj_set_style_pad_left(header, LV_PART_MAIN, LV_STATE_DEFAULT, lv_obj_get_style_pad_left(calendar, LV_PART_MAIN));
@ -59,20 +59,20 @@ lv_obj_t * lv_calendar_header_arrow_create(lv_obj_t * parent, lv_obj_t * calenda
lv_obj_set_flex_flow(header, LV_FLEX_FLOW_ROW);
lv_obj_set_flex_place(header, LV_FLEX_PLACE_START, LV_FLEX_PLACE_CENTER, LV_FLEX_PLACE_START);
lv_obj_t * mo_prev = lv_btn_create(header, NULL);
lv_obj_set_style_content_text(mo_prev, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_LEFT);
lv_obj_t * mo_prev = lv_btn_create(header);
lv_obj_set_style_bg_img_src(mo_prev, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_LEFT);
lv_obj_set_size(mo_prev, btn_size, btn_size);
lv_obj_add_event_cb(mo_prev, month_event_cb, calendar);
lv_obj_clear_flag(mo_prev, LV_OBJ_FLAG_CLICK_FOCUSABLE);
lv_obj_t * label = lv_label_create(header, NULL);
lv_obj_t * label = lv_label_create(header);
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_obj_set_style_text_align(label, LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_CENTER);
lv_obj_set_flex_grow(label, 1);
lv_label_set_text_fmt(label, "%d %s", cur_date->year, month_names_def[cur_date->month - 1]);
lv_obj_t * mo_next = lv_btn_create(header, NULL);
lv_obj_set_style_content_text(mo_next, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_RIGHT);
lv_obj_t * mo_next = lv_btn_create(header);
lv_obj_set_style_bg_img_src(mo_next, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_RIGHT);
lv_obj_set_size(mo_next, btn_size, btn_size);
lv_obj_add_event_cb(mo_next, month_event_cb, calendar);
lv_obj_clear_flag(mo_next, LV_OBJ_FLAG_CLICK_FOCUSABLE);

View File

@ -31,7 +31,6 @@ extern "C" {
/**
* Create a calendar objects
* @param par pointer to an object, it will be the parent of the new calendar
* @param copy pointer to a calendar object, if not NULL then the new object will be copied from it
* @return pointer to the created calendar
*/
lv_obj_t * lv_calendar_header_arrow_create(lv_obj_t * parent, lv_obj_t * calendar, lv_coord_t btn_size);

View File

@ -51,7 +51,7 @@ static const char * year_list = {
lv_obj_t * lv_calendar_header_dropdown_create(lv_obj_t * parent, lv_obj_t * calendar)
{
lv_obj_t * header = lv_obj_create(parent, NULL);
lv_obj_t * header = lv_obj_create(parent);
/*Use the same paddings as the calendar*/
lv_obj_set_style_pad_left(header, LV_PART_MAIN, LV_STATE_DEFAULT, lv_obj_get_style_pad_left(calendar, LV_PART_MAIN));
@ -68,13 +68,13 @@ lv_obj_t * lv_calendar_header_dropdown_create(lv_obj_t * parent, lv_obj_t * cale
lv_obj_set_flex_flow(header, LV_FLEX_FLOW_ROW);
lv_obj_set_flex_place(header, LV_FLEX_PLACE_START, LV_FLEX_PLACE_CENTER, LV_FLEX_PLACE_START);
lv_obj_t * year_dd = lv_dropdown_create(header, NULL);
lv_obj_t * year_dd = lv_dropdown_create(header);
lv_dropdown_set_options(year_dd, year_list);
lv_dropdown_set_selected(year_dd, 2023 - cur_date->year);
lv_obj_add_event_cb(year_dd, year_event_cb, calendar);
lv_obj_set_flex_grow(year_dd, 1);
lv_obj_t * month_dd = lv_dropdown_create(header, NULL);
lv_obj_t * month_dd = lv_dropdown_create(header);
lv_dropdown_set_options(month_dd, month_list);
lv_dropdown_set_selected(month_dd, cur_date->month - 1);
lv_obj_add_event_cb(month_dd, month_event_cb, calendar);

View File

@ -31,7 +31,6 @@ extern "C" {
/**
* Create a calendar objects
* @param par pointer to an object, it will be the parent of the new calendar
* @param copy pointer to a calendar object, if not NULL then the new object will be copied from it
* @return pointer to the created calendar
*/
lv_obj_t * lv_calendar_header_dropdown_create(lv_obj_t * parent, lv_obj_t * calendar);

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