diff --git a/examples/get_started/lv_example_get_started_1.c b/examples/get_started/lv_example_get_started_1.c index df6e4cf5d..9b3134328 100644 --- a/examples/get_started/lv_example_get_started_1.c +++ b/examples/get_started/lv_example_get_started_1.c @@ -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); } diff --git a/examples/get_started/lv_example_get_started_2.c b/examples/get_started/lv_example_get_started_2.c index fb0feb89c..6dc5d48f4 100644 --- a/examples/get_started/lv_example_get_started_2.c +++ b/examples/get_started/lv_example_get_started_2.c @@ -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); } diff --git a/examples/get_started/lv_example_get_started_3.c b/examples/get_started/lv_example_get_started_3.c index f5494f8c4..09827645f 100644 --- a/examples/get_started/lv_example_get_started_3.c +++ b/examples/get_started/lv_example_get_started_3.c @@ -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*/ } diff --git a/examples/layouts/flex/lv_example_flex_1.c b/examples/layouts/flex/lv_example_flex_1.c index 4f80ded2f..ede6e2b65 100644 --- a/examples/layouts/flex/lv_example_flex_1.c +++ b/examples/layouts/flex/lv_example_flex_1.c @@ -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); } diff --git a/examples/layouts/flex/lv_example_flex_2.c b/examples/layouts/flex/lv_example_flex_2.c index af988cd17..eeee83f4b 100644 --- a/examples/layouts/flex/lv_example_flex_2.c +++ b/examples/layouts/flex/lv_example_flex_2.c @@ -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); } } diff --git a/examples/layouts/flex/lv_example_flex_3.c b/examples/layouts/flex/lv_example_flex_3.c index 0e0eeb13e..b56933aa5 100644 --- a/examples/layouts/flex/lv_example_flex_3.c +++ b/examples/layouts/flex/lv_example_flex_3.c @@ -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*/ } diff --git a/examples/layouts/flex/lv_example_flex_4.c b/examples/layouts/flex/lv_example_flex_4.c index 85c5d4bb3..e5b87fe97 100644 --- a/examples/layouts/flex/lv_example_flex_4.c +++ b/examples/layouts/flex/lv_example_flex_4.c @@ -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); } } diff --git a/examples/layouts/flex/lv_example_flex_5.c b/examples/layouts/flex/lv_example_flex_5.c index 9e5a08960..2c61e2c2a 100644 --- a/examples/layouts/flex/lv_example_flex_5.c +++ b/examples/layouts/flex/lv_example_flex_5.c @@ -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); } diff --git a/examples/layouts/flex/lv_example_flex_6.c b/examples/layouts/flex/lv_example_flex_6.c index 2b308bc0b..1fd0b0ab1 100644 --- a/examples/layouts/flex/lv_example_flex_6.c +++ b/examples/layouts/flex/lv_example_flex_6.c @@ -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); } diff --git a/examples/layouts/grid/lv_example_grid_1.c b/examples/layouts/grid/lv_example_grid_1.c index 611b5b752..fe4e5788e 100644 --- a/examples/layouts/grid/lv_example_grid_1.c +++ b/examples/layouts/grid/lv_example_grid_1.c @@ -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); } diff --git a/examples/layouts/grid/lv_example_grid_2.c b/examples/layouts/grid/lv_example_grid_2.c index 02d7f2732..46f1c51f1 100644 --- a/examples/layouts/grid/lv_example_grid_2.c +++ b/examples/layouts/grid/lv_example_grid_2.c @@ -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"); } diff --git a/examples/layouts/grid/lv_example_grid_3.c b/examples/layouts/grid/lv_example_grid_3.c index 4989f22f3..2c5fc370d 100644 --- a/examples/layouts/grid/lv_example_grid_3.c +++ b/examples/layouts/grid/lv_example_grid_3.c @@ -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); } diff --git a/examples/layouts/grid/lv_example_grid_4.c b/examples/layouts/grid/lv_example_grid_4.c index e884c5076..5532c1a9b 100644 --- a/examples/layouts/grid/lv_example_grid_4.c +++ b/examples/layouts/grid/lv_example_grid_4.c @@ -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); } diff --git a/examples/layouts/grid/lv_example_grid_5.c b/examples/layouts/grid/lv_example_grid_5.c index c516c3ca9..642c0fada 100644 --- a/examples/layouts/grid/lv_example_grid_5.c +++ b/examples/layouts/grid/lv_example_grid_5.c @@ -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); } diff --git a/examples/layouts/grid/lv_example_grid_6.c b/examples/layouts/grid/lv_example_grid_6.c index 9624d7e3b..2157aacf3 100644 --- a/examples/layouts/grid/lv_example_grid_6.c +++ b/examples/layouts/grid/lv_example_grid_6.c @@ -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); } diff --git a/examples/scroll/lv_example_scroll_1.c b/examples/scroll/lv_example_scroll_1.c index 14b1e19d2..833ef4fe1 100644 --- a/examples/scroll/lv_example_scroll_1.c +++ b/examples/scroll/lv_example_scroll_1.c @@ -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); } diff --git a/examples/scroll/lv_example_scroll_2.c b/examples/scroll/lv_example_scroll_2.c index 5e15c5600..7ae9eb40a 100644 --- a/examples/scroll/lv_example_scroll_2.c +++ b/examples/scroll/lv_example_scroll_2.c @@ -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 diff --git a/examples/scroll/lv_example_scroll_3.c b/examples/scroll/lv_example_scroll_3.c index 9d2d64d45..79091dad5 100644 --- a/examples/scroll/lv_example_scroll_3.c +++ b/examples/scroll/lv_example_scroll_3.c @@ -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 diff --git a/examples/styles/lv_example_style_1.c b/examples/styles/lv_example_style_1.c index 2e978d65c..f8ec9ba1f 100644 --- a/examples/styles/lv_example_style_1.c +++ b/examples/styles/lv_example_style_1.c @@ -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); } diff --git a/examples/styles/lv_example_style_10.c b/examples/styles/lv_example_style_10.c index 417d632a6..e46d35823 100644 --- a/examples/styles/lv_example_style_10.c +++ b/examples/styles/lv_example_style_10.c @@ -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); //} diff --git a/examples/styles/lv_example_style_11.c b/examples/styles/lv_example_style_11.c index 6a95e9634..fa28e0e4f 100644 --- a/examples/styles/lv_example_style_11.c +++ b/examples/styles/lv_example_style_11.c @@ -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); } diff --git a/examples/styles/lv_example_style_2.c b/examples/styles/lv_example_style_2.c index 4e0d102f1..d1faa2c1e 100644 --- a/examples/styles/lv_example_style_2.c +++ b/examples/styles/lv_example_style_2.c @@ -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); } diff --git a/examples/styles/lv_example_style_3.c b/examples/styles/lv_example_style_3.c index f95bf4d4c..f8e9fdd5b 100644 --- a/examples/styles/lv_example_style_3.c +++ b/examples/styles/lv_example_style_3.c @@ -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); } diff --git a/examples/styles/lv_example_style_4.c b/examples/styles/lv_example_style_4.c index c0b298c41..ca06afd29 100644 --- a/examples/styles/lv_example_style_4.c +++ b/examples/styles/lv_example_style_4.c @@ -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); } diff --git a/examples/styles/lv_example_style_5.c b/examples/styles/lv_example_style_5.c index 2102b7aea..e69de29bb 100644 --- a/examples/styles/lv_example_style_5.c +++ b/examples/styles/lv_example_style_5.c @@ -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 diff --git a/examples/styles/lv_example_style_7.c b/examples/styles/lv_example_style_7.c index e8cd5b906..ce09c30c2 100644 --- a/examples/styles/lv_example_style_7.c +++ b/examples/styles/lv_example_style_7.c @@ -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"); diff --git a/examples/styles/lv_example_style_8.c b/examples/styles/lv_example_style_8.c index f0c0ccfa3..9bff1e057 100644 --- a/examples/styles/lv_example_style_8.c +++ b/examples/styles/lv_example_style_8.c @@ -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}}; diff --git a/examples/styles/lv_example_style_9.c b/examples/styles/lv_example_style_9.c index 535ca2f9b..97a7c4573 100644 --- a/examples/styles/lv_example_style_9.c +++ b/examples/styles/lv_example_style_9.c @@ -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); diff --git a/examples/widgets/arc/lv_example_arc_1.c b/examples/widgets/arc/lv_example_arc_1.c index 8abb4b51c..b9e0a3eb2 100644 --- a/examples/widgets/arc/lv_example_arc_1.c +++ b/examples/widgets/arc/lv_example_arc_1.c @@ -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); diff --git a/examples/widgets/arc/lv_example_arc_2.c b/examples/widgets/arc/lv_example_arc_2.c index 674d771b6..495716b05 100644 --- a/examples/widgets/arc/lv_example_arc_2.c +++ b/examples/widgets/arc/lv_example_arc_2.c @@ -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); diff --git a/examples/widgets/bar/lv_example_bar_1.c b/examples/widgets/bar/lv_example_bar_1.c index b2bd80347..b068282cc 100644 --- a/examples/widgets/bar/lv_example_bar_1.c +++ b/examples/widgets/bar/lv_example_bar_1.c @@ -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); diff --git a/examples/widgets/bar/lv_example_bar_2.c b/examples/widgets/bar/lv_example_bar_2.c index 7d842e5cc..9aea3c878 100644 --- a/examples/widgets/bar/lv_example_bar_2.c +++ b/examples/widgets/bar/lv_example_bar_2.c @@ -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); diff --git a/examples/widgets/bar/lv_example_bar_3.c b/examples/widgets/bar/lv_example_bar_3.c index 1640ee13c..ecd2fb4d5 100644 --- a/examples/widgets/bar/lv_example_bar_3.c +++ b/examples/widgets/bar/lv_example_bar_3.c @@ -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); diff --git a/examples/widgets/bar/lv_example_bar_4.c b/examples/widgets/bar/lv_example_bar_4.c index 9d4f2f246..4b7288799 100644 --- a/examples/widgets/bar/lv_example_bar_4.c +++ b/examples/widgets/bar/lv_example_bar_4.c @@ -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); diff --git a/examples/widgets/bar/lv_example_bar_5.c b/examples/widgets/bar/lv_example_bar_5.c index a5a5735b8..5ae92f639 100644 --- a/examples/widgets/bar/lv_example_bar_5.c +++ b/examples/widgets/bar/lv_example_bar_5.c @@ -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 diff --git a/examples/widgets/bar/lv_example_bar_6.c b/examples/widgets/bar/lv_example_bar_6.c index 47e9922ec..49c57e510 100644 --- a/examples/widgets/bar/lv_example_bar_6.c +++ b/examples/widgets/bar/lv_example_bar_6.c @@ -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 diff --git a/examples/widgets/btn/lv_example_btn_1.c b/examples/widgets/btn/lv_example_btn_1.c index 0114ab7eb..b2e8f9134 100644 --- a/examples/widgets/btn/lv_example_btn_1.c +++ b/examples/widgets/btn/lv_example_btn_1.c @@ -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 diff --git a/examples/widgets/btn/lv_example_btn_2.c b/examples/widgets/btn/lv_example_btn_2.c index 544e6056e..4dd61cc0b 100644 --- a/examples/widgets/btn/lv_example_btn_2.c +++ b/examples/widgets/btn/lv_example_btn_2.c @@ -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); diff --git a/examples/widgets/btn/lv_example_btn_3.c b/examples/widgets/btn/lv_example_btn_3.c index 295fd5c44..aefb87818 100644 --- a/examples/widgets/btn/lv_example_btn_3.c +++ b/examples/widgets/btn/lv_example_btn_3.c @@ -1,6 +1,6 @@ #include "../../../lvgl.h" #include -#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 diff --git a/examples/widgets/btnmatrix/lv_example_btnmatrix_1.c b/examples/widgets/btnmatrix/lv_example_btnmatrix_1.c index 35b274ab1..85306832a 100644 --- a/examples/widgets/btnmatrix/lv_example_btnmatrix_1.c +++ b/examples/widgets/btnmatrix/lv_example_btnmatrix_1.c @@ -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); diff --git a/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c b/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c index 1852a15d4..56d9cc62b 100644 --- a/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c +++ b/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c @@ -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); } diff --git a/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c b/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c index 3ec75f57b..f3d1417fc 100644 --- a/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c +++ b/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c @@ -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); diff --git a/examples/widgets/canvas/lv_example_canvas_1.c b/examples/widgets/canvas/lv_example_canvas_1.c index 0802c5212..cfc39c20d 100644 --- a/examples/widgets/canvas/lv_example_canvas_1.c +++ b/examples/widgets/canvas/lv_example_canvas_1.c @@ -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); diff --git a/examples/widgets/canvas/lv_example_canvas_2.c b/examples/widgets/canvas/lv_example_canvas_2.c index 49e4f3330..a7bb02314 100644 --- a/examples/widgets/canvas/lv_example_canvas_2.c +++ b/examples/widgets/canvas/lv_example_canvas_2.c @@ -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()); diff --git a/examples/widgets/chart/lv_example_chart_1.c b/examples/widgets/chart/lv_example_chart_1.c index d69351da2..cb7e03f36 100644 --- a/examples/widgets/chart/lv_example_chart_1.c +++ b/examples/widgets/chart/lv_example_chart_1.c @@ -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*/ diff --git a/examples/widgets/chart/lv_example_chart_2.c b/examples/widgets/chart/lv_example_chart_2.c index 66986fefe..4aa742d2b 100644 --- a/examples/widgets/chart/lv_example_chart_2.c +++ b/examples/widgets/chart/lv_example_chart_2.c @@ -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*/ diff --git a/examples/widgets/chart/lv_example_chart_3.c b/examples/widgets/chart/lv_example_chart_3.c index 912cda945..b255dc01f 100644 --- a/examples/widgets/chart/lv_example_chart_3.c +++ b/examples/widgets/chart/lv_example_chart_3.c @@ -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); diff --git a/examples/widgets/chart/lv_example_chart_4.c b/examples/widgets/chart/lv_example_chart_4.c index 48bd74ca2..36d9af4ca 100644 --- a/examples/widgets/chart/lv_example_chart_4.c +++ b/examples/widgets/chart/lv_example_chart_4.c @@ -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); diff --git a/examples/widgets/chart/lv_example_chart_5.c b/examples/widgets/chart/lv_example_chart_5.c index 35ec53b2c..a30e214af 100644 --- a/examples/widgets/chart/lv_example_chart_5.c +++ b/examples/widgets/chart/lv_example_chart_5.c @@ -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)); diff --git a/examples/widgets/chart/lv_example_chart_6.c b/examples/widgets/chart/lv_example_chart_6.c index e3cb539ea..d7a2190c4 100644 --- a/examples/widgets/chart/lv_example_chart_6.c +++ b/examples/widgets/chart/lv_example_chart_6.c @@ -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); diff --git a/examples/widgets/checkbox/lv_example_checkbox_1.c b/examples/widgets/checkbox/lv_example_checkbox_1.c index d44be9915..9483942e9 100644 --- a/examples/widgets/checkbox/lv_example_checkbox_1.c +++ b/examples/widgets/checkbox/lv_example_checkbox_1.c @@ -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); diff --git a/examples/widgets/dropdown/lv_example_dropdown_1.c b/examples/widgets/dropdown/lv_example_dropdown_1.c index 0878a594f..f27c8f7dd 100644 --- a/examples/widgets/dropdown/lv_example_dropdown_1.c +++ b/examples/widgets/dropdown/lv_example_dropdown_1.c @@ -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" diff --git a/examples/widgets/dropdown/lv_example_dropdown_2.c b/examples/widgets/dropdown/lv_example_dropdown_2.c index 1be861b97..5bed4dbce 100644 --- a/examples/widgets/dropdown/lv_example_dropdown_2.c +++ b/examples/widgets/dropdown/lv_example_dropdown_2.c @@ -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); diff --git a/examples/widgets/dropdown/lv_example_dropdown_3.c b/examples/widgets/dropdown/lv_example_dropdown_3.c index 6e13e7789..663813160 100644 --- a/examples/widgets/dropdown/lv_example_dropdown_3.c +++ b/examples/widgets/dropdown/lv_example_dropdown_3.c @@ -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" diff --git a/examples/widgets/img/lv_example_img_1.c b/examples/widgets/img/lv_example_img_1.c index 835603909..d3dab4f54 100644 --- a/examples/widgets/img/lv_example_img_1.c +++ b/examples/widgets/img/lv_example_img_1.c @@ -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); } diff --git a/examples/widgets/img/lv_example_img_2.c b/examples/widgets/img/lv_example_img_2.c index fad8c11c5..5350f719f 100644 --- a/examples/widgets/img/lv_example_img_2.c +++ b/examples/widgets/img/lv_example_img_2.c @@ -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); diff --git a/examples/widgets/img/lv_example_img_3.c b/examples/widgets/img/lv_example_img_3.c index d4fa853b8..21989ef33 100644 --- a/examples/widgets/img/lv_example_img_3.c +++ b/examples/widgets/img/lv_example_img_3.c @@ -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*/ diff --git a/examples/widgets/img/lv_example_img_4.c b/examples/widgets/img/lv_example_img_4.c index 945ab2fdd..a6f525f5c 100644 --- a/examples/widgets/img/lv_example_img_4.c +++ b/examples/widgets/img/lv_example_img_4.c @@ -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); diff --git a/examples/widgets/imgbtn/lv_example_imgbtn_1.c b/examples/widgets/imgbtn/lv_example_imgbtn_1.c index aec29aa27..d18ffbd85 100644 --- a/examples/widgets/imgbtn/lv_example_imgbtn_1.c +++ b/examples/widgets/imgbtn/lv_example_imgbtn_1.c @@ -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); } diff --git a/examples/widgets/keyboard/lv_example_keyboard_1.c b/examples/widgets/keyboard/lv_example_keyboard_1.c index b166e9379..d20460de4 100644 --- a/examples/widgets/keyboard/lv_example_keyboard_1.c +++ b/examples/widgets/keyboard/lv_example_keyboard_1.c @@ -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); diff --git a/examples/widgets/label/lv_example_label_1.c b/examples/widgets/label/lv_example_label_1.c index d7fcebef8..344e45a51 100644 --- a/examples/widgets/label/lv_example_label_1.c +++ b/examples/widgets/label/lv_example_label_1.c @@ -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. "); diff --git a/examples/widgets/label/lv_example_label_2.c b/examples/widgets/label/lv_example_label_2.c index ccfa84a16..05ad9667f 100644 --- a/examples/widgets/label/lv_example_label_2.c +++ b/examples/widgets/label/lv_example_label_2.c @@ -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" diff --git a/examples/widgets/line/lv_example_line_1.c b/examples/widgets/line/lv_example_line_1.c index a03910d6b..d05be5dee 100644 --- a/examples/widgets/line/lv_example_line_1.c +++ b/examples/widgets/line/lv_example_line_1.c @@ -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); diff --git a/examples/widgets/list/lv_example_list_1.c b/examples/widgets/list/lv_example_list_1.c index 80100cbf1..5ea9d0aeb 100644 --- a/examples/widgets/list/lv_example_list_1.c +++ b/examples/widgets/list/lv_example_list_1.c @@ -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); } diff --git a/examples/widgets/meter/lv_example_meter_1.c b/examples/widgets/meter/lv_example_meter_1.c index 49aa01653..47c2d7d4a 100644 --- a/examples/widgets/meter/lv_example_meter_1.c +++ b/examples/widgets/meter/lv_example_meter_1.c @@ -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*/ diff --git a/examples/widgets/meter/lv_example_meter_2.c b/examples/widgets/meter/lv_example_meter_2.c index aa73fefea..b863e7cda 100644 --- a/examples/widgets/meter/lv_example_meter_2.c +++ b/examples/widgets/meter/lv_example_meter_2.c @@ -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*/ diff --git a/examples/widgets/meter/lv_example_meter_3.c b/examples/widgets/meter/lv_example_meter_3.c index a679e37ac..2cd04587f 100644 --- a/examples/widgets/meter/lv_example_meter_3.c +++ b/examples/widgets/meter/lv_example_meter_3.c @@ -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*/ diff --git a/examples/widgets/meter/lv_example_meter_4.c b/examples/widgets/meter/lv_example_meter_4.c index c51b8b33a..b88a7b806 100644 --- a/examples/widgets/meter/lv_example_meter_4.c +++ b/examples/widgets/meter/lv_example_meter_4.c @@ -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*/ diff --git a/examples/widgets/obj/lv_example_obj_1.c b/examples/widgets/obj/lv_example_obj_1.c index a10797d90..1ac4452ff 100644 --- a/examples/widgets/obj/lv_example_obj_1.c +++ b/examples/widgets/obj/lv_example_obj_1.c @@ -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); } diff --git a/examples/widgets/roller/lv_example_roller_1.c b/examples/widgets/roller/lv_example_roller_1.c index 2639109cf..bf64835eb 100644 --- a/examples/widgets/roller/lv_example_roller_1.c +++ b/examples/widgets/roller/lv_example_roller_1.c @@ -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" diff --git a/examples/widgets/roller/lv_example_roller_2.c b/examples/widgets/roller/lv_example_roller_2.c index 0f0cf0ba8..f8d78873a 100644 --- a/examples/widgets/roller/lv_example_roller_2.c +++ b/examples/widgets/roller/lv_example_roller_2.c @@ -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); diff --git a/examples/widgets/slider/lv_example_slider_1.c b/examples/widgets/slider/lv_example_slider_1.c index d1a2c6b0b..c53ae8ee8 100644 --- a/examples/widgets/slider/lv_example_slider_1.c +++ b/examples/widgets/slider/lv_example_slider_1.c @@ -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); diff --git a/examples/widgets/slider/lv_example_slider_2.c b/examples/widgets/slider/lv_example_slider_2.c index 92cd604a5..59d93eacd 100644 --- a/examples/widgets/slider/lv_example_slider_2.c +++ b/examples/widgets/slider/lv_example_slider_2.c @@ -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 diff --git a/examples/widgets/slider/lv_example_slider_3.c b/examples/widgets/slider/lv_example_slider_3.c index 89ccde46b..1e6ad812d 100644 --- a/examples/widgets/slider/lv_example_slider_3.c +++ b/examples/widgets/slider/lv_example_slider_3.c @@ -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 diff --git a/examples/widgets/spinbox/lv_example_spinbox_1.c b/examples/widgets/spinbox/lv_example_spinbox_1.c index 0e5c55990..7057d04c5 100644 --- a/examples/widgets/spinbox/lv_example_spinbox_1.c +++ b/examples/widgets/spinbox/lv_example_spinbox_1.c @@ -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); } diff --git a/examples/widgets/switch/lv_example_switch_1.c b/examples/widgets/switch/lv_example_switch_1.c index e64b8181d..8d13097dd 100644 --- a/examples/widgets/switch/lv_example_switch_1.c +++ b/examples/widgets/switch/lv_example_switch_1.c @@ -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); } diff --git a/examples/widgets/table/lv_example_table_1.c b/examples/widgets/table/lv_example_table_1.c index c8da231b2..ae524f4b3 100644 --- a/examples/widgets/table/lv_example_table_1.c +++ b/examples/widgets/table/lv_example_table_1.c @@ -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"); diff --git a/examples/widgets/table/lv_example_table_2.c b/examples/widgets/table/lv_example_table_2.c index de342a7d3..6b4b428d6 100644 --- a/examples/widgets/table/lv_example_table_2.c +++ b/examples/widgets/table/lv_example_table_2.c @@ -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); diff --git a/examples/widgets/tabview/lv_example_tabview_1.c b/examples/widgets/tabview/lv_example_tabview_1.c index 7742b7e6e..b4e032535 100644 --- a/examples/widgets/tabview/lv_example_tabview_1.c +++ b/examples/widgets/tabview/lv_example_tabview_1.c @@ -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); diff --git a/examples/widgets/textarea/lv_example_textarea_1.c b/examples/widgets/textarea/lv_example_textarea_1.c index 7ced95953..384246364 100644 --- a/examples/widgets/textarea/lv_example_textarea_1.c +++ b/examples/widgets/textarea/lv_example_textarea_1.c @@ -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); diff --git a/examples/widgets/textarea/lv_example_textarea_2.c b/examples/widgets/textarea/lv_example_textarea_2.c index fae2f5eac..376f9db85 100644 --- a/examples/widgets/textarea/lv_example_textarea_2.c +++ b/examples/widgets/textarea/lv_example_textarea_2.c @@ -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); diff --git a/examples/widgets/textarea/lv_example_textarea_3.c b/examples/widgets/textarea/lv_example_textarea_3.c index e5be569cd..af89e78f2 100644 --- a/examples/widgets/textarea/lv_example_textarea_3.c +++ b/examples/widgets/textarea/lv_example_textarea_3.c @@ -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); diff --git a/examples/widgets/tileview/lv_example_tileview_1.c b/examples/widgets/tileview/lv_example_tileview_1.c index 2bbf769dc..24f456757 100644 --- a/examples/widgets/tileview/lv_example_tileview_1.c +++ b/examples/widgets/tileview/lv_example_tileview_1.c @@ -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); diff --git a/examples/widgets/win/lv_example_win_1.c b/examples/widgets/win/lv_example_win_1.c index 7a5f71366..491490cee 100644 --- a/examples/widgets/win/lv_example_win_1.c +++ b/examples/widgets/win/lv_example_win_1.c @@ -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" diff --git a/src/core/lv_obj.c b/src/core/lv_obj.c index b0f55f961..442147a28 100644 --- a/src/core/lv_obj.c +++ b/src/core/lv_obj.c @@ -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); diff --git a/src/core/lv_obj.h b/src/core/lv_obj.h index c31048fbf..0fd5abdbf 100644 --- a/src/core/lv_obj.h +++ b/src/core/lv_obj.h @@ -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); /*--------------------- diff --git a/src/core/lv_obj_class.c b/src/core/lv_obj_class.c index 7d9c6afe0..23680273d 100644 --- a/src/core/lv_obj_class.c +++ b/src/core/lv_obj_class.c @@ -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) diff --git a/src/core/lv_obj_class.h b/src/core/lv_obj_class.h index 70ddd5cac..151531558 100644 --- a/src/core/lv_obj_class.h +++ b/src/core/lv_obj_class.h @@ -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); diff --git a/src/core/lv_obj_draw.c b/src/core/lv_obj_draw.c index 2027a5c16..a05ef804c 100644 --- a/src/core/lv_obj_draw.c +++ b/src/core/lv_obj_draw.c @@ -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); diff --git a/src/core/lv_obj_style.c b/src/core/lv_obj_style.c index 8f7799cbf..522035389 100644 --- a/src/core/lv_obj_style.c +++ b/src/core/lv_obj_style.c @@ -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)) { diff --git a/src/core/lv_obj_style_gen.h b/src/core/lv_obj_style_gen.h index 8e8e355c0..23cc66185 100644 --- a/src/core/lv_obj_style_gen.h +++ b/src/core/lv_obj_style_gen.h @@ -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); -} - diff --git a/src/core/lv_obj_tree.h b/src/core/lv_obj_tree.h index 2749ae90b..51ef3137c 100644 --- a/src/core/lv_obj_tree.h +++ b/src/core/lv_obj_tree.h @@ -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); /** diff --git a/src/draw/lv_draw_rect.c b/src/draw/lv_draw_rect.c index afa320c1e..bd3098743 100644 --- a/src/draw/lv_draw_rect.c +++ b/src/draw/lv_draw_rect.c @@ -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) { diff --git a/src/draw/lv_draw_rect.h b/src/draw/lv_draw_rect.h index 06cc47c27..f4d05922b 100644 --- a/src/draw/lv_draw_rect.h +++ b/src/draw/lv_draw_rect.h @@ -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; /********************** diff --git a/src/extra/themes/default/lv_theme_default.c b/src/extra/themes/default/lv_theme_default.c index 6035b0c72..03a2ccff4 100644 --- a/src/extra/themes/default/lv_theme_default.c +++ b/src/extra/themes/default/lv_theme_default.c @@ -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)); diff --git a/src/extra/widgets/calendar/lv_calendar.c b/src/extra/widgets/calendar/lv_calendar.c index dd239958d..7eb9ada29 100644 --- a/src/extra/widgets/calendar/lv_calendar.c +++ b/src/extra/widgets/calendar/lv_calendar.c @@ -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'*/ diff --git a/src/extra/widgets/calendar/lv_calendar_header_arrow.c b/src/extra/widgets/calendar/lv_calendar_header_arrow.c index a4e6e031f..1c3bf4de8 100644 --- a/src/extra/widgets/calendar/lv_calendar_header_arrow.c +++ b/src/extra/widgets/calendar/lv_calendar_header_arrow.c @@ -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); diff --git a/src/extra/widgets/calendar/lv_calendar_header_arrow.h b/src/extra/widgets/calendar/lv_calendar_header_arrow.h index 52d38b5ca..5b3274673 100644 --- a/src/extra/widgets/calendar/lv_calendar_header_arrow.h +++ b/src/extra/widgets/calendar/lv_calendar_header_arrow.h @@ -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); diff --git a/src/extra/widgets/calendar/lv_calendar_header_dropdown.c b/src/extra/widgets/calendar/lv_calendar_header_dropdown.c index d9b22c4ed..0fa81d950 100644 --- a/src/extra/widgets/calendar/lv_calendar_header_dropdown.c +++ b/src/extra/widgets/calendar/lv_calendar_header_dropdown.c @@ -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); diff --git a/src/extra/widgets/calendar/lv_calendar_header_dropdown.h b/src/extra/widgets/calendar/lv_calendar_header_dropdown.h index b29f1d576..cb84c426b 100644 --- a/src/extra/widgets/calendar/lv_calendar_header_dropdown.h +++ b/src/extra/widgets/calendar/lv_calendar_header_dropdown.h @@ -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); diff --git a/src/extra/widgets/colorwheel/lv_colorwheel.c b/src/extra/widgets/colorwheel/lv_colorwheel.c index 6859e0056..d9d3194d5 100644 --- a/src/extra/widgets/colorwheel/lv_colorwheel.c +++ b/src/extra/widgets/colorwheel/lv_colorwheel.c @@ -32,7 +32,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_colorwheel_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_colorwheel_constructor(lv_obj_t * obj); static void lv_colorwheel_event(lv_obj_t * obj, lv_event_t e); static void draw_disc_grad(lv_obj_t * obj); @@ -68,13 +68,12 @@ static bool create_knob_recolor; /** * Create a color_picker object * @param par pointer to an object, it will be the parent of the new color_picker - * @param copy pointer to a color_picker object, if not NULL then the new object will be copied from it * @return pointer to the created color_picker */ lv_obj_t * lv_colorwheel_create(lv_obj_t * parent, bool knob_recolor) { create_knob_recolor = knob_recolor; - return lv_obj_create_from_class(&lv_colorwheel_class, parent, NULL); + return lv_obj_create_from_class(&lv_colorwheel_class, parent); } /*===================== @@ -207,10 +206,8 @@ bool lv_colorwheel_get_color_mode_fixed(lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_colorwheel_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_colorwheel_constructor(lv_obj_t * obj) { - LV_UNUSED(copy); - lv_colorwheel_t * colorwheel = (lv_colorwheel_t *)obj; colorwheel->hsv.h = 0; colorwheel->hsv.s = 100; diff --git a/src/extra/widgets/imgbtn/lv_imgbtn.c b/src/extra/widgets/imgbtn/lv_imgbtn.c index fad6d9bc2..e1af3d7c9 100644 --- a/src/extra/widgets/imgbtn/lv_imgbtn.c +++ b/src/extra/widgets/imgbtn/lv_imgbtn.c @@ -23,7 +23,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_imgbtn_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_imgbtn_constructor(lv_obj_t * obj); static void draw_main(lv_obj_t * obj); static void lv_imgbtn_event(lv_obj_t * imgbtn, lv_event_t e); static void refr_img(lv_obj_t * imgbtn); @@ -51,13 +51,11 @@ const lv_obj_class_t lv_imgbtn_class = { /** * Create a image button object * @param par pointer to an object, it will be the parent of the new image button - * @param copy pointer to a image button object, if not NULL then the new object will be copied from - * it * @return pointer to the created image button */ lv_obj_t * lv_imgbtn_create(lv_obj_t * parent) { - return lv_obj_create_from_class(&lv_imgbtn_class, parent, NULL); + return lv_obj_create_from_class(&lv_imgbtn_class, parent); } /*===================== @@ -149,10 +147,8 @@ const void * lv_imgbtn_get_src_right(lv_obj_t * obj, lv_imgbtn_state_t state) * STATIC FUNCTIONS **********************/ -static void lv_imgbtn_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_imgbtn_constructor(lv_obj_t * obj) { - LV_UNUSED(copy); - lv_imgbtn_t * imgbtn = (lv_imgbtn_t *)obj; /*Initialize the allocated 'ext'*/ lv_memset_00((void *)imgbtn->img_src_mid, sizeof(imgbtn->img_src_mid)); diff --git a/src/extra/widgets/imgbtn/lv_imgbtn.h b/src/extra/widgets/imgbtn/lv_imgbtn.h index 56e71f7a1..20eee9ce2 100644 --- a/src/extra/widgets/imgbtn/lv_imgbtn.h +++ b/src/extra/widgets/imgbtn/lv_imgbtn.h @@ -51,8 +51,6 @@ extern const lv_obj_class_t lv_imgbtn_class; /** * Create a image button objects * @param par pointer to an object, it will be the parent of the new image button - * @param copy pointer to a image button object, if not NULL then the new object will be copied from - * it * @return pointer to the created image button */ lv_obj_t * lv_imgbtn_create(lv_obj_t * parent); diff --git a/src/extra/widgets/keyboard/lv_keyboard.c b/src/extra/widgets/keyboard/lv_keyboard.c index c58963b3f..083d45c0a 100644 --- a/src/extra/widgets/keyboard/lv_keyboard.c +++ b/src/extra/widgets/keyboard/lv_keyboard.c @@ -23,7 +23,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_keyboard_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_keyboard_constructor(lv_obj_t * obj); static void lv_keyboard_update_map(lv_obj_t * obj); @@ -115,12 +115,11 @@ static const lv_btnmatrix_ctrl_t * kb_ctrl[5] = { /** * Create a keyboard objects * @param par pointer to an object, it will be the parent of the new keyboard - * @param copy pointer to a keyboard object, if not NULL then the new object will be copied from it * @return pointer to the created keyboard */ lv_obj_t * lv_keyboard_create(lv_obj_t * parent) { - return lv_obj_create_from_class(&lv_keyboard_class, parent, NULL); + return lv_obj_create_from_class(&lv_keyboard_class, parent); } /*===================== @@ -319,10 +318,8 @@ void lv_keyboard_def_event_cb(lv_obj_t * obj, lv_event_t event) * STATIC FUNCTIONS **********************/ -static void lv_keyboard_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_keyboard_constructor(lv_obj_t * obj) { - LV_UNUSED(copy); - lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICK_FOCUSABLE); lv_keyboard_t * keyboard = (lv_keyboard_t *)obj; diff --git a/src/extra/widgets/keyboard/lv_keyboard.h b/src/extra/widgets/keyboard/lv_keyboard.h index 3c5f6da23..461d11076 100644 --- a/src/extra/widgets/keyboard/lv_keyboard.h +++ b/src/extra/widgets/keyboard/lv_keyboard.h @@ -60,7 +60,6 @@ extern const lv_obj_class_t lv_keyboard_class; /** * Create a keyboard objects * @param par pointer to an object, it will be the parent of the new keyboard - * @param copy pointer to a keyboard object, if not NULL then the new object will be copied from it * @return pointer to the created keyboard */ lv_obj_t * lv_keyboard_create(lv_obj_t * parent); diff --git a/src/extra/widgets/led/lv_led.c b/src/extra/widgets/led/lv_led.c index ef1f6c38e..c2d0ab385 100644 --- a/src/extra/widgets/led/lv_led.c +++ b/src/extra/widgets/led/lv_led.c @@ -32,7 +32,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_led_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_led_constructor(lv_obj_t * obj); static void lv_led_event(lv_obj_t * obj, lv_event_t e); /********************** @@ -56,12 +56,11 @@ const lv_obj_class_t lv_led_class = { /** * Create a led objects * @param par pointer to an object, it will be the parent of the new led - * @param copy pointer to a led object, if not NULL then the new object will be copied from it * @return pointer to the created led */ lv_obj_t * lv_led_create(lv_obj_t * parent) { - return lv_obj_create_from_class(&lv_led_class, parent, NULL); + return lv_obj_create_from_class(&lv_led_class, parent); } /*===================== @@ -149,9 +148,8 @@ uint8_t lv_led_get_brightness(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_led_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_led_constructor(lv_obj_t * obj) { - LV_UNUSED(copy); lv_led_t * led = (lv_led_t *)obj; led->color = lv_theme_get_color_primary(obj); led->bright = LV_LED_BRIGHT_MAX; diff --git a/src/extra/widgets/led/lv_led.h b/src/extra/widgets/led/lv_led.h index b3fe918e2..7c9b350cb 100644 --- a/src/extra/widgets/led/lv_led.h +++ b/src/extra/widgets/led/lv_led.h @@ -42,7 +42,6 @@ extern const lv_obj_class_t lv_led_class; /** * Create a led objects * @param par pointer to an object, it will be the parent of the new led - * @param copy pointer to a led object, if not NULL then the new object will be copied from it * @return pointer to the created led */ lv_obj_t * lv_led_create(lv_obj_t * parent); diff --git a/src/extra/widgets/list/lv_list.c b/src/extra/widgets/list/lv_list.c index 2a9928608..287935528 100644 --- a/src/extra/widgets/list/lv_list.c +++ b/src/extra/widgets/list/lv_list.c @@ -53,7 +53,7 @@ const lv_obj_class_t lv_list_text_class = { lv_obj_t * lv_list_create(lv_obj_t * parent) { - lv_obj_t * list = lv_obj_create_from_class(&lv_list_class, parent, NULL); + lv_obj_t * list = lv_obj_create_from_class(&lv_list_class, parent); lv_obj_set_size(list, LV_DPX(200), LV_DPX(300)); lv_obj_set_flex_flow(list, LV_FLEX_FLOW_COLUMN); @@ -62,7 +62,7 @@ lv_obj_t * lv_list_create(lv_obj_t * parent) lv_obj_t * lv_list_add_text(lv_obj_t * list, const char * txt) { - lv_obj_t * label = lv_obj_create_from_class(&lv_list_text_class, list, NULL); + lv_obj_t * label = lv_obj_create_from_class(&lv_list_text_class, list); lv_label_set_text(label, txt); lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR); lv_obj_set_width(label, LV_SIZE_PCT(100)); @@ -71,17 +71,17 @@ lv_obj_t * lv_list_add_text(lv_obj_t * list, const char * txt) lv_obj_t * lv_list_add_btn(lv_obj_t * list, const char * icon, const char * txt, lv_event_cb_t event_cb) { - lv_obj_t * btn = lv_obj_create_from_class(&lv_list_btn_class, list, NULL); + lv_obj_t * btn = lv_obj_create_from_class(&lv_list_btn_class, list); lv_obj_set_size(btn, LV_SIZE_PCT(100), LV_SIZE_CONTENT); lv_obj_add_event_cb(btn, event_cb, NULL); if(icon) { - lv_obj_t * img = lv_img_create(btn, NULL); + lv_obj_t * img = lv_img_create(btn); lv_img_set_src(img, icon); } if(txt) { - lv_obj_t * label = lv_label_create(btn, NULL); + lv_obj_t * label = lv_label_create(btn); lv_label_set_text(label, txt); lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR); lv_obj_set_flex_grow(label, 1); diff --git a/src/extra/widgets/msgbox/lv_msgbox.c b/src/extra/widgets/msgbox/lv_msgbox.c index 47eefd03c..4960045a1 100644 --- a/src/extra/widgets/msgbox/lv_msgbox.c +++ b/src/extra/widgets/msgbox/lv_msgbox.c @@ -39,20 +39,18 @@ const lv_obj_class_t lv_msgbox_class = {.base_class = &lv_obj_class}; /** * Create a message box objects * @param par pointer to an object, it will be the parent of the new message box - * @param copy pointer to a message box object, if not NULL then the new object will be copied from - * it * @return pointer to the created message box */ lv_obj_t * lv_msgbox_create(const char * title, const char * txt, const char * btn_txts[], bool add_close_btn) { - lv_obj_t * parent = lv_obj_create(lv_layer_top(), NULL); + lv_obj_t * parent = lv_obj_create(lv_layer_top()); lv_obj_set_size(parent, LV_SIZE_PCT(100), LV_SIZE_PCT(100)); lv_obj_remove_style(parent, LV_PART_ANY, LV_STATE_ANY, NULL); lv_obj_set_style_bg_color(parent, LV_PART_MAIN, LV_STATE_DEFAULT, lv_color_grey()); lv_obj_set_style_bg_opa(parent, LV_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); - lv_obj_t * mbox = lv_obj_create_from_class(&lv_msgbox_class, parent, NULL); + lv_obj_t * mbox = lv_obj_create_from_class(&lv_msgbox_class, parent); LV_ASSERT_MALLOC(mbox); if(mbox == NULL) return NULL; @@ -63,29 +61,29 @@ lv_obj_t * lv_msgbox_create(const char * title, const char * txt, const char * b lv_obj_set_flex_flow(mbox, LV_FLEX_FLOW_ROW); lv_obj_t * label; - label = lv_label_create(mbox, NULL); + label = lv_label_create(mbox); lv_label_set_text(label, title); lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR); if(add_close_btn) lv_obj_set_flex_grow(label, 1); else lv_obj_set_width(label, LV_SIZE_PCT(100)); if(add_close_btn) { - lv_obj_t * close_btn = lv_btn_create(mbox, NULL); + lv_obj_t * close_btn = lv_btn_create(mbox); lv_obj_set_ext_click_area(close_btn, LV_DPX(10)); lv_obj_add_event_cb(close_btn, msgbox_close_event_cb, NULL); - label = lv_label_create(close_btn, NULL); + label = lv_label_create(close_btn); lv_label_set_text(label, LV_SYMBOL_CLOSE); lv_coord_t close_btn_size = LV_MAX(lv_obj_get_width(label), lv_obj_get_height(label)) + LV_DPX(10); lv_obj_set_size(close_btn, close_btn_size, close_btn_size); lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); } - label = lv_label_create(mbox, NULL); + label = lv_label_create(mbox); lv_label_set_text(label, txt); lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP); lv_obj_set_width(label, LV_SIZE_PCT(100)); - lv_obj_t * btns = lv_btnmatrix_create(mbox, NULL); + lv_obj_t * btns = lv_btnmatrix_create(mbox); lv_btnmatrix_set_map(btns, btn_txts); lv_btnmatrix_set_btn_ctrl_all(btns, LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_NO_REPEAT); diff --git a/src/extra/widgets/msgbox/lv_msgbox.h b/src/extra/widgets/msgbox/lv_msgbox.h index 024d74ba9..44d314482 100644 --- a/src/extra/widgets/msgbox/lv_msgbox.h +++ b/src/extra/widgets/msgbox/lv_msgbox.h @@ -42,8 +42,6 @@ extern const lv_obj_class_t lv_msgbox_class; /** * Create a message box objects * @param par pointer to an object, it will be the parent of the new message box - * @param copy pointer to a message box object, if not NULL then the new object will be copied from - * it * @return pointer to the created message box */ lv_obj_t * lv_msgbox_create(const char * title, const char * txt, const char * btn_txts[], bool add_close_btn); diff --git a/src/extra/widgets/spinbox/lv_spinbox.c b/src/extra/widgets/spinbox/lv_spinbox.c index f7c5589eb..768084ae3 100644 --- a/src/extra/widgets/spinbox/lv_spinbox.c +++ b/src/extra/widgets/spinbox/lv_spinbox.c @@ -22,7 +22,7 @@ * STATIC PROTOTYPES **********************/ -static void lv_spinbox_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_spinbox_constructor(lv_obj_t * obj); static void lv_spinbox_event(lv_obj_t * obj, lv_event_t e); static void lv_spinbox_updatevalue(lv_obj_t * obj); @@ -44,15 +44,9 @@ const lv_obj_class_t lv_spinbox_class = { * GLOBAL FUNCTIONS **********************/ -/** - * Create a spinbox object - * @param par pointer to an object, it will be the parent of the new spinbox - * @param copy pointer to a spinbox object, if not NULL then the new object will be copied from it - * @return pointer to the created spinbox - */ lv_obj_t * lv_spinbox_create(lv_obj_t * parent) { - return lv_obj_create_from_class(&lv_spinbox_class, parent, NULL); + return lv_obj_create_from_class(&lv_spinbox_class, parent); } /*===================== @@ -275,10 +269,8 @@ void lv_spinbox_decrement(lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_spinbox_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_spinbox_constructor(lv_obj_t * obj) { - LV_UNUSED(copy); - LV_LOG_TRACE("begin"); lv_spinbox_t * spinbox = (lv_spinbox_t *)obj; diff --git a/src/extra/widgets/spinbox/lv_spinbox.h b/src/extra/widgets/spinbox/lv_spinbox.h index 1d649fdde..9f93fdd16 100644 --- a/src/extra/widgets/spinbox/lv_spinbox.h +++ b/src/extra/widgets/spinbox/lv_spinbox.h @@ -53,7 +53,6 @@ extern const lv_obj_class_t lv_spinbox_class; /** * Create a spinbox objects * @param par pointer to an object, it will be the parent of the new spinbox - * @param copy pointer to a spinbox object, if not NULL then the new object will be copied from it * @return pointer to the created spinbox */ lv_obj_t * lv_spinbox_create(lv_obj_t * parent); diff --git a/src/extra/widgets/spinner/lv_spinner.c b/src/extra/widgets/spinner/lv_spinner.c index 78d2f22f0..5767127af 100644 --- a/src/extra/widgets/spinner/lv_spinner.c +++ b/src/extra/widgets/spinner/lv_spinner.c @@ -38,14 +38,12 @@ static void arc_anim_end_angle(void * obj, int32_t v); /** * Create a spinner object * @param par pointer to an object, it will be the parent of the new spinner - * @param copy pointer to a spinner object, if not NULL then the new object will be copied from - * it * @return pointer to the created spinner */ -lv_obj_t * lv_spinner_create(lv_obj_t * par, uint32_t time, uint32_t arc_length) +lv_obj_t * lv_spinner_create(lv_obj_t * parent, uint32_t time, uint32_t arc_length) { /*Create the ancestor of spinner*/ - lv_obj_t * spinner = lv_arc_create(par, NULL); + lv_obj_t * spinner = lv_arc_create(parent); LV_ASSERT_MALLOC(spinner); if(spinner == NULL) return NULL; diff --git a/src/extra/widgets/spinner/lv_spinner.h b/src/extra/widgets/spinner/lv_spinner.h index 92cdac573..9d344d8ec 100644 --- a/src/extra/widgets/spinner/lv_spinner.h +++ b/src/extra/widgets/spinner/lv_spinner.h @@ -34,7 +34,7 @@ extern "C" { * GLOBAL PROTOTYPES **********************/ -lv_obj_t * lv_spinner_create(lv_obj_t * par, uint32_t time, uint32_t arc_length); +lv_obj_t * lv_spinner_create(lv_obj_t * parent, uint32_t time, uint32_t arc_length); /********************** * MACROS diff --git a/src/extra/widgets/tabview/lv_tabview.c b/src/extra/widgets/tabview/lv_tabview.c index 644907c14..7d6862a5c 100644 --- a/src/extra/widgets/tabview/lv_tabview.c +++ b/src/extra/widgets/tabview/lv_tabview.c @@ -20,7 +20,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_tabview_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_tabview_constructor(lv_obj_t * obj); static void lv_tabview_destructor(lv_obj_t * obj); static void btns_event_cb(lv_obj_t * btns, lv_event_t e); static void cont_event_cb(lv_obj_t * cont, lv_event_t e); @@ -49,7 +49,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * parent, lv_dir_t tab_pos, lv_coord_t tab { tabpos_create = tab_pos; tabsize_create = tab_size; - return lv_obj_create_from_class(&lv_tabview_class, parent, NULL); + return lv_obj_create_from_class(&lv_tabview_class, parent); } lv_obj_t * lv_tabview_add_tab(lv_obj_t * obj, const char * name) @@ -57,7 +57,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * obj, const char * name) lv_tabview_t * tabview = (lv_tabview_t *)obj; lv_obj_t * cont = lv_tabview_get_content(obj); - lv_obj_t * page = lv_obj_create(cont, NULL); + lv_obj_t * page = lv_obj_create(cont); lv_obj_clear_flag(page, LV_OBJ_FLAG_CLICK_FOCUSABLE); uint32_t tab_id = lv_obj_get_child_cnt(cont); @@ -145,9 +145,8 @@ lv_obj_t * lv_tabview_get_tab_btns(lv_obj_t * tv) * STATIC FUNCTIONS **********************/ -static void lv_tabview_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_tabview_constructor(lv_obj_t * obj) { - LV_UNUSED(copy); lv_tabview_t * tabview = (lv_tabview_t *)obj; tabview->tab_pos = tabpos_create; @@ -172,8 +171,8 @@ static void lv_tabview_constructor(lv_obj_t * obj, const lv_obj_t * copy) lv_obj_t * btnm; lv_obj_t * cont; - btnm = lv_btnmatrix_create(obj, NULL); - cont = lv_obj_create(obj, NULL); + btnm = lv_btnmatrix_create(obj); + cont = lv_obj_create(obj); lv_btnmatrix_set_one_checked(btnm, true); tabview->map = lv_mem_alloc(sizeof(const char *)); diff --git a/src/extra/widgets/tileview/lv_tileview.c b/src/extra/widgets/tileview/lv_tileview.c index d836ead8a..df7c67854 100644 --- a/src/extra/widgets/tileview/lv_tileview.c +++ b/src/extra/widgets/tileview/lv_tileview.c @@ -20,8 +20,8 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_tileview_constructor(lv_obj_t * obj, const lv_obj_t * copy); -static void lv_tileview_tile_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_tileview_constructor(lv_obj_t * obj); +static void lv_tileview_tile_constructor(lv_obj_t * obj); static void tileview_event_cb(lv_obj_t * tv, lv_event_t e); /********************** @@ -48,15 +48,9 @@ static uint32_t create_row_id; * GLOBAL FUNCTIONS **********************/ -/** - * Create a tileview object - * @param par pointer to an object, it will be the parent of the new tileview - * @param copy pointer to a tileview object, if not NULL then the new object will be copied from it - * @return pointer to the created tileview - */ lv_obj_t * lv_tileview_create(lv_obj_t * parent) { - return lv_obj_create_from_class(&lv_tileview_class, parent, NULL); + return lv_obj_create_from_class(&lv_tileview_class, parent); } /*====================== @@ -68,7 +62,7 @@ lv_obj_t * lv_tileview_add_tile(lv_obj_t * tv, uint8_t col_id, uint8_t row_id, l create_dir = dir; create_col_id = col_id; create_row_id = row_id; - return lv_obj_create_from_class(&lv_tileview_tile_class, tv, NULL); + return lv_obj_create_from_class(&lv_tileview_tile_class, tv); } void lv_obj_set_tile(lv_obj_t * tv, lv_obj_t * tile_obj, lv_anim_enable_t anim_en) @@ -107,9 +101,8 @@ void lv_obj_set_tile_id(lv_obj_t * tv, uint32_t col_id, uint32_t row_id, lv_anim * STATIC FUNCTIONS **********************/ -static void lv_tileview_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_tileview_constructor(lv_obj_t * obj) { - LV_UNUSED(copy); lv_obj_set_size(obj, LV_SIZE_PCT(100), LV_SIZE_PCT(100)); lv_obj_add_event_cb(obj, tileview_event_cb, NULL); lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ONE); @@ -118,9 +111,8 @@ static void lv_tileview_constructor(lv_obj_t * obj, const lv_obj_t * copy) } -static void lv_tileview_tile_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_tileview_tile_constructor(lv_obj_t * obj) { - LV_UNUSED(copy); lv_obj_t * parent = lv_obj_get_parent(obj); lv_obj_set_size(obj, LV_SIZE_PCT(100), LV_SIZE_PCT(100)); lv_obj_set_pos(obj, create_col_id * lv_obj_get_width_fit(parent), create_row_id * lv_obj_get_height_fit(parent)); diff --git a/src/extra/widgets/tileview/lv_tileview.h b/src/extra/widgets/tileview/lv_tileview.h index 32fc983fa..8fdb8d1e0 100644 --- a/src/extra/widgets/tileview/lv_tileview.h +++ b/src/extra/widgets/tileview/lv_tileview.h @@ -43,7 +43,6 @@ extern const lv_obj_class_t lv_tileview_tile_class; /** * Create a tileview objects * @param par pointer to an object, it will be the parent of the new tileview - * @param copy pointer to a tileview object, if not NULL then the new object will be copied from it * @return pointer to the created tileview */ lv_obj_t * lv_tileview_create(lv_obj_t * parent); diff --git a/src/extra/widgets/win/lv_win.c b/src/extra/widgets/win/lv_win.c index 16071bbe3..dfc50d789 100644 --- a/src/extra/widgets/win/lv_win.c +++ b/src/extra/widgets/win/lv_win.c @@ -21,7 +21,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_win_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_win_constructor(lv_obj_t * obj); /********************** * STATIC VARIABLES @@ -39,13 +39,13 @@ static lv_coord_t create_header_height; lv_obj_t * lv_win_create(lv_obj_t * parent, lv_coord_t header_height) { create_header_height = header_height; - return lv_obj_create_from_class(&lv_win_class, parent, NULL); + return lv_obj_create_from_class(&lv_win_class, parent); } lv_obj_t * lv_win_add_title(lv_obj_t * win, const char * txt) { lv_obj_t * header = lv_win_get_header(win); - lv_obj_t * title = lv_label_create(header, NULL); + lv_obj_t * title = lv_label_create(header); lv_label_set_long_mode(title, LV_LABEL_LONG_DOT); lv_label_set_text(title, txt); lv_obj_set_flex_grow(title, 1); @@ -55,11 +55,11 @@ lv_obj_t * lv_win_add_title(lv_obj_t * win, const char * txt) lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * icon, lv_coord_t btn_w, lv_event_cb_t event_cb) { lv_obj_t * header = lv_win_get_header(win); - lv_obj_t * btn = lv_btn_create(header, NULL); + lv_obj_t * btn = lv_btn_create(header); lv_obj_set_size(btn, btn_w, LV_SIZE_PCT(100)); lv_obj_add_event_cb(btn, event_cb, NULL); - lv_obj_t * img = lv_img_create(btn, NULL); + lv_obj_t * img = lv_img_create(btn); lv_img_set_src(img, icon); lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0); @@ -80,18 +80,17 @@ lv_obj_t * lv_win_get_content(lv_obj_t * win) * STATIC FUNCTIONS **********************/ -static void lv_win_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_win_constructor(lv_obj_t * obj) { - LV_UNUSED(copy); lv_obj_t * parent = lv_obj_get_parent(obj); lv_obj_set_size(obj, lv_obj_get_width(parent), lv_obj_get_height(parent)); lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN); - lv_obj_t * header = lv_obj_create(obj, NULL); + lv_obj_t * header = lv_obj_create(obj); lv_obj_set_size(header, LV_SIZE_PCT(100), create_header_height); lv_obj_set_flex_flow(header, LV_FLEX_FLOW_ROW); - lv_obj_t * cont = lv_obj_create(obj, NULL); + lv_obj_t * cont = lv_obj_create(obj); lv_obj_set_flex_grow(cont, 1); lv_obj_set_width(cont, LV_SIZE_PCT(100)); } diff --git a/src/hal/lv_hal_disp.c b/src/hal/lv_hal_disp.c index 63a0cb224..9758d5736 100644 --- a/src/hal/lv_hal_disp.c +++ b/src/hal/lv_hal_disp.c @@ -131,9 +131,9 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) } #endif - disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/ - disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/ - disp->sys_layer = lv_obj_create(NULL, NULL); /*Create sys layer on the display*/ + disp->act_scr = lv_obj_create(NULL); /*Create a default screen on the display*/ + disp->top_layer = lv_obj_create(NULL); /*Create top layer on the display*/ + disp->sys_layer = lv_obj_create(NULL); /*Create sys layer on the display*/ lv_obj_remove_style(disp->top_layer, LV_PART_ANY, LV_STATE_ANY, NULL); lv_obj_remove_style(disp->sys_layer, LV_PART_ANY, LV_STATE_ANY, NULL); lv_obj_clear_flag(disp->top_layer, LV_OBJ_FLAG_CLICKABLE); diff --git a/src/misc/lv_style.c b/src/misc/lv_style.c index e8f12d406..4dd29e0bf 100644 --- a/src/misc/lv_style.c +++ b/src/misc/lv_style.c @@ -221,7 +221,6 @@ lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop) case LV_STYLE_SHADOW_OPA: case LV_STYLE_LINE_OPA: case LV_STYLE_ARC_OPA: - case LV_STYLE_CONTENT_OPA: value.num = LV_OPA_COVER; break; case LV_STYLE_BG_GRAD_STOP: @@ -231,7 +230,6 @@ lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop) value.num = LV_BORDER_SIDE_FULL; break; case LV_STYLE_TEXT_FONT: - case LV_STYLE_CONTENT_FONT: value.ptr = LV_FONT_DEFAULT; break; case LV_STYLE_SIZE: diff --git a/src/misc/lv_style.h b/src/misc/lv_style.h index 7e9f0fa9b..ebc0adeeb 100644 --- a/src/misc/lv_style.h +++ b/src/misc/lv_style.h @@ -213,16 +213,6 @@ typedef enum { /*Group 6*/ LV_STYLE_CONTENT_TEXT = 96 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_CONTENT_ALIGN = 97 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_CONTENT_OFS_X = 98 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_CONTENT_OFS_Y = 99 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_CONTENT_FONT = 100 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT, - LV_STYLE_CONTENT_COLOR = 101 | LV_STYLE_PROP_INHERIT, - LV_STYLE_CONTENT_COLOR_FILTERED = 101 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_FILTER, - LV_STYLE_CONTENT_OPA = 102 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT, - LV_STYLE_CONTENT_LETTER_SPACE = 103 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT, - LV_STYLE_CONTENT_LINE_SPACE = 104 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT, - LV_STYLE_CONTENT_DECOR = 105 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT, _LV_STYLE_LAST_BUILT_IN_PROP = 111, diff --git a/src/misc/lv_style_gen.h b/src/misc/lv_style_gen.h index e1418cd2b..efc098326 100644 --- a/src/misc/lv_style_gen.h +++ b/src/misc/lv_style_gen.h @@ -648,91 +648,3 @@ static inline void lv_style_set_arc_img_src(lv_style_t * style, const void * val lv_style_set_prop(style, LV_STYLE_ARC_IMG_SRC, v); } -static inline void lv_style_set_content_text(lv_style_t * style, const char * value) -{ - lv_style_value_t v = { - .ptr = value - }; - lv_style_set_prop(style, LV_STYLE_CONTENT_TEXT, v); -} - -static inline void lv_style_set_content_align(lv_style_t * style, lv_align_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_CONTENT_ALIGN, v); -} - -static inline void lv_style_set_content_ofs_x(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_CONTENT_OFS_X, v); -} - -static inline void lv_style_set_content_ofs_y(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_CONTENT_OFS_Y, v); -} - -static inline void lv_style_set_content_opa(lv_style_t * style, lv_opa_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_CONTENT_OPA, v); -} - -static inline void lv_style_set_content_font(lv_style_t * style, const lv_font_t * value) -{ - lv_style_value_t v = { - .ptr = value - }; - lv_style_set_prop(style, LV_STYLE_CONTENT_FONT, v); -} - -static inline void lv_style_set_content_color(lv_style_t * style, lv_color_t value) -{ - lv_style_value_t v = { - .color = value - }; - lv_style_set_prop(style, LV_STYLE_CONTENT_COLOR, v); -} - -static inline void lv_style_set_content_color_filtered(lv_style_t * style, lv_color_t value) -{ - lv_style_value_t v = { - .color = value - }; - lv_style_set_prop(style, LV_STYLE_CONTENT_COLOR_FILTERED, v); -} - -static inline void lv_style_set_content_letter_space(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_CONTENT_LETTER_SPACE, v); -} - -static inline void lv_style_set_content_line_space(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_CONTENT_LINE_SPACE, v); -} - -static inline void lv_style_set_content_decor(lv_style_t * style, lv_text_decor_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_CONTENT_DECOR, v); -} - diff --git a/src/widgets/lv_arc.c b/src/widgets/lv_arc.c index 9048e790f..c26a149f1 100644 --- a/src/widgets/lv_arc.c +++ b/src/widgets/lv_arc.c @@ -30,7 +30,7 @@ * STATIC PROTOTYPES **********************/ -static void lv_arc_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_arc_constructor(lv_obj_t * obj); static void lv_arc_draw(lv_obj_t * obj); static void lv_arc_event(lv_obj_t * obj, lv_event_t e); static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angle, uint8_t part); @@ -60,13 +60,12 @@ const lv_obj_class_t lv_arc_class = { /** * Create a arc object * @param par pointer to an object, it will be the parent of the new arc - * @param copy pointer to a arc object, if not NULL then the new object will be copied from it * @return pointer to the created arc */ -lv_obj_t * lv_arc_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_arc_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_arc_class, parent, copy); + return lv_obj_create_from_class(&lv_arc_class, parent); } /*====================== @@ -480,7 +479,7 @@ lv_arc_type_t lv_arc_get_type(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_arc_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_arc_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); @@ -502,27 +501,9 @@ static void lv_arc_constructor(lv_obj_t * obj, const lv_obj_t * copy) arc->last_tick = lv_tick_get(); arc->last_angle =arc->indic_angle_end; - /*Init the new arc arc*/ - if(copy == NULL) { - lv_obj_add_flag(obj, LV_OBJ_FLAG_CLICKABLE); - lv_obj_set_ext_click_area(obj, LV_DPI_DEF / 10); - } - /*Copy an existing arc*/ - else { - lv_arc_t * copy_arc = (lv_arc_t *)copy; - arc->indic_angle_start = copy_arc->indic_angle_start; - arc->indic_angle_end = copy_arc->indic_angle_end; - arc->bg_angle_start = copy_arc->bg_angle_start; - arc->bg_angle_end = copy_arc->bg_angle_end; - arc->type = copy_arc->type; - arc->value = copy_arc->value; - arc->min_value = copy_arc->min_value; - arc->max_value = copy_arc->max_value; - arc->dragging = copy_arc->dragging; - arc->chg_rate = copy_arc->chg_rate; - arc->last_tick = copy_arc->last_tick; - arc->last_angle = copy_arc->last_angle; - } + lv_obj_add_flag(obj, LV_OBJ_FLAG_CLICKABLE); + lv_obj_set_ext_click_area(obj, LV_DPI_DEF / 10); + LV_TRACE_OBJ_CREATE("finished"); } diff --git a/src/widgets/lv_arc.h b/src/widgets/lv_arc.h index 1487aa2b6..bca78478e 100644 --- a/src/widgets/lv_arc.h +++ b/src/widgets/lv_arc.h @@ -61,10 +61,9 @@ extern const lv_obj_class_t lv_arc_class; /** * Create a arc objects * @param par pointer to an object, it will be the parent of the new arc - * @param copy pointer to a arc object, if not NULL then the new object will be copied from it * @return pointer to the created arc */ -lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy); +lv_obj_t * lv_arc_create(lv_obj_t * parent); /*====================== * Add/remove functions diff --git a/src/widgets/lv_bar.c b/src/widgets/lv_bar.c index 5a33fdd23..a63edcdd5 100644 --- a/src/widgets/lv_bar.c +++ b/src/widgets/lv_bar.c @@ -45,7 +45,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_bar_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_bar_constructor(lv_obj_t * obj); static void lv_bar_destructor(lv_obj_t * obj); static void lv_bar_event(lv_obj_t * bar, lv_event_t e); static void draw_indic(lv_obj_t * bar); @@ -74,10 +74,10 @@ const lv_obj_class_t lv_bar_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_bar_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_bar_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_bar_class, parent, copy); + return lv_obj_create_from_class(&lv_bar_class, parent); } /*===================== @@ -198,7 +198,7 @@ lv_bar_mode_t lv_bar_get_mode(lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_bar_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_bar_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); @@ -212,22 +212,12 @@ static void lv_bar_constructor(lv_obj_t * obj, const lv_obj_t * copy) lv_bar_init_anim(obj, &bar->cur_value_anim); lv_bar_init_anim(obj, &bar->start_value_anim); - if(copy == NULL) { - lv_obj_clear_flag(obj, LV_OBJ_FLAG_CHECKABLE); - lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_set_size(obj, LV_DPI_DEF * 2, LV_DPI_DEF / 10); - lv_bar_set_value(obj, 0, LV_ANIM_OFF); - } else { - lv_bar_t * copy_bar = (lv_bar_t *)copy; - bar->min_value = copy_bar->min_value; - bar->start_value = copy_bar->start_value; - bar->max_value = copy_bar->max_value; - bar->cur_value = copy_bar->cur_value; - bar->mode = copy_bar->mode; + lv_obj_clear_flag(obj, LV_OBJ_FLAG_CHECKABLE); + lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); + lv_obj_set_size(obj, LV_DPI_DEF * 2, LV_DPI_DEF / 10); + lv_bar_set_value(obj, 0, LV_ANIM_OFF); - lv_bar_set_value(obj, bar->cur_value, LV_ANIM_OFF); - } - LV_TRACE_OBJ_CREATE("finished"); + LV_TRACE_OBJ_CREATE("finished"); } static void lv_bar_destructor(lv_obj_t * obj) @@ -406,16 +396,13 @@ static void draw_indic(lv_obj_t * obj) lv_opa_t bg_opa = draw_indic_dsc.bg_opa; lv_opa_t bg_img_opa = draw_indic_dsc.bg_img_opa; lv_opa_t border_opa = draw_indic_dsc.border_opa; - lv_opa_t content_opa = draw_indic_dsc.content_opa; draw_indic_dsc.bg_opa = LV_OPA_TRANSP; draw_indic_dsc.bg_img_opa = LV_OPA_TRANSP; draw_indic_dsc.border_opa = LV_OPA_TRANSP; - draw_indic_dsc.content_opa = LV_OPA_TRANSP; lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc); draw_indic_dsc.bg_opa = bg_opa; draw_indic_dsc.bg_img_opa = bg_img_opa; draw_indic_dsc.border_opa = border_opa; - draw_indic_dsc.content_opa = content_opa; } #if LV_DRAW_COMPLEX @@ -433,10 +420,8 @@ static void draw_indic(lv_obj_t * obj) /*Draw_only the background and background image*/ lv_opa_t shadow_opa = draw_indic_dsc.shadow_opa; lv_opa_t border_opa = draw_indic_dsc.border_opa; - lv_opa_t content_opa = draw_indic_dsc.content_opa; draw_indic_dsc.border_opa = LV_OPA_TRANSP; draw_indic_dsc.shadow_opa = LV_OPA_TRANSP; - draw_indic_dsc.content_opa = LV_OPA_TRANSP; /*Get the max possible indicator area. The gradient should be applied on this*/ lv_area_t mask_indic_max_area; @@ -464,24 +449,17 @@ static void draw_indic(lv_obj_t * obj) lv_draw_rect(&mask_indic_max_area, clip_area, &draw_indic_dsc); draw_indic_dsc.border_opa = border_opa; draw_indic_dsc.shadow_opa = shadow_opa; - draw_indic_dsc.content_opa = content_opa; /*Draw the border*/ draw_indic_dsc.bg_opa = LV_OPA_TRANSP; draw_indic_dsc.bg_img_opa = LV_OPA_TRANSP; draw_indic_dsc.shadow_opa = LV_OPA_TRANSP; - draw_indic_dsc.content_opa = LV_OPA_TRANSP; lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc); #if LV_DRAW_COMPLEX lv_draw_mask_remove_id(mask_indic_id); lv_draw_mask_remove_id(mask_bg_id); #endif - - /*When not masks draw the content*/ - draw_indic_dsc.content_opa = content_opa; - draw_indic_dsc.border_opa = LV_OPA_TRANSP; - lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc); } static void lv_bar_event(lv_obj_t * obj, lv_event_t e) diff --git a/src/widgets/lv_bar.h b/src/widgets/lv_bar.h index 9889e17a9..ea09e93d5 100644 --- a/src/widgets/lv_bar.h +++ b/src/widgets/lv_bar.h @@ -65,11 +65,9 @@ extern const lv_obj_class_t lv_bar_class; /** * Create a bar objects * @param parent pointer to an object, it will be the parent of the new bar - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other bar to copy. * @return pointer to the created bar */ -lv_obj_t * lv_bar_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_bar_create(lv_obj_t * parent); /*===================== * Setter functions diff --git a/src/widgets/lv_btn.c b/src/widgets/lv_btn.c index f58ecdb03..47bf6fdba 100644 --- a/src/widgets/lv_btn.c +++ b/src/widgets/lv_btn.c @@ -23,7 +23,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_btn_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_btn_constructor(lv_obj_t * obj); /********************** * STATIC VARIABLES @@ -42,25 +42,23 @@ const lv_obj_class_t lv_btn_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_btn_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_btn_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_btn_class, parent, copy); + return lv_obj_create_from_class(&lv_btn_class, parent); } /********************** * STATIC FUNCTIONS **********************/ -static void lv_btn_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_btn_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); - if(copy == NULL) { - lv_obj_set_size(obj, LV_DPI_DEF, LV_DPI_DEF / 3); - lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); - } + lv_obj_set_size(obj, LV_DPI_DEF, LV_DPI_DEF / 3); + lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); + lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); LV_TRACE_OBJ_CREATE("finished"); } diff --git a/src/widgets/lv_btn.h b/src/widgets/lv_btn.h index fd0fa9d93..8a5af5102 100644 --- a/src/widgets/lv_btn.h +++ b/src/widgets/lv_btn.h @@ -39,11 +39,9 @@ extern const lv_obj_class_t lv_btn_class; /** * Create a button object * @param parent pointer to an object, it will be the parent of the new button - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other button to copy. * @return pointer to the created button */ -lv_obj_t * lv_btn_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_btn_create(lv_obj_t * parent); /********************** * MACROS diff --git a/src/widgets/lv_btnmatrix.c b/src/widgets/lv_btnmatrix.c index 333ffd62e..341fb51ae 100644 --- a/src/widgets/lv_btnmatrix.c +++ b/src/widgets/lv_btnmatrix.c @@ -32,7 +32,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_btnmatrix_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_btnmatrix_constructor(lv_obj_t * obj); static void lv_btnmatrix_destructor(lv_obj_t * obj); static void lv_btnmatrix_event(lv_obj_t * obj, lv_event_t e); static void draw_main(lv_obj_t * obj); @@ -71,10 +71,10 @@ const lv_obj_class_t lv_btnmatrix_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_btnmatrix_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_btnmatrix_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_btnmatrix_class, parent, copy); + return lv_obj_create_from_class(&lv_btnmatrix_class, parent); } /*===================== @@ -354,7 +354,7 @@ bool lv_btnmatrix_get_one_checked(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_btnmatrix_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_btnmatrix_constructor(lv_obj_t * obj) { lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; btnm->btn_cnt = 0; @@ -365,17 +365,8 @@ static void lv_btnmatrix_constructor(lv_obj_t * obj, const lv_obj_t * copy) btnm->recolor = 0; btnm->one_check = 0; - /*Init the new button matrix object*/ - if(copy == NULL) { - lv_btnmatrix_set_map(obj, lv_btnmatrix_def_map); - lv_obj_set_size(obj, LV_DPI_DEF * 2, LV_DPI_DEF * 1); - } - /*Copy an existing object*/ - else { - lv_btnmatrix_t * copy_btnm = (lv_btnmatrix_t *)copy; - lv_btnmatrix_set_map(obj, copy_btnm->map_p); - lv_btnmatrix_set_ctrl_map(obj, copy_btnm->ctrl_bits); - } + lv_btnmatrix_set_map(obj, lv_btnmatrix_def_map); + lv_obj_set_size(obj, LV_DPI_DEF * 2, LV_DPI_DEF * 1); LV_LOG_TRACE("finshed"); } diff --git a/src/widgets/lv_btnmatrix.h b/src/widgets/lv_btnmatrix.h index e6bd17416..76168f904 100644 --- a/src/widgets/lv_btnmatrix.h +++ b/src/widgets/lv_btnmatrix.h @@ -71,11 +71,9 @@ extern const lv_obj_class_t lv_btnmatrix_class; /** * Create a button matrix objects * @param parent pointer to an object, it will be the parent of the new button matrix - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other button matrix to copy. * @return pointer to the created button matrix */ -lv_obj_t * lv_btnmatrix_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_btnmatrix_create(lv_obj_t * parent); /*===================== * Setter functions diff --git a/src/widgets/lv_canvas.c b/src/widgets/lv_canvas.c index d4c1d7686..980d7d7fa 100644 --- a/src/widgets/lv_canvas.c +++ b/src/widgets/lv_canvas.c @@ -27,7 +27,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_canvas_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_canvas_constructor(lv_obj_t * obj); static void set_set_px_cb(lv_disp_drv_t * disp_drv, lv_img_cf_t cf); static void set_px_true_color_alpha(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, @@ -65,10 +65,10 @@ const lv_obj_class_t lv_canvas_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_canvas_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_canvas_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_canvas_class, parent, copy); + return lv_obj_create_from_class(&lv_canvas_class, parent); } /*===================== @@ -892,14 +892,12 @@ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_ * STATIC FUNCTIONS **********************/ -static void lv_canvas_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_canvas_constructor(lv_obj_t * obj) { - LV_UNUSED(copy); LV_TRACE_OBJ_CREATE("begin"); lv_canvas_t * canvas = (lv_canvas_t *)obj; - /*Initialize the allocated 'ext'*/ canvas->dsc.header.always_zero = 0; canvas->dsc.header.cf = LV_IMG_CF_TRUE_COLOR; canvas->dsc.header.h = 0; diff --git a/src/widgets/lv_canvas.h b/src/widgets/lv_canvas.h index c0736394b..d8c3148ea 100644 --- a/src/widgets/lv_canvas.h +++ b/src/widgets/lv_canvas.h @@ -40,11 +40,10 @@ typedef struct { /** * Create a canvas object - * @param par pointer to an object, it will be the parent of the new canvas - * @param copy pointer to a canvas object, if not NULL then the new object will be copied from it - * @return pointer to the created canvas + * @param parent pointer to an object, it will be the parent of the new canvas + * @return pointer to the created canvas */ -lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy); +lv_obj_t * lv_canvas_create(lv_obj_t * parent); /*===================== * Setter functions diff --git a/src/widgets/lv_chart.c b/src/widgets/lv_chart.c index 798e466ad..be6f64144 100644 --- a/src/widgets/lv_chart.c +++ b/src/widgets/lv_chart.c @@ -36,7 +36,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_chart_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_chart_constructor(lv_obj_t * obj); static void lv_chart_destructor(lv_obj_t * obj); static void lv_chart_event(lv_obj_t * obj, lv_event_t e); @@ -67,10 +67,10 @@ const lv_obj_class_t lv_chart_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_chart_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_chart_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_chart_class, parent, copy); + return lv_obj_create_from_class(&lv_chart_class, parent); } void lv_chart_set_type(lv_obj_t * obj, lv_chart_type_t type) @@ -562,7 +562,7 @@ uint32_t lv_chart_get_pressed_point(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_chart_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_chart_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); @@ -585,20 +585,8 @@ static void lv_chart_constructor(lv_obj_t * obj, const lv_obj_t * copy) chart->zoom_x = LV_IMG_ZOOM_NONE; chart->zoom_y = LV_IMG_ZOOM_NONE; - /*Init the new chart background object*/ - if(copy == NULL) { - lv_obj_set_size(obj, LV_DPI_DEF * 3, LV_DPI_DEF * 2); - } - else { - lv_chart_t * chart_copy = (lv_chart_t*)copy; + lv_obj_set_size(obj, LV_DPI_DEF * 3, LV_DPI_DEF * 2); - chart->type = chart_copy->type; - chart->hdiv_cnt = chart_copy->hdiv_cnt; - chart->vdiv_cnt = chart_copy->vdiv_cnt; - chart->point_cnt = chart_copy->point_cnt; - lv_memcpy_small(chart->ymin, chart_copy->ymin, sizeof(chart->ymin)); - lv_memcpy_small(chart->ymax, chart_copy->ymax, sizeof(chart->ymax)); - } LV_TRACE_OBJ_CREATE("finished"); } diff --git a/src/widgets/lv_chart.h b/src/widgets/lv_chart.h index d3d2ab750..de7b64f15 100644 --- a/src/widgets/lv_chart.h +++ b/src/widgets/lv_chart.h @@ -115,11 +115,9 @@ extern const lv_obj_class_t lv_chart_class; /** * Create a chart objects * @param parent pointer to an object, it will be the parent of the new button - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other chart to copy. * @return pointer to the created chart */ -lv_obj_t * lv_chart_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_chart_create(lv_obj_t * parent); /** * Set a new type for a chart diff --git a/src/widgets/lv_checkbox.c b/src/widgets/lv_checkbox.c index b0cd4880c..7ac6d94a6 100644 --- a/src/widgets/lv_checkbox.c +++ b/src/widgets/lv_checkbox.c @@ -26,7 +26,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_checkbox_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_checkbox_constructor(lv_obj_t * obj); static void lv_checkbox_destructor(lv_obj_t * obj); static void lv_checkbox_event(lv_obj_t * obj, lv_event_t e); static void lv_checkbox_draw(lv_obj_t * obj); @@ -50,10 +50,10 @@ const lv_obj_class_t lv_checkbox_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_checkbox_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_checkbox_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_checkbox_class, parent, copy); + return lv_obj_create_from_class(&lv_checkbox_class, parent); } /*===================== @@ -108,23 +108,17 @@ const char * lv_checkbox_get_text(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_checkbox_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_checkbox_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); lv_checkbox_t * cb = (lv_checkbox_t *)obj; - /*Init the new checkbox object*/ - if(copy == NULL) { - cb->txt = "Check box"; - cb->static_txt = 1; - lv_obj_add_flag(obj, LV_OBJ_FLAG_CLICKABLE); - lv_obj_add_flag(obj, LV_OBJ_FLAG_CHECKABLE); - lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - } - else { -// const lv_checkbox_t * copy_ext = (const lv_checkbox_t *)copy; - } + cb->txt = "Check box"; + cb->static_txt = 1; + lv_obj_add_flag(obj, LV_OBJ_FLAG_CLICKABLE); + lv_obj_add_flag(obj, LV_OBJ_FLAG_CHECKABLE); + lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); LV_TRACE_OBJ_CREATE("finished"); } diff --git a/src/widgets/lv_checkbox.h b/src/widgets/lv_checkbox.h index 05bd6ce17..a1027a021 100644 --- a/src/widgets/lv_checkbox.h +++ b/src/widgets/lv_checkbox.h @@ -41,11 +41,9 @@ extern const lv_obj_class_t lv_checkbox_class; /** * Create a check box object * @param parent pointer to an object, it will be the parent of the new button - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other check box to copy. * @return pointer to the created check box */ -lv_obj_t * lv_checkbox_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_checkbox_create(lv_obj_t * parent); /*===================== * Setter functions diff --git a/src/widgets/lv_dropdown.c b/src/widgets/lv_dropdown.c index ccaed47c6..f4f5023c6 100644 --- a/src/widgets/lv_dropdown.c +++ b/src/widgets/lv_dropdown.c @@ -35,13 +35,13 @@ /********************** * STATIC PROTOTYPES **********************/ -static lv_obj_t * lv_dropdown_list_create(lv_obj_t * parent, const lv_obj_t * copy); -static void lv_dropdown_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static lv_obj_t * lv_dropdown_list_create(lv_obj_t * parent); +static void lv_dropdown_constructor(lv_obj_t * obj); static void lv_dropdown_destructor(lv_obj_t * obj); static void lv_dropdown_event(lv_obj_t * obj, lv_event_t e); static void draw_main(lv_obj_t * obj); -static void lv_dropdown_list_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_dropdown_list_constructor(lv_obj_t * obj); static void lv_dropdown_list_destructor(lv_obj_t * list_obj); static void lv_dropdown_list_event(lv_obj_t * list, lv_event_t e); static void draw_list(lv_obj_t * obj); @@ -83,10 +83,10 @@ const lv_obj_class_t lv_dropdown_list_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_dropdown_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_dropdown_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_dropdown_class, parent, copy); + return lv_obj_create_from_class(&lv_dropdown_class, parent); } /*===================== @@ -425,7 +425,7 @@ void lv_dropdown_open(lv_obj_t * dropdown_obj) lv_obj_add_state(dropdown_obj, LV_STATE_CHECKED); if(dropdown->list == NULL) { - lv_obj_t * list_obj = lv_dropdown_list_create(lv_obj_get_screen(dropdown_obj), NULL); + lv_obj_t * list_obj = lv_dropdown_list_create(lv_obj_get_screen(dropdown_obj)); ((lv_dropdown_list_t*) list_obj)->dropdown = dropdown_obj; dropdown->list = list_obj; lv_obj_clear_flag(dropdown->list, LV_OBJ_FLAG_CLICK_FOCUSABLE); @@ -529,12 +529,12 @@ void lv_dropdown_close(lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static lv_obj_t * lv_dropdown_list_create(lv_obj_t * parent, const lv_obj_t * copy) +static lv_obj_t * lv_dropdown_list_create(lv_obj_t * parent) { - return lv_obj_create_from_class(&lv_dropdown_list_class, parent, copy); + return lv_obj_create_from_class(&lv_dropdown_list_class, parent); } -static void lv_dropdown_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_dropdown_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); @@ -554,27 +554,9 @@ static void lv_dropdown_constructor(lv_obj_t * obj, const lv_obj_t * copy) dropdown->dir = LV_DIR_BOTTOM; dropdown->max_height = (3 * lv_disp_get_ver_res(NULL)) / 4; - - if(copy == NULL) { - lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); - lv_obj_set_size(obj, LV_DPX(150), LV_SIZE_CONTENT); - lv_dropdown_set_options_static(obj, "Option 1\nOption 2\nOption 3"); - } - /*Copy an existing drop down list*/ - else { -// lv_dropdown_ext_t * copy_ext = lv_obj_get_ext_attr(copy); -// if(copy_dropdown->static_txt == 0) -// lv_dropdown_set_options(ddlist, lv_dropdown_get_options(copy)); -// else -// lv_dropdown_set_options_static(ddlist, lv_dropdown_get_options(copy)); -// dropdown->option_cnt = copy_dropdown->option_cnt; -// dropdown->sel_opt_id = copy_dropdown->sel_opt_id; -// dropdown->sel_opt_id_orig = copy_dropdown->sel_opt_id; -// dropdown->symbol = copy_dropdown->symbol; -// dropdown->max_height = copy_dropdown->max_height; -// dropdown->text = copy_dropdown->text; -// dropdown->dir = copy_dropdown->dir; - } + lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); + lv_obj_set_size(obj, LV_DPX(150), LV_SIZE_CONTENT); + lv_dropdown_set_options_static(obj, "Option 1\nOption 2\nOption 3"); LV_TRACE_OBJ_CREATE("finished"); } @@ -594,13 +576,12 @@ static void lv_dropdown_destructor(lv_obj_t * obj) } } -static void lv_dropdown_list_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_dropdown_list_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); - LV_UNUSED(copy); lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); - lv_label_create(obj, NULL); + lv_label_create(obj); LV_TRACE_OBJ_CREATE("finished"); } diff --git a/src/widgets/lv_dropdown.h b/src/widgets/lv_dropdown.h index 8c8b1c704..7af638cdd 100644 --- a/src/widgets/lv_dropdown.h +++ b/src/widgets/lv_dropdown.h @@ -66,11 +66,9 @@ extern const lv_obj_class_t lv_dropdown_list_class; /** * Create a drop-down list objects * @param parent pointer to an object, it will be the parent of the new drop-down list - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other drop-down list to copy. * @return pointer to the created drop-down list */ -lv_obj_t * lv_dropdown_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_dropdown_create(lv_obj_t * parent); /*===================== * Setter functions diff --git a/src/widgets/lv_img.c b/src/widgets/lv_img.c index 833e65079..a98bd0cb3 100644 --- a/src/widgets/lv_img.c +++ b/src/widgets/lv_img.c @@ -28,7 +28,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_img_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_img_constructor(lv_obj_t * obj); static void lv_img_destructor(lv_obj_t * obj); static void lv_img_event(lv_obj_t * obj, lv_event_t e); static void draw_img(lv_obj_t * obj, lv_event_t e); @@ -52,10 +52,10 @@ const lv_obj_class_t lv_img_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_img_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_img_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_img_class, parent, copy); + return lv_obj_create_from_class(&lv_img_class, parent); } /*===================== @@ -358,7 +358,7 @@ bool lv_img_get_antialias(lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_img_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_img_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); @@ -377,24 +377,10 @@ static void lv_img_constructor(lv_obj_t * obj, const lv_obj_t * copy) img->pivot.x = 0; img->pivot.y = 0; - if(copy == NULL) { - lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE); - lv_obj_add_flag(obj, LV_OBJ_FLAG_ADV_HITTEST); + lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE); + lv_obj_add_flag(obj, LV_OBJ_FLAG_ADV_HITTEST); - /*Enable auto size for non screens - *because image screens are wallpapers - *and must be screen sized*/ - if(obj->parent) lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - } - else { - lv_img_t * copy_img = (lv_img_t *)copy; - img->zoom = copy_img->zoom; - img->angle = copy_img->angle; - img->antialias = copy_img->antialias; - img->offset = copy_img->offset; - img->pivot = copy_img->pivot; - lv_img_set_src(obj, copy_img->src); - } + if(obj->parent) lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); LV_TRACE_OBJ_CREATE("finished"); } diff --git a/src/widgets/lv_img.h b/src/widgets/lv_img.h index 4b8a8a564..f731eae91 100644 --- a/src/widgets/lv_img.h +++ b/src/widgets/lv_img.h @@ -52,11 +52,9 @@ extern const lv_obj_class_t lv_img_class; /** * Create a image objects * @param parent pointer to an object, it will be the parent of the new image - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other bar to copy. * @return pointer to the created image */ -lv_obj_t * lv_img_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_img_create(lv_obj_t * parent); /*===================== * Setter functions diff --git a/src/widgets/lv_label.c b/src/widgets/lv_label.c index 1b2316dab..ee907c9a1 100644 --- a/src/widgets/lv_label.c +++ b/src/widgets/lv_label.c @@ -34,7 +34,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_label_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_label_constructor(lv_obj_t * obj); static void lv_label_destructor(lv_obj_t * obj); static void lv_label_event_cb(lv_obj_t * obj, lv_event_t e); static void draw_main(lv_obj_t * obj); @@ -68,10 +68,10 @@ const lv_obj_class_t lv_label_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_label_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_label_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_label_class, parent, copy); + return lv_obj_create_from_class(&lv_label_class, parent); } /*===================== @@ -692,7 +692,7 @@ void lv_label_cut_text(lv_obj_t * obj, uint32_t pos, uint32_t cnt) * STATIC FUNCTIONS **********************/ -static void lv_label_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_label_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); @@ -719,11 +719,10 @@ static void lv_label_constructor(lv_obj_t * obj, const lv_obj_t * copy) label->dot.tmp_ptr = NULL; label->dot_tmp_alloc = 0; - if(copy == NULL) { - lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE); - lv_label_set_long_mode(obj, LV_LABEL_LONG_EXPAND); - lv_label_set_text(obj, "Text"); - } + lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE); + lv_label_set_long_mode(obj, LV_LABEL_LONG_EXPAND); + lv_label_set_text(obj, "Text"); + LV_TRACE_OBJ_CREATE("finished"); } diff --git a/src/widgets/lv_label.h b/src/widgets/lv_label.h index 55fa825fd..7aad87620 100644 --- a/src/widgets/lv_label.h +++ b/src/widgets/lv_label.h @@ -84,12 +84,10 @@ extern const lv_obj_class_t lv_label_class; /** * Create a label objects - * @param parent pointer to an object, it will be the parent of the new label - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other label to copy. + * @param parent pointer to an object, it will be the parent of the new labely. * @return pointer to the created button */ -lv_obj_t * lv_label_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_label_create(lv_obj_t * parent); /*===================== * Setter functions diff --git a/src/widgets/lv_line.c b/src/widgets/lv_line.c index 1589d6fe7..67870dcc8 100644 --- a/src/widgets/lv_line.c +++ b/src/widgets/lv_line.c @@ -28,7 +28,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_line_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_line_constructor(lv_obj_t * obj); static void lv_line_event(lv_obj_t * obj, lv_event_t e); /********************** @@ -49,10 +49,10 @@ const lv_obj_class_t lv_line_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_line_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_line_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_line_class, parent, copy); + return lv_obj_create_from_class(&lv_line_class, parent); } /*===================== @@ -101,7 +101,7 @@ bool lv_line_get_y_invert(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_line_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_line_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); @@ -111,19 +111,8 @@ static void lv_line_constructor(lv_obj_t * obj, const lv_obj_t * copy) line->point_array = NULL; line->y_inv = 0; - - /*Init the new line*/ - if(copy == NULL) { - lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE); - } - /*Copy an existing object*/ - else { - lv_line_t * copy_line = (lv_line_t *)copy; - lv_line_set_y_invert(obj, lv_line_get_y_invert(copy)); - lv_line_set_points(obj, copy_line->point_array, copy_line->point_num); - - } + lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE); LV_TRACE_OBJ_CREATE("finished"); } diff --git a/src/widgets/lv_line.h b/src/widgets/lv_line.h index 9636e687d..4ba05e88f 100644 --- a/src/widgets/lv_line.h +++ b/src/widgets/lv_line.h @@ -46,7 +46,7 @@ extern const lv_obj_class_t lv_line_class; * @param par pointer to an object, it will be the parent of the new line * @return pointer to the created line */ -lv_obj_t * lv_line_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_line_create(lv_obj_t * parent); /*===================== * Setter functions diff --git a/src/widgets/lv_meter.c b/src/widgets/lv_meter.c index 83a943c97..02e992d91 100644 --- a/src/widgets/lv_meter.c +++ b/src/widgets/lv_meter.c @@ -27,7 +27,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_meter_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_meter_constructor(lv_obj_t * obj); static void lv_meter_destructor(lv_obj_t * obj); static void lv_meter_event(lv_obj_t * obj, lv_event_t e); static void draw_arcs(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area_t * scale_area); @@ -56,10 +56,10 @@ const lv_obj_class_t lv_meter_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_meter_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_meter_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_meter_class, parent, copy); + return lv_obj_create_from_class(&lv_meter_class, parent); } /*===================== @@ -246,7 +246,7 @@ void lv_meter_set_indicator_end_value(lv_obj_t * obj, lv_meter_indicator_t * ind * STATIC FUNCTIONS **********************/ -static void lv_meter_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_meter_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); @@ -254,19 +254,7 @@ static void lv_meter_constructor(lv_obj_t * obj, const lv_obj_t * copy) _lv_ll_init(&meter->scale_ll, sizeof(lv_meter_scale_t)); - /*Init the new line meter line meter*/ - if(copy == NULL) { - lv_obj_set_size(obj, 3 * LV_DPI_DEF / 2, 3 * LV_DPI_DEF / 2); - } - /*Copy an existing line meter*/ - else { -// lv_meter_ext_t * copy_ext = lv_obj_get_ext_attr(copy); -// meter->scale_angle = copy_meter->scale_angle; -// meter->line_cnt = copy_meter->line_cnt; -// meter->min_value = copy_meter->min_value; -// meter->max_value = copy_meter->max_value; -// meter->cur_value = copy_meter->cur_value; - } + lv_obj_set_size(obj, 3 * LV_DPI_DEF / 2, 3 * LV_DPI_DEF / 2); LV_TRACE_OBJ_CREATE("finished"); } diff --git a/src/widgets/lv_meter.h b/src/widgets/lv_meter.h index a187d5174..8000b837c 100644 --- a/src/widgets/lv_meter.h +++ b/src/widgets/lv_meter.h @@ -101,12 +101,10 @@ extern const lv_obj_class_t lv_meter_class; /** * Create a meter objects - * @param parent pointer to an object, it will be the parent of the new bar - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other meter to copy. + * @param parent pointer to an object, it will be the parent of the new bar. * @return pointer to the created meter */ -lv_obj_t * lv_meter_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_meter_create(lv_obj_t * parent); /*===================== * Add scale diff --git a/src/widgets/lv_roller.c b/src/widgets/lv_roller.c index 63911e065..6b17f5d0f 100644 --- a/src/widgets/lv_roller.c +++ b/src/widgets/lv_roller.c @@ -28,7 +28,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_roller_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_roller_constructor(lv_obj_t * obj); static void lv_roller_event(lv_obj_t * obj, lv_event_t e); static void lv_roller_label_event(lv_obj_t * label, lv_event_t e); static void draw_main(lv_obj_t * obj, lv_event_t e); @@ -69,13 +69,12 @@ const lv_obj_class_t lv_roller_label_class = { /** * Create a roller object * @param par pointer to an object, it will be the parent of the new roller - * @param copy pointer to a roller object, if not NULL then the new object will be copied from it * @return pointer to the created roller */ -lv_obj_t * lv_roller_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_roller_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_roller_class, parent, copy); + return lv_obj_create_from_class(&lv_roller_class, parent); } /*===================== @@ -282,7 +281,7 @@ uint16_t lv_roller_get_option_cnt(const lv_obj_t * obj) **********************/ -static void lv_roller_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_roller_constructor(lv_obj_t * obj) { lv_roller_t * roller = (lv_roller_t*)obj; @@ -291,24 +290,13 @@ static void lv_roller_constructor(lv_obj_t * obj, const lv_obj_t * copy) roller->sel_opt_id = 0; roller->sel_opt_id_ori = 0; - /*Init the new roller roller*/ - if(copy == NULL) { - lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_CHAIN); - lv_obj_set_width(obj, LV_SIZE_CONTENT); + lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); + lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_CHAIN); + lv_obj_set_width(obj, LV_SIZE_CONTENT); - lv_obj_create_from_class(&lv_roller_label_class, obj, NULL); - lv_roller_set_options(obj, "Option 1\nOption 2\nOption 3\nOption 4\nOption 5", LV_ROLLER_MODE_NORMAL); - lv_obj_set_height(obj, LV_DPI_DEF); - } - else { - lv_obj_create_from_class(&lv_roller_label_class, obj, NULL); - lv_roller_t * copy_roller = (lv_roller_t *)copy; - roller->mode = copy_roller->mode; - roller->option_cnt = copy_roller->option_cnt; - roller->sel_opt_id = copy_roller->sel_opt_id; - roller->sel_opt_id_ori = copy_roller->sel_opt_id; - } + lv_obj_create_from_class(&lv_roller_label_class, obj); + lv_roller_set_options(obj, "Option 1\nOption 2\nOption 3\nOption 4\nOption 5", LV_ROLLER_MODE_NORMAL); + lv_obj_set_height(obj, LV_DPI_DEF); LV_LOG_TRACE("finshed"); } diff --git a/src/widgets/lv_roller.h b/src/widgets/lv_roller.h index 5c303d289..24202734b 100644 --- a/src/widgets/lv_roller.h +++ b/src/widgets/lv_roller.h @@ -54,12 +54,10 @@ extern const lv_obj_class_t lv_roller_class; /** * Create a roller objects - * @param parent pointer to an object, it will be the parent of the new roller - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other roller to copy. + * @param parent pointer to an object, it will be the parent of the new roller. * @return pointer to the created roller */ -lv_obj_t * lv_roller_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_roller_create(lv_obj_t * parent); /*===================== * Setter functions diff --git a/src/widgets/lv_slider.c b/src/widgets/lv_slider.c index b6dc0485f..3e085c26d 100644 --- a/src/widgets/lv_slider.c +++ b/src/widgets/lv_slider.c @@ -31,7 +31,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_slider_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_slider_constructor(lv_obj_t * obj); static void lv_slider_event(lv_obj_t * obj, lv_event_t e); static void position_knob(lv_obj_t * obj, lv_area_t * knob_area, lv_coord_t knob_size, bool hor); static void draw_knob(lv_obj_t * obj); @@ -55,10 +55,10 @@ const lv_obj_class_t lv_slider_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_slider_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_slider_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_slider_class, parent, copy); + return lv_obj_create_from_class(&lv_slider_class, parent); } bool lv_slider_is_dragged(const lv_obj_t * obj) @@ -73,7 +73,7 @@ bool lv_slider_is_dragged(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_slider_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_slider_constructor(lv_obj_t * obj) { lv_slider_t * slider = (lv_slider_t *)obj; @@ -82,18 +82,10 @@ static void lv_slider_constructor(lv_obj_t * obj, const lv_obj_t * copy) slider->dragging = 0; slider->left_knob_focus = 0; - /*Init the new slider slider*/ - if(copy == NULL) { - lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_CHAIN); - lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_set_ext_click_area(obj, LV_DPX(8)); - lv_obj_set_height(obj, LV_DPX(10)); - } else { - lv_slider_t * copy_slider = (lv_slider_t * ) copy; - lv_area_copy(&slider->left_knob_area, ©_slider->left_knob_area); - lv_area_copy(&slider->right_knob_area, ©_slider->right_knob_area); - } - + lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_CHAIN); + lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); + lv_obj_set_ext_click_area(obj, LV_DPX(8)); + lv_obj_set_height(obj, LV_DPX(10)); } static void lv_slider_event(lv_obj_t * obj, lv_event_t e) diff --git a/src/widgets/lv_slider.h b/src/widgets/lv_slider.h index 1dba0b357..12b147ab2 100644 --- a/src/widgets/lv_slider.h +++ b/src/widgets/lv_slider.h @@ -57,12 +57,10 @@ extern const lv_obj_class_t lv_slider_class; /** * Create a slider objects - * @param parent pointer to an object, it will be the parent of the new slider - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other slider to copy. + * @param parent pointer to an object, it will be the parent of the new slider. * @return pointer to the created slider */ -lv_obj_t * lv_slider_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_slider_create(lv_obj_t * parent); /*===================== * Setter functions diff --git a/src/widgets/lv_switch.c b/src/widgets/lv_switch.c index a4dfe2f3b..63c2bb2a0 100644 --- a/src/widgets/lv_switch.c +++ b/src/widgets/lv_switch.c @@ -33,7 +33,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_switch_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_switch_constructor(lv_obj_t * obj); static void lv_switch_event(lv_obj_t * obj, lv_event_t e); static void draw_main(lv_obj_t * obj); @@ -55,32 +55,23 @@ const lv_obj_class_t lv_switch_class = { * GLOBAL FUNCTIONS **********************/ -/** - * Create a switch objects - * @param parent pointer to an object, it will be the parent of the new switch - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other switch to copy. - * @return pointer to the created switch - */ -lv_obj_t * lv_switch_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_switch_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_switch_class, parent, copy); + return lv_obj_create_from_class(&lv_switch_class, parent); } /********************** * STATIC FUNCTIONS **********************/ -static void lv_switch_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_switch_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); - if(copy == NULL) { - lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_add_flag(obj, LV_OBJ_FLAG_CHECKABLE); - lv_obj_set_size(obj, LV_DPX(60), LV_DPX(35)); - } + lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); + lv_obj_add_flag(obj, LV_OBJ_FLAG_CHECKABLE); + lv_obj_set_size(obj, LV_DPX(60), LV_DPX(35)); LV_TRACE_OBJ_CREATE("finished"); } diff --git a/src/widgets/lv_switch.h b/src/widgets/lv_switch.h index c226a13ca..caf7460bc 100644 --- a/src/widgets/lv_switch.h +++ b/src/widgets/lv_switch.h @@ -46,11 +46,9 @@ extern const lv_obj_class_t lv_switch_class; /** * Create a switch objects * @param parent pointer to an object, it will be the parent of the new switch - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other switch to copy. * @return pointer to the created switch */ -lv_obj_t * lv_switch_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_switch_create(lv_obj_t * parent); /********************** * MACROS diff --git a/src/widgets/lv_table.c b/src/widgets/lv_table.c index 428038268..3c2ed68d9 100644 --- a/src/widgets/lv_table.c +++ b/src/widgets/lv_table.c @@ -29,7 +29,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_table_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_table_constructor(lv_obj_t * obj); static void lv_table_destructor(lv_obj_t * obj); static void lv_table_event(lv_obj_t * obj, lv_event_t e); static void draw_main(lv_obj_t * obj); @@ -58,10 +58,10 @@ const lv_obj_class_t lv_table_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_table_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_table_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_table_class, parent, copy); + return lv_obj_create_from_class(&lv_table_class, parent); } /*===================== @@ -395,38 +395,22 @@ void lv_table_get_selected_cell(lv_obj_t * obj, uint16_t * row, uint16_t * col) * STATIC FUNCTIONS **********************/ -static void lv_table_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_table_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); lv_table_t * table = (lv_table_t *)obj; - /*Initialize the allocated 'ext'*/ - table->cell_data = NULL; - table->col_cnt = 0; - table->row_cnt = 0; - table->row_h = NULL; - table->col_w = NULL; + table->col_cnt = 1; + table->row_cnt = 1; + table->col_w = lv_mem_alloc(table->col_cnt * sizeof(table->col_w[0])); + table->row_h = lv_mem_alloc(table->row_cnt * sizeof(table->row_h[0])); + table->col_w[0] = LV_DPI_DEF; + table->row_h[0] = LV_DPI_DEF; + table->cell_data = lv_mem_realloc(table->cell_data, table->row_cnt * table->col_cnt * sizeof(char *)); + table->cell_data[0] = NULL; - /*Init the new table table*/ - if(copy == NULL) { - table->col_cnt = 1; - table->row_cnt = 1; - table->col_w = lv_mem_alloc(table->col_cnt * sizeof(table->col_w[0])); - table->row_h = lv_mem_alloc(table->row_cnt * sizeof(table->row_h[0])); - table->col_w[0] = LV_DPI_DEF; - table->row_h[0] = LV_DPI_DEF; - table->cell_data = lv_mem_realloc(table->cell_data, table->row_cnt * table->col_cnt * sizeof(char *)); - table->cell_data[0] = NULL; - - lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - } - /*Copy an existing table*/ - else { - lv_table_t * copy_table = (lv_table_t *)copy; - lv_table_set_row_cnt(obj, copy_table->row_cnt); - lv_table_set_col_cnt(obj, copy_table->col_cnt); - } + lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); LV_TRACE_OBJ_CREATE("finished"); } diff --git a/src/widgets/lv_table.h b/src/widgets/lv_table.h index cc11f89e8..cd87e19b7 100644 --- a/src/widgets/lv_table.h +++ b/src/widgets/lv_table.h @@ -67,10 +67,9 @@ extern const lv_obj_class_t lv_table_class; /** * Create a table object * @param parent pointer to an object, it will be the parent of the new table - * @param copy pointer to a table object, if not NULL then the new object will be copied from it * @return pointer to the created table */ -lv_obj_t * lv_table_create(lv_obj_t * parent, const lv_obj_t * copy); +lv_obj_t * lv_table_create(lv_obj_t * parent); /*===================== * Setter functions diff --git a/src/widgets/lv_textarea.c b/src/widgets/lv_textarea.c index e6fd01e07..8aac52a7b 100644 --- a/src/widgets/lv_textarea.c +++ b/src/widgets/lv_textarea.c @@ -45,7 +45,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_textarea_constructor(lv_obj_t * obj, const lv_obj_t * copy); +static void lv_textarea_constructor(lv_obj_t * obj); static void lv_textarea_destructor(lv_obj_t * obj); static void lv_textarea_event(lv_obj_t * obj, lv_event_t e); static void cursor_blink_anim_cb(void * obj, int32_t show); @@ -84,13 +84,12 @@ static const char * ta_insert_replace; /** * Create a text area objects * @param par pointer to an object, it will be the parent of the new text area - * @param copy pointer to a text area object, if not NULL then the new object will be copied from it * @return pointer to the created text area */ -lv_obj_t * lv_textarea_create(lv_obj_t * parent, const lv_obj_t * copy) +lv_obj_t * lv_textarea_create(lv_obj_t * parent) { LV_LOG_INFO("begin") - return lv_obj_create_from_class(&lv_textarea_class, parent, copy); + return lv_obj_create_from_class(&lv_textarea_class, parent); } /*====================== @@ -942,7 +941,7 @@ void lv_textarea_cursor_up(lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_textarea_constructor(lv_obj_t * obj, const lv_obj_t * copy) +static void lv_textarea_constructor(lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); @@ -964,42 +963,11 @@ static void lv_textarea_constructor(lv_obj_t * obj, const lv_obj_t * copy) ta->label = NULL; ta->placeholder_txt = NULL; - /*Init the new text area object*/ - if(copy == NULL) { - ta->label = lv_label_create(obj, NULL); - lv_label_set_long_mode(ta->label, LV_LABEL_LONG_WRAP); - lv_label_set_text(ta->label, ""); - lv_obj_set_size(obj, LV_TEXTAREA_DEF_WIDTH, LV_TEXTAREA_DEF_HEIGHT); - lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); - } - /*Copy an existing object*/ - else { - - lv_textarea_t * copy_ta = (lv_textarea_t *)copy; - ta->label = lv_label_create(obj, copy_ta->label); - ta->pwd_mode = copy_ta->pwd_mode; - ta->accepted_chars = copy_ta->accepted_chars; - ta->max_length = copy_ta->max_length; - ta->cursor.pos = copy_ta->cursor.pos; - ta->cursor.valid_x = copy_ta->cursor.valid_x; - - if(ta->pwd_mode != 0) pwd_char_hider(obj); - - if(copy_ta->placeholder_txt) { - lv_textarea_set_placeholder_text(obj, copy_ta->placeholder_txt); - } - - if(copy_ta->pwd_tmp) { - uint32_t len = strlen(copy_ta->pwd_tmp) + 1; - ta->pwd_tmp = lv_mem_alloc(len); - LV_ASSERT_MALLOC(ta->pwd_tmp); - if(ta->pwd_tmp == NULL) return; - - lv_memcpy(ta->pwd_tmp, copy_ta->pwd_tmp, len); - } - - if(copy_ta->one_line) lv_textarea_set_one_line(obj, true); - } + ta->label = lv_label_create(obj); + lv_label_set_long_mode(ta->label, LV_LABEL_LONG_WRAP); + lv_label_set_text(ta->label, ""); + lv_obj_set_size(obj, LV_TEXTAREA_DEF_WIDTH, LV_TEXTAREA_DEF_HEIGHT); + lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); start_cursor_blink(obj); diff --git a/src/widgets/lv_textarea.h b/src/widgets/lv_textarea.h index d07d4d74d..d22bb93b8 100644 --- a/src/widgets/lv_textarea.h +++ b/src/widgets/lv_textarea.h @@ -77,11 +77,10 @@ enum { /** * Create a text area objects - * @param par pointer to an object, it will be the parent of the new text area - * @param copy pointer to a text area object, if not NULL then the new object will be copied from it - * @return pointer to the created text area + * @param parent pointer to an object, it will be the parent of the new text area + * @return pointer to the created text area */ -lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy); +lv_obj_t * lv_textarea_create(lv_obj_t * parent); /*====================== * Add/remove functions diff --git a/tests/lv_test_core/lv_test_obj.c b/tests/lv_test_core/lv_test_obj.c index ba22bfac5..86f5cd190 100644 --- a/tests/lv_test_core/lv_test_obj.c +++ b/tests/lv_test_core/lv_test_obj.c @@ -61,7 +61,7 @@ static void create_delete_change_parent(void) lv_test_print("Create an object on the default screen"); lv_test_assert_int_eq(0, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count before creation"); - lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); + lv_obj_t * obj = lv_obj_create(lv_scr_act()); lv_test_assert_int_eq(1, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count after creation"); lv_test_assert_int_eq(0, lv_obj_get_child_cnt(obj), "New object's children count after creation"); @@ -71,8 +71,8 @@ static void create_delete_change_parent(void) lv_test_assert_int_eq(0, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count after delete"); lv_test_print("Create two objects"); - lv_obj_t * obj_parent = lv_obj_create(lv_scr_act(), NULL); - lv_obj_t * obj_child = lv_obj_create(lv_scr_act(), NULL); + lv_obj_t * obj_parent = lv_obj_create(lv_scr_act()); + lv_obj_t * obj_child = lv_obj_create(lv_scr_act()); lv_test_assert_int_eq(2, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count after creation"); lv_test_print("Change the parent of the second object to the first"); diff --git a/tests/lv_test_widgets/lv_test_label.c b/tests/lv_test_widgets/lv_test_label.c index f6f89e868..16aaa2492 100644 --- a/tests/lv_test_widgets/lv_test_label.c +++ b/tests/lv_test_widgets/lv_test_label.c @@ -63,7 +63,7 @@ typedef int _keep_pedantic_happy; // lv_test_print("Create a label"); // lv_test_print("---------------------------"); // -// lv_label_create(lv_scr_act(), NULL); +// lv_label_create(lv_scr_act()); //#if LV_COLOR_DEPTH == 32 // lv_test_assert_img_eq("lv_test_img32_label_1.png", "Create a label and leave the default settings"); //#endif