How to use lv_obj_align_to inside layouts

Description

I can’t seem to figure out a way to use “lv_obj_align_to” inside flex or grid layouts. I’m beginning to think that this ain’t feasible and probably not the indented way to do things?

What MCU/Processor/Board and compiler are you using?

Simulator using SDL

What LVGL version are you using?

GIT master

What do you want to achieve?

I’d like to place a label right beside a LED inside a flex or grid layout using lv_obj_align_to. I guess one can probably get away by creating an extra row or column for this, but it seems like unnecessary work for just adding a label?

Code to reproduce

The following snippet creates a 1x1 grid layout and places a led in the center of it’s only row/column. Afterwards a label gets added which then should be placed right beside the led object.

  // Create main grid
  static lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
  static lv_coord_t row_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
  lv_obj_t* scr = lv_scr_act();
#ifdef USE_GRID
  lv_obj_set_style_grid_column_dsc_array(scr, col_dsc, 0);
  lv_obj_set_style_grid_row_dsc_array(scr, row_dsc, 0);
  lv_obj_set_layout(scr, LV_LAYOUT_GRID);
#endif

  // LED
  lv_obj_t* led = lv_led_create(scr);
#ifdef USE_GRID
  lv_obj_set_grid_cell(
    led, LV_GRID_ALIGN_CENTER, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1);
#endif

  // Label
  lv_obj_t* label = lv_label_create(scr);
  lv_obj_align_to(label, led, LV_ALIGN_OUT_RIGHT_MID, 20, 0);

Screenshot and/or video