Moved CD Volume slider to Sound panel

This commit is contained in:
Dimitris Panokostas 2020-08-17 01:44:35 +02:00
parent 3d7ec86ca2
commit 8df6d45571
2 changed files with 38 additions and 40 deletions

View file

@ -59,9 +59,6 @@ static gcn::CheckBox* chkCD;
static gcn::DropDown* cboCDFile;
static gcn::Button* cmdCDEject;
static gcn::Button* cmdCDSelect;
static gcn::Label* lblCDVol;
static gcn::Label* lblCDVolInfo;
static gcn::Slider* sldCDVol;
static int GetHDType(const int index)
{
@ -248,7 +245,6 @@ public:
CDCheckActionListener* cdCheckActionListener;
class CDButtonActionListener : public gcn::ActionListener
{
public:
@ -293,22 +289,12 @@ public:
CDButtonActionListener* cdButtonActionListener;
class GenericActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent) override
{
if (actionEvent.getSource() == sldCDVol)
{
const auto newvol = 100 - static_cast<int>(sldCDVol->getValue());
if (changed_prefs.sound_volume_cd != newvol)
{
changed_prefs.sound_volume_cd = newvol;
RefreshPanelHD();
}
}
else if (actionEvent.getSource() == chkHDReadOnly)
if (actionEvent.getSource() == chkHDReadOnly)
{
changed_prefs.harddrive_read_only = chkHDReadOnly->isSelected();
}
@ -460,17 +446,6 @@ void InitPanelHD(const struct _ConfigCategory& category)
cboCDFile->setId("cboCD");
cboCDFile->addActionListener(cdFileActionListener);
lblCDVol = new gcn::Label("CD Volume:");
lblCDVol->setAlignment(gcn::Graphics::RIGHT);
sldCDVol = new gcn::Slider(0, 100);
sldCDVol->setSize(200, SLIDER_HEIGHT);
sldCDVol->setBaseColor(gui_baseCol);
sldCDVol->setMarkerLength(20);
sldCDVol->setStepLength(10);
sldCDVol->setId("CDVol");
sldCDVol->addActionListener(genericActionListener);
lblCDVolInfo = new gcn::Label("80 %");
int posX = DISTANCE_BORDER + 2 + SMALL_BUTTON_WIDTH + 34;
for (col = 0; col < COL_COUNT; ++col)
{
@ -516,10 +491,6 @@ void InitPanelHD(const struct _ConfigCategory& category)
category.panel->add(cboCDFile, DISTANCE_BORDER, posY);
posY += cboCDFile->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblCDVol, DISTANCE_BORDER, posY);
category.panel->add(sldCDVol, DISTANCE_BORDER + lblCDVol->getWidth() + 8, posY);
category.panel->add(lblCDVolInfo, sldCDVol->getX() + sldCDVol->getWidth() + 12, posY);
RefreshPanelHD();
}
@ -550,9 +521,6 @@ void ExitPanelHD()
delete cmdCDEject;
delete cmdCDSelect;
delete cboCDFile;
delete lblCDVol;
delete lblCDVolInfo;
delete sldCDVol;
delete cdCheckActionListener;
delete cdButtonActionListener;
@ -660,13 +628,6 @@ void RefreshPanelHD()
cmdCDEject->setEnabled(changed_prefs.cdslots[0].inuse);
cmdCDSelect->setEnabled(changed_prefs.cdslots[0].inuse);
cboCDFile->setEnabled(changed_prefs.cdslots[0].inuse);
sldCDVol->setEnabled(changed_prefs.cdslots[0].inuse);
lblCDVol->setEnabled(changed_prefs.cdslots[0].inuse);
lblCDVolInfo->setEnabled(changed_prefs.cdslots[0].inuse);
sldCDVol->setValue(100 - changed_prefs.sound_volume_cd);
snprintf(tmp, 32, "%d %%", 100 - changed_prefs.sound_volume_cd);
lblCDVolInfo->setCaption(tmp);
}

View file

@ -35,6 +35,9 @@ static gcn::Window* grpVolume;
static gcn::Label* lblPaulaVol;
static gcn::Label* lblPaulaVolInfo;
static gcn::Slider* sldPaulaVol;
static gcn::Label* lblCDVol;
static gcn::Label* lblCDVolInfo;
static gcn::Slider* sldCDVol;
static int curr_separation_idx;
static int curr_stereodelay_idx;
@ -322,6 +325,12 @@ public:
if (changed_prefs.sound_volume_paula != newvol)
changed_prefs.sound_volume_paula = newvol;
}
else if (actionEvent.getSource() == sldCDVol)
{
const auto newvol = 100 - static_cast<int>(sldCDVol->getValue());
if (changed_prefs.sound_volume_cd != newvol)
changed_prefs.sound_volume_cd = newvol;
}
RefreshPanelSound();
}
@ -415,6 +424,17 @@ void InitPanelSound(const struct _ConfigCategory& category)
sldPaulaVol->addActionListener(soundActionListener);
lblPaulaVolInfo = new gcn::Label("100 %");
lblCDVol = new gcn::Label("CD Volume:");
lblCDVol->setAlignment(gcn::Graphics::RIGHT);
sldCDVol = new gcn::Slider(0, 100);
sldCDVol->setSize(150, SLIDER_HEIGHT);
sldCDVol->setBaseColor(gui_baseCol);
sldCDVol->setMarkerLength(20);
sldCDVol->setStepLength(10);
sldCDVol->setId("sldCDVol");
sldCDVol->addActionListener(soundActionListener);
lblCDVolInfo = new gcn::Label("80 %");
grpSound = new gcn::Window("Sound Emulation");
grpSound->add(optSoundDisabled, 10, 10);
grpSound->add(optSoundDisabledEmu, 10, 40);
@ -429,6 +449,9 @@ void InitPanelSound(const struct _ConfigCategory& category)
grpVolume->add(lblPaulaVol, 10, 10);
grpVolume->add(sldPaulaVol, lblPaulaVol->getX() + lblPaulaVol->getWidth() + 10, lblPaulaVol->getY());
grpVolume->add(lblPaulaVolInfo, sldPaulaVol->getX() + sldPaulaVol->getWidth() + 10, sldPaulaVol->getY());
grpVolume->add(lblCDVol, lblPaulaVol->getX(), lblPaulaVol->getY() + lblPaulaVol->getHeight() + DISTANCE_NEXT_Y);
grpVolume->add(sldCDVol, sldPaulaVol->getX(), lblCDVol->getY());
grpVolume->add(lblCDVolInfo, sldCDVol->getX() + sldCDVol->getWidth() + 10, sldCDVol->getY());
grpVolume->setMovable(false);
grpVolume->setSize(category.panel->getWidth() - DISTANCE_BORDER * 2 - grpSound->getWidth() - DISTANCE_NEXT_X, grpSound->getHeight());
grpVolume->setTitleBarHeight(TITLEBAR_HEIGHT);
@ -469,6 +492,12 @@ void ExitPanelSound()
delete optSoundEmulated;
delete optSoundEmulatedBest;
delete grpSound;
delete lblPaulaVol;
delete lblPaulaVolInfo;
delete sldPaulaVol;
delete lblCDVol;
delete lblCDVolInfo;
delete sldCDVol;
delete grpVolume;
delete lblChannelMode;
delete cboChannelMode;
@ -567,6 +596,14 @@ void RefreshPanelSound()
snprintf(tmp, sizeof tmp - 1, "%d %%", 100 - changed_prefs.sound_volume_paula);
lblPaulaVolInfo->setCaption(tmp);
sldCDVol->setEnabled(changed_prefs.cdslots[0].inuse);
lblCDVol->setEnabled(changed_prefs.cdslots[0].inuse);
lblCDVolInfo->setEnabled(changed_prefs.cdslots[0].inuse);
sldCDVol->setValue(100 - changed_prefs.sound_volume_cd);
snprintf(tmp, 10, "%d %%", 100 - changed_prefs.sound_volume_cd);
lblCDVolInfo->setCaption(tmp);
cboChannelMode->setEnabled(changed_prefs.produce_sound > 0);
lblFrequency->setEnabled(changed_prefs.produce_sound > 0);
cboFrequency->setEnabled(changed_prefs.produce_sound > 0);