Tables: Angled headers: improve clipping of text since multi-line labels makes clipping issues visible. (#6917)

This commit is contained in:
ocornut 2024-02-19 20:49:52 +01:00
parent 405e54ebd5
commit c16043c1d5

View File

@ -3252,9 +3252,11 @@ void ImGui::TableAngledHeadersRowEx(float angle, float max_label_width)
if (label_name_eol == NULL) if (label_name_eol == NULL)
label_name_eol = label_name_end; label_name_eol = label_name_end;
// FIXME: Individual line clipping for right-most column is broken for negative angles.
ImVec2 label_size = CalcTextSize(label_name, label_name_eol); ImVec2 label_size = CalcTextSize(label_name, label_name_eol);
float clip_width = max_label_width - padding.y; // Using padding.y*2.0f would be symetrical but hide more text. float clip_width = max_label_width - padding.y; // Using padding.y*2.0f would be symetrical but hide more text.
ImRect clip_r(window->ClipRect.Min, window->ClipRect.Min + ImVec2(clip_width, label_size.y)); float clip_height = ImMin(label_size.y, column->ClipRect.Max.x - column->WorkMinX - line_off_curr_x);
ImRect clip_r(window->ClipRect.Min, window->ClipRect.Min + ImVec2(clip_width, clip_height));
int vtx_idx_begin = draw_list->_VtxCurrentIdx; int vtx_idx_begin = draw_list->_VtxCurrentIdx;
RenderTextEllipsis(draw_list, clip_r.Min, clip_r.Max, clip_r.Max.x, clip_r.Max.x, label_name, label_name_eol, &label_size); RenderTextEllipsis(draw_list, clip_r.Min, clip_r.Max, clip_r.Max.x, clip_r.Max.x, label_name, label_name_eol, &label_size);
int vtx_idx_end = draw_list->_VtxCurrentIdx; int vtx_idx_end = draw_list->_VtxCurrentIdx;