refactor(flex): change the name of teh built-in flex layouts

This commit is contained in:
Gabor Kiss-Vamosi
2021-03-08 23:30:27 +01:00
parent 289f8e4bac
commit 94431f8aaf
13 changed files with 42 additions and 42 deletions

View File

@@ -9,7 +9,7 @@ void lv_example_flex_3(void)
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL); lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_size(cont, 300, 220); lv_obj_set_size(cont, 300, 220);
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_layout(cont, &lv_flex_queue); lv_obj_set_layout(cont, &lv_flex_row_nowrap);
lv_obj_t * obj; lv_obj_t * obj;
obj = lv_obj_create(cont, NULL); obj = lv_obj_create(cont, NULL);

View File

@@ -19,7 +19,7 @@ void lv_example_flex_5(void)
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL); lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_size(cont, 300, 220); lv_obj_set_size(cont, 300, 220);
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_layout(cont, &lv_flex_inline); lv_obj_set_layout(cont, &lv_flex_row_wrap);
uint32_t i; uint32_t i;
for(i = 0; i < 9; i++) { for(i = 0; i < 9; i++) {

View File

@@ -11,7 +11,7 @@ void lv_example_flex_6(void)
lv_obj_set_base_dir(cont, LV_BIDI_DIR_RTL); lv_obj_set_base_dir(cont, LV_BIDI_DIR_RTL);
lv_obj_set_size(cont, 300, 220); lv_obj_set_size(cont, 300, 220);
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_layout(cont, &lv_flex_center_column); lv_obj_set_layout(cont, &lv_flex_column_center);
uint32_t i; uint32_t i;
for(i = 0; i < 20; i++) { for(i = 0; i < 20; i++) {

View File

@@ -19,7 +19,7 @@ void lv_example_scroll_2(void)
lv_obj_t * panel = lv_obj_create(lv_scr_act(), NULL); lv_obj_t * panel = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_size(panel, 280, 150); lv_obj_set_size(panel, 280, 150);
lv_obj_set_scroll_snap_x(panel, LV_SCROLL_SNAP_CENTER); lv_obj_set_scroll_snap_x(panel, LV_SCROLL_SNAP_CENTER);
lv_obj_set_layout(panel, &lv_flex_queue); lv_obj_set_layout(panel, &lv_flex_row_nowrap);
lv_obj_center(panel); lv_obj_center(panel);
uint32_t i; uint32_t i;

View File

@@ -10,7 +10,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event)
void lv_example_switch_1(void) void lv_example_switch_1(void)
{ {
lv_obj_set_layout(lv_scr_act(), &lv_flex_center_column); lv_obj_set_layout(lv_scr_act(), &lv_flex_column_center);
lv_obj_t * sw; lv_obj_t * sw;

View File

@@ -42,17 +42,7 @@ static lv_obj_t * get_next_item(lv_obj_t * cont, bool rev, int32_t * item_id);
* GLOBAL VARIABLES * GLOBAL VARIABLES
**********************/ **********************/
const lv_flex_t lv_flex_inline = { const lv_flex_t lv_flex_row_center = {
.base.update_cb = flex_update,
.item_main_place = LV_FLEX_PLACE_START,
.item_cross_place = LV_FLEX_PLACE_CENTER,
.track_cross_place = LV_FLEX_PLACE_START,
.dir = LV_FLEX_FLOW_ROW,
.wrap = 1
};
const lv_flex_t lv_flex_center_row = {
.base.update_cb = flex_update, .base.update_cb = flex_update,
.item_main_place = LV_FLEX_PLACE_CENTER, .item_main_place = LV_FLEX_PLACE_CENTER,
.item_cross_place = LV_FLEX_PLACE_CENTER, .item_cross_place = LV_FLEX_PLACE_CENTER,
@@ -61,7 +51,7 @@ const lv_flex_t lv_flex_center_row = {
.wrap = 1 .wrap = 1
}; };
const lv_flex_t lv_flex_center_column = { const lv_flex_t lv_flex_column_center = {
.base.update_cb = flex_update, .base.update_cb = flex_update,
.item_main_place = LV_FLEX_PLACE_CENTER, .item_main_place = LV_FLEX_PLACE_CENTER,
.item_cross_place = LV_FLEX_PLACE_CENTER, .item_cross_place = LV_FLEX_PLACE_CENTER,
@@ -70,23 +60,16 @@ const lv_flex_t lv_flex_center_column = {
.wrap = 1 .wrap = 1
}; };
const lv_flex_t lv_flex_stacked = { const lv_flex_t lv_flex_row_wrap = {
.base.update_cb = flex_update, .base.update_cb = flex_update,
.item_main_place = LV_FLEX_PLACE_START, .item_main_place = LV_FLEX_PLACE_START,
.item_cross_place = LV_FLEX_PLACE_CENTER, .item_cross_place = LV_FLEX_PLACE_CENTER,
.track_cross_place = LV_FLEX_PLACE_START, .track_cross_place = LV_FLEX_PLACE_START,
.dir = LV_FLEX_FLOW_COLUMN .dir = LV_FLEX_FLOW_ROW,
.wrap = 1
}; };
const lv_flex_t lv_flex_queue = { const lv_flex_t lv_flex_row_even = {
.base.update_cb = flex_update,
.item_main_place = LV_FLEX_PLACE_START,
.item_cross_place = LV_FLEX_PLACE_START,
.track_cross_place = LV_FLEX_PLACE_START,
.dir = LV_FLEX_FLOW_ROW
};
const lv_flex_t lv_flex_even = {
.base.update_cb = flex_update, .base.update_cb = flex_update,
.item_main_place = LV_FLEX_PLACE_SPACE_EVENLY, .item_main_place = LV_FLEX_PLACE_SPACE_EVENLY,
.item_cross_place = LV_FLEX_PLACE_CENTER, .item_cross_place = LV_FLEX_PLACE_CENTER,
@@ -95,6 +78,23 @@ const lv_flex_t lv_flex_even = {
.wrap = 1 .wrap = 1
}; };
const lv_flex_t lv_flex_column_nowrap = {
.base.update_cb = flex_update,
.item_main_place = LV_FLEX_PLACE_START,
.item_cross_place = LV_FLEX_PLACE_CENTER,
.track_cross_place = LV_FLEX_PLACE_START,
.dir = LV_FLEX_FLOW_COLUMN
};
const lv_flex_t lv_flex_row_nowrap = {
.base.update_cb = flex_update,
.item_main_place = LV_FLEX_PLACE_START,
.item_cross_place = LV_FLEX_PLACE_CENTER,
.track_cross_place = LV_FLEX_PLACE_START,
.dir = LV_FLEX_FLOW_ROW
};
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
**********************/ **********************/

View File

@@ -102,12 +102,12 @@ void lv_obj_set_flex_grow(struct _lv_obj_t * obj, uint8_t grow);
/** /**
* Predefines flex layouts * Predefines flex layouts
*/ */
extern const lv_flex_t lv_flex_inline; /**< Just put the items next to each other with wrap*/ extern const lv_flex_t lv_flex_row_wrap; /**< Just put the items next to each other with wrap*/
extern const lv_flex_t lv_flex_center_row; /**< Center in a row with wrap*/ extern const lv_flex_t lv_flex_row_center; /**< Center in a row with wrap*/
extern const lv_flex_t lv_flex_center_column; /**< Center in a column with wrap*/ extern const lv_flex_t lv_flex_column_center; /**< Center in a column with wrap*/
extern const lv_flex_t lv_flex_stacked; /**< Stack the items vertically without wrapping*/ extern const lv_flex_t lv_flex_column_nowrap; /**< Stack the items vertically without wrapping*/
extern const lv_flex_t lv_flex_queue; /**< Put the items next to each other without wrap*/ extern const lv_flex_t lv_flex_row_nowrap; /**< Put the items next to each other without wrap*/
extern const lv_flex_t lv_flex_even; /**< Place the items evenly in row with wrapping and vertical centering*/ extern const lv_flex_t lv_flex_row_even; /**< Place the items evenly in row with wrapping and vertical centering*/
/********************** /**********************
* MACROS * MACROS

View File

@@ -56,7 +56,7 @@ lv_obj_t * lv_calendar_header_arrow_create(lv_obj_t * parent, lv_obj_t * calenda
lv_coord_t w = lv_obj_get_width(calendar); lv_coord_t w = lv_obj_get_width(calendar);
lv_obj_set_size(header, w, LV_SIZE_CONTENT); lv_obj_set_size(header, w, LV_SIZE_CONTENT);
lv_obj_set_layout(header, &lv_flex_center_row); lv_obj_set_layout(header, &lv_flex_row_center);
lv_obj_t * mo_prev = lv_btn_create(header, NULL); lv_obj_t * mo_prev = lv_btn_create(header, NULL);
lv_obj_set_style_content_text(mo_prev, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_LEFT); lv_obj_set_style_content_text(mo_prev, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_LEFT);

View File

@@ -65,7 +65,7 @@ lv_obj_t * lv_calendar_header_dropdown_create(lv_obj_t * parent, lv_obj_t * cale
lv_coord_t w = lv_obj_get_width(calendar); lv_coord_t w = lv_obj_get_width(calendar);
lv_obj_set_size(header, w, LV_SIZE_CONTENT); lv_obj_set_size(header, w, LV_SIZE_CONTENT);
lv_obj_set_layout(header, &lv_flex_center_row); lv_obj_set_layout(header, &lv_flex_row_center);
lv_obj_t * year_dd = lv_dropdown_create(header, NULL); lv_obj_t * year_dd = lv_dropdown_create(header, NULL);
lv_dropdown_set_options(year_dd, year_list); lv_dropdown_set_options(year_dd, year_list);

View File

@@ -55,7 +55,7 @@ lv_obj_t * lv_list_create(lv_obj_t * parent)
{ {
lv_obj_t * list = lv_obj_create_from_class(&lv_list_class, parent, NULL); lv_obj_t * list = lv_obj_create_from_class(&lv_list_class, parent, NULL);
lv_obj_set_size(list, LV_DPX(200), LV_DPX(300)); lv_obj_set_size(list, LV_DPX(200), LV_DPX(300));
lv_obj_set_layout(list, &lv_flex_stacked); lv_obj_set_layout(list, &lv_flex_column_nowrap);
return list; return list;
} }
@@ -74,7 +74,7 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const char * icon, const char * txt,
lv_obj_t * btn = lv_obj_create_from_class(&lv_list_btn_class, list, NULL); lv_obj_t * btn = lv_obj_create_from_class(&lv_list_btn_class, list, NULL);
lv_obj_set_size(btn, LV_SIZE_PCT(100), LV_SIZE_CONTENT); lv_obj_set_size(btn, LV_SIZE_PCT(100), LV_SIZE_CONTENT);
lv_obj_add_event_cb(btn, event_cb, NULL); lv_obj_add_event_cb(btn, event_cb, NULL);
lv_obj_set_layout(btn, &lv_flex_inline); lv_obj_set_layout(btn, &lv_flex_row_wrap);
if(icon) { if(icon) {
lv_obj_t * img = lv_img_create(btn, NULL); lv_obj_t * img = lv_img_create(btn, NULL);

View File

@@ -60,7 +60,7 @@ lv_obj_t * lv_msgbox_create(const char * title, const char * txt, const char * b
if(w > 2 * LV_DPI_DEF) w = 2 * LV_DPI_DEF; if(w > 2 * LV_DPI_DEF) w = 2 * LV_DPI_DEF;
lv_obj_set_size(mbox, w, LV_SIZE_CONTENT); lv_obj_set_size(mbox, w, LV_SIZE_CONTENT);
lv_obj_set_layout(mbox, &lv_flex_inline); lv_obj_set_layout(mbox, &lv_flex_row_wrap);
lv_obj_t * label; lv_obj_t * label;
label = lv_label_create(mbox, NULL); label = lv_label_create(mbox, NULL);

View File

@@ -202,7 +202,7 @@ static void lv_tabview_constructor(lv_obj_t * obj, const lv_obj_t * copy)
break; break;
} }
lv_obj_set_layout(cont, &lv_flex_queue); lv_obj_set_layout(cont, &lv_flex_row_nowrap);
lv_obj_set_scroll_snap_x(cont, LV_SCROLL_SNAP_CENTER); lv_obj_set_scroll_snap_x(cont, LV_SCROLL_SNAP_CENTER);
lv_obj_add_flag(cont, LV_OBJ_FLAG_SCROLL_ONE); lv_obj_add_flag(cont, LV_OBJ_FLAG_SCROLL_ONE);
lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLL_ON_FOCUS); lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLL_ON_FOCUS);

View File

@@ -85,11 +85,11 @@ static void lv_win_constructor(lv_obj_t * obj, const lv_obj_t * copy)
LV_UNUSED(copy); LV_UNUSED(copy);
lv_obj_t * parent = lv_obj_get_parent(obj); lv_obj_t * parent = lv_obj_get_parent(obj);
lv_obj_set_size(obj, lv_obj_get_width(parent), lv_obj_get_height(parent)); lv_obj_set_size(obj, lv_obj_get_width(parent), lv_obj_get_height(parent));
lv_obj_set_layout(obj, &lv_flex_stacked); lv_obj_set_layout(obj, &lv_flex_column_nowrap);
lv_obj_t * header = lv_obj_create(obj, NULL); lv_obj_t * header = lv_obj_create(obj, NULL);
lv_obj_set_size(header, LV_SIZE_PCT(100), create_header_height); lv_obj_set_size(header, LV_SIZE_PCT(100), create_header_height);
lv_obj_set_layout(header, &lv_flex_inline); lv_obj_set_layout(header, &lv_flex_row_wrap);
lv_obj_t * cont = lv_obj_create(obj, NULL); lv_obj_t * cont = lv_obj_create(obj, NULL);
lv_obj_set_flex_grow(cont, 1); lv_obj_set_flex_grow(cont, 1);