1
0
mirror of synced 2024-09-24 11:38:26 +02:00

fix: Various scaling issues

This commit is contained in:
WerWolv 2023-12-10 22:37:26 +01:00
parent ef7898ea8d
commit 1ba34c233e
3 changed files with 11 additions and 4 deletions

View File

@ -10,6 +10,7 @@ namespace hex::plugin::builtin {
~ViewSettings() override;
void drawContent() override;
void drawAlwaysVisibleContent() override;
[[nodiscard]] bool shouldDraw() const override { return true; }
[[nodiscard]] bool hasViewMenuItemEntry() const override { return false; }

View File

@ -107,13 +107,13 @@ namespace hex::plugin::builtin {
}
bool configureUIScale() {
int interfaceScaleSetting = int(ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.scaling_factor", 0.0F).get<float>() * 10.0F);
int interfaceScaleSetting = int(ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.scaling_factor", 1.0F).get<float>() * 10.0F);
float interfaceScaling;
if (interfaceScaleSetting == 0)
interfaceScaling = ImHexApi::System::getNativeScale();
else
interfaceScaling = int(interfaceScaleSetting / 10.0F);
interfaceScaling = interfaceScaleSetting / 10.0F;
ImHexApi::System::impl::setGlobalScale(interfaceScaling);
@ -121,7 +121,10 @@ namespace hex::plugin::builtin {
}
bool loadFontsImpl(bool loadUnicode) {
const float defaultFontSize = ImHexApi::Fonts::DefaultFontSize * std::round(ImHexApi::System::getGlobalScale());
float defaultFontSize = ImHexApi::Fonts::DefaultFontSize * ImHexApi::System::getGlobalScale();
if (defaultFontSize == 0.0F)
defaultFontSize = ImHexApi::Fonts::DefaultFontSize;
// Reset used font size back to the default size
ImHexApi::Fonts::impl::setFontSize(defaultFontSize);
@ -348,8 +351,8 @@ namespace hex::plugin::builtin {
}
void addInitTasks() {
ImHexApi::System::addStartupTask("Configuring UI scale", true, configureUIScale);
ImHexApi::System::addStartupTask("Loading fonts", true, loadFonts);
ImHexApi::System::addStartupTask("Checking for updates", true, checkForUpdates);
ImHexApi::System::addStartupTask("Configuring UI scale", true, configureUIScale);
}
}

View File

@ -103,7 +103,9 @@ namespace hex::plugin::builtin {
ImGui::EndTabBar();
}
}
void ViewSettings::drawAlwaysVisibleContent() {
// If a restart is required, ask the user if they want to restart
if (!this->getWindowOpenState() && this->m_restartRequested) {
PopupQuestion::open("hex.builtin.view.settings.restart_question"_lang,
@ -115,4 +117,5 @@ namespace hex::plugin::builtin {
}
}
}