mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
impr: Better font scaling with larger backing scale factors
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <hex/api/events/events_gui.hpp>
|
||||
#include <hex/api/events/events_interaction.hpp>
|
||||
#include <hex/api/events/requests_gui.hpp>
|
||||
#include <hex/api/theme_manager.hpp>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
@@ -154,6 +155,27 @@ namespace hex {
|
||||
}
|
||||
|
||||
void Window::endNativeWindowFrame() {
|
||||
static float prevScaleFactor = 0;
|
||||
|
||||
const float currScaleFactor = MAIN_THREAD_EM_ASM_DOUBLE({
|
||||
try {
|
||||
// Take square root of scaling to counter scaling applied by Browser
|
||||
return Math.sqrt(window.devicePixelRatio);
|
||||
} catch (e) {
|
||||
return 1.0;
|
||||
}
|
||||
});
|
||||
if (prevScaleFactor != 0 && prevScaleFactor != currScaleFactor) {
|
||||
EventDPIChanged::post(prevScaleFactor, currScaleFactor);
|
||||
resizeCanvas();
|
||||
|
||||
ImHexApi::System::impl::setNativeScale(currScaleFactor);
|
||||
|
||||
ThemeManager::reapplyCurrentTheme();
|
||||
ImGui::GetStyle().ScaleAllSizes(currScaleFactor);
|
||||
}
|
||||
|
||||
prevScaleFactor = currScaleFactor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/theme_manager.hpp>
|
||||
|
||||
#include "window.hpp"
|
||||
|
||||
|
||||
#if defined(OS_WINDOWS)
|
||||
|
||||
#include "messaging.hpp"
|
||||
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/theme_manager.hpp>
|
||||
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
#include <hex/helpers/default_paths.hpp>
|
||||
|
||||
@@ -813,8 +813,6 @@ namespace hex {
|
||||
// NOTE: This needs to be done before a new frame is started, otherwise ImGui won't handle docking correctly
|
||||
LayoutManager::process();
|
||||
WorkspaceManager::process();
|
||||
|
||||
ImGui::GetIO().FontGlobalScale = 1.0F / ImHexApi::System::getBackingScaleFactor();
|
||||
}
|
||||
|
||||
void Window::drawImGui() {
|
||||
|
||||
Reference in New Issue
Block a user