mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-13 04:39:02 +08:00
Tables: fixed angled headers with frozen columns.
This commit is contained in:
parent
f7fc186408
commit
83c4336828
@ -5275,12 +5275,14 @@ static void ShowDemoWindowTables()
|
|||||||
|
|
||||||
static ImGuiTableFlags table_flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerH | ImGuiTableFlags_Hideable | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_HighlightHoveredColumn;
|
static ImGuiTableFlags table_flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerH | ImGuiTableFlags_Hideable | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_HighlightHoveredColumn;
|
||||||
static bool bools[columns_count * rows_count] = {}; // Dummy storage selection storage
|
static bool bools[columns_count * rows_count] = {}; // Dummy storage selection storage
|
||||||
|
static int frozen_cols = 1;
|
||||||
static int frozen_rows = 2;
|
static int frozen_rows = 2;
|
||||||
ImGui::CheckboxFlags("_ScrollX", &table_flags, ImGuiTableFlags_ScrollX);
|
ImGui::CheckboxFlags("_ScrollX", &table_flags, ImGuiTableFlags_ScrollX);
|
||||||
ImGui::CheckboxFlags("_ScrollY", &table_flags, ImGuiTableFlags_ScrollY);
|
ImGui::CheckboxFlags("_ScrollY", &table_flags, ImGuiTableFlags_ScrollY);
|
||||||
ImGui::CheckboxFlags("_NoBordersInBody", &table_flags, ImGuiTableFlags_NoBordersInBody);
|
ImGui::CheckboxFlags("_NoBordersInBody", &table_flags, ImGuiTableFlags_NoBordersInBody);
|
||||||
ImGui::CheckboxFlags("_HighlightHoveredColumn", &table_flags, ImGuiTableFlags_HighlightHoveredColumn);
|
ImGui::CheckboxFlags("_HighlightHoveredColumn", &table_flags, ImGuiTableFlags_HighlightHoveredColumn);
|
||||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
||||||
|
ImGui::SliderInt("Frozen columns", &frozen_cols, 0, 2);
|
||||||
ImGui::SliderInt("Frozen rows", &frozen_rows, 0, 2);
|
ImGui::SliderInt("Frozen rows", &frozen_rows, 0, 2);
|
||||||
|
|
||||||
if (ImGui::BeginTable("table_angled_headers", columns_count, table_flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 12)))
|
if (ImGui::BeginTable("table_angled_headers", columns_count, table_flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 12)))
|
||||||
@ -5288,7 +5290,7 @@ static void ShowDemoWindowTables()
|
|||||||
ImGui::TableSetupColumn(column_names[0], ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_NoReorder);
|
ImGui::TableSetupColumn(column_names[0], ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_NoReorder);
|
||||||
for (int n = 1; n < columns_count; n++)
|
for (int n = 1; n < columns_count; n++)
|
||||||
ImGui::TableSetupColumn(column_names[n], ImGuiTableColumnFlags_AngledHeader | ImGuiTableColumnFlags_WidthFixed);
|
ImGui::TableSetupColumn(column_names[n], ImGuiTableColumnFlags_AngledHeader | ImGuiTableColumnFlags_WidthFixed);
|
||||||
ImGui::TableSetupScrollFreeze(0, frozen_rows);
|
ImGui::TableSetupScrollFreeze(frozen_cols, frozen_rows);
|
||||||
|
|
||||||
ImGui::TableAngledHeadersRow(); // Draw angled headers for all columns with the ImGuiTableColumnFlags_AngledHeader flag.
|
ImGui::TableAngledHeadersRow(); // Draw angled headers for all columns with the ImGuiTableColumnFlags_AngledHeader flag.
|
||||||
ImGui::TableHeadersRow(); // Draw remaining headers and allow access to context-menu and other functions.
|
ImGui::TableHeadersRow(); // Draw remaining headers and allow access to context-menu and other functions.
|
||||||
|
@ -3166,9 +3166,13 @@ void ImGui::TableAngledHeadersRowEx(float angle, float max_label_width)
|
|||||||
TableNextRow(ImGuiTableRowFlags_Headers, row_height);
|
TableNextRow(ImGuiTableRowFlags_Headers, row_height);
|
||||||
TableNextColumn();
|
TableNextColumn();
|
||||||
table->DrawSplitter->SetCurrentChannel(draw_list, TABLE_DRAW_CHANNEL_BG0);
|
table->DrawSplitter->SetCurrentChannel(draw_list, TABLE_DRAW_CHANNEL_BG0);
|
||||||
PushClipRect(table->BgClipRect.Min, table->BgClipRect.Max, false); // Span all columns
|
float clip_rect_min_x = table->BgClipRect.Min.x;
|
||||||
|
if (table->FreezeColumnsCount > 0)
|
||||||
|
clip_rect_min_x = ImMax(clip_rect_min_x, table->Columns[table->FreezeColumnsCount - 1].MaxX);
|
||||||
TableSetBgColor(ImGuiTableBgTarget_RowBg0, 0); // Cancel
|
TableSetBgColor(ImGuiTableBgTarget_RowBg0, 0); // Cancel
|
||||||
|
PushClipRect(table->BgClipRect.Min, table->BgClipRect.Max, false); // Span all columns
|
||||||
draw_list->AddRectFilled(table->BgClipRect.Min, table->BgClipRect.Max, GetColorU32(ImGuiCol_TableHeaderBg, 0.25f)); // FIXME-STYLE: Change row background with an arbitrary color.
|
draw_list->AddRectFilled(table->BgClipRect.Min, table->BgClipRect.Max, GetColorU32(ImGuiCol_TableHeaderBg, 0.25f)); // FIXME-STYLE: Change row background with an arbitrary color.
|
||||||
|
PushClipRect(ImVec2(clip_rect_min_x, table->BgClipRect.Min.y), table->BgClipRect.Max, true); // Span all columns
|
||||||
|
|
||||||
const ImRect row_r(table->WorkRect.Min.x, table->BgClipRect.Min.y, table->WorkRect.Max.x, window->DC.CursorPos.y + row_height);
|
const ImRect row_r(table->WorkRect.Min.x, table->BgClipRect.Min.y, table->WorkRect.Max.x, window->DC.CursorPos.y + row_height);
|
||||||
const ImGuiID row_id = GetID("##AngledHeaders");
|
const ImGuiID row_id = GetID("##AngledHeaders");
|
||||||
@ -3230,6 +3234,7 @@ void ImGui::TableAngledHeadersRowEx(float angle, float max_label_width)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PopClipRect();
|
PopClipRect();
|
||||||
|
PopClipRect();
|
||||||
table->TempData->AngledheadersExtraWidth = ImMax(0.0f, max_x - table->Columns[table->RightMostEnabledColumn].MaxX);
|
table->TempData->AngledheadersExtraWidth = ImMax(0.0f, max_x - table->Columns[table->RightMostEnabledColumn].MaxX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user