refactor(coords) rename LV_SIZE_PCT to LV_PCT

This commit is contained in:
Gabor Kiss-Vamosi
2021-04-18 12:19:02 +02:00
parent 03efd13e4f
commit 2fb8b672ae
10 changed files with 27 additions and 27 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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