1
0
mirror of synced 2024-12-01 02:37:18 +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 setupNativeWindow();
void beginNativeWindowFrame(); void beginNativeWindowFrame();
void endNativeWindowFrame(); void endNativeWindowFrame();
void drawTitleBar() const; void drawTitleBar();
void frameBegin(); void frameBegin();
void frame(); void frame();
@ -61,6 +61,8 @@ namespace hex {
bool m_unlockFrameRate = false; bool m_unlockFrameRate = false;
ImGuiExt::ImHexCustomData m_imguiCustomData; 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 titleBarHeight = ImGui::GetCurrentWindowRead()->MenuBarHeight();
auto buttonSize = ImVec2(titleBarHeight * 1.5F, titleBarHeight - 1); auto buttonSize = ImVec2(titleBarHeight * 1.5F, titleBarHeight - 1);
@ -260,9 +260,11 @@ namespace hex {
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetColorU32(ImGuiCol_ScrollbarGrabHovered)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetColorU32(ImGuiCol_ScrollbarGrabHovered));
const auto windowSize = ImHexApi::System::getMainWindowSize(); 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); const auto searchBoxPos = ImVec2((windowSize / 2 - searchBoxSize / 2).x, 3_scaled);
m_searchBarPosition = searchBoxPos.x;
// Custom titlebar buttons implementation for borderless window mode // Custom titlebar buttons implementation for borderless window mode
auto &titleBarButtons = ContentRegistry::Interface::impl::getTitleBarButtons(); auto &titleBarButtons = ContentRegistry::Interface::impl::getTitleBarButtons();
@ -519,9 +521,11 @@ namespace hex {
} }
}; };
const auto windowWidth = ImHexApi::System::getMainWindowSize().x; static u32 menuEndPos = 0;
if (windowWidth > 1200_scaled) {
if (menuEndPos < m_searchBarPosition) {
drawMenu(); drawMenu();
menuEndPos = ImGui::GetCursorPosX();
} else { } else {
if (ImGui::BeginMenu(ICON_VS_MENU)) { if (ImGui::BeginMenu(ICON_VS_MENU)) {
drawMenu(); drawMenu();