lvgl/src/lv_objx/lv_cont.c
/**
 * Handle the grid layout. Align same-sized objects in a grid
 * @param cont pointer to an object which layout should be handled
 */
Handle the grid layout. Align same-sized objects in a grid
@param cont pointer to an object which layout should be handled
Handle the grid layout . Align same - sized objects in a grid @param cont pointer to an object which layout should be handled
static void lv_cont_layout_grid(lv_obj_t * cont)
{
    const lv_style_t * style = lv_obj_get_style(cont);
    lv_coord_t w_fit         =  lv_obj_get_width_fit(cont);
    lv_coord_t h_obj         = lv_obj_get_height(lv_obj_get_child(cont, NULL));
    lv_coord_t y_ofs = h_obj + style->body.padding.inner;
    lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
    lv_coord_t act_x = style->body.padding.left;
    lv_coord_t act_y = style->body.padding.top;
    lv_obj_t * child;
    LV_LL_READ_BACK(cont->child_ll, child)
    {
        if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
        lv_coord_t obj_w = lv_obj_get_width(child);
        if(act_x + style->body.padding.inner + obj_w > w_fit) {
            act_x = style->body.padding.left;
            act_y += y_ofs;
        }
        lv_obj_set_pos(child, act_x, act_y);
        act_x += style->body.padding.inner + obj_w;
    }
    lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
}
static void lv_cont_layout_grid ( lv_obj_t * cont ) { const lv_style_t * style = lv_obj_get_style ( cont ) ; lv_coord_t w_fit = lv_obj_get_width_fit ( cont ) ; lv_coord_t h_obj = lv_obj_get_height ( lv_obj_get_child ( cont , NULL ) ) ; lv_coord_t y_ofs = h_obj + style -> body . padding . inner ; lv_obj_set_protect ( cont , LV_PROTECT_CHILD_CHG ) ; lv_coord_t act_x = style -> body . padding . left ; lv_coord_t act_y = style -> body . padding . top ; lv_obj_t * child ; LV_LL_READ_BACK ( cont -> child_ll , child ) { if ( lv_obj_get_hidden ( child ) != false || lv_obj_is_protected ( child , LV_PROTECT_POS ) != false ) continue ; lv_coord_t obj_w = lv_obj_get_width ( child ) ; if ( act_x + style -> body . padding . inner + obj_w > w_fit ) { act_x = style -> body . padding . left ; act_y += y_ofs ; } lv_obj_set_pos ( child , act_x , act_y ) ; act_x += style -> body . padding . inner + obj_w ; } lv_obj_clear_protect ( cont , LV_PROTECT_CHILD_CHG ) ; }
Handle the grid layout.
Handle the grid layout .
/* Disable child change action because the children will be moved a lot
     * an unnecessary child change signals could be sent*/ /* Align the children */