Table cell color overlaping on fixed header #7041

Closed
opened 2023-11-21 12:29:38 +00:00 by MayitaMayoso · 0 comments
MayitaMayoso commented 2023-11-21 12:29:38 +00:00 (Migrated from github.com)
Dear ImGui 1.89.7 WIP (18967)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201703
define: __linux__
define: __GNUC__=8
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000041
 NavEnableKeyboard
 DockingEnable
io.ConfigViewportsNoTaskBarIcon
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000140E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 2048,4096
io.DisplaySize: 2560.00,1362.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Version/Branch of Dear ImGui:

Version: 1.89.7
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glfw.h + imgui_impl_opengl3.h
Compiler: GNUC
Operating System: Debian 10

My Issue/Question:

Hello! I have a table where a column is a check that tints into red or green. So I just found myself in a situation where the cell background color is drawn above the fixed header when I scroll.
image

So far my code simply creates the table, defines the columns then fill the cells with a particular color:

if (ImGui::BeginTable("##Table", 6, TableFlags))
{
	ImGui::SetWindowFontScale(1.3);
	ImGui::TableSetupColumn("Game", ImGuiTableColumnFlags_WidthFixed, Size.x * 0.2f);
	ImGui::TableSetupColumn("LoadJson", ImGuiTableColumnFlags_WidthFixed, Size.x * 0.05f);
	ImGui::TableSetupColumn("LGM", ImGuiTableColumnFlags_WidthFixed, Size.x * 0.05f);
	ImGui::TableSetupColumn("FastTest", ImGuiTableColumnFlags_WidthFixed, Size.x * 0.05f);
	ImGui::TableSetupColumn("Consumer", ImGuiTableColumnFlags_WidthFixed, Size.x * 0.05f);
	ImGui::TableSetupColumn("Error", ImGuiTableColumnFlags_WidthStretch);
	ImGui::TableSetupScrollFreeze(0, 1);
	ImGui::TableHeadersRow();
	ImGui::SetWindowFontScale(1);

	for (auto& File : std::filesystem::directory_iterator(Settings::DefaultSlotsDefinitionPath))
	{
		RenderItem(File.path());
	}

	ImGui::EndTable();
}

RenderItem():

ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%s", File.filename().c_str());
ImGui::TableNextColumn();
ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ImGui::ColorConvertFloat4ToU32(ImVec4(.9, .0, .0, .5)));
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetColumnWidth() / 2 - 10);
ImGui::Text(ICON_MD_CHECK);
ImGui::TableNextColumn();
...

On the rest of the code I have some styling elements like changing the padding, etc.. that I decided not to copy so I keep this post from being too large. Header color alpha thought is 100% so I don't think that's the problem.

``` Dear ImGui 1.89.7 WIP (18967) -------------------------------- sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20 define: __cplusplus=201703 define: __linux__ define: __GNUC__=8 define: IMGUI_HAS_VIEWPORT define: IMGUI_HAS_DOCK -------------------------------- io.BackendPlatformName: imgui_impl_glfw io.BackendRendererName: imgui_impl_opengl3 io.ConfigFlags: 0x00000041 NavEnableKeyboard DockingEnable io.ConfigViewportsNoTaskBarIcon io.ConfigViewportsNoDecoration io.ConfigInputTextCursorBlink io.ConfigWindowsResizeFromEdges io.ConfigMemoryCompactTimer = 60.0 io.BackendFlags: 0x0000140E HasMouseCursors HasSetMousePos PlatformHasViewports RendererHasVtxOffset RendererHasViewports -------------------------------- io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 2048,4096 io.DisplaySize: 2560.00,1362.00 io.DisplayFramebufferScale: 1.00,1.00 -------------------------------- style.WindowPadding: 8.00,8.00 style.WindowBorderSize: 1.00 style.FramePadding: 4.00,3.00 style.FrameRounding: 0.00 style.FrameBorderSize: 0.00 style.ItemSpacing: 8.00,4.00 style.ItemInnerSpacing: 4.00,4.00 ``` **Version/Branch of Dear ImGui:** Version: 1.89.7 Branch: docking **Back-end/Renderer/Compiler/OS** Back-ends: imgui_impl_glfw.h + imgui_impl_opengl3.h Compiler: GNUC Operating System: Debian 10 **My Issue/Question:** Hello! I have a table where a column is a check that tints into red or green. So I just found myself in a situation where the cell background color is drawn above the fixed header when I scroll. ![image](https://github.com/ocornut/imgui/assets/45299117/7f15c990-7b54-4b41-823a-ae1e598d4984) So far my code simply creates the table, defines the columns then fill the cells with a particular color: ```c++ if (ImGui::BeginTable("##Table", 6, TableFlags)) { ImGui::SetWindowFontScale(1.3); ImGui::TableSetupColumn("Game", ImGuiTableColumnFlags_WidthFixed, Size.x * 0.2f); ImGui::TableSetupColumn("LoadJson", ImGuiTableColumnFlags_WidthFixed, Size.x * 0.05f); ImGui::TableSetupColumn("LGM", ImGuiTableColumnFlags_WidthFixed, Size.x * 0.05f); ImGui::TableSetupColumn("FastTest", ImGuiTableColumnFlags_WidthFixed, Size.x * 0.05f); ImGui::TableSetupColumn("Consumer", ImGuiTableColumnFlags_WidthFixed, Size.x * 0.05f); ImGui::TableSetupColumn("Error", ImGuiTableColumnFlags_WidthStretch); ImGui::TableSetupScrollFreeze(0, 1); ImGui::TableHeadersRow(); ImGui::SetWindowFontScale(1); for (auto& File : std::filesystem::directory_iterator(Settings::DefaultSlotsDefinitionPath)) { RenderItem(File.path()); } ImGui::EndTable(); } ``` RenderItem(): ```c++ ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Text("%s", File.filename().c_str()); ImGui::TableNextColumn(); ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ImGui::ColorConvertFloat4ToU32(ImVec4(.9, .0, .0, .5))); ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetColumnWidth() / 2 - 10); ImGui::Text(ICON_MD_CHECK); ImGui::TableNextColumn(); ... ``` On the rest of the code I have some styling elements like changing the padding, etc.. that I decided not to copy so I keep this post from being too large. Header color alpha thought is 100% so I don't think that's the problem.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#7041
No description provided.