From 2fb8b672aebfb9f16075e6b3f9438c38955f4cf8 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 18 Apr 2021 12:19:02 +0200 Subject: [PATCH] refactor(coords) rename LV_SIZE_PCT to LV_PCT --- examples/layouts/flex/lv_example_flex_1.c | 4 ++-- .../widgets/tileview/lv_example_tileview_1.c | 2 +- src/extra/widgets/keyboard/lv_keyboard.c | 4 ++-- src/extra/widgets/list/lv_list.c | 4 ++-- src/extra/widgets/msgbox/lv_msgbox.c | 6 +++--- src/extra/widgets/tabview/lv_tabview.c | 16 ++++++++-------- src/extra/widgets/tileview/lv_tileview.c | 4 ++-- src/extra/widgets/win/lv_win.c | 10 +++++----- src/misc/lv_area.h | 2 +- src/widgets/lv_chart.c | 2 +- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/examples/layouts/flex/lv_example_flex_1.c b/examples/layouts/flex/lv_example_flex_1.c index 7e6f1e971..f9494da7d 100644 --- a/examples/layouts/flex/lv_example_flex_1.c +++ b/examples/layouts/flex/lv_example_flex_1.c @@ -25,7 +25,7 @@ void lv_example_flex_1(void) /*Add items to the row*/ obj= lv_btn_create(cont_row); - lv_obj_set_size(obj, 100, LV_SIZE_PCT(100)); + lv_obj_set_size(obj, 100, LV_PCT(100)); label = lv_label_create(obj); lv_label_set_text_fmt(label, "Item: %d", i); @@ -33,7 +33,7 @@ void lv_example_flex_1(void) /*Add items to the column*/ obj = lv_btn_create(cont_col); - lv_obj_set_size(obj, LV_SIZE_PCT(100), LV_SIZE_CONTENT); + lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT); label = lv_label_create(obj); lv_label_set_text_fmt(label, "Item: %d", i); diff --git a/examples/widgets/tileview/lv_example_tileview_1.c b/examples/widgets/tileview/lv_example_tileview_1.c index 9d562efb8..e36d54246 100644 --- a/examples/widgets/tileview/lv_example_tileview_1.c +++ b/examples/widgets/tileview/lv_example_tileview_1.c @@ -31,7 +31,7 @@ void lv_example_tileview_1(void) /*Tile3: a list*/ lv_obj_t * tile3 = lv_tileview_add_tile(tv, 1, 1, LV_DIR_LEFT); lv_obj_t * list = lv_list_create(tile3); - lv_obj_set_size(list, LV_SIZE_PCT(100), LV_SIZE_PCT(100)); + lv_obj_set_size(list, LV_PCT(100), LV_PCT(100)); lv_list_add_btn(list, NULL, "One", NULL); lv_list_add_btn(list, NULL, "Two", NULL); diff --git a/src/extra/widgets/keyboard/lv_keyboard.c b/src/extra/widgets/keyboard/lv_keyboard.c index 45955b31b..1f8433079 100644 --- a/src/extra/widgets/keyboard/lv_keyboard.c +++ b/src/extra/widgets/keyboard/lv_keyboard.c @@ -32,8 +32,8 @@ static void lv_keyboard_update_map(lv_obj_t * obj); **********************/ const lv_obj_class_t lv_keyboard_class = { .constructor_cb = lv_keyboard_constructor, - .width_def = LV_SIZE_PCT(100), - .height_def = LV_SIZE_PCT(50), + .width_def = LV_PCT(100), + .height_def = LV_PCT(50), .instance_size = sizeof(lv_keyboard_t), .editable = 1, .base_class = &lv_btnmatrix_class diff --git a/src/extra/widgets/list/lv_list.c b/src/extra/widgets/list/lv_list.c index 7bcc0d546..cbba06563 100644 --- a/src/extra/widgets/list/lv_list.c +++ b/src/extra/widgets/list/lv_list.c @@ -66,14 +66,14 @@ 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); 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)); + lv_obj_set_width(label, LV_PCT(100)); return label; } 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); - lv_obj_set_size(btn, LV_SIZE_PCT(100), LV_SIZE_CONTENT); + lv_obj_set_size(btn, LV_PCT(100), LV_SIZE_CONTENT); lv_obj_add_event_cb(btn, event_cb, NULL); if(icon) { diff --git a/src/extra/widgets/msgbox/lv_msgbox.c b/src/extra/widgets/msgbox/lv_msgbox.c index 6c7ce6a4a..8237fad90 100644 --- a/src/extra/widgets/msgbox/lv_msgbox.c +++ b/src/extra/widgets/msgbox/lv_msgbox.c @@ -44,7 +44,7 @@ const lv_obj_class_t lv_msgbox_class = {.base_class = &lv_obj_class}; 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()); - lv_obj_set_size(parent, LV_SIZE_PCT(100), LV_SIZE_PCT(100)); + lv_obj_set_size(parent, LV_PCT(100), LV_PCT(100)); lv_obj_remove_style_all(parent); lv_obj_set_style_bg_color(parent, lv_color_grey(), 0); @@ -65,7 +65,7 @@ lv_obj_t * lv_msgbox_create(const char * title, const char * txt, const char * b 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)); + else lv_obj_set_width(label, LV_PCT(100)); if(add_close_btn) { lv_obj_t * close_btn = lv_btn_create(mbox); @@ -81,7 +81,7 @@ lv_obj_t * lv_msgbox_create(const char * title, const char * txt, const char * b 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_set_width(label, LV_PCT(100)); lv_obj_t * btns = lv_btnmatrix_create(mbox); lv_btnmatrix_set_map(btns, btn_txts); diff --git a/src/extra/widgets/tabview/lv_tabview.c b/src/extra/widgets/tabview/lv_tabview.c index c513f9173..7c617441c 100644 --- a/src/extra/widgets/tabview/lv_tabview.c +++ b/src/extra/widgets/tabview/lv_tabview.c @@ -31,8 +31,8 @@ static void cont_event_cb(lv_event_t * e); const lv_obj_class_t lv_tabview_class = { .constructor_cb = lv_tabview_constructor, .destructor_cb = lv_tabview_destructor, - .width_def = LV_SIZE_PCT(100), - .height_def = LV_SIZE_PCT(100), + .width_def = LV_PCT(100), + .height_def = LV_PCT(100), .base_class = &lv_obj_class, .instance_size = sizeof(lv_tabview_t)}; @@ -60,7 +60,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * obj, const char * name) lv_obj_t * cont = lv_tabview_get_content(obj); lv_obj_t * page = lv_obj_create(cont); - lv_obj_set_size(page, LV_SIZE_PCT(100), LV_SIZE_PCT(100)); + lv_obj_set_size(page, LV_PCT(100), LV_PCT(100)); lv_obj_clear_flag(page, LV_OBJ_FLAG_CLICK_FOCUSABLE); uint32_t tab_id = lv_obj_get_child_cnt(cont); @@ -168,7 +168,7 @@ static void lv_tabview_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob break; } - lv_obj_set_size(obj, LV_SIZE_PCT(100), LV_SIZE_PCT(100)); + lv_obj_set_size(obj, LV_PCT(100), LV_PCT(100)); lv_obj_t * btnm; lv_obj_t * cont; @@ -189,14 +189,14 @@ static void lv_tabview_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob switch(tabview->tab_pos) { case LV_DIR_TOP: case LV_DIR_BOTTOM: - lv_obj_set_size(btnm, LV_SIZE_PCT(100), tabsize_create); - lv_obj_set_width(cont, LV_SIZE_PCT(100)); + lv_obj_set_size(btnm, LV_PCT(100), tabsize_create); + lv_obj_set_width(cont, LV_PCT(100)); lv_obj_set_flex_grow(cont, 1); break; case LV_DIR_LEFT: case LV_DIR_RIGHT: - lv_obj_set_size(btnm, tabsize_create, LV_SIZE_PCT(100)); - lv_obj_set_height(cont, LV_SIZE_PCT(100)); + lv_obj_set_size(btnm, tabsize_create, LV_PCT(100)); + lv_obj_set_height(cont, LV_PCT(100)); lv_obj_set_flex_grow(cont, 1); break; } diff --git a/src/extra/widgets/tileview/lv_tileview.c b/src/extra/widgets/tileview/lv_tileview.c index 892480536..c7b36ea7e 100644 --- a/src/extra/widgets/tileview/lv_tileview.c +++ b/src/extra/widgets/tileview/lv_tileview.c @@ -104,7 +104,7 @@ void lv_obj_set_tile_id(lv_obj_t * tv, uint32_t col_id, uint32_t row_id, lv_anim static void lv_tileview_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) { LV_UNUSED(class_p); - lv_obj_set_size(obj, LV_SIZE_PCT(100), LV_SIZE_PCT(100)); + lv_obj_set_size(obj, LV_PCT(100), LV_PCT(100)); lv_obj_add_event_cb(obj, tileview_event_cb, NULL); lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ONE); lv_obj_set_scroll_snap_x(obj, LV_SCROLL_SNAP_CENTER); @@ -116,7 +116,7 @@ static void lv_tileview_tile_constructor(const lv_obj_class_t * class_p, lv_obj_ { LV_UNUSED(class_p); 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_size(obj, LV_PCT(100), LV_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)); lv_tileview_tile_t * tile = (lv_tileview_tile_t *)obj; diff --git a/src/extra/widgets/win/lv_win.c b/src/extra/widgets/win/lv_win.c index 74b622b0a..9c8a37294 100644 --- a/src/extra/widgets/win/lv_win.c +++ b/src/extra/widgets/win/lv_win.c @@ -28,8 +28,8 @@ static void lv_win_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj); **********************/ const lv_obj_class_t lv_win_class = { .constructor_cb = lv_win_constructor, - .width_def = LV_SIZE_PCT(100), - .height_def = LV_SIZE_PCT(100), + .width_def = LV_PCT(100), + .height_def = LV_PCT(100), .base_class = &lv_obj_class, .instance_size = sizeof(lv_win_t) }; @@ -62,7 +62,7 @@ lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * icon, lv_coord_t btn_w, l { lv_obj_t * header = lv_win_get_header(win); lv_obj_t * btn = lv_btn_create(header); - lv_obj_set_size(btn, btn_w, LV_SIZE_PCT(100)); + lv_obj_set_size(btn, btn_w, LV_PCT(100)); lv_obj_add_event_cb(btn, event_cb, NULL); lv_obj_t * img = lv_img_create(btn); @@ -94,13 +94,13 @@ static void lv_win_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN); lv_obj_t * header = lv_obj_create(obj); - lv_obj_set_size(header, LV_SIZE_PCT(100), create_header_height); + lv_obj_set_size(header, LV_PCT(100), create_header_height); 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_CENTER); lv_obj_t * cont = lv_obj_create(obj); lv_obj_set_flex_grow(cont, 1); - lv_obj_set_width(cont, LV_SIZE_PCT(100)); + lv_obj_set_width(cont, LV_PCT(100)); } #endif diff --git a/src/misc/lv_area.h b/src/misc/lv_area.h index 393a8d9d9..f7bae42e6 100644 --- a/src/misc/lv_area.h +++ b/src/misc/lv_area.h @@ -241,7 +241,7 @@ void _lv_area_align(const lv_area_t * base, const lv_area_t * to_align, lv_align #define LV_COORD_SET_SPEC(x) ((x) | _LV_COORD_TYPE_SPEC) /*Special coordinates*/ -#define LV_SIZE_PCT(x) LV_COORD_SET_SPEC(x) +#define LV_PCT(x) LV_COORD_SET_SPEC(x) #define LV_COORD_IS_PCT(x) ((LV_COORD_IS_SPEC(x) && _LV_COORD_PLAIN(x) <= 1000) ? true : false) #define LV_COORD_GET_PCT(x) _LV_COORD_PLAIN(x) #define LV_SIZE_CONTENT LV_COORD_SET_SPEC(1001) diff --git a/src/widgets/lv_chart.c b/src/widgets/lv_chart.c index 3d046668c..761147000 100644 --- a/src/widgets/lv_chart.c +++ b/src/widgets/lv_chart.c @@ -55,7 +55,7 @@ const lv_obj_class_t lv_chart_class = { .constructor_cb = lv_chart_constructor, .destructor_cb = lv_chart_destructor, .event_cb = lv_chart_event, - .width_def = LV_SIZE_PCT(100), + .width_def = LV_PCT(100), .height_def = LV_DPI_DEF * 2, .instance_size = sizeof(lv_chart_t), .base_class = &lv_obj_class