Skip to content

Commit

Permalink
libgui|GuiApp: Handleng built-in config variable
Browse files Browse the repository at this point in the history
Add Config.ui.scaleFactor if missing because it is assumed to always exist.
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 89e039e commit 33fc9a3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions doomsday/libs/gui/src/guiapp.cpp
Expand Up @@ -42,6 +42,8 @@

namespace de {

DE_STATIC_STRING(VAR_UI_SCALE_FACTOR, "ui.scaleFactor");

static Value *Function_DisplayMode_OriginalMode(Context &, const Function::ArgumentValues &)
{
SDL_DisplayMode mode;
Expand Down Expand Up @@ -184,14 +186,19 @@ void GuiApp::initSubsystems(SubsystemInitFlags subsystemInitFlags)
{
App::initSubsystems(subsystemInitFlags); // reads Config

if (!Config::get().has(VAR_UI_SCALE_FACTOR()))
{
Config::get().set(VAR_UI_SCALE_FACTOR(), 1.0f);
}

// The "-dpi" option overrides the detected pixel ratio.
if (auto dpi = commandLine().check("-dpi", 1))
{
d->windowPixelRatio = dpi.params.at(0).toFloat();
}
setPixelRatio(d->windowPixelRatio);

Config::get("ui.scaleFactor").audienceForChange() += d;
Config::get(VAR_UI_SCALE_FACTOR()).audienceForChange() += d;
}

const Rule &GuiApp::pixelRatio() const
Expand All @@ -209,7 +216,7 @@ void GuiApp::setPixelRatio(float pixelRatio)
d->windowPixelRatio = pixelRatio;

// Apply the overall UI scale factor.
pixelRatio *= config().getf("ui.scaleFactor", 1.0f);
pixelRatio *= config().getf(VAR_UI_SCALE_FACTOR(), 1.0f);

if (!fequal(d->pixelRatio->value(), pixelRatio))
{
Expand Down

0 comments on commit 33fc9a3

Please sign in to comment.