1
0
mirror of synced 2024-11-24 15:50:16 +01:00

impr: Handle hiding of main menu better

This commit is contained in:
WerWolv 2023-12-31 11:39:06 +01:00
parent b76e7ff678
commit b22d90f9ca
2 changed files with 11 additions and 5 deletions

View File

@ -32,7 +32,7 @@ namespace hex {
void setupNativeWindow();
void beginNativeWindowFrame();
void endNativeWindowFrame();
void drawTitleBar() const;
void drawTitleBar();
void frameBegin();
void frame();
@ -61,6 +61,8 @@ namespace hex {
bool m_unlockFrameRate = false;
ImGuiExt::ImHexCustomData m_imguiCustomData;
u32 m_searchBarPosition;
};
}

View File

@ -250,7 +250,7 @@ namespace hex {
}
}
void Window::drawTitleBar() const {
void Window::drawTitleBar() {
auto titleBarHeight = ImGui::GetCurrentWindowRead()->MenuBarHeight();
auto buttonSize = ImVec2(titleBarHeight * 1.5F, titleBarHeight - 1);
@ -260,9 +260,11 @@ namespace hex {
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetColorU32(ImGuiCol_ScrollbarGrabHovered));
const auto windowSize = ImHexApi::System::getMainWindowSize();
const auto searchBoxSize = ImVec2(std::sqrt(windowSize.x) * 14_scaled, titleBarHeight - 3_scaled);
const auto searchBoxSize = ImVec2(windowSize.x / 2.5, titleBarHeight - 3_scaled);
const auto searchBoxPos = ImVec2((windowSize / 2 - searchBoxSize / 2).x, 3_scaled);
m_searchBarPosition = searchBoxPos.x;
// Custom titlebar buttons implementation for borderless window mode
auto &titleBarButtons = ContentRegistry::Interface::impl::getTitleBarButtons();
@ -519,9 +521,11 @@ namespace hex {
}
};
const auto windowWidth = ImHexApi::System::getMainWindowSize().x;
if (windowWidth > 1200_scaled) {
static u32 menuEndPos = 0;
if (menuEndPos < m_searchBarPosition) {
drawMenu();
menuEndPos = ImGui::GetCursorPosX();
} else {
if (ImGui::BeginMenu(ICON_VS_MENU)) {
drawMenu();