mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-05-21 04:59:05 -05:00
fix: DPI scaling
This commit is contained in:
@@ -78,7 +78,6 @@ namespace hex {
|
||||
ImHexApi::System::impl::setNativeScale(newScale);
|
||||
|
||||
ThemeManager::reapplyCurrentTheme();
|
||||
ImGui::GetStyle().ScaleAllSizes(newScale);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -153,6 +152,11 @@ namespace hex {
|
||||
// Custom window procedure for borderless window
|
||||
static LRESULT borderlessWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch (uMsg) {
|
||||
case WM_MOVE: {
|
||||
auto imhexWindow = static_cast<Window*>(glfwGetWindowUserPointer(ImHexApi::System::getMainWindowHandle()));
|
||||
imhexWindow->fullFrame();
|
||||
break;
|
||||
}
|
||||
case WM_MOUSELAST:
|
||||
break;
|
||||
case WM_NCACTIVATE:
|
||||
@@ -310,6 +314,7 @@ namespace hex {
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <content/popups/popup_crash_recovered.hpp>
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <hex/api/theme_manager.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
@@ -322,6 +323,10 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
});
|
||||
|
||||
RequestChangeTheme::subscribe([](const std::string &theme) {
|
||||
ThemeManager::changeTheme(theme);
|
||||
});
|
||||
|
||||
fs::setFileBrowserErrorCallback([](const std::string& errMsg){
|
||||
#if defined(NFD_PORTAL)
|
||||
ui::PopupError::open(hex::format("hex.builtin.popup.error.file_dialog.portal"_lang, errMsg));
|
||||
|
||||
@@ -627,7 +627,7 @@ namespace hex::plugin::builtin {
|
||||
ImHexApi::System::setTargetFPS(static_cast<float>(value.get<int>(14)));
|
||||
});
|
||||
|
||||
RequestChangeTheme::subscribe([](const std::string &theme) {
|
||||
static auto updateTextures = [](float scale) {
|
||||
auto changeTexture = [&](const std::string &path) {
|
||||
return ImGuiExt::Texture::fromImage(romfs::get(path).span(), ImGuiExt::Texture::Filter::Nearest);
|
||||
};
|
||||
@@ -636,15 +636,13 @@ namespace hex::plugin::builtin {
|
||||
return ImGuiExt::Texture::fromSVG(romfs::get(path).span(), width, 0, ImGuiExt::Texture::Filter::Linear);
|
||||
};
|
||||
|
||||
ThemeManager::changeTheme(theme);
|
||||
s_bannerTexture = changeTextureSvg(hex::format("assets/{}/banner.svg", ThemeManager::getImageTheme()), 300_scaled);
|
||||
s_nightlyTexture = changeTextureSvg(hex::format("assets/{}/nightly.svg", "common"), 35_scaled);
|
||||
s_bannerTexture = changeTextureSvg(hex::format("assets/{}/banner.svg", ThemeManager::getImageTheme()), 300 * scale);
|
||||
s_nightlyTexture = changeTextureSvg(hex::format("assets/{}/nightly.svg", "common"), 35 * scale);
|
||||
s_backdropTexture = changeTexture(hex::format("assets/{}/backdrop.png", ThemeManager::getImageTheme()));
|
||||
};
|
||||
|
||||
if (!s_bannerTexture->isValid()) {
|
||||
log::error("Failed to load banner texture!");
|
||||
}
|
||||
});
|
||||
RequestChangeTheme::subscribe([]() { updateTextures(ImHexApi::System::getGlobalScale()); });
|
||||
EventDPIChanged::subscribe([](float, float newScale) { updateTextures(newScale); } );
|
||||
|
||||
// Clear project context if we go back to the welcome screen
|
||||
EventProviderChanged::subscribe([](const hex::prv::Provider *oldProvider, const hex::prv::Provider *newProvider) {
|
||||
|
||||
@@ -115,4 +115,8 @@ IMHEX_LIBRARY_SETUP("Fonts") {
|
||||
hex::fonts::setupFonts();
|
||||
hex::ImHexApi::Fonts::setDefaultFont(hex::fonts::Default());
|
||||
});
|
||||
|
||||
hex::EventDPIChanged::subscribe([](float, float newScale) {
|
||||
ImGui::GetIO().ConfigDpiScaleFonts = newScale;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user