From 81524e1cb634881b7c1629f7030facb308f5f853 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 12 Sep 2017 23:07:39 +0300 Subject: Add option for enable high dpi mode in SDL 2. --- src/gui/widgets/tabs/setup_video.cpp | 28 +++++++++++++++++++++++++++- src/gui/widgets/tabs/setup_video.h | 4 ++++ 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index 785ab5a33..b5b74e2b9 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -90,6 +90,11 @@ Setup_Video::Setup_Video(const Widget2 *const widget) : mCustomCursorEnabled(config.getBoolValue("customcursor")), mEnableResize(config.getBoolValue("enableresize")), mNoFrame(config.getBoolValue("noframe")), +#ifdef USE_SDL2 + mAllowHighDPI(config.getBoolValue("allowHighDPI")), + // TRANSLATORS: video settings checkbox + mAllowHighDPICheckBox(new CheckBox(this, _("High DPI"), mAllowHighDPI)), +#endif // USE_SDL2 mCustomCursorCheckBox(new CheckBox(this, #ifdef ANDROID // TRANSLATORS: video settings checkbox @@ -145,6 +150,10 @@ Setup_Video::Setup_Video(const Widget2 *const widget) : mOpenGLDropDown->setActionEventId("opengl"); mEnableResizeCheckBox->setActionEventId("enableresize"); mNoFrameCheckBox->setActionEventId("noframe"); +#ifdef USE_SDL2 + mAllowHighDPICheckBox->setActionEventId("allowHighDPI"); + mAllowHighDPICheckBox->addActionListener(this); +#endif // USE_SDL2 mModeList->addActionListener(this); mCustomCursorCheckBox->addActionListener(this); @@ -168,6 +177,9 @@ Setup_Video::Setup_Video(const Widget2 *const widget) : place(1, 2, mEnableResizeCheckBox, 2); place(1, 3, mNoFrameCheckBox, 2); +#ifdef USE_SDL2 + place(1, 4, mAllowHighDPICheckBox, 2); +#endif // USE_SDL2 place(0, 6, mFpsSlider); place(1, 6, mFpsCheckBox).setPadding(3); @@ -312,6 +324,9 @@ void Setup_Video::apply() mOpenGLEnabled = intToRenderType(config.getIntValue("opengl")); mEnableResize = config.getBoolValue("enableresize"); mNoFrame = config.getBoolValue("noframe"); +#ifdef USE_SDL2 + mAllowHighDPI = config.getBoolValue("allowHighDPI"); +#endif // USE_SDL2 } void Setup_Video::cancel() @@ -331,6 +346,9 @@ void Setup_Video::cancel() mAltFpsLabel->setCaption(_("Alt FPS limit: ") + toString(mAltFps)); mEnableResizeCheckBox->setSelected(mEnableResize); mNoFrameCheckBox->setSelected(mNoFrame); +#ifdef USE_SDL2 + mAllowHighDPICheckBox->setSelected(mAllowHighDPI); +#endif // USE_SDL2 config.setValue("screen", mFullScreenEnabled); @@ -344,7 +362,9 @@ void Setup_Video::cancel() config.setValue("customcursor", mCustomCursorEnabled); config.setValue("opengl", CAST_S32(mOpenGLEnabled)); config.setValue("enableresize", mEnableResize); - config.setValue("noframe", mNoFrame); +#ifdef USE_SDL2 + config.setValue("allowHighDPI", mAllowHighDPI); +#endif // USE_SDL2 } void Setup_Video::action(const ActionEvent &event) @@ -485,6 +505,12 @@ void Setup_Video::action(const ActionEvent &event) { config.setValue("noframe", mNoFrameCheckBox->isSelected()); } +#ifdef USE_SDL2 + else if (id == "allowHighDPI") + { + config.setValue("allowHighDPI", mAllowHighDPICheckBox->isSelected()); + } +#endif // USE_SDL2 #if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__) else if (id == "detect") { diff --git a/src/gui/widgets/tabs/setup_video.h b/src/gui/widgets/tabs/setup_video.h index 6c3b09e9e..e327a29d8 100644 --- a/src/gui/widgets/tabs/setup_video.h +++ b/src/gui/widgets/tabs/setup_video.h @@ -76,6 +76,10 @@ class Setup_Video final : public SetupTab, bool mCustomCursorEnabled; bool mEnableResize; bool mNoFrame; +#ifdef USE_SDL2 + bool mAllowHighDPI; + CheckBox *mAllowHighDPICheckBox; +#endif // USE_SDL2 CheckBox *mCustomCursorCheckBox; CheckBox *mEnableResizeCheckBox; CheckBox *mNoFrameCheckBox; -- cgit v1.2.3-60-g2f50