Fix menu header width and scrollbar calculations. (#5975)

This commit is contained in:
Malkierian
2025-11-24 07:00:37 -07:00
committed by GitHub
parent c68c8f1284
commit 2ee4e70b9a

View File

@@ -650,18 +650,15 @@ void Menu::DrawElement() {
ImVec2 pos = window->DC.CursorPos; ImVec2 pos = window->DC.CursorPos;
float centerX = pos.x + windowWidth / 2 - (style.ItemSpacing.x * (menuEntries.size() + 1)); float centerX = pos.x + windowWidth / 2 - (style.ItemSpacing.x * (menuEntries.size() + 1));
std::vector<ImVec2> headerSizes; std::vector<ImVec2> headerSizes;
float headerWidth = style.ItemSpacing.x + 20; float headerWidth = 0.0f;
bool headerSearch = !CVarGetInteger(CVAR_SETTING("Menu.SidebarSearch"), 0); bool headerSearch = !CVarGetInteger(CVAR_SETTING("Menu.SidebarSearch"), 0);
if (headerSearch) { if (headerSearch) {
headerWidth += 200.0f + style.ItemSpacing.x + style.FramePadding.x; headerWidth += 200.0f;
} }
for (auto& label : menuOrder) { for (auto& label : menuOrder) {
ImVec2 size = ImGui::CalcTextSize(label.c_str()); ImVec2 size = ImGui::CalcTextSize(label.c_str());
headerSizes.push_back(size); headerSizes.push_back(size);
headerWidth += size.x + style.FramePadding.x * 2; headerWidth += size.x + style.FramePadding.x * 2 + style.ItemSpacing.x;
if (label == headerIndex) {
headerWidth += style.ItemSpacing.x;
}
} }
// Full screen menu with widths below 1280, heights below 800. // Full screen menu with widths below 1280, heights below 800.