diff --git a/GSR/GSR.cs b/GSR/GSR.cs index f3dabcf..4dda055 100644 --- a/GSR/GSR.cs +++ b/GSR/GSR.cs @@ -359,26 +359,29 @@ public int MainLoop() _mainWindow.NewFrame(); - var statusBarHeight = 0f; + _imGuiMenuBar.RunMenuBar(); + // position of the emu window is below the menu bar + var barHeight = ImGui.GetFrameHeight(); + + var statusBarHeight = 0.0f; if (!_config.HideStatusBar) { _osdManager.RunStatusBar(); - statusBarHeight = ImGui.GetFrameHeight(); + statusBarHeight = barHeight; } var vp = ImGui.GetMainViewport(); - ImGui.SetNextWindowPos(vp.Pos); - ImGui.SetNextWindowSize(vp.Size - new Vector2(0, statusBarHeight)); + ImGui.SetNextWindowPos(vp.Pos + new Vector2(0, barHeight)); + ImGui.SetNextWindowSize(vp.Size - new Vector2(0, barHeight + statusBarHeight)); ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0); ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0); ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0)); - if (ImGui.Begin("GSR", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoBringToFrontOnFocus)) + if (ImGui.Begin("GSR", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoBringToFrontOnFocus)) { DrawEmu(); ImGui.PopStyleVar(3); - _imGuiMenuBar.RunMenuBar(); _imGuiModals.RunModals(); } else diff --git a/GSR/Gui/ImGuiMenuBar.cs b/GSR/Gui/ImGuiMenuBar.cs index abbf3ba..1448053 100644 --- a/GSR/Gui/ImGuiMenuBar.cs +++ b/GSR/Gui/ImGuiMenuBar.cs @@ -15,7 +15,7 @@ internal sealed class ImGuiMenuBar(Config config, EmuManager emuManager, RomLoad { public void RunMenuBar() { - if (ImGui.BeginMenuBar()) + if (ImGui.BeginMainMenuBar()) { if (ImGui.BeginMenu("File")) { @@ -233,7 +233,7 @@ public void RunMenuBar() ImGui.EndMenu(); } - ImGui.EndMenuBar(); + ImGui.EndMainMenuBar(); } } } diff --git a/GSR/Gui/ImGuiWindow.cs b/GSR/Gui/ImGuiWindow.cs index 798992f..f0b929e 100644 --- a/GSR/Gui/ImGuiWindow.cs +++ b/GSR/Gui/ImGuiWindow.cs @@ -554,6 +554,10 @@ public ImGuiWindow(string windowName, Config config, bool isMainWindow) // this doesn't matter too much in dark mode // but without a border light mode is terrible style.FrameBorderSize = 1; + + // this must be done in order to scaling to properly take effect for e.g. GetFrameHeight() calls + ImGui.NewFrame(); + ImGui.EndFrame(); } catch { @@ -922,20 +926,11 @@ public void NewFrame() SetFont(dpiScale); _dpiScale = dpiScale; - // can't use SetWindowSize, ImGui.GetFrameHeight() is not up to date - if (!_isFullscreen) - { - var newWidth = _lastWidth * _lastScale; - var newHeight = _lastHeight * _lastScale; - // nasty hack to account for ImGui.GetFrameHeight() not being up to date - var frameHeight = io.Fonts.Fonts[0].FontSize + ImGui.GetStyle().FramePadding.Y * 2.0f; - newHeight += (int)(frameHeight * _lastBars); - SdlRenderer.GetRendererOutputSize(out var lastDisplayW, out var lastDisplayH); - SDL_GetWindowSize(SdlWindow, out var lastWindowWidth, out var lastWindowHeight); - newWidth = newWidth * lastWindowWidth / lastDisplayW; - newHeight = newHeight * lastWindowHeight / lastDisplayH; - SDL_SetWindowSize(SdlWindow, newWidth, newHeight); - } + // get ImGui.GetFrameHeight() up to date (important for SetWindowSize) + ImGui.NewFrame(); + ImGui.EndFrame(); + + SetWindowSize(_lastWidth, _lastHeight, _lastScale, _lastBars); } }