Description
I have a table where I want to set a header row in a different larger font size. However as the main table has font size 18 the first row (using font size 24) is too short.
What MCU/Processor/Board and compiler are you using?
Linux/SDL and Arduino
What LVGL version are you using?
8.3.4
What do you want to achieve?
I would like to change the header row to show the text without being chopped off.
What have you tried so far?
Setting the font of the table to 24 then overriding the rows > 0 to use font 18 but that causes other weird behavior including wrapping where not applicable.
Code to reproduce
void create_tabCalendar(lv_obj_t * parent)
{
calendartable = lv_table_create(parent);
//8.1 to fix
//lv_obj_set_drag_parent(calendartable, true);
lv_obj_set_style_radius(calendartable, 10, 0);
lv_obj_set_style_clip_corner(calendartable, true, 0);
lv_obj_set_pos(calendartable, 40, -13);
//lv_obj_set_style_pad_bottom(calendartable, -5, LV_PART_MAIN);
lv_obj_set_style_pad_bottom(parent, 5, LV_PART_MAIN);
//lv_obj_clear_flag( parent, LV_OBJ_FLAG_SCROLLABLE );
lv_obj_set_style_border_color(calendartable, MAIN_BORDER_COLOUR, LV_PART_MAIN);
lv_obj_set_style_border_color(calendartable, MAIN_BORDER_COLOUR, LV_PART_ITEMS);
lv_obj_set_style_pad_top(calendartable, 5, LV_PART_ITEMS);
lv_obj_set_style_pad_bottom(calendartable, 5, LV_PART_ITEMS);
lv_obj_set_style_pad_left(calendartable, 10, LV_PART_ITEMS);
lv_obj_set_style_pad_right(calendartable, 2, LV_PART_ITEMS);
lv_table_set_col_cnt(calendartable, 4);
lv_table_set_row_cnt(calendartable, calendarRows+1);
lv_table_set_col_width(calendartable, 0, 260);
lv_table_set_col_width(calendartable, 1, 340);
lv_table_set_col_width(calendartable, 2, 150);
lv_table_set_col_width(calendartable, 3, 150);
lv_obj_set_style_text_font(calendartable, &lv_font_montserrat_18, 0);
lv_table_set_cell_value(calendartable, 0, 0, "Calendar");
lv_table_set_cell_value(calendartable, 0, 1, "Summary");
lv_table_set_cell_value(calendartable, 0, 2, "Start");
lv_table_set_cell_value(calendartable, 0, 3, "End");
lv_obj_add_event_cb(calendartable, draw_part_calendar_event_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
}
static void draw_part_calendar_event_cb(lv_event_t * e)
{
lv_obj_t * obj = lv_event_get_target(e);
lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e);
/*If the cells are drawn...*/
if(dsc->part == LV_PART_ITEMS) {
uint32_t row = dsc->id / lv_table_get_col_cnt(obj);
dsc->rect_dsc->bg_color = lv_color_hex(MAIN_BG_COLOUR);
if(row == 0) {
dsc->label_dsc->font = &lv_font_montserrat_24;
}
}
}
Screenshot and/or video
@bader / @kisvegabor any help you can give would be greatly appreciated.
Thanks in advance!