feat(style): store layout and position coordinates as style properties
related to #2152
This commit is contained in:
@@ -9,22 +9,18 @@ void lv_example_grid_3(void)
|
||||
/*Column 1: fix width 60 px
|
||||
*Column 2: 1 unit from the remaining free space
|
||||
*Column 3: 2 unit from the remaining free space*/
|
||||
static lv_coord_t col_dsc[3] = {60, LV_GRID_FR(1), LV_GRID_FR(2)};
|
||||
static lv_coord_t col_dsc[] = {60, LV_GRID_FR(1), LV_GRID_FR(2), LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
/*Row 1: fix width 60 px
|
||||
*Row 2: 1 unit from the remaining free space
|
||||
*Row 3: fix width 60 px*/
|
||||
static lv_coord_t row_dsc[3] = {40, LV_GRID_FR(1), 40};
|
||||
|
||||
static lv_grid_t grid;
|
||||
lv_grid_init(&grid);
|
||||
lv_grid_set_template(&grid, col_dsc, 3, row_dsc, 3);
|
||||
static lv_coord_t row_dsc[] = {40, LV_GRID_FR(1), 40, LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
/*Create a container with grid*/
|
||||
lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_set_layout(cont, &grid);
|
||||
lv_obj_set_grid_template(cont, col_dsc, row_dsc);
|
||||
|
||||
lv_obj_t * label;
|
||||
lv_obj_t * obj;
|
||||
|
||||
Reference in New Issue
Block a user