From a2f3022188889d2245893ab7bafabf1ec93362c8 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 25 Mar 2021 16:14:17 +0100 Subject: [PATCH] api(align) save align in style and handle x/y according to it --- .../get_started/lv_example_get_started_1.c | 3 +- .../get_started/lv_example_get_started_2.c | 4 +- .../get_started/lv_example_get_started_3.c | 10 +-- examples/layouts/flex/lv_example_flex_1.c | 8 +- examples/layouts/flex/lv_example_flex_2.c | 3 +- examples/layouts/flex/lv_example_flex_3.c | 2 +- examples/layouts/flex/lv_example_flex_4.c | 3 +- examples/layouts/flex/lv_example_flex_5.c | 4 +- examples/layouts/flex/lv_example_flex_6.c | 4 +- examples/layouts/grid/lv_example_grid_1.c | 4 +- examples/layouts/grid/lv_example_grid_2.c | 2 +- examples/layouts/grid/lv_example_grid_3.c | 4 +- examples/layouts/grid/lv_example_grid_4.c | 4 +- examples/layouts/grid/lv_example_grid_5.c | 4 +- examples/layouts/grid/lv_example_grid_6.c | 4 +- examples/scroll/lv_example_scroll_2.c | 4 +- examples/scroll/lv_example_scroll_3.c | 2 +- examples/styles/lv_example_style_1.c | 2 +- examples/styles/lv_example_style_11.c | 2 +- examples/styles/lv_example_style_2.c | 2 +- examples/styles/lv_example_style_3.c | 2 +- examples/styles/lv_example_style_4.c | 2 +- examples/styles/lv_example_style_7.c | 2 +- examples/styles/lv_example_style_8.c | 2 +- examples/styles/lv_example_style_9.c | 5 +- examples/widgets/arc/lv_example_arc_1.c | 2 +- examples/widgets/arc/lv_example_arc_2.c | 2 +- examples/widgets/bar/lv_example_bar_1.c | 2 +- examples/widgets/bar/lv_example_bar_2.c | 2 +- examples/widgets/bar/lv_example_bar_3.c | 2 +- examples/widgets/bar/lv_example_bar_4.c | 2 +- examples/widgets/bar/lv_example_bar_5.c | 4 +- examples/widgets/btn/lv_example_btn_1.c | 7 +- examples/widgets/btn/lv_example_btn_2.c | 4 +- examples/widgets/btn/lv_example_btn_3.c | 2 +- .../btnmatrix/lv_example_btnmatrix_1.c | 2 +- .../btnmatrix/lv_example_btnmatrix_2.c | 2 +- .../btnmatrix/lv_example_btnmatrix_3.c | 2 +- .../widgets/calendar/lv_example_calendar_1.c | 2 +- examples/widgets/canvas/lv_example_canvas_1.c | 2 +- examples/widgets/chart/lv_example_chart_1.c | 2 +- examples/widgets/chart/lv_example_chart_2.c | 2 +- examples/widgets/chart/lv_example_chart_3.c | 2 +- examples/widgets/chart/lv_example_chart_4.c | 2 +- examples/widgets/chart/lv_example_chart_5.c | 6 +- examples/widgets/chart/lv_example_chart_6.c | 4 +- .../colorwheel/lv_example_colorwheel_1.c | 2 +- .../widgets/dropdown/lv_example_dropdown_1.c | 2 +- .../widgets/dropdown/lv_example_dropdown_2.c | 8 +- .../widgets/dropdown/lv_example_dropdown_3.c | 2 +- examples/widgets/img/lv_example_img_1.c | 4 +- examples/widgets/img/lv_example_img_2.c | 10 +-- examples/widgets/img/lv_example_img_3.c | 2 +- examples/widgets/img/lv_example_img_4.c | 2 +- examples/widgets/imgbtn/lv_example_imgbtn_1.c | 4 +- .../widgets/keyboard/lv_example_keyboard_1.c | 4 +- examples/widgets/label/lv_example_label_1.c | 4 +- examples/widgets/label/lv_example_label_2.c | 4 +- examples/widgets/led/lv_example_led_1.c | 6 +- examples/widgets/line/lv_example_line_1.c | 2 +- examples/widgets/list/lv_example_list_1.c | 13 +-- examples/widgets/meter/lv_example_meter_1.c | 2 +- examples/widgets/meter/lv_example_meter_2.c | 2 +- examples/widgets/meter/lv_example_meter_3.c | 2 +- examples/widgets/meter/lv_example_meter_4.c | 2 +- examples/widgets/msgbox/lv_example_msgbox_1.c | 2 +- examples/widgets/obj/lv_example_obj_1.c | 4 +- examples/widgets/roller/lv_example_roller_1.c | 2 +- examples/widgets/roller/lv_example_roller_2.c | 6 +- examples/widgets/slider/lv_example_slider_1.c | 6 +- .../widgets/spinbox/lv_example_spinbox_1.c | 6 +- .../widgets/spinner/lv_example_spinner_1.c | 2 +- examples/widgets/table/lv_example_table_1.c | 2 +- examples/widgets/table/lv_example_table_2.c | 4 +- .../widgets/textarea/lv_example_textarea_1.c | 4 +- .../widgets/textarea/lv_example_textarea_2.c | 6 +- .../widgets/tileview/lv_example_tileview_1.c | 4 +- src/core/lv_obj.c | 8 +- src/core/lv_obj_pos.c | 81 +++++++++++++++---- src/core/lv_obj_pos.h | 13 ++- src/core/lv_obj_style_gen.h | 18 ++++- src/extra/themes/default/lv_theme_default.c | 10 +-- .../calendar/lv_calendar_header_arrow.c | 2 +- .../calendar/lv_calendar_header_dropdown.c | 2 +- src/extra/widgets/keyboard/lv_keyboard.c | 2 +- src/extra/widgets/msgbox/lv_msgbox.c | 2 +- src/extra/widgets/win/lv_win.c | 2 +- src/misc/lv_area.c | 16 ++-- src/misc/lv_area.h | 19 ++--- src/misc/lv_style.h | 4 +- src/misc/lv_style_gen.h | 11 ++- src/widgets/lv_dropdown.c | 8 +- 92 files changed, 271 insertions(+), 197 deletions(-) diff --git a/examples/get_started/lv_example_get_started_1.c b/examples/get_started/lv_example_get_started_1.c index 9b3134328..e519abc8f 100644 --- a/examples/get_started/lv_example_get_started_1.c +++ b/examples/get_started/lv_example_get_started_1.c @@ -10,7 +10,6 @@ static void btn_event_cb(lv_obj_t * btn, lv_event_t event) /*Get the first child of the button which is the label and change its text*/ lv_obj_t * label = lv_obj_get_child(btn, 0); lv_label_set_text_fmt(label, "Button: %d", cnt); - lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); } } @@ -26,7 +25,7 @@ void lv_example_get_started_1(void) 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); + lv_obj_center(label); } #endif diff --git a/examples/get_started/lv_example_get_started_2.c b/examples/get_started/lv_example_get_started_2.c index 6dc5d48f4..3131cf636 100644 --- a/examples/get_started/lv_example_get_started_2.c +++ b/examples/get_started/lv_example_get_started_2.c @@ -46,7 +46,7 @@ void lv_example_get_started_2(void) 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); + lv_obj_center(label); /*Create an other button and use the red style too*/ lv_obj_t * btn2 = lv_btn_create(lv_scr_act()); @@ -60,7 +60,7 @@ void lv_example_get_started_2(void) 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); + lv_obj_center(label); } #endif diff --git a/examples/get_started/lv_example_get_started_3.c b/examples/get_started/lv_example_get_started_3.c index 09827645f..791ae2f96 100644 --- a/examples/get_started/lv_example_get_started_3.c +++ b/examples/get_started/lv_example_get_started_3.c @@ -8,7 +8,7 @@ static void slider_event_cb(lv_obj_t * slider, lv_event_t event) if(event == LV_EVENT_VALUE_CHANGED) { /*Refresh the text*/ lv_label_set_text_fmt(label, "%d", lv_slider_get_value(slider)); - lv_obj_align(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align below the slider*/ + lv_obj_align_to(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align below the slider*/ } } @@ -19,14 +19,14 @@ 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()); - 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*/ + lv_obj_set_width(slider, 200); /*Set the width*/ + lv_obj_center(slider); /*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()); lv_label_set_text(label, "0"); - lv_obj_align(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align below the slider*/ + lv_obj_align_to(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align below the slider*/ } #endif diff --git a/examples/layouts/flex/lv_example_flex_1.c b/examples/layouts/flex/lv_example_flex_1.c index ede6e2b65..0181057ac 100644 --- a/examples/layouts/flex/lv_example_flex_1.c +++ b/examples/layouts/flex/lv_example_flex_1.c @@ -9,13 +9,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()); lv_obj_set_size(cont_row, 300, 75); - lv_obj_align(cont_row, NULL, LV_ALIGN_IN_TOP_MID, 0, 5); + lv_obj_align(cont_row, LV_ALIGN_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()); lv_obj_set_size(cont_col, 200, 150); - lv_obj_align(cont_col, cont_row, LV_ALIGN_OUT_BOTTOM_MID, 0, 5); + lv_obj_align_to(cont_col, cont_row, LV_ALIGN_OUT_BOTTOM_MID, 0, 5); lv_obj_set_flex_flow(cont_col, LV_FLEX_FLOW_COLUMN); uint32_t i; @@ -29,7 +29,7 @@ void lv_example_flex_1(void) label = lv_label_create(obj); lv_label_set_text_fmt(label, "Item: %d", i); - lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(label); /*Add items to the column*/ obj = lv_obj_create(cont_col); @@ -37,7 +37,7 @@ void lv_example_flex_1(void) label = lv_label_create(obj); lv_label_set_text_fmt(label, "Item: %d", i); - lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(label); } } diff --git a/examples/layouts/flex/lv_example_flex_2.c b/examples/layouts/flex/lv_example_flex_2.c index eeee83f4b..fd6b50286 100644 --- a/examples/layouts/flex/lv_example_flex_2.c +++ b/examples/layouts/flex/lv_example_flex_2.c @@ -14,7 +14,7 @@ void lv_example_flex_2(void) 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_center(cont); lv_obj_add_style(cont, LV_PART_MAIN, LV_STATE_DEFAULT, &style); uint32_t i; @@ -24,6 +24,7 @@ void lv_example_flex_2(void) lv_obj_t * label = lv_label_create(obj); lv_label_set_text_fmt(label, "%d", i); + lv_obj_center(label); } } diff --git a/examples/layouts/flex/lv_example_flex_3.c b/examples/layouts/flex/lv_example_flex_3.c index b56933aa5..b635d1ed9 100644 --- a/examples/layouts/flex/lv_example_flex_3.c +++ b/examples/layouts/flex/lv_example_flex_3.c @@ -8,7 +8,7 @@ void lv_example_flex_3(void) { 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_center(cont); lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW); lv_obj_t * obj; diff --git a/examples/layouts/flex/lv_example_flex_4.c b/examples/layouts/flex/lv_example_flex_4.c index e5b87fe97..614af733b 100644 --- a/examples/layouts/flex/lv_example_flex_4.c +++ b/examples/layouts/flex/lv_example_flex_4.c @@ -9,7 +9,7 @@ void lv_example_flex_4(void) 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_center(cont); lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_COLUMN_REVERSE); uint32_t i; @@ -19,6 +19,7 @@ void lv_example_flex_4(void) lv_obj_t * label = lv_label_create(obj); lv_label_set_text_fmt(label, "Item: %d", i); + lv_obj_center(label); } } diff --git a/examples/layouts/flex/lv_example_flex_5.c b/examples/layouts/flex/lv_example_flex_5.c index 2c61e2c2a..4ee717050 100644 --- a/examples/layouts/flex/lv_example_flex_5.c +++ b/examples/layouts/flex/lv_example_flex_5.c @@ -18,7 +18,7 @@ void lv_example_flex_5(void) { 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_center(cont); lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW_WRAP); uint32_t i; @@ -28,7 +28,7 @@ void lv_example_flex_5(void) 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); + lv_obj_center(label); } lv_anim_t a; diff --git a/examples/layouts/flex/lv_example_flex_6.c b/examples/layouts/flex/lv_example_flex_6.c index 1fd0b0ab1..187801db0 100644 --- a/examples/layouts/flex/lv_example_flex_6.c +++ b/examples/layouts/flex/lv_example_flex_6.c @@ -10,7 +10,7 @@ void lv_example_flex_6(void) 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); + lv_obj_center(cont); lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW_WRAP); uint32_t i; @@ -20,7 +20,7 @@ void lv_example_flex_6(void) 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); + lv_obj_center(label); } } #endif diff --git a/examples/layouts/grid/lv_example_grid_1.c b/examples/layouts/grid/lv_example_grid_1.c index fe4e5788e..c07c661b9 100644 --- a/examples/layouts/grid/lv_example_grid_1.c +++ b/examples/layouts/grid/lv_example_grid_1.c @@ -14,7 +14,7 @@ void lv_example_grid_1(void) 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); - lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(cont); lv_obj_set_layout(cont, LV_LAYOUT_GRID); lv_obj_t * label; @@ -33,7 +33,7 @@ void lv_example_grid_1(void) 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); + lv_obj_center(label); } } diff --git a/examples/layouts/grid/lv_example_grid_2.c b/examples/layouts/grid/lv_example_grid_2.c index 46f1c51f1..0c49d723c 100644 --- a/examples/layouts/grid/lv_example_grid_2.c +++ b/examples/layouts/grid/lv_example_grid_2.c @@ -14,7 +14,7 @@ void lv_example_grid_2(void) 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); + lv_obj_center(cont); lv_obj_t * label; lv_obj_t * obj; diff --git a/examples/layouts/grid/lv_example_grid_3.c b/examples/layouts/grid/lv_example_grid_3.c index 2c5fc370d..9019560f4 100644 --- a/examples/layouts/grid/lv_example_grid_3.c +++ b/examples/layouts/grid/lv_example_grid_3.c @@ -19,7 +19,7 @@ void lv_example_grid_3(void) /*Create a container with grid*/ 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_center(cont); lv_obj_set_grid_template(cont, col_dsc, row_dsc); lv_obj_t * label; @@ -37,7 +37,7 @@ void lv_example_grid_3(void) 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); + lv_obj_center(label); } } diff --git a/examples/layouts/grid/lv_example_grid_4.c b/examples/layouts/grid/lv_example_grid_4.c index 5532c1a9b..7ee648c3d 100644 --- a/examples/layouts/grid/lv_example_grid_4.c +++ b/examples/layouts/grid/lv_example_grid_4.c @@ -17,7 +17,7 @@ void lv_example_grid_4(void) 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); - lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(cont); lv_obj_t * label; lv_obj_t * obj; @@ -34,7 +34,7 @@ void lv_example_grid_4(void) 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); + lv_obj_center(label); } } diff --git a/examples/layouts/grid/lv_example_grid_5.c b/examples/layouts/grid/lv_example_grid_5.c index 642c0fada..11dbe11bc 100644 --- a/examples/layouts/grid/lv_example_grid_5.c +++ b/examples/layouts/grid/lv_example_grid_5.c @@ -24,7 +24,7 @@ void lv_example_grid_5(void) /*Create a container with grid*/ 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_center(cont); lv_obj_set_grid_template(cont, col_dsc, row_dsc); lv_obj_t * label; @@ -39,7 +39,7 @@ void lv_example_grid_5(void) LV_GRID_STRETCH, row, 1); 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); + lv_obj_center(label); } lv_anim_t a; diff --git a/examples/layouts/grid/lv_example_grid_6.c b/examples/layouts/grid/lv_example_grid_6.c index 2157aacf3..f73226b2d 100644 --- a/examples/layouts/grid/lv_example_grid_6.c +++ b/examples/layouts/grid/lv_example_grid_6.c @@ -13,7 +13,7 @@ void lv_example_grid_6(void) /*Create a container with grid*/ 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_center(cont); lv_obj_set_base_dir(cont, LV_BIDI_DIR_RTL); lv_obj_set_grid_template(cont, col_dsc, row_dsc); @@ -32,7 +32,7 @@ void lv_example_grid_6(void) 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); + lv_obj_center(label); } } diff --git a/examples/scroll/lv_example_scroll_2.c b/examples/scroll/lv_example_scroll_2.c index 7ae9eb40a..00ad1b6b4 100644 --- a/examples/scroll/lv_example_scroll_2.c +++ b/examples/scroll/lv_example_scroll_2.c @@ -42,11 +42,11 @@ 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()); - lv_obj_align(sw, NULL, LV_ALIGN_IN_TOP_RIGHT, -20, 10); + lv_obj_align(sw, LV_ALIGN_TOP_RIGHT, -20, 10); lv_obj_add_event_cb(sw, sw_event_cb, panel); 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); + lv_obj_align_to(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 79091dad5..7accf32ee 100644 --- a/examples/scroll/lv_example_scroll_3.c +++ b/examples/scroll/lv_example_scroll_3.c @@ -36,7 +36,7 @@ void lv_example_scroll_3(void) 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_align(float_btn, LV_ALIGN_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_bg_img_src(float_btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_PLUS); diff --git a/examples/styles/lv_example_style_1.c b/examples/styles/lv_example_style_1.c index f8ec9ba1f..77307de0f 100644 --- a/examples/styles/lv_example_style_1.c +++ b/examples/styles/lv_example_style_1.c @@ -23,7 +23,7 @@ void lv_example_style_1(void) /*Create an object with the new style*/ 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); + lv_obj_center(obj); } #endif diff --git a/examples/styles/lv_example_style_11.c b/examples/styles/lv_example_style_11.c index fa28e0e4f..35aefb933 100644 --- a/examples/styles/lv_example_style_11.c +++ b/examples/styles/lv_example_style_11.c @@ -16,7 +16,7 @@ void lv_example_style_11(void) /*Create an object with the new style*/ 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); + lv_obj_center(obj); } #endif diff --git a/examples/styles/lv_example_style_2.c b/examples/styles/lv_example_style_2.c index d1faa2c1e..57463c823 100644 --- a/examples/styles/lv_example_style_2.c +++ b/examples/styles/lv_example_style_2.c @@ -23,7 +23,7 @@ void lv_example_style_2(void) /*Create an object with the new style*/ 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); + lv_obj_center(obj); } #endif diff --git a/examples/styles/lv_example_style_3.c b/examples/styles/lv_example_style_3.c index f8e9fdd5b..f04bee2c3 100644 --- a/examples/styles/lv_example_style_3.c +++ b/examples/styles/lv_example_style_3.c @@ -22,7 +22,7 @@ void lv_example_style_3(void) /*Create an object with the new style*/ 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); + lv_obj_center(obj); } #endif diff --git a/examples/styles/lv_example_style_4.c b/examples/styles/lv_example_style_4.c index ca06afd29..2d7457e46 100644 --- a/examples/styles/lv_example_style_4.c +++ b/examples/styles/lv_example_style_4.c @@ -23,7 +23,7 @@ void lv_example_style_4(void) /*Create an object with the new style*/ 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); + lv_obj_center(obj); } #endif diff --git a/examples/styles/lv_example_style_7.c b/examples/styles/lv_example_style_7.c index ce09c30c2..78319c4fc 100644 --- a/examples/styles/lv_example_style_7.c +++ b/examples/styles/lv_example_style_7.c @@ -27,7 +27,7 @@ void lv_example_style_7(void) lv_label_set_text(obj, "Text of\n" "a label"); - lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(obj); } #endif diff --git a/examples/styles/lv_example_style_8.c b/examples/styles/lv_example_style_8.c index 9bff1e057..1843e4160 100644 --- a/examples/styles/lv_example_style_8.c +++ b/examples/styles/lv_example_style_8.c @@ -20,7 +20,7 @@ void lv_example_style_8(void) static lv_point_t p[] = {{10, 30}, {30, 50}, {100, 0}}; lv_line_set_points(obj, p, 3); - lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(obj); } #endif diff --git a/examples/styles/lv_example_style_9.c b/examples/styles/lv_example_style_9.c index 97a7c4573..2c6063a68 100644 --- a/examples/styles/lv_example_style_9.c +++ b/examples/styles/lv_example_style_9.c @@ -16,8 +16,6 @@ void lv_example_style_9(void) lv_style_set_border_width(&style, 2); lv_style_set_border_color(&style, lv_color_blue()); -// lv_style_set_pad_all(&style, 10); - lv_style_set_img_recolor(&style, lv_color_blue()); lv_style_set_img_recolor_opa(&style, LV_OPA_50); lv_style_set_transform_angle(&style, 300); @@ -28,9 +26,8 @@ void lv_example_style_9(void) LV_IMG_DECLARE(img_cogwheel_argb); lv_img_set_src(obj, &img_cogwheel_argb); - lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); -// lv_obj_set_width(obj, 200); + lv_obj_center(obj); } #endif diff --git a/examples/widgets/arc/lv_example_arc_1.c b/examples/widgets/arc/lv_example_arc_1.c index b9e0a3eb2..9250d0ab8 100644 --- a/examples/widgets/arc/lv_example_arc_1.c +++ b/examples/widgets/arc/lv_example_arc_1.c @@ -8,7 +8,7 @@ void lv_example_arc_1(void) 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); + lv_obj_center(arc); } #endif diff --git a/examples/widgets/arc/lv_example_arc_2.c b/examples/widgets/arc/lv_example_arc_2.c index 495716b05..3431419bc 100644 --- a/examples/widgets/arc/lv_example_arc_2.c +++ b/examples/widgets/arc/lv_example_arc_2.c @@ -29,7 +29,7 @@ void lv_example_arc_2(void) 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); + lv_obj_center(arc); /*Create an `lv_timer` to update the arc. *Store the `arc` in the user data*/ diff --git a/examples/widgets/bar/lv_example_bar_1.c b/examples/widgets/bar/lv_example_bar_1.c index b068282cc..9136d1284 100644 --- a/examples/widgets/bar/lv_example_bar_1.c +++ b/examples/widgets/bar/lv_example_bar_1.c @@ -5,7 +5,7 @@ void lv_example_bar_1(void) { 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_obj_center(bar1); 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 9aea3c878..f6daff111 100644 --- a/examples/widgets/bar/lv_example_bar_2.c +++ b/examples/widgets/bar/lv_example_bar_2.c @@ -27,7 +27,7 @@ void lv_example_bar_2(void) lv_obj_add_style(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, &style_indic); lv_obj_set_size(bar, 200, 20); - lv_obj_align(bar, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(bar); lv_bar_set_value(bar, 100, LV_ANIM_ON); } diff --git a/examples/widgets/bar/lv_example_bar_3.c b/examples/widgets/bar/lv_example_bar_3.c index ecd2fb4d5..6495aeb74 100644 --- a/examples/widgets/bar/lv_example_bar_3.c +++ b/examples/widgets/bar/lv_example_bar_3.c @@ -29,7 +29,7 @@ void lv_example_bar_3(void) 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); + lv_obj_center(bar); lv_bar_set_range(bar, -20, 40); lv_anim_t a; diff --git a/examples/widgets/bar/lv_example_bar_4.c b/examples/widgets/bar/lv_example_bar_4.c index 4b7288799..b6342fd4b 100644 --- a/examples/widgets/bar/lv_example_bar_4.c +++ b/examples/widgets/bar/lv_example_bar_4.c @@ -18,7 +18,7 @@ void lv_example_bar_4(void) lv_obj_add_style(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, &style_indic); lv_obj_set_size(bar, 260, 20); - lv_obj_align(bar, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(bar); lv_bar_set_mode(bar, LV_BAR_MODE_RANGE); lv_bar_set_value(bar, 90, LV_ANIM_OFF); lv_bar_set_start_value(bar, 20, LV_ANIM_OFF); diff --git a/examples/widgets/bar/lv_example_bar_5.c b/examples/widgets/bar/lv_example_bar_5.c index 5ae92f639..c2f888d5b 100644 --- a/examples/widgets/bar/lv_example_bar_5.c +++ b/examples/widgets/bar/lv_example_bar_5.c @@ -9,7 +9,7 @@ void lv_example_bar_5(void) 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_align(bar_ltr, 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"); @@ -17,7 +17,7 @@ void lv_example_bar_5(void) 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_align(bar_rtl, 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"); } diff --git a/examples/widgets/btn/lv_example_btn_1.c b/examples/widgets/btn/lv_example_btn_1.c index b2e8f9134..6b68c47ac 100644 --- a/examples/widgets/btn/lv_example_btn_1.c +++ b/examples/widgets/btn/lv_example_btn_1.c @@ -15,10 +15,10 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) void lv_example_btn_1(void) { lv_obj_t * 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_align(btn1, LV_ALIGN_CENTER, 0, -40); label = lv_label_create(btn1); lv_label_set_text(label, "Button"); @@ -26,11 +26,12 @@ void lv_example_btn_1(void) 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_center(btn2); lv_obj_add_flag(btn2, LV_OBJ_FLAG_CHECKABLE); lv_obj_set_height(btn2, LV_SIZE_CONTENT); label = lv_label_create(btn2); lv_label_set_text(label, "Toggle"); + lv_obj_center(label); } #endif diff --git a/examples/widgets/btn/lv_example_btn_2.c b/examples/widgets/btn/lv_example_btn_2.c index 4dd61cc0b..e8adb7fcc 100644 --- a/examples/widgets/btn/lv_example_btn_2.c +++ b/examples/widgets/btn/lv_example_btn_2.c @@ -41,11 +41,11 @@ void lv_example_btn_2(void) 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_center(btn1); lv_obj_t * label = lv_label_create(btn1); lv_label_set_text(label, "Button"); - lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(label); } #endif diff --git a/examples/widgets/btn/lv_example_btn_3.c b/examples/widgets/btn/lv_example_btn_3.c index aefb87818..15b7bb0da 100644 --- a/examples/widgets/btn/lv_example_btn_3.c +++ b/examples/widgets/btn/lv_example_btn_3.c @@ -46,7 +46,7 @@ void lv_example_btn_3(void) lv_style_set_transition(&style_pr, &transition_dsc_pr); lv_obj_t * btn1 = lv_btn_create(lv_scr_act()); - lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, -80); + lv_obj_align(btn1, 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); diff --git a/examples/widgets/btnmatrix/lv_example_btnmatrix_1.c b/examples/widgets/btnmatrix/lv_example_btnmatrix_1.c index 85306832a..87f7410a3 100644 --- a/examples/widgets/btnmatrix/lv_example_btnmatrix_1.c +++ b/examples/widgets/btnmatrix/lv_example_btnmatrix_1.c @@ -23,7 +23,7 @@ void lv_example_btnmatrix_1(void) 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); lv_btnmatrix_set_btn_ctrl(btnm1, 11, LV_BTNMATRIX_CTRL_CHECKED); - lv_obj_align(btnm1, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(btnm1, LV_ALIGN_CENTER, 0, 0); lv_obj_add_event_cb(btnm1, event_handler, NULL); } diff --git a/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c b/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c index 56d9cc62b..33e677f87 100644 --- a/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c +++ b/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c @@ -64,7 +64,7 @@ void lv_example_btnmatrix_2(void) { 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); + lv_obj_center(btnm); } #endif diff --git a/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c b/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c index f3d1417fc..759e1f705 100644 --- a/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c +++ b/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c @@ -62,7 +62,7 @@ void lv_example_btnmatrix_3(void) lv_btnmatrix_set_one_checked(btnm, true); lv_btnmatrix_set_btn_ctrl(btnm, 1, LV_BTNMATRIX_CTRL_CHECKED); - lv_obj_align(btnm, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(btnm); } diff --git a/examples/widgets/calendar/lv_example_calendar_1.c b/examples/widgets/calendar/lv_example_calendar_1.c index 0fcc43a6f..bc9828e14 100644 --- a/examples/widgets/calendar/lv_example_calendar_1.c +++ b/examples/widgets/calendar/lv_example_calendar_1.c @@ -15,7 +15,7 @@ void lv_example_calendar_1(void) { lv_obj_t * calendar = lv_calendar_create(lv_scr_act()); lv_obj_set_size(calendar, 200, 200); - lv_obj_align(calendar, NULL, LV_ALIGN_CENTER, 0, 20); + lv_obj_align(calendar, LV_ALIGN_CENTER, 0, 20); lv_obj_add_event_cb(calendar, event_handler, NULL); lv_calendar_set_today_date(calendar, 2021, 02, 23); diff --git a/examples/widgets/canvas/lv_example_canvas_1.c b/examples/widgets/canvas/lv_example_canvas_1.c index cfc39c20d..6ab074405 100644 --- a/examples/widgets/canvas/lv_example_canvas_1.c +++ b/examples/widgets/canvas/lv_example_canvas_1.c @@ -29,7 +29,7 @@ void lv_example_canvas_1(void) 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_obj_center(canvas); lv_canvas_fill_bg(canvas, lv_color_grey_lighten_3(), LV_OPA_COVER); lv_canvas_draw_rect(canvas, 70, 60, 100, 70, &rect_dsc); diff --git a/examples/widgets/chart/lv_example_chart_1.c b/examples/widgets/chart/lv_example_chart_1.c index cb7e03f36..6425780df 100644 --- a/examples/widgets/chart/lv_example_chart_1.c +++ b/examples/widgets/chart/lv_example_chart_1.c @@ -7,7 +7,7 @@ void lv_example_chart_1(void) lv_obj_t * chart; 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_obj_center(chart); lv_chart_set_type(chart, LV_CHART_TYPE_LINE); /*Show lines and points too*/ /*Add two data series*/ diff --git a/examples/widgets/chart/lv_example_chart_2.c b/examples/widgets/chart/lv_example_chart_2.c index 4aa742d2b..bc9307bc4 100644 --- a/examples/widgets/chart/lv_example_chart_2.c +++ b/examples/widgets/chart/lv_example_chart_2.c @@ -62,7 +62,7 @@ void lv_example_chart_2(void) /*Create a chart1*/ 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_obj_center(chart1); lv_chart_set_type(chart1, LV_CHART_TYPE_LINE); /*Show lines and points too*/ lv_obj_add_event_cb(chart1, event_cb, NULL); diff --git a/examples/widgets/chart/lv_example_chart_3.c b/examples/widgets/chart/lv_example_chart_3.c index b255dc01f..6096d9909 100644 --- a/examples/widgets/chart/lv_example_chart_3.c +++ b/examples/widgets/chart/lv_example_chart_3.c @@ -22,7 +22,7 @@ void lv_example_chart_3(void) lv_obj_t * chart; 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_obj_center(chart); lv_chart_set_type(chart, LV_CHART_TYPE_BAR); lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_Y, 0, 100); lv_chart_set_range(chart, LV_CHART_AXIS_SECONDARY_Y, 0, 400); diff --git a/examples/widgets/chart/lv_example_chart_4.c b/examples/widgets/chart/lv_example_chart_4.c index 36d9af4ca..d2cc0ab05 100644 --- a/examples/widgets/chart/lv_example_chart_4.c +++ b/examples/widgets/chart/lv_example_chart_4.c @@ -59,7 +59,7 @@ void lv_example_chart_4(void) lv_obj_t * chart; 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_obj_center(chart); lv_obj_add_event_cb(chart, event_cb, NULL); lv_obj_refresh_ext_draw_size(chart); diff --git a/examples/widgets/chart/lv_example_chart_5.c b/examples/widgets/chart/lv_example_chart_5.c index a30e214af..bfb37e167 100644 --- a/examples/widgets/chart/lv_example_chart_5.c +++ b/examples/widgets/chart/lv_example_chart_5.c @@ -71,7 +71,7 @@ void lv_example_chart_5(void) /*Create a chart*/ 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_obj_align(chart, LV_ALIGN_CENTER, -30, -30); lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_Y, -1000, 1000); /*Do not display points on the data*/ @@ -88,13 +88,13 @@ void lv_example_chart_5(void) 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); + lv_obj_align_to(slider, chart, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); 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)); - lv_obj_align(slider, chart, LV_ALIGN_OUT_RIGHT_MID, 20, 0); + lv_obj_align_to(slider, chart, LV_ALIGN_OUT_RIGHT_MID, 20, 0); } #endif diff --git a/examples/widgets/chart/lv_example_chart_6.c b/examples/widgets/chart/lv_example_chart_6.c index d7a2190c4..429c4838d 100644 --- a/examples/widgets/chart/lv_example_chart_6.c +++ b/examples/widgets/chart/lv_example_chart_6.c @@ -59,7 +59,7 @@ void lv_example_chart_6(void) { chart = lv_chart_create(lv_scr_act()); lv_obj_set_size(chart, 200, 150); - lv_obj_align(chart, NULL, LV_ALIGN_CENTER, 0, -10); + lv_obj_align(chart, LV_ALIGN_CENTER, 0, -10); lv_chart_set_axis_tick(chart, LV_CHART_AXIS_PRIMARY_Y, 10, 5, 6, 5, true, 40); lv_chart_set_axis_tick(chart, LV_CHART_AXIS_X, 10, 5, 10, 1, true, 30); @@ -79,7 +79,7 @@ void lv_example_chart_6(void) 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); + lv_obj_align_to(label, chart, LV_ALIGN_OUT_TOP_MID, 0, -5); } diff --git a/examples/widgets/colorwheel/lv_example_colorwheel_1.c b/examples/widgets/colorwheel/lv_example_colorwheel_1.c index 5b098cc6a..66e3b5229 100644 --- a/examples/widgets/colorwheel/lv_example_colorwheel_1.c +++ b/examples/widgets/colorwheel/lv_example_colorwheel_1.c @@ -7,7 +7,7 @@ void lv_example_colorwheel_1(void) cw = lv_colorwheel_create(lv_scr_act(), true); lv_obj_set_size(cw, 200, 200); - lv_obj_align(cw, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(cw); } #endif diff --git a/examples/widgets/dropdown/lv_example_dropdown_1.c b/examples/widgets/dropdown/lv_example_dropdown_1.c index f27c8f7dd..a6b97a3aa 100644 --- a/examples/widgets/dropdown/lv_example_dropdown_1.c +++ b/examples/widgets/dropdown/lv_example_dropdown_1.c @@ -28,7 +28,7 @@ void lv_example_dropdown_1(void) "Lemon\n" "Nuts"); - lv_obj_align(dd, NULL, LV_ALIGN_IN_TOP_MID, 0, 20); + lv_obj_align(dd, LV_ALIGN_TOP_MID, 0, 20); lv_obj_add_event_cb(dd, event_handler, NULL); } diff --git a/examples/widgets/dropdown/lv_example_dropdown_2.c b/examples/widgets/dropdown/lv_example_dropdown_2.c index 5bed4dbce..1ff4db290 100644 --- a/examples/widgets/dropdown/lv_example_dropdown_2.c +++ b/examples/widgets/dropdown/lv_example_dropdown_2.c @@ -17,25 +17,25 @@ void lv_example_dropdown_2(void) lv_obj_t * dd; 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); + lv_obj_align(dd, LV_ALIGN_TOP_MID, 0, 10); 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); + lv_obj_align(dd, LV_ALIGN_BOTTOM_MID, 0, -10); 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); + lv_obj_align(dd, LV_ALIGN_LEFT_MID, 10, 0); 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); - lv_obj_align(dd, NULL, LV_ALIGN_IN_RIGHT_MID, -10, 0); + lv_obj_align(dd, LV_ALIGN_RIGHT_MID, -10, 0); } #endif diff --git a/examples/widgets/dropdown/lv_example_dropdown_3.c b/examples/widgets/dropdown/lv_example_dropdown_3.c index 663813160..0a151db74 100644 --- a/examples/widgets/dropdown/lv_example_dropdown_3.c +++ b/examples/widgets/dropdown/lv_example_dropdown_3.c @@ -17,7 +17,7 @@ void lv_example_dropdown_3(void) { /*Create a drop down list*/ lv_obj_t * dropdown = lv_dropdown_create(lv_scr_act()); - lv_obj_align(dropdown, NULL, LV_ALIGN_IN_TOP_LEFT, 10, 10); + lv_obj_align(dropdown, LV_ALIGN_TOP_LEFT, 10, 10); lv_dropdown_set_options(dropdown, "New project\n" "New file\n" "Open project\n" diff --git a/examples/widgets/img/lv_example_img_1.c b/examples/widgets/img/lv_example_img_1.c index d3dab4f54..854fb3b89 100644 --- a/examples/widgets/img/lv_example_img_1.c +++ b/examples/widgets/img/lv_example_img_1.c @@ -7,12 +7,12 @@ void lv_example_img_1(void) LV_IMG_DECLARE(img_cogwheel_argb); 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_align(img1, LV_ALIGN_CENTER, 0, -20); lv_obj_set_size(img1, 200, 200); 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); + lv_obj_align_to(img2, img1, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); } #endif diff --git a/examples/widgets/img/lv_example_img_2.c b/examples/widgets/img/lv_example_img_2.c index 5350f719f..f637448f2 100644 --- a/examples/widgets/img/lv_example_img_2.c +++ b/examples/widgets/img/lv_example_img_2.c @@ -24,16 +24,16 @@ void lv_example_img_2(void) lv_slider_set_value(blue_slider, LV_OPA_60, LV_ANIM_OFF); lv_slider_set_value(intense_slider, LV_OPA_50, LV_ANIM_OFF); - lv_obj_align(red_slider, NULL, LV_ALIGN_IN_LEFT_MID, 25, 0); - lv_obj_align(green_slider, red_slider, LV_ALIGN_OUT_RIGHT_MID, 25, 0); - lv_obj_align(blue_slider, green_slider, LV_ALIGN_OUT_RIGHT_MID, 25, 0); - lv_obj_align(intense_slider, blue_slider, LV_ALIGN_OUT_RIGHT_MID, 25, 0); + lv_obj_align(red_slider, LV_ALIGN_LEFT_MID, 25, 0); + lv_obj_align_to(green_slider, red_slider, LV_ALIGN_OUT_RIGHT_MID, 25, 0); + lv_obj_align_to(blue_slider, green_slider, LV_ALIGN_OUT_RIGHT_MID, 25, 0); + lv_obj_align_to(intense_slider, blue_slider, LV_ALIGN_OUT_RIGHT_MID, 25, 0); /*Now create the actual image*/ LV_IMG_DECLARE(img_cogwheel_argb) 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); + lv_obj_align(img1, LV_ALIGN_RIGHT_MID, -20, 0); lv_event_send(intense_slider, LV_EVENT_VALUE_CHANGED, NULL); } diff --git a/examples/widgets/img/lv_example_img_3.c b/examples/widgets/img/lv_example_img_3.c index 21989ef33..1309bf99e 100644 --- a/examples/widgets/img/lv_example_img_3.c +++ b/examples/widgets/img/lv_example_img_3.c @@ -22,7 +22,7 @@ void lv_example_img_3(void) /*Now create the actual image*/ 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_obj_align(img, LV_ALIGN_CENTER, 50, 50); lv_img_set_pivot(img, 0, 0); /*Rotate around the top left corner*/ lv_anim_t a; diff --git a/examples/widgets/img/lv_example_img_4.c b/examples/widgets/img/lv_example_img_4.c index a6f525f5c..097d02d37 100644 --- a/examples/widgets/img/lv_example_img_4.c +++ b/examples/widgets/img/lv_example_img_4.c @@ -24,7 +24,7 @@ void lv_example_img_4(void) 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); - lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(img); lv_anim_t a; lv_anim_init(&a); diff --git a/examples/widgets/imgbtn/lv_example_imgbtn_1.c b/examples/widgets/imgbtn/lv_example_imgbtn_1.c index d18ffbd85..433d43e20 100644 --- a/examples/widgets/imgbtn/lv_example_imgbtn_1.c +++ b/examples/widgets/imgbtn/lv_example_imgbtn_1.c @@ -30,12 +30,12 @@ void lv_example_imgbtn_1(void) lv_obj_add_style(imgbtn1, LV_PART_MAIN, LV_STATE_DEFAULT, &style_def); lv_obj_add_style(imgbtn1, LV_PART_MAIN, LV_STATE_PRESSED, &style_pr); - lv_obj_align(imgbtn1, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(imgbtn1, LV_ALIGN_CENTER, 0, 0); /*Create a label on the image button*/ lv_obj_t * label = lv_label_create(imgbtn1); lv_label_set_text(label, "Button"); - lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, -4); + lv_obj_align(label, LV_ALIGN_CENTER, 0, -4); } #endif diff --git a/examples/widgets/keyboard/lv_example_keyboard_1.c b/examples/widgets/keyboard/lv_example_keyboard_1.c index d20460de4..55a17003f 100644 --- a/examples/widgets/keyboard/lv_example_keyboard_1.c +++ b/examples/widgets/keyboard/lv_example_keyboard_1.c @@ -23,12 +23,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()); - lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_LEFT, 10, 10); + lv_obj_align(ta, LV_ALIGN_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()); - lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_RIGHT, -10, 10); + lv_obj_align(ta, LV_ALIGN_TOP_RIGHT, -10, 10); lv_obj_add_event_cb(ta, ta_event_cb, kb); lv_keyboard_set_textarea(kb, ta); diff --git a/examples/widgets/label/lv_example_label_1.c b/examples/widgets/label/lv_example_label_1.c index 344e45a51..c190550d1 100644 --- a/examples/widgets/label/lv_example_label_1.c +++ b/examples/widgets/label/lv_example_label_1.c @@ -13,14 +13,14 @@ void lv_example_label_1(void) "and wrap long text automatically."); lv_obj_set_width(label1, 150); /*Set smaller width to make the lines wrap*/ lv_obj_set_style_text_align(label1, LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_CENTER); - lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, -40); + lv_obj_align(label1, LV_ALIGN_CENTER, 0, -40); 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. "); - lv_obj_align(label2, NULL, LV_ALIGN_CENTER, 0, 40); + lv_obj_align(label2, LV_ALIGN_CENTER, 0, 40); } #endif diff --git a/examples/widgets/label/lv_example_label_2.c b/examples/widgets/label/lv_example_label_2.c index 05ad9667f..faf49f0e4 100644 --- a/examples/widgets/label/lv_example_label_2.c +++ b/examples/widgets/label/lv_example_label_2.c @@ -27,10 +27,10 @@ void lv_example_label_2(void) lv_label_set_text(shadow_label, lv_label_get_text(main_label)); /*Position the main label*/ - lv_obj_align(main_label, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(main_label, LV_ALIGN_CENTER, 0, 0); /*Shift the second label down and to the right by 2 pixel*/ - lv_obj_align(shadow_label, main_label, LV_ALIGN_IN_TOP_LEFT, 2, 2); + lv_obj_align_to(shadow_label, main_label, LV_ALIGN_TOP_LEFT, 2, 2); } #endif diff --git a/examples/widgets/led/lv_example_led_1.c b/examples/widgets/led/lv_example_led_1.c index 2feece3c5..b1d5d52b1 100644 --- a/examples/widgets/led/lv_example_led_1.c +++ b/examples/widgets/led/lv_example_led_1.c @@ -8,18 +8,18 @@ void lv_example_led_1(void) { /*Create a LED and switch it OFF*/ lv_obj_t * led1 = lv_led_create(lv_scr_act()); - lv_obj_align(led1, NULL, LV_ALIGN_CENTER, -80, 0); + lv_obj_align(led1, LV_ALIGN_CENTER, -80, 0); lv_led_off(led1); /*Copy the previous LED and set a brightness*/ lv_obj_t * led2 = lv_led_create(lv_scr_act()); - lv_obj_align(led2, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(led2, LV_ALIGN_CENTER, 0, 0); lv_led_set_brightness(led2, 150); lv_led_set_color(led2, lv_color_red()); /*Copy the previous LED and switch it ON*/ lv_obj_t * led3 = lv_led_create(lv_scr_act()); - lv_obj_align(led3, NULL, LV_ALIGN_CENTER, 80, 0); + lv_obj_align(led3, LV_ALIGN_CENTER, 80, 0); lv_led_on(led3); } diff --git a/examples/widgets/line/lv_example_line_1.c b/examples/widgets/line/lv_example_line_1.c index d05be5dee..0d3dce854 100644 --- a/examples/widgets/line/lv_example_line_1.c +++ b/examples/widgets/line/lv_example_line_1.c @@ -18,7 +18,7 @@ void lv_example_line_1(void) 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); + lv_obj_center(line1); } #endif diff --git a/examples/widgets/list/lv_example_list_1.c b/examples/widgets/list/lv_example_list_1.c index 5ea9d0aeb..b51b90d97 100644 --- a/examples/widgets/list/lv_example_list_1.c +++ b/examples/widgets/list/lv_example_list_1.c @@ -13,19 +13,8 @@ void lv_example_list_1(void) /*Create a list*/ list1 = lv_list_create(lv_scr_act()); lv_obj_set_size(list1, 180, 220); - lv_obj_align(list1, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(list1); - - uint32_t t = lv_tick_get(); - int i; - for(i = 0; i < 3; i++) { -// lv_btn_create(lv_scr_act()); - lv_list_add_btn(list1, LV_SYMBOL_FILE, "New", event_handler); - } - - printf("%d\n", t); - - return; /*Add buttons to the list*/ lv_list_add_text(list1, "File"); 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 47c2d7d4a..ccd1e3d5d 100644 --- a/examples/widgets/meter/lv_example_meter_1.c +++ b/examples/widgets/meter/lv_example_meter_1.c @@ -14,7 +14,7 @@ static void set_value(void * indic, int32_t v) void lv_example_meter_1(void) { meter = lv_meter_create(lv_scr_act()); - lv_obj_align(meter, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(meter); /*Add a scale first*/ lv_meter_scale_t * scale = lv_meter_add_scale(meter); diff --git a/examples/widgets/meter/lv_example_meter_2.c b/examples/widgets/meter/lv_example_meter_2.c index b863e7cda..21684af6a 100644 --- a/examples/widgets/meter/lv_example_meter_2.c +++ b/examples/widgets/meter/lv_example_meter_2.c @@ -15,7 +15,7 @@ static void set_value(void * indic, int32_t v) void lv_example_meter_2(void) { meter = lv_meter_create(lv_scr_act()); - lv_obj_align(meter, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(meter); /*Remove the circle from the middle*/ lv_obj_remove_style(meter, LV_PART_INDICATOR, LV_STATE_ANY, NULL); diff --git a/examples/widgets/meter/lv_example_meter_3.c b/examples/widgets/meter/lv_example_meter_3.c index 2cd04587f..9f3ec20d5 100644 --- a/examples/widgets/meter/lv_example_meter_3.c +++ b/examples/widgets/meter/lv_example_meter_3.c @@ -15,7 +15,7 @@ static void set_value(void * indic, int32_t v) void lv_example_meter_3(void) { meter = lv_meter_create(lv_scr_act()); - lv_obj_align(meter, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(meter); /*Create a scale for the minutes*/ /*61 ticks in a 360 degrees range (the last and the first line overlaps)*/ diff --git a/examples/widgets/meter/lv_example_meter_4.c b/examples/widgets/meter/lv_example_meter_4.c index b88a7b806..e19a885e9 100644 --- a/examples/widgets/meter/lv_example_meter_4.c +++ b/examples/widgets/meter/lv_example_meter_4.c @@ -7,7 +7,7 @@ void lv_example_meter_4(void) { lv_obj_t * meter = lv_meter_create(lv_scr_act()); - lv_obj_align(meter, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(meter); /*Remove the background and the circle from the middle*/ lv_obj_remove_style(meter, LV_PART_MAIN, LV_STATE_ANY, NULL); diff --git a/examples/widgets/msgbox/lv_example_msgbox_1.c b/examples/widgets/msgbox/lv_example_msgbox_1.c index b3518026b..7a398bffa 100644 --- a/examples/widgets/msgbox/lv_example_msgbox_1.c +++ b/examples/widgets/msgbox/lv_example_msgbox_1.c @@ -14,7 +14,7 @@ void lv_example_msgbox_1(void) lv_obj_t * mbox1 = lv_msgbox_create("Hello", "This is a message box with two buttons.", btns, true); lv_obj_add_event_cb(mbox1, event_cb, NULL); - lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); /*Align to the corner*/ + lv_obj_center(mbox1); } #endif diff --git a/examples/widgets/obj/lv_example_obj_1.c b/examples/widgets/obj/lv_example_obj_1.c index 1ac4452ff..f03dd9c66 100644 --- a/examples/widgets/obj/lv_example_obj_1.c +++ b/examples/widgets/obj/lv_example_obj_1.c @@ -6,7 +6,7 @@ void lv_example_obj_1(void) lv_obj_t * obj1; obj1 = lv_obj_create(lv_scr_act()); lv_obj_set_size(obj1, 100, 50); - lv_obj_align(obj1, NULL, LV_ALIGN_CENTER, -60, -30); + lv_obj_align(obj1, LV_ALIGN_CENTER, -60, -30); static lv_style_t style_shadow; lv_style_init(&style_shadow); @@ -17,6 +17,6 @@ void lv_example_obj_1(void) lv_obj_t * obj3; 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); + lv_obj_align(obj3, LV_ALIGN_CENTER, 60, 30); } #endif diff --git a/examples/widgets/roller/lv_example_roller_1.c b/examples/widgets/roller/lv_example_roller_1.c index bf64835eb..31ba39eeb 100644 --- a/examples/widgets/roller/lv_example_roller_1.c +++ b/examples/widgets/roller/lv_example_roller_1.c @@ -32,7 +32,7 @@ void lv_example_roller_1(void) LV_ROLLER_MODE_INFINITE); lv_roller_set_visible_row_count(roller1, 4); - lv_obj_align(roller1, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(roller1); lv_obj_add_event_cb(roller1, event_handler, NULL); } diff --git a/examples/widgets/roller/lv_example_roller_2.c b/examples/widgets/roller/lv_example_roller_2.c index f8d78873a..2c8a47741 100644 --- a/examples/widgets/roller/lv_example_roller_2.c +++ b/examples/widgets/roller/lv_example_roller_2.c @@ -30,7 +30,7 @@ void lv_example_roller_2(void) lv_obj_set_width(roller, 100); lv_obj_add_style(roller, LV_PART_SELECTED, LV_STATE_DEFAULT, &style_sel); lv_obj_set_style_text_align(roller, LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_LEFT); - lv_obj_align(roller, NULL, LV_ALIGN_IN_LEFT_MID, 10, 0); + lv_obj_align(roller, LV_ALIGN_LEFT_MID, 10, 0); lv_obj_add_event_cb(roller, event_handler, NULL); lv_roller_set_selected(roller, 2, LV_ANIM_OFF); @@ -39,7 +39,7 @@ void lv_example_roller_2(void) 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); - lv_obj_align(roller, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(roller, LV_ALIGN_CENTER, 0, 0); lv_obj_add_event_cb(roller, event_handler, NULL); lv_roller_set_selected(roller, 5, LV_ANIM_OFF); @@ -50,7 +50,7 @@ void lv_example_roller_2(void) lv_obj_set_width(roller, 80); lv_obj_add_style(roller, LV_PART_SELECTED, LV_STATE_DEFAULT, &style_sel); lv_obj_set_style_text_align(roller, LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_RIGHT); - lv_obj_align(roller, NULL, LV_ALIGN_IN_RIGHT_MID, -10, 0); + lv_obj_align(roller, LV_ALIGN_RIGHT_MID, -10, 0); lv_obj_add_event_cb(roller, event_handler, NULL); lv_roller_set_selected(roller, 8, LV_ANIM_OFF); } diff --git a/examples/widgets/slider/lv_example_slider_1.c b/examples/widgets/slider/lv_example_slider_1.c index c53ae8ee8..e0ccc8870 100644 --- a/examples/widgets/slider/lv_example_slider_1.c +++ b/examples/widgets/slider/lv_example_slider_1.c @@ -11,14 +11,14 @@ 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()); - lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(slider); lv_obj_add_event_cb(slider, slider_event_cb, NULL); /*Create a label below the slider*/ 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); + lv_obj_align_to(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); } static void slider_event_cb(lv_obj_t * slider, lv_event_t event) @@ -27,7 +27,7 @@ static void slider_event_cb(lv_obj_t * slider, lv_event_t event) char buf[8]; lv_snprintf(buf, sizeof(buf), "%d%%", lv_slider_get_value(slider)); lv_label_set_text(slider_label, buf); - lv_obj_align(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); + lv_obj_align_to(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); } } diff --git a/examples/widgets/spinbox/lv_example_spinbox_1.c b/examples/widgets/spinbox/lv_example_spinbox_1.c index 7057d04c5..7ec808e14 100644 --- a/examples/widgets/spinbox/lv_example_spinbox_1.c +++ b/examples/widgets/spinbox/lv_example_spinbox_1.c @@ -28,19 +28,19 @@ void lv_example_spinbox_1(void) lv_spinbox_set_digit_format(spinbox, 5, 2); lv_spinbox_step_prev(spinbox); lv_obj_set_width(spinbox, 100); - lv_obj_align(spinbox, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(spinbox); lv_coord_t h = lv_obj_get_height(spinbox); 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_align_to(btn, spinbox, LV_ALIGN_OUT_RIGHT_MID, 5, 0); 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()); lv_obj_set_size(btn, h, h); - lv_obj_align(btn, spinbox, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align_to(btn, spinbox, LV_ALIGN_OUT_LEFT_MID, -5, 0); 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/spinner/lv_example_spinner_1.c b/examples/widgets/spinner/lv_example_spinner_1.c index 43af3cdc5..fd47b4edb 100644 --- a/examples/widgets/spinner/lv_example_spinner_1.c +++ b/examples/widgets/spinner/lv_example_spinner_1.c @@ -6,7 +6,7 @@ void lv_example_spinner_1(void) /*Create a spinner*/ lv_obj_t * spinner = lv_spinner_create(lv_scr_act(), 1000, 60); lv_obj_set_size(spinner, 100, 100); - lv_obj_align(spinner, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(spinner); } #endif diff --git a/examples/widgets/table/lv_example_table_1.c b/examples/widgets/table/lv_example_table_1.c index ae524f4b3..7ecd188c7 100644 --- a/examples/widgets/table/lv_example_table_1.c +++ b/examples/widgets/table/lv_example_table_1.c @@ -57,7 +57,7 @@ void lv_example_table_1(void) /*Set a smaller height to the table. It'll make it scrollable*/ lv_obj_set_height(table, 200); - lv_obj_align(table, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(table); /*Add an event callback to to apply some custom drawing*/ lv_obj_add_event_cb(table, event_cb, NULL); diff --git a/examples/widgets/table/lv_example_table_2.c b/examples/widgets/table/lv_example_table_2.c index 6b4b428d6..364aa04fb 100644 --- a/examples/widgets/table/lv_example_table_2.c +++ b/examples/widgets/table/lv_example_table_2.c @@ -75,7 +75,7 @@ void lv_example_table_2(void) lv_table_set_cell_value_fmt(table, i, 0, "Item %d", i + 1); } - lv_obj_align(table, NULL, LV_ALIGN_CENTER, 0, -20); + lv_obj_align(table, LV_ALIGN_CENTER, 0, -20); /*Add an event callback to to apply some custom drawing*/ lv_obj_add_event_cb(table, event_cb, NULL); @@ -92,7 +92,7 @@ void lv_example_table_2(void) "and %d items were added in %d ms", mem_used, ITEM_CNT, elaps); - lv_obj_align(label, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -10); + lv_obj_align(label, LV_ALIGN_BOTTOM_MID, 0, -10); } diff --git a/examples/widgets/textarea/lv_example_textarea_1.c b/examples/widgets/textarea/lv_example_textarea_1.c index 384246364..f3889513b 100644 --- a/examples/widgets/textarea/lv_example_textarea_1.c +++ b/examples/widgets/textarea/lv_example_textarea_1.c @@ -19,7 +19,7 @@ void lv_example_textarea_1(void) { 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_align(ta, LV_ALIGN_TOP_MID, 0, 10); lv_obj_add_state(ta, LV_STATE_FOCUSED); /*To be sure the cursor is visible*/ static const char * btnm_map[] = {"1", "2", "3", "\n", @@ -29,7 +29,7 @@ void lv_example_textarea_1(void) 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_align(btnm, LV_ALIGN_BOTTOM_MID, 0, -10); lv_obj_add_event_cb(btnm, btnm_event_handler, ta); lv_obj_clear_flag(btnm, LV_OBJ_FLAG_CLICK_FOCUSABLE); /*To keep the text area focused on button clicks*/ lv_btnmatrix_set_map(btnm, btnm_map); diff --git a/examples/widgets/textarea/lv_example_textarea_2.c b/examples/widgets/textarea/lv_example_textarea_2.c index 376f9db85..eae754bb3 100644 --- a/examples/widgets/textarea/lv_example_textarea_2.c +++ b/examples/widgets/textarea/lv_example_textarea_2.c @@ -19,18 +19,18 @@ void lv_example_textarea_2(void) /*Create a label and position it above the text box*/ 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); + lv_obj_align_to(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()); lv_textarea_set_password_mode(oneline_ta, false); - lv_obj_align(oneline_ta, NULL, LV_ALIGN_IN_TOP_RIGHT, -5, 20); + lv_obj_align(oneline_ta, LV_ALIGN_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()); lv_label_set_text(oneline_label, "Text:"); - lv_obj_align(oneline_label, oneline_ta, LV_ALIGN_OUT_TOP_LEFT, 0, 0); + lv_obj_align_to(oneline_label, oneline_ta, LV_ALIGN_OUT_TOP_LEFT, 0, 0); /*Create a keyboard*/ kb = lv_keyboard_create(lv_scr_act()); diff --git a/examples/widgets/tileview/lv_example_tileview_1.c b/examples/widgets/tileview/lv_example_tileview_1.c index 24f456757..a66771475 100644 --- a/examples/widgets/tileview/lv_example_tileview_1.c +++ b/examples/widgets/tileview/lv_example_tileview_1.c @@ -14,7 +14,7 @@ void lv_example_tileview_1(void) lv_obj_t * tile1 = lv_tileview_add_tile(tv, 0, 0, LV_DIR_BOTTOM); 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); + lv_obj_center(label); /*Tile2: a button*/ @@ -26,7 +26,7 @@ void lv_example_tileview_1(void) lv_label_set_text(label, "Scroll up or right"); lv_obj_set_size(btn, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - lv_obj_align(btn, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_center(btn); /*Tile3: a list*/ lv_obj_t * tile3 = lv_tileview_add_tile(tv, 1, 1, LV_DIR_LEFT); diff --git a/src/core/lv_obj.c b/src/core/lv_obj.c index 442147a28..5e5d9925e 100644 --- a/src/core/lv_obj.c +++ b/src/core/lv_obj.c @@ -905,6 +905,7 @@ static void lv_obj_event_cb(lv_obj_t * obj, lv_event_t e) lv_obj_t * child = lv_obj_get_child(obj, i); lv_obj_refr_size(child); + lv_obj_refr_pos(child); } if(lv_obj_get_style_layout(obj, LV_PART_MAIN)) { @@ -912,8 +913,11 @@ static void lv_obj_event_cb(lv_obj_t * obj, lv_event_t e) } } else if(e == LV_EVENT_CHILD_CHANGED) { -// lv_obj_mark_layout_as_dirty(obj); - if(lv_obj_get_style_layout(obj, LV_PART_MAIN)) { + lv_coord_t w = lv_obj_get_style_width(obj, LV_PART_MAIN); + lv_coord_t h = lv_obj_get_style_height(obj, LV_PART_MAIN); + lv_coord_t align = lv_obj_get_style_align(obj, LV_PART_MAIN); + uint16_t layout = lv_obj_get_style_layout(obj, LV_PART_MAIN); + if(layout || align || w == LV_SIZE_CONTENT || h == LV_SIZE_CONTENT) { lv_obj_mark_layout_as_dirty(obj); } } diff --git a/src/core/lv_obj_pos.c b/src/core/lv_obj_pos.c index 1c931713a..a80770fd6 100644 --- a/src/core/lv_obj_pos.c +++ b/src/core/lv_obj_pos.c @@ -45,7 +45,6 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) lv_obj_set_x(obj, x); lv_obj_set_y(obj, y); - } void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x) @@ -163,8 +162,6 @@ void lv_obj_refr_size(lv_obj_t * obj) /*Invalidate the new area*/ lv_obj_invalidate(obj); - /*Calculate the required auto sizes*/ - /*If the object was out of the parent invalidate the new scrollbar area too. *If it wasn't out of the parent but out now, also invalidate the srollbars*/ bool on2 = _lv_area_is_in(&obj->coords, &parent_fit_area, 0); @@ -291,7 +288,13 @@ uint32_t lv_layout_register(lv_layout_update_cb_t cb) return layout_cnt; /*No -1 to skip 0th index*/ } -void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs) +void lv_obj_align(lv_obj_t * obj, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs) +{ + lv_obj_set_style_align(obj, LV_PART_MAIN, LV_STATE_DEFAULT, align); + lv_obj_set_pos(obj, x_ofs, y_ofs); +} + +void lv_obj_align_to(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs) { LV_ASSERT_OBJ(obj, MY_CLASS); @@ -310,40 +313,40 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width(obj) / 2; y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height(obj) / 2; break; - case LV_ALIGN_IN_TOP_LEFT: + case LV_ALIGN_TOP_LEFT: x = 0; y = 0; break; - case LV_ALIGN_IN_TOP_MID: + case LV_ALIGN_TOP_MID: x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width(obj) / 2; y = 0; break; - case LV_ALIGN_IN_TOP_RIGHT: + case LV_ALIGN_TOP_RIGHT: x = lv_obj_get_width_fit(base) - lv_obj_get_width(obj); y = 0; break; - case LV_ALIGN_IN_BOTTOM_LEFT: + case LV_ALIGN_BOTTOM_LEFT: x = 0; y = lv_obj_get_height_fit(base) - lv_obj_get_height(obj); break; - case LV_ALIGN_IN_BOTTOM_MID: + case LV_ALIGN_BOTTOM_MID: x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width(obj) / 2; y = lv_obj_get_height_fit(base) - lv_obj_get_height(obj); break; - case LV_ALIGN_IN_BOTTOM_RIGHT: + case LV_ALIGN_BOTTOM_RIGHT: x = lv_obj_get_width_fit(base) - lv_obj_get_width(obj); y = lv_obj_get_height_fit(base) - lv_obj_get_height(obj); break; - case LV_ALIGN_IN_LEFT_MID: + case LV_ALIGN_LEFT_MID: x = 0; y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height(obj) / 2; break; - case LV_ALIGN_IN_RIGHT_MID: + case LV_ALIGN_RIGHT_MID: x = lv_obj_get_width_fit(base) - lv_obj_get_width(obj); y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height(obj) / 2; break; @@ -411,8 +414,9 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co x += x_ofs + base->coords.x1 - parent->coords.x1 + lv_obj_get_scroll_left(parent); y += y_ofs + base->coords.y1 - parent->coords.y1 + lv_obj_get_scroll_top(parent); - + lv_obj_set_style_align(obj, LV_PART_MAIN, LV_STATE_DEFAULT, LV_ALIGN_TOP_LEFT); lv_obj_set_pos(obj, x, y); + } void lv_obj_get_coords(const lv_obj_t * obj, lv_area_t * coords) @@ -570,9 +574,58 @@ bool lv_obj_handle_self_size_chg(struct _lv_obj_t * obj) void lv_obj_refr_pos(lv_obj_t * obj) { + lv_obj_t * parent = lv_obj_get_parent(obj); lv_coord_t x = lv_obj_get_style_x(obj, LV_PART_MAIN); lv_coord_t y = lv_obj_get_style_y(obj, LV_PART_MAIN); - lv_obj_move_to(obj, x, y); + if(parent == NULL) { + lv_obj_move_to(obj, x, y); + return; + } + + lv_align_t align = lv_obj_get_style_align(obj, LV_PART_MAIN); + if(align == LV_ALIGN_TOP_LEFT) { + lv_obj_move_to(obj, x, y); + } + else { + lv_coord_t pw = lv_obj_get_width_fit(parent); + lv_coord_t ph = lv_obj_get_height_fit(parent); + lv_coord_t w = lv_obj_get_width(obj); + lv_coord_t h = lv_obj_get_height(obj); + + switch(align) { + case LV_ALIGN_TOP_MID: + x += pw / 2 - w / 2; + break; + case LV_ALIGN_TOP_RIGHT: + x += pw - w; + break; + case LV_ALIGN_LEFT_MID: + y += ph / 2 - h / 2; + break; + case LV_ALIGN_BOTTOM_LEFT: + y += ph - h; + break; + case LV_ALIGN_BOTTOM_MID: + x += pw / 2 - w / 2; + y += ph - h; + break; + case LV_ALIGN_BOTTOM_RIGHT: + x += pw - w; + y += ph - h; + break; + case LV_ALIGN_RIGHT_MID: + x += pw - w; + y += ph / 2 - h / 2; + break; + case LV_ALIGN_CENTER: + x += pw / 2 - w / 2; + y += ph / 2 - h / 2; + break; + default: + break; + } + lv_obj_move_to(obj, x, y); + } } void lv_obj_move_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) diff --git a/src/core/lv_obj_pos.h b/src/core/lv_obj_pos.h index 4ee953eff..01f04d192 100644 --- a/src/core/lv_obj_pos.h +++ b/src/core/lv_obj_pos.h @@ -137,6 +137,15 @@ void lv_obj_update_layout(struct _lv_obj_t * obj); */ uint32_t lv_layout_register(lv_layout_update_cb_t cb); +/** + * Align an object to an other object. + * @param obj pointer to an object to align + * @param align type of alignment (see 'lv_align_t' enum) `LV_ALIGN_OUT_...` can't be used. + * @param x_ofs x coordinate offset after alignment + * @param y_ofs y coordinate offset after alignment + */ +void lv_obj_align(struct _lv_obj_t * obj, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs); + /** * Align an object to an other object. * @param obj pointer to an object to align @@ -146,7 +155,7 @@ uint32_t lv_layout_register(lv_layout_update_cb_t cb); * @param y_ofs y coordinate offset after alignment * @note if the position or size of `base` changes `obj` needs to be aligned manually again */ -void lv_obj_align(struct _lv_obj_t * obj, const struct _lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs); +void lv_obj_align_to(struct _lv_obj_t * obj, const struct _lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs); /** * Align an object to the center on its parent. @@ -155,7 +164,7 @@ void lv_obj_align(struct _lv_obj_t * obj, const struct _lv_obj_t * base, lv_alig */ static inline void lv_obj_center(struct _lv_obj_t * obj) { - lv_obj_align(obj, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(obj, LV_ALIGN_CENTER, 0, 0); } diff --git a/src/core/lv_obj_style_gen.h b/src/core/lv_obj_style_gen.h index 23cc66185..43bd87d86 100644 --- a/src/core/lv_obj_style_gen.h +++ b/src/core/lv_obj_style_gen.h @@ -136,9 +136,15 @@ static inline lv_coord_t lv_obj_get_style_y(const struct _lv_obj_t * obj, uint32 return (lv_coord_t)v.num; } -static inline lv_coord_t lv_obj_get_style_layout(const struct _lv_obj_t * obj, uint32_t part) +static inline uint16_t lv_obj_get_style_layout(const struct _lv_obj_t * obj, uint32_t part) { lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LAYOUT); + return (lv_align_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_align(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ALIGN); return (lv_coord_t)v.num; } @@ -668,7 +674,8 @@ static inline void lv_obj_set_style_y(struct _lv_obj_t * obj, uint32_t part, uin }; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_Y, v); } -static inline void lv_obj_set_style_layout(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) + +static inline void lv_obj_set_style_layout(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_align_t value) { lv_style_value_t v = { .num = (int32_t)value @@ -676,6 +683,13 @@ static inline void lv_obj_set_style_layout(struct _lv_obj_t * obj, uint32_t part lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_LAYOUT, v); } +static inline void lv_obj_set_style_align(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_ALIGN, v); +} static inline void lv_obj_set_style_bg_color(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value) { diff --git a/src/extra/themes/default/lv_theme_default.c b/src/extra/themes/default/lv_theme_default.c index 03a2ccff4..f87cb2c56 100644 --- a/src/extra/themes/default/lv_theme_default.c +++ b/src/extra/themes/default/lv_theme_default.c @@ -269,11 +269,11 @@ static void style_init(void) lv_style_set_pad_column(&styles->btn, LV_DPX(5)); lv_style_set_pad_row(&styles->btn, LV_DPX(5)); #if LV_USE_FLEX - lv_style_set_layout(&styles->btn, LV_LAYOUT_FLEX); - lv_style_set_flex_flow(&styles->btn, LV_FLEX_FLOW_ROW); - lv_style_set_flex_main_place(&styles->btn, LV_FLEX_PLACE_CENTER); - lv_style_set_flex_cross_place(&styles->btn, LV_FLEX_PLACE_CENTER); - lv_style_set_flex_track_place(&styles->btn, LV_FLEX_PLACE_CENTER); +// lv_style_set_layout(&styles->btn, LV_LAYOUT_FLEX); +// lv_style_set_flex_flow(&styles->btn, LV_FLEX_FLOW_ROW); +// lv_style_set_flex_main_place(&styles->btn, LV_FLEX_PLACE_CENTER); +// lv_style_set_flex_cross_place(&styles->btn, LV_FLEX_PLACE_CENTER); +// lv_style_set_flex_track_place(&styles->btn, LV_FLEX_PLACE_CENTER); #endif diff --git a/src/extra/widgets/calendar/lv_calendar_header_arrow.c b/src/extra/widgets/calendar/lv_calendar_header_arrow.c index 1c3bf4de8..01580cc17 100644 --- a/src/extra/widgets/calendar/lv_calendar_header_arrow.c +++ b/src/extra/widgets/calendar/lv_calendar_header_arrow.c @@ -77,7 +77,7 @@ lv_obj_t * lv_calendar_header_arrow_create(lv_obj_t * parent, lv_obj_t * calenda lv_obj_add_event_cb(mo_next, month_event_cb, calendar); lv_obj_clear_flag(mo_next, LV_OBJ_FLAG_CLICK_FOCUSABLE); - lv_obj_align(header, calendar, LV_ALIGN_OUT_TOP_MID, 0, 0); + lv_obj_align_to(header, calendar, LV_ALIGN_OUT_TOP_MID, 0, 0); return header; } diff --git a/src/extra/widgets/calendar/lv_calendar_header_dropdown.c b/src/extra/widgets/calendar/lv_calendar_header_dropdown.c index 0fa81d950..e3f4cffc2 100644 --- a/src/extra/widgets/calendar/lv_calendar_header_dropdown.c +++ b/src/extra/widgets/calendar/lv_calendar_header_dropdown.c @@ -80,7 +80,7 @@ lv_obj_t * lv_calendar_header_dropdown_create(lv_obj_t * parent, lv_obj_t * cale lv_obj_add_event_cb(month_dd, month_event_cb, calendar); lv_obj_set_flex_grow(month_dd, 1); - lv_obj_align(header, calendar, LV_ALIGN_OUT_TOP_MID, 0, 0); + lv_obj_align_to(header, calendar, LV_ALIGN_OUT_TOP_MID, 0, 0); return header; } diff --git a/src/extra/widgets/keyboard/lv_keyboard.c b/src/extra/widgets/keyboard/lv_keyboard.c index 083d45c0a..315d04be3 100644 --- a/src/extra/widgets/keyboard/lv_keyboard.c +++ b/src/extra/widgets/keyboard/lv_keyboard.c @@ -328,7 +328,7 @@ static void lv_keyboard_constructor(lv_obj_t * obj) lv_obj_t * parent = lv_obj_get_parent(obj); lv_obj_set_size(obj, lv_obj_get_width_fit(parent), lv_obj_get_height_fit(parent) / 2); - lv_obj_align(obj, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); + lv_obj_align(obj, LV_ALIGN_BOTTOM_MID, 0, 0); lv_obj_add_event_cb(obj, lv_keyboard_def_event_cb, NULL); lv_obj_set_base_dir(obj, LV_BIDI_DIR_LTR); diff --git a/src/extra/widgets/msgbox/lv_msgbox.c b/src/extra/widgets/msgbox/lv_msgbox.c index 4960045a1..007a13b03 100644 --- a/src/extra/widgets/msgbox/lv_msgbox.c +++ b/src/extra/widgets/msgbox/lv_msgbox.c @@ -75,7 +75,7 @@ lv_obj_t * lv_msgbox_create(const char * title, const char * txt, const char * b 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); + lv_obj_align(label, LV_ALIGN_CENTER, 0, 0); } label = lv_label_create(mbox); diff --git a/src/extra/widgets/win/lv_win.c b/src/extra/widgets/win/lv_win.c index dfc50d789..bd2c5a867 100644 --- a/src/extra/widgets/win/lv_win.c +++ b/src/extra/widgets/win/lv_win.c @@ -61,7 +61,7 @@ lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * icon, lv_coord_t btn_w, l lv_obj_t * img = lv_img_create(btn); lv_img_set_src(img, icon); - lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(img, LV_ALIGN_CENTER, 0, 0); return btn; } diff --git a/src/misc/lv_area.c b/src/misc/lv_area.c index 609bc9f17..4ba14eec8 100644 --- a/src/misc/lv_area.c +++ b/src/misc/lv_area.c @@ -280,40 +280,40 @@ void _lv_area_align(const lv_area_t * base, const lv_area_t * to_align, lv_align res->y = lv_area_get_height(base) / 2 - lv_area_get_height(to_align) / 2; break; - case LV_ALIGN_IN_TOP_LEFT: + case LV_ALIGN_TOP_LEFT: res->x = 0; res->y = 0; break; - case LV_ALIGN_IN_TOP_MID: + case LV_ALIGN_TOP_MID: res->x = lv_area_get_width(base) / 2 - lv_area_get_width(to_align) / 2; res->y = 0; break; - case LV_ALIGN_IN_TOP_RIGHT: + case LV_ALIGN_TOP_RIGHT: res->x = lv_area_get_width(base) - lv_area_get_width(to_align); res->y = 0; break; - case LV_ALIGN_IN_BOTTOM_LEFT: + case LV_ALIGN_BOTTOM_LEFT: res->x = 0; res->y = lv_area_get_height(base) - lv_area_get_height(to_align); break; - case LV_ALIGN_IN_BOTTOM_MID: + case LV_ALIGN_BOTTOM_MID: res->x = lv_area_get_width(base) / 2 - lv_area_get_width(to_align) / 2; res->y = lv_area_get_height(base) - lv_area_get_height(to_align); break; - case LV_ALIGN_IN_BOTTOM_RIGHT: + case LV_ALIGN_BOTTOM_RIGHT: res->x = lv_area_get_width(base) - lv_area_get_width(to_align); res->y = lv_area_get_height(base) - lv_area_get_height(to_align); break; - case LV_ALIGN_IN_LEFT_MID: + case LV_ALIGN_LEFT_MID: res->x = 0; res->y = lv_area_get_height(base) / 2 - lv_area_get_height(to_align) / 2; break; - case LV_ALIGN_IN_RIGHT_MID: + case LV_ALIGN_RIGHT_MID: res->x = lv_area_get_width(base) - lv_area_get_width(to_align); res->y = lv_area_get_height(base) / 2 - lv_area_get_height(to_align) / 2; break; diff --git a/src/misc/lv_area.h b/src/misc/lv_area.h index b495fd13b..20ac488d5 100644 --- a/src/misc/lv_area.h +++ b/src/misc/lv_area.h @@ -59,15 +59,16 @@ typedef struct { /** Alignments*/ enum { - LV_ALIGN_CENTER = 0, - LV_ALIGN_IN_TOP_LEFT, - LV_ALIGN_IN_TOP_MID, - LV_ALIGN_IN_TOP_RIGHT, - LV_ALIGN_IN_BOTTOM_LEFT, - LV_ALIGN_IN_BOTTOM_MID, - LV_ALIGN_IN_BOTTOM_RIGHT, - LV_ALIGN_IN_LEFT_MID, - LV_ALIGN_IN_RIGHT_MID, + LV_ALIGN_TOP_LEFT = 0, + LV_ALIGN_TOP_MID, + LV_ALIGN_TOP_RIGHT, + LV_ALIGN_BOTTOM_LEFT, + LV_ALIGN_BOTTOM_MID, + LV_ALIGN_BOTTOM_RIGHT, + LV_ALIGN_LEFT_MID, + LV_ALIGN_RIGHT_MID, + LV_ALIGN_CENTER, + LV_ALIGN_OUT_TOP_LEFT, LV_ALIGN_OUT_TOP_MID, LV_ALIGN_OUT_TOP_RIGHT, diff --git a/src/misc/lv_style.h b/src/misc/lv_style.h index ebc0adeeb..ec74c90ae 100644 --- a/src/misc/lv_style.h +++ b/src/misc/lv_style.h @@ -139,6 +139,7 @@ typedef enum { LV_STYLE_X = 24 | LV_STYLE_PROP_LAYOUT_REFR, LV_STYLE_Y = 25 | LV_STYLE_PROP_LAYOUT_REFR, LV_STYLE_LAYOUT = 26 | LV_STYLE_PROP_LAYOUT_REFR, + LV_STYLE_ALIGN = 27 | LV_STYLE_PROP_LAYOUT_REFR, /*Group 2*/ LV_STYLE_BG_COLOR = 32, @@ -211,9 +212,6 @@ typedef enum { LV_STYLE_TEXT_DECOR = 92 | LV_STYLE_PROP_INHERIT, LV_STYLE_TEXT_ALIGN = 93 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_LAYOUT_REFR, - /*Group 6*/ - LV_STYLE_CONTENT_TEXT = 96 | LV_STYLE_PROP_EXT_DRAW, - _LV_STYLE_LAST_BUILT_IN_PROP = 111, LV_STYLE_PROP_ALL = 0xFFFF diff --git a/src/misc/lv_style_gen.h b/src/misc/lv_style_gen.h index efc098326..5dcc73576 100644 --- a/src/misc/lv_style_gen.h +++ b/src/misc/lv_style_gen.h @@ -183,8 +183,7 @@ static inline void lv_style_set_y(lv_style_t * style, lv_coord_t value) lv_style_set_prop(style, LV_STYLE_Y, v); } - -static inline void lv_style_set_layout(lv_style_t * style, lv_coord_t value) +static inline void lv_style_set_layout(lv_style_t * style, uint16_t value) { lv_style_value_t v = { .num = (int32_t)value @@ -192,6 +191,14 @@ static inline void lv_style_set_layout(lv_style_t * style, lv_coord_t value) lv_style_set_prop(style, LV_STYLE_LAYOUT, v); } +static inline void lv_style_set_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_ALIGN, v); +} + static inline void lv_style_set_bg_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = { diff --git a/src/widgets/lv_dropdown.c b/src/widgets/lv_dropdown.c index f4f5023c6..898d7d8b3 100644 --- a/src/widgets/lv_dropdown.c +++ b/src/widgets/lv_dropdown.c @@ -486,10 +486,10 @@ void lv_dropdown_open(lv_obj_t * dropdown_obj) position_to_selected(dropdown_obj); - if(dir == LV_DIR_BOTTOM) lv_obj_align(dropdown->list, dropdown_obj, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); - else if(dir == LV_DIR_TOP) lv_obj_align(dropdown->list, dropdown_obj, LV_ALIGN_OUT_TOP_LEFT, 0, 0); - else if(dir == LV_DIR_LEFT) lv_obj_align(dropdown->list, dropdown_obj, LV_ALIGN_OUT_LEFT_TOP, 0, 0); - else if(dir == LV_DIR_RIGHT) lv_obj_align(dropdown->list, dropdown_obj, LV_ALIGN_OUT_RIGHT_TOP, 0, 0); + if(dir == LV_DIR_BOTTOM) lv_obj_align_to(dropdown->list, dropdown_obj, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); + else if(dir == LV_DIR_TOP) lv_obj_align_to(dropdown->list, dropdown_obj, LV_ALIGN_OUT_TOP_LEFT, 0, 0); + else if(dir == LV_DIR_LEFT) lv_obj_align_to(dropdown->list, dropdown_obj, LV_ALIGN_OUT_LEFT_TOP, 0, 0); + else if(dir == LV_DIR_RIGHT) lv_obj_align_to(dropdown->list, dropdown_obj, LV_ALIGN_OUT_RIGHT_TOP, 0, 0); if(dropdown->dir == LV_DIR_LEFT || dropdown->dir == LV_DIR_RIGHT) {