mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
feat: Added DPI awareness on Windows, added FiraCode as optional default font
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/event_manager.hpp>
|
||||
#include <hex/api_urls.hpp>
|
||||
|
||||
#include <hex/api/task_manager.hpp>
|
||||
@@ -98,15 +99,20 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
bool configureUIScale() {
|
||||
int interfaceScaleSetting = int(ContentRegistry::Settings::read<float>("hex.builtin.setting.interface", "hex.builtin.setting.interface.scaling_factor", 1.0F) * 10.0F);
|
||||
EventDPIChanged::subscribe([](float, float newScaling) {
|
||||
int interfaceScaleSetting = int(ContentRegistry::Settings::read<float>("hex.builtin.setting.interface", "hex.builtin.setting.interface.scaling_factor", 0.0F) * 10.0F);
|
||||
|
||||
float interfaceScaling;
|
||||
if (interfaceScaleSetting == 0)
|
||||
interfaceScaling = ImHexApi::System::getNativeScale();
|
||||
else
|
||||
interfaceScaling = interfaceScaleSetting / 10.0F;
|
||||
float interfaceScaling;
|
||||
if (interfaceScaleSetting == 0)
|
||||
interfaceScaling = newScaling;
|
||||
else
|
||||
interfaceScaling = interfaceScaleSetting / 10.0F;
|
||||
|
||||
ImHexApi::System::impl::setGlobalScale(interfaceScaling);
|
||||
ImHexApi::System::impl::setGlobalScale(interfaceScaling);
|
||||
});
|
||||
|
||||
const auto nativeScale = ImHexApi::System::getNativeScale();
|
||||
EventDPIChanged::post(nativeScale, nativeScale);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -201,6 +201,10 @@ namespace hex::plugin::builtin {
|
||||
return m_value;
|
||||
}
|
||||
|
||||
float getValue() const {
|
||||
return m_value;
|
||||
}
|
||||
|
||||
private:
|
||||
float m_value = 1.0F;
|
||||
};
|
||||
@@ -834,6 +838,14 @@ namespace hex::plugin::builtin {
|
||||
.requiresRestart()
|
||||
.setEnabledCallback(customFontsEnabled);
|
||||
|
||||
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.font", "hex.builtin.setting.font.custom_font", "hex.builtin.setting.font.pixel_perfect_default_font", true)
|
||||
.setEnabledCallback([customFontPathSetting] {
|
||||
auto &fontPath = static_cast<Widgets::FilePicker &>(customFontPathSetting.getWidget());
|
||||
|
||||
return fontPath.getPath().empty();
|
||||
})
|
||||
.requiresRestart();
|
||||
|
||||
const auto customFontSettingsEnabled = [customFontEnabledSetting, customFontPathSetting] {
|
||||
auto &customFontsEnabled = static_cast<Widgets::Checkbox &>(customFontEnabledSetting.getWidget());
|
||||
auto &fontPath = static_cast<Widgets::FilePicker &>(customFontPathSetting.getWidget());
|
||||
|
||||
Reference in New Issue
Block a user