fix: Menu bar being gone on the Web build

This commit is contained in:
WerWolv
2025-05-24 23:10:53 +02:00
parent 04f817c042
commit d26bcc1abe

View File

@@ -402,8 +402,6 @@ namespace hex::plugin::builtin {
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0F);
ImGui::SetNextWindowScroll(ImVec2(0, 0));
auto window = ImHexApi::System::getMainWindowHandle();
#if defined(OS_MACOS)
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(ImGui::GetStyle().FramePadding.x, 8_scaled));
ON_SCOPE_EXIT { ImGui::PopStyleVar(); };
@@ -412,39 +410,10 @@ namespace hex::plugin::builtin {
if (ImGui::BeginMainMenuBar()) {
drawTitleBarBackDrop();
ImGui::Dummy({});
ImGui::PopStyleVar(2);
drawTitleBar();
#if defined(OS_MACOS)
if (ImHexApi::System::isBorderlessWindowModeEnabled()) {
const auto windowSize = ImHexApi::System::getMainWindowSize();
const auto menuUnderlaySize = ImVec2(windowSize.x, ImGui::GetCurrentWindowRead()->MenuBarHeight);
ImGui::SetCursorPos(ImVec2());
// Prevent window from being moved unless title bar is hovered
if (!ImGui::IsAnyItemHovered()) {
const auto cursorPos = ImGui::GetCursorScreenPos();
if (ImGui::IsMouseHoveringRect(cursorPos, cursorPos + menuUnderlaySize) && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
macosHandleTitlebarDoubleClickGesture(window);
}
macosSetWindowMovable(window, true);
} else {
macosSetWindowMovable(window, false);
}
}
#endif
ImGui::EndMainMenuBar();
} else {
ImGui::PopStyleVar(2);
}
auto window = ImHexApi::System::getMainWindowHandle();
menu::enableNativeMenuBar(s_useNativeMenuBar);
if (menu::beginMainMenuBar()) {
if (ImHexApi::System::isBorderlessWindowModeEnabled()) {
@@ -484,6 +453,41 @@ namespace hex::plugin::builtin {
menu::endMainMenuBar();
}
menu::enableNativeMenuBar(false);
if (ImGui::BeginMainMenuBar()) {
ImGui::Dummy({});
ImGui::PopStyleVar(2);
drawTitleBar();
#if defined(OS_MACOS)
if (ImHexApi::System::isBorderlessWindowModeEnabled()) {
const auto windowSize = ImHexApi::System::getMainWindowSize();
const auto menuUnderlaySize = ImVec2(windowSize.x, ImGui::GetCurrentWindowRead()->MenuBarHeight);
ImGui::SetCursorPos(ImVec2());
// Prevent window from being moved unless title bar is hovered
if (!ImGui::IsAnyItemHovered()) {
const auto cursorPos = ImGui::GetCursorScreenPos();
if (ImGui::IsMouseHoveringRect(cursorPos, cursorPos + menuUnderlaySize) && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
macosHandleTitlebarDoubleClickGesture(window);
}
macosSetWindowMovable(window, true);
} else {
macosSetWindowMovable(window, false);
}
}
#endif
ImGui::EndMainMenuBar();
} else {
ImGui::PopStyleVar(2);
}
}
void drawToolbar() {