impr: Make title bar backdrop actually a backdrop and not an overlay

This commit is contained in:
WerWolv
2025-05-24 11:57:02 +02:00
parent 39bc165f36
commit 7acc5fc02e

View File

@@ -407,6 +407,42 @@ namespace hex::plugin::builtin {
ON_SCOPE_EXIT { ImGui::PopStyleVar(); };
#endif
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()) {
@@ -447,42 +483,6 @@ namespace hex::plugin::builtin {
menu::endMainMenuBar();
}
menu::enableNativeMenuBar(false);
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);
}
}
void drawToolbar() {