Custom cell-draw in lv_table V9

Description

Hi!

I’m trying to port an application that makes heavy use of lv_table from V8 to V9.
But the code in the documentation to get descriptors for the cell and its label doesn’t seem to be in phase with the current implementation.

What’s the correct way to get descriptors to the rectangle and label to apply different colors/formatting ?

Thanks in advance,
Mike

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

Code::Blocks simulator

What LVGL version are you using?

V9

What do you want to achieve?

Apply some custom drawing to cells in lv_table as described in the simple table example in the documentation.

But the example refers to non-existent functions in the code.

Code to reproduce

These two functions taken from the event callback in the example are nowhere to be found in the simulator code :

		lv_draw_fill_dsc_t *fill_dsc = lv_draw_task_get_fill_dsc( draw_task );
		lv_draw_label_dsc_t *label_dsc = lv_draw_task_get_label_dsc( draw_task );

Hello Mike,

I also could not find out how to properly do it from the documentation, here’s how I do it now in v9. Seems to work well. Code below is for changing the color and alignment of a label based on the column it is in.

static void ev_TabDraw_cb(lv_event_t* event)
{
    lv_draw_task_t * draw_task = lv_event_get_draw_task(event);
    lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;

    if(base_dsc->part == LV_PART_ITEMS)
    {
        uint32_t row = base_dsc->id1;
        uint32_t col = base_dsc->id2;

        if (draw_task->type == LV_DRAW_TASK_TYPE_LABEL)
        {
            lv_draw_label_dsc_t* label_dsc = draw_task->draw_dsc;

            switch (col) {
                case TABLE_COLUMN_FIELD:
                    label_dsc->align = LV_TEXT_ALIGN_LEFT;
                    break;

                case TABLE_COLUMN_VALUE:
                    label_dsc->align = LV_TEXT_ALIGN_RIGHT;
                    break;

                case TABLE_COLUMN_UNIT:
                    label_dsc->align = LV_TEXT_ALIGN_LEFT;
                    label_dsc->color = lv_color_hex(TABLE_COL_UNIT);
                    break;
               default:
                    break;
            }
      }
}

Thank you very much, Tinus. This is most helpful.