|
1 | | -// dear imgui, v1.91b |
| 1 | +// dear imgui, v1.92.0 WIP |
2 | 2 | // (tables and columns code) |
3 | 3 |
|
4 | 4 | /* |
@@ -451,6 +451,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG |
451 | 451 | // But at this point we do NOT have a correct value for .Max.y (unless a height has been explicitly passed in). It will only be updated in EndTable(). |
452 | 452 | table->WorkRect = table->OuterRect = table->InnerRect = outer_rect; |
453 | 453 | table->HasScrollbarYPrev = table->HasScrollbarYCurr = false; |
| 454 | + table->InnerWindow->DC.TreeDepth++; // This is designed to always linking ImGuiTreeNodeFlags_DrawLines linking accross a table |
454 | 455 | } |
455 | 456 |
|
456 | 457 | // Push a standardized ID for both child-using and not-child-using tables |
@@ -1510,6 +1511,7 @@ void ImGui::EndTable() |
1510 | 1511 | } |
1511 | 1512 | else |
1512 | 1513 | { |
| 1514 | + table->InnerWindow->DC.TreeDepth--; |
1513 | 1515 | ItemSize(table->OuterRect.GetSize()); |
1514 | 1516 | ItemAdd(table->OuterRect, 0); |
1515 | 1517 | } |
@@ -1951,7 +1953,10 @@ void ImGui::TableEndRow(ImGuiTable* table) |
1951 | 1953 | IM_ASSERT(table->IsInsideRow); |
1952 | 1954 |
|
1953 | 1955 | if (table->CurrentColumn != -1) |
| 1956 | + { |
1954 | 1957 | TableEndCell(table); |
| 1958 | + table->CurrentColumn = -1; |
| 1959 | + } |
1955 | 1960 |
|
1956 | 1961 | // Logging |
1957 | 1962 | if (g.LogEnabled) |
@@ -2191,6 +2196,7 @@ void ImGui::TableBeginCell(ImGuiTable* table, int column_n) |
2191 | 2196 | g.LastItemData.StatusFlags = 0; |
2192 | 2197 | } |
2193 | 2198 |
|
| 2199 | + // Also see TablePushColumnChannel() |
2194 | 2200 | if (table->Flags & ImGuiTableFlags_NoClip) |
2195 | 2201 | { |
2196 | 2202 | // FIXME: if we end up drawing all borders/bg in EndTable, could remove this and just assert that channel hasn't changed. |
@@ -2464,10 +2470,38 @@ void ImGui::TablePopBackgroundChannel() |
2464 | 2470 | ImGuiContext& g = *GImGui; |
2465 | 2471 | ImGuiWindow* window = g.CurrentWindow; |
2466 | 2472 | ImGuiTable* table = g.CurrentTable; |
2467 | | - ImGuiTableColumn* column = &table->Columns[table->CurrentColumn]; |
2468 | 2473 |
|
2469 | 2474 | // Optimization: avoid PopClipRect() + SetCurrentChannel() |
2470 | 2475 | SetWindowClipRectBeforeSetChannel(window, table->HostBackupInnerClipRect); |
| 2476 | + table->DrawSplitter->SetCurrentChannel(window->DrawList, table->Columns[table->CurrentColumn].DrawChannelCurrent); |
| 2477 | +} |
| 2478 | + |
| 2479 | +// Also see TableBeginCell() |
| 2480 | +void ImGui::TablePushColumnChannel(int column_n) |
| 2481 | +{ |
| 2482 | + ImGuiContext& g = *GImGui; |
| 2483 | + ImGuiTable* table = g.CurrentTable; |
| 2484 | + |
| 2485 | + // Optimization: avoid SetCurrentChannel() + PushClipRect() |
| 2486 | + if (table->Flags & ImGuiTableFlags_NoClip) |
| 2487 | + return; |
| 2488 | + ImGuiWindow* window = g.CurrentWindow; |
| 2489 | + const ImGuiTableColumn* column = &table->Columns[column_n]; |
| 2490 | + SetWindowClipRectBeforeSetChannel(window, column->ClipRect); |
| 2491 | + table->DrawSplitter->SetCurrentChannel(window->DrawList, column->DrawChannelCurrent); |
| 2492 | +} |
| 2493 | + |
| 2494 | +void ImGui::TablePopColumnChannel() |
| 2495 | +{ |
| 2496 | + ImGuiContext& g = *GImGui; |
| 2497 | + ImGuiTable* table = g.CurrentTable; |
| 2498 | + |
| 2499 | + // Optimization: avoid PopClipRect() + SetCurrentChannel() |
| 2500 | + if ((table->Flags & ImGuiTableFlags_NoClip) || (table->CurrentColumn == -1)) // Calling TreePop() after TableNextRow() is supported. |
| 2501 | + return; |
| 2502 | + ImGuiWindow* window = g.CurrentWindow; |
| 2503 | + const ImGuiTableColumn* column = &table->Columns[table->CurrentColumn]; |
| 2504 | + SetWindowClipRectBeforeSetChannel(window, column->ClipRect); |
2471 | 2505 | table->DrawSplitter->SetCurrentChannel(window->DrawList, column->DrawChannelCurrent); |
2472 | 2506 | } |
2473 | 2507 |
|
@@ -3244,7 +3278,7 @@ void ImGui::TableHeader(const char* label) |
3244 | 3278 | // Render clipped label. Clipping here ensure that in the majority of situations, all our header cells will |
3245 | 3279 | // be merged into a single draw call. |
3246 | 3280 | //window->DrawList->AddCircleFilled(ImVec2(ellipsis_max, label_pos.y), 40, IM_COL32_WHITE); |
3247 | | - RenderTextEllipsis(window->DrawList, label_pos, ImVec2(ellipsis_max, label_pos.y + label_height + g.Style.FramePadding.y), ellipsis_max, ellipsis_max, label, label_end, &label_size); |
| 3281 | + RenderTextEllipsis(window->DrawList, label_pos, ImVec2(ellipsis_max, bb.Max.y), ellipsis_max, label, label_end, &label_size); |
3248 | 3282 |
|
3249 | 3283 | const bool text_clipped = label_size.x > (ellipsis_max - label_pos.x); |
3250 | 3284 | if (text_clipped && hovered && g.ActiveId == 0) |
@@ -3341,7 +3375,7 @@ void ImGui::TableAngledHeadersRowEx(ImGuiID row_id, float angle, float max_label |
3341 | 3375 | ButtonBehavior(row_r, row_id, NULL, NULL); |
3342 | 3376 | KeepAliveID(row_id); |
3343 | 3377 |
|
3344 | | - const float ascent_scaled = g.Font->Ascent * g.FontScale; // FIXME: Standardize those scaling factors better |
| 3378 | + const float ascent_scaled = g.FontBaked->Ascent * g.FontBakedScale; // FIXME: Standardize those scaling factors better |
3345 | 3379 | const float line_off_for_ascent_x = (ImMax((g.FontSize - ascent_scaled) * 0.5f, 0.0f) / -sin_a) * (flip_label ? -1.0f : 1.0f); |
3346 | 3380 | const ImVec2 padding = g.Style.CellPadding; // We will always use swapped component |
3347 | 3381 | const ImVec2 align = g.Style.TableAngledHeadersTextAlign; |
@@ -3396,7 +3430,7 @@ void ImGui::TableAngledHeadersRowEx(ImGuiID row_id, float angle, float max_label |
3396 | 3430 | ImRect clip_r(window->ClipRect.Min, window->ClipRect.Min + ImVec2(clip_width, clip_height)); |
3397 | 3431 | int vtx_idx_begin = draw_list->_VtxCurrentIdx; |
3398 | 3432 | PushStyleColor(ImGuiCol_Text, request->TextColor); |
3399 | | - RenderTextEllipsis(draw_list, clip_r.Min, clip_r.Max, clip_r.Max.x, clip_r.Max.x, label_name, label_name_eol, &label_size); |
| 3433 | + RenderTextEllipsis(draw_list, clip_r.Min, clip_r.Max, clip_r.Max.x, label_name, label_name_eol, &label_size); |
3400 | 3434 | PopStyleColor(); |
3401 | 3435 | int vtx_idx_end = draw_list->_VtxCurrentIdx; |
3402 | 3436 |
|
|
0 commit comments