Tables: create a separate background draw channel for rows below the frozen line.

This commit is contained in:
ocornut
2020-10-30 20:30:53 +01:00
parent fae362fd0b
commit 557253e776
3 changed files with 32 additions and 17 deletions

View File

@ -3803,6 +3803,7 @@ static void ShowDemoWindowTables()
static int freeze_rows = 1;
PushStyleCompact();
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", (unsigned int*)&flags, ImGuiTableFlags_ScrollX);
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", (unsigned int*)&flags, ImGuiTableFlags_ScrollY);
ImGui::SetNextItemWidth(ImGui::GetFrameHeight());
ImGui::DragInt("freeze_cols", &freeze_cols, 0.2f, 0, 9, NULL, ImGuiSliderFlags_NoInput);
@ -4070,14 +4071,14 @@ static void ShowDemoWindowTables()
ImGui::SetNextItemOpen(open_action != 0);
if (ImGui::TreeNode("Background color"))
{
static ImGuiTableFlags table_flags = ImGuiTableFlags_RowBg;
static ImGuiTableFlags flags = ImGuiTableFlags_RowBg;
static int row_bg_type = 1;
static int row_bg_target = 1;
static int cell_bg_type = 1;
PushStyleCompact();
ImGui::CheckboxFlags("ImGuiTableFlags_Borders", (unsigned int*)&table_flags, ImGuiTableFlags_Borders);
ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", (unsigned int*)&table_flags, ImGuiTableFlags_RowBg);
ImGui::CheckboxFlags("ImGuiTableFlags_Borders", (unsigned int*)&flags, ImGuiTableFlags_Borders);
ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", (unsigned int*)&flags, ImGuiTableFlags_RowBg);
ImGui::SameLine(); HelpMarker("ImGuiTableFlags_RowBg automatically sets RowBg0 to alternative colors pulled from the Style.");
ImGui::Combo("row bg type", (int*)&row_bg_type, "None\0Red\0Gradient\0");
ImGui::Combo("row bg target", (int*)&row_bg_target, "RowBg0\0RowBg1\0"); ImGui::SameLine(); HelpMarker("Target RowBg0 to override the alternating odd/even colors,\nTarget RowBg1 to blend with them.");
@ -4087,7 +4088,7 @@ static void ShowDemoWindowTables()
IM_ASSERT(cell_bg_type >= 0 && cell_bg_type <= 1);
PopStyleCompact();
if (ImGui::BeginTable("##Table", 5, table_flags))
if (ImGui::BeginTable("##Table", 5, flags))
{
for (int row = 0; row < 6; row++)
{