From a7265febdff011dae28fd90457af719bc0f538fc Mon Sep 17 00:00:00 2001 From: OmniaX-Dev Date: Mon, 27 Apr 2026 07:21:23 +0200 Subject: [PATCH] Fixed scaling related bug --- other/TODO.txt | 1 + src/ogfx/gui/ToolBar.cpp | 2 +- src/ogfx/gui/Window.cpp | 2 +- src/ogfx/gui/Window.hpp | 4 ++-- src/test/GuiTest.cpp | 1 + 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/other/TODO.txt b/other/TODO.txt index e15de79..2037977 100644 --- a/other/TODO.txt +++ b/other/TODO.txt @@ -46,6 +46,7 @@ XML Layout file? Add Hex Editor widget Add Message Boxes FIX: Widget Content extents increasing negatively not showing scrollbars +FIX: Button state getting hung after showing an openFileDialog diff --git a/src/ogfx/gui/ToolBar.cpp b/src/ogfx/gui/ToolBar.cpp index 36ef386..5ce2fd0 100644 --- a/src/ogfx/gui/ToolBar.cpp +++ b/src/ogfx/gui/ToolBar.cpp @@ -74,7 +74,7 @@ namespace ogfx h = m_height; f32 offset_y = 0; if (isStatusBar()) - offset_y = (win.getWindowHeight() / win.getScaleFactor()) - m_height; + offset_y = win.getWindowHeight() - m_height; else if (win.getMenuBar().isVisible()) offset_y += win.getMenuBar().geth(); sety(offset_y); diff --git a/src/ogfx/gui/Window.cpp b/src/ogfx/gui/Window.cpp index 3578b85..ccda826 100644 --- a/src/ogfx/gui/Window.cpp +++ b/src/ogfx/gui/Window.cpp @@ -242,7 +242,7 @@ namespace ogfx f32 s = getScaleFactor(); auto state = getWindowState(); if (!state.maximized && !state.fullscreen) - setSize(getWindowWidth() * s, getWindowHeight() * s); + setSize(getWindowWidth(false) * s, getWindowHeight(false) * s); SDL_SetRenderScale(m_renderer, s, s); } diff --git a/src/ogfx/gui/Window.hpp b/src/ogfx/gui/Window.hpp index af264d6..eb4e60d 100644 --- a/src/ogfx/gui/Window.hpp +++ b/src/ogfx/gui/Window.hpp @@ -127,8 +127,8 @@ namespace ogfx inline void hide(void) { SDL_HideWindow(m_window); m_visible = false; } inline void show(void) { SDL_ShowWindow(m_window); m_visible = true; } inline String getTitle(void) const { return m_title; } - inline i32 getWindowWidth(void) const { return m_windowWidth; } - inline i32 getWindowHeight(void) const { return m_windowHeight; } + inline i32 getWindowWidth(bool scaled = true) const { return scaled ? cast(m_windowWidth) / getScaleFactor() : m_windowWidth; } + inline i32 getWindowHeight(bool scaled = true) const { return scaled ? cast(m_windowHeight) / getScaleFactor() : m_windowHeight; } inline Color getClearColor(void) const { return m_clearColor; } inline void setClearColor(const Color& color) { m_clearColor = color; } inline SDL_Renderer* getSDLRenderer(void) { return m_renderer; } diff --git a/src/test/GuiTest.cpp b/src/test/GuiTest.cpp index 0172d73..4390f18 100644 --- a/src/test/GuiTest.cpp +++ b/src/test/GuiTest.cpp @@ -273,6 +273,7 @@ class Window : public ogfx::gui::Window { auto& wrd = cast(signal.userData); m_tabs.setSize(cast(getWindowWidth()), cast(getWindowHeight() - getMenuBar().geth() - getToolBar().geth() - getStatusBar().geth())); + std::cout << m_tabs.getSize() << "\n"; m_tabs.setPosition(0, -1); m_tabs.refreshCurrentTab();