I have a table that I want to use for calendar purposes. Google calendars allow you to colour the entries and i would like to replicate that on the table.
As the colours come through as #x i would like to use the recolor but i dont think that exists for tables?
I suspect that the answer is to use more style parts and fix the colours to rgb values.
What MCU/Processor/Board and compiler are you using?
PC sim and RPIZero
What LVGL version are you using?
7.9.0 dev
What do you want to achieve?
Recolour text in tables based on #x data i get back from the google calendar API
What have you tried so far?
Checking the docs etc
Code to reproduce
None yet really
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.
It’s doable but I’m concerned about the property bloat. In the meantime, I think you could also manually add the feature by adding label_dsc.flag = LV_TXT_FLAG_RECOLOR;here.
I was thinking a lot about how to make the styling of tables and button matrices easier and more flexible and finally came up with (I think) a good solution.
The idea is to let the user add a custom cell drawer function that looks something like this:
bool my_drawer(lv_obj_t * table, uint32_t row, uint32_t col,
lv_draw_rect_dsc_t * rect_draw_dsc, lv_draw_label_dsc_t * label_draw_dsc,
const lv_area_t * draw_area, const lv_area_t * clip_area)
{
/*Draw anything you want in a specific cell. E.g. checkbox*/
if(row == 1 && col == 1) {
...
/*Tell LVGL the drawing happened and no more drawing needs to be done on this cell*/
return true;
}
/*Just modify some draw dsc-s*/
/*Make every 2nd row gray*/
if(row % 2) rect_draw_dsc->bg_color = lv_color_hex3(0xccc);
/*Make a specific cell red*/
if(row == 3 && col == 1) rect_draw_dsc->bg_color = LV_COOR_RED;
/*Tell LVGL no drawing happened, and use the modified draw dsc-s to draw the cell*/
return false;
}
What do you think about it?
I know it does not solve your problem with v7 but we’d great to hear if this approach can work for you.
@embeddedt
I’m ok with adding recoloring in v7 but it’s limited only to the text. To check the background color of the cells it can’t be avoided to create many styles for each cell type.