From efa82628d5918fd37a34a780129162308aa507a4 Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Thu, 23 Feb 2017 01:07:28 +0100 Subject: [PATCH] Added Scaling Method option in GUI --- src/include/options.h | 1 + src/osdep/gui/PanelDisplay.cpp | 64 +++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/include/options.h b/src/include/options.h index 47df1aa8..a6316844 100644 --- a/src/include/options.h +++ b/src/include/options.h @@ -179,6 +179,7 @@ struct uae_prefs { int kbd_led_num; int kbd_led_scr; int kbd_led_cap; + int scaling_method; #endif bool immediate_blits; diff --git a/src/osdep/gui/PanelDisplay.cpp b/src/osdep/gui/PanelDisplay.cpp index 1c13943c..027c700f 100644 --- a/src/osdep/gui/PanelDisplay.cpp +++ b/src/osdep/gui/PanelDisplay.cpp @@ -28,25 +28,29 @@ static gcn::Label* lblAmigaHeight; static gcn::Label* lblAmigaHeightInfo; static gcn::Slider* sldAmigaHeight; static gcn::UaeCheckBox* chkFrameskip; +static gcn::Window* grpScalingMethod; +static gcn::UaeRadioButton* optAuto; +static gcn::UaeRadioButton* optNearest; +static gcn::UaeRadioButton* optLinear; class AmigaScreenActionListener : public gcn::ActionListener { public: - void action(const gcn::ActionEvent& actionEvent) + void action(const gcn::ActionEvent& actionEvent) override { if (actionEvent.getSource() == sldAmigaWidth) { - if (changed_prefs.gfx_size.width != amigawidth_values[(int)(sldAmigaWidth->getValue())]) + if (changed_prefs.gfx_size.width != amigawidth_values[int(sldAmigaWidth->getValue())]) { - changed_prefs.gfx_size.width = amigawidth_values[(int)(sldAmigaWidth->getValue())]; + changed_prefs.gfx_size.width = amigawidth_values[int(sldAmigaWidth->getValue())]; RefreshPanelDisplay(); } } else if (actionEvent.getSource() == sldAmigaHeight) { - if (changed_prefs.gfx_size.height != amigaheight_values[(int)(sldAmigaHeight->getValue())]) + if (changed_prefs.gfx_size.height != amigaheight_values[int(sldAmigaHeight->getValue())]) { - changed_prefs.gfx_size.height = amigaheight_values[(int)(sldAmigaHeight->getValue())]; + changed_prefs.gfx_size.height = amigaheight_values[int(sldAmigaHeight->getValue())]; RefreshPanelDisplay(); } } @@ -59,6 +63,21 @@ public: AmigaScreenActionListener* amigaScreenActionListener; +class ScalingMethodActionListener : public gcn::ActionListener +{ +public: + void action(const gcn::ActionEvent& actionEvent) override + { + if (actionEvent.getSource() == optAuto) + changed_prefs.scaling_method = -1; + else if (actionEvent.getSource() == optNearest) + changed_prefs.scaling_method = 0; + else if (actionEvent.getSource() == optLinear) + changed_prefs.scaling_method = 1; + } +}; + +static ScalingMethodActionListener* scalingMethodActionListener; void InitPanelDisplay(const struct _ConfigCategory& category) { @@ -111,6 +130,28 @@ void InitPanelDisplay(const struct _ConfigCategory& category) category.panel->add(grpAmigaScreen); category.panel->add(chkFrameskip, DISTANCE_BORDER, DISTANCE_BORDER + grpAmigaScreen->getHeight() + DISTANCE_NEXT_Y); + scalingMethodActionListener = new ScalingMethodActionListener(); + + optAuto = new gcn::UaeRadioButton("Auto", "radioscalingmethodgroup"); + optAuto->addActionListener(scalingMethodActionListener); + + optNearest = new gcn::UaeRadioButton("Nearest Neighbor (pixelated)", "radioscalingmethodgroup"); + optNearest->addActionListener(scalingMethodActionListener); + + optLinear = new gcn::UaeRadioButton("Linear (smooth)", "radioscalingmethodgroup"); + optLinear->addActionListener(scalingMethodActionListener); + + grpScalingMethod = new gcn::Window("Scaling method"); + grpScalingMethod->setPosition(DISTANCE_BORDER, DISTANCE_BORDER + grpAmigaScreen->getHeight() + DISTANCE_NEXT_Y); + grpScalingMethod->add(optAuto, 5, 10); + grpScalingMethod->add(optNearest, 5, 40); + grpScalingMethod->add(optLinear, 5, 70); + grpScalingMethod->setMovable(false); + grpScalingMethod->setSize(260, optLinear->getY() + optLinear->getHeight() + 30); + grpScalingMethod->setBaseColor(gui_baseCol); + + category.panel->add(grpScalingMethod); + RefreshPanelDisplay(); } @@ -126,6 +167,12 @@ void ExitPanelDisplay() delete grpAmigaScreen; delete chkFrameskip; delete amigaScreenActionListener; + + delete optAuto; + delete optNearest; + delete optLinear; + delete grpScalingMethod; + delete scalingMethodActionListener; } @@ -157,4 +204,11 @@ void RefreshPanelDisplay() } chkFrameskip->setSelected(changed_prefs.gfx_framerate); + + if (changed_prefs.scaling_method == -1) + optAuto->setSelected(true); + else if (changed_prefs.scaling_method == 0) + optNearest->setSelected(true); + else if (changed_prefs.scaling_method == 1) + optLinear->setSelected(true); }