From 681f81211f25c4c9fc163e0ec4d005f796da547d Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 27 Dec 2012 15:08:54 +0100 Subject: FLUIDSYNTH: Add separate dialog for FluidSynth settings I don't really understand what these parameters do, or what the sensible values are, so for now the sliders are limited only by the allowed (or, in one case, "safe") values. --- gui/fluidsynth-dialog.cpp | 341 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 341 insertions(+) create mode 100644 gui/fluidsynth-dialog.cpp (limited to 'gui/fluidsynth-dialog.cpp') diff --git a/gui/fluidsynth-dialog.cpp b/gui/fluidsynth-dialog.cpp new file mode 100644 index 0000000000..c7e646e5f3 --- /dev/null +++ b/gui/fluidsynth-dialog.cpp @@ -0,0 +1,341 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "gui/fluidsynth-dialog.h" +#include "gui/widgets/tab.h" +#include "gui/widgets/popup.h" + +#include "common/config-manager.h" +#include "common/translation.h" +#include "common/debug.h" + +namespace GUI { + +enum { + kOverrideChorusCmd = 'ocho', + kChorusVoiceCountChangedCmd = 'cvcc', + kChorusLevelChangedCmd = 'clec', + kChorusSpeedChangedCmd = 'cspc', + kChorusDepthChangedCmd = 'cdec', + + kOverrideReverbCmd = 'orev', + kReverbRoomSizeChangedCmd = 'rrsc', + kReverbDampingChangedCmd = 'rdac', + kReverbWidthChangedCmd = 'rwic', + kReverbLevelChangedCmd = 'rlec' +}; + +enum { + kWaveFormTypeSine = 0, + kWaveFormTypeTriangle = 1 +}; + +enum { + kInterpolationNone = 0, + kInterpolationLinear = 1, + kInterpolation4thOrder = 2, + kInterpolation7thOrder = 3 +}; + +FluidSynthSettingsDialog::FluidSynthSettingsDialog() + : Dialog("FluidSynthSettings") { + _domain = Common::ConfigManager::kApplicationDomain; + + _tabWidget = new TabWidget(this, "FluidSynthSettings.TabWidget"); + + _tabWidget->addTab(_("Chorus")); + + _chorusOverride = new CheckboxWidget(_tabWidget, "FluidSynthSettings_Chorus.EnableTabCheckbox", _("Override chorus settings"), 0, kOverrideChorusCmd); + + _chorusVoiceCountDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.VoiceCountText", _("Voice count:")); + _chorusVoiceCountSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Chorus.VoiceCountSlider", 0, kChorusVoiceCountChangedCmd); + _chorusVoiceCountSlider->setMinValue(0); + _chorusVoiceCountSlider->setMaxValue(99); + _chorusVoiceCountLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.VoiceCountLabel", "3"); + + _chorusLevelDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.LevelText", _("Level:")); + _chorusLevelSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Chorus.LevelSlider", 0, kChorusLevelChangedCmd); + _chorusLevelSlider->setMinValue(0); + _chorusLevelSlider->setMaxValue(1000); + _chorusLevelLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.LevelLabel", "2.00"); + + _chorusSpeedDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.SpeedText", _("Speed (Hz):")); + _chorusSpeedSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Chorus.SpeedSlider", 0, kChorusSpeedChangedCmd); + _chorusSpeedSlider->setMinValue(29); + _chorusSpeedSlider->setMaxValue(500); + _chorusSpeedSlider->setValue(29); + _chorusSpeedLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.SpeedLabel", "0.30"); + + _chorusDepthDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.DepthText", _("Depth:")); + _chorusDepthSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Chorus.DepthSlider", 0, kChorusDepthChangedCmd); + _chorusDepthSlider->setMinValue(0); + _chorusDepthSlider->setMaxValue(2100); + _chorusDepthLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.DepthLabel", "8.00"); + + _chorusWaveFormTypePopUpDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.WaveFormTypeText", _("Waveform type:")); + _chorusWaveFormTypePopUp = new PopUpWidget(_tabWidget, "FluidSynthSettings_Chorus.WaveFormType"); + + _chorusWaveFormTypePopUp->appendEntry(_("Sine"), kWaveFormTypeSine); + _chorusWaveFormTypePopUp->appendEntry(_("Triangle"), kWaveFormTypeTriangle); + + _tabWidget->addTab(_("Reverb")); + + _reverbOverride = new CheckboxWidget(_tabWidget, "FluidSynthSettings_Reverb.EnableTabCheckbox", _("Override reverb settings"), 0, kOverrideReverbCmd); + + _reverbRoomSizeDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeText", _("Room size:")); + _reverbRoomSizeSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeSlider", 0, kReverbRoomSizeChangedCmd); + _reverbRoomSizeSlider->setMinValue(0); + _reverbRoomSizeSlider->setMaxValue(120); + _reverbRoomSizeLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeLabel", "0.20"); + + _reverbDampingDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingText", _("Damping:")); + _reverbDampingSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingSlider", 0, kReverbDampingChangedCmd); + _reverbDampingSlider->setMinValue(0); + _reverbDampingSlider->setMaxValue(100); + _reverbDampingLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingLabel", "0.00"); + + _reverbWidthDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.WidthText", _("Width:")); + _reverbWidthSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.WidthSlider", 0, kReverbWidthChangedCmd); + _reverbWidthSlider->setMinValue(0); + _reverbWidthSlider->setMaxValue(1000); + _reverbWidthLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.WidthLabel", "0.5"); + + _reverbLevelDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.LevelText", _("Level:")); + _reverbLevelSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.LevelSlider", 0, kReverbLevelChangedCmd); + _reverbLevelSlider->setMinValue(0); + _reverbLevelSlider->setMaxValue(100); + _reverbLevelLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.LevelLabel", "0.90"); + + _tabWidget->addTab(_("Misc")); + + _miscInterpolationPopUpDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Misc.InterpolationText", _("Interpolation:")); + _miscInterpolationPopUp = new PopUpWidget(_tabWidget, "FluidSynthSettings_Misc.Interpolation"); + + _miscInterpolationPopUp->appendEntry(_("None (fastest)"), kInterpolationNone); + _miscInterpolationPopUp->appendEntry(_("Linear"), kInterpolationLinear); + _miscInterpolationPopUp->appendEntry(_("Fourth-order"), kInterpolation4thOrder); + _miscInterpolationPopUp->appendEntry(_("Seventh-order"), kInterpolation7thOrder); + + _tabWidget->setActiveTab(0); + + new ButtonWidget(this, "FluidSynthSettings.Cancel", _("Cancel"), 0, kCloseCmd); + new ButtonWidget(this, "FluidSynthSettings.Ok", _("OK"), 0, kOKCmd); +} + +FluidSynthSettingsDialog::~FluidSynthSettingsDialog() { +} + +void FluidSynthSettingsDialog::open() { + Dialog::open(); + + // Reset result value + setResult(0); + + bool e; + + e = ConfMan.hasKey("fluidsynth_chorus_nr", _domain) || + ConfMan.hasKey("fluidsynth_chorus_level", _domain) || + ConfMan.hasKey("fluidsynth_chorus_speed", _domain) || + ConfMan.hasKey("fluidsynth_chorus_depth", _domain) || + ConfMan.hasKey("fluidsynth_chorus_waveform", _domain); + _chorusOverride->setState(e); + + e = ConfMan.hasKey("fluidsynth_reverb_roomsize", _domain) || + ConfMan.hasKey("fluidsynth_reverb_damping", _domain) || + ConfMan.hasKey("fluidsynth_reverb_width", _domain) || + ConfMan.hasKey("fluidsynth_reverb_level", _domain); + _reverbOverride->setState(e); + + _chorusVoiceCountSlider->setValue(ConfMan.getInt("fluidsynth_chorus_nr", _domain)); + _chorusVoiceCountLabel->setLabel(Common::String::format("%d", _chorusVoiceCountSlider->getValue())); + _chorusLevelSlider->setValue(ConfMan.getInt("fluidsynth_chorus_level", _domain)); + _chorusLevelLabel->setLabel(Common::String::format("%.2f", (double)_chorusLevelSlider->getValue() / 100.0)); + _chorusSpeedSlider->setValue(ConfMan.getInt("fluidsynth_chorus_speed", _domain)); + _chorusSpeedLabel->setLabel(Common::String::format("%.2f", (double)_chorusSpeedSlider->getValue() / 100.0)); + _chorusDepthSlider->setValue(ConfMan.getInt("fluidsynth_chorus_depth", _domain)); + _chorusDepthLabel->setLabel(Common::String::format("%.2f", (double)_chorusDepthSlider->getValue() / 100.0)); + + Common::String waveForm = ConfMan.get("fluidsynth_chorus_waveform", _domain); + if (waveForm == "sine") { + _chorusWaveFormTypePopUp->setSelectedTag(kWaveFormTypeSine); + } else if (waveForm == "triangle") { + _chorusWaveFormTypePopUp->setSelectedTag(kWaveFormTypeTriangle); + } + + _reverbRoomSizeSlider->setValue(ConfMan.getInt("fluidsynth_reverb_roomsize", _domain)); + _reverbRoomSizeLabel->setLabel(Common::String::format("%.2f", (double)_reverbRoomSizeSlider->getValue() / 100.0)); + _reverbDampingSlider->setValue(ConfMan.getInt("fluidsynth_reverb_damping", _domain)); + _reverbDampingLabel->setLabel(Common::String::format("%.2f", (double)_reverbDampingSlider->getValue() / 100.0)); + _reverbWidthSlider->setValue(ConfMan.getInt("fluidsynth_reverb_width", _domain)); + _reverbWidthLabel->setLabel(Common::String::format("%.2f", (double)_reverbWidthSlider->getValue() / 10.0)); + _reverbLevelSlider->setValue(ConfMan.getInt("fluidsynth_reverb_level", _domain)); + _reverbLevelLabel->setLabel(Common::String::format("%.2f", (double)_reverbLevelSlider->getValue() / 100.0)); + + Common::String interpolation = ConfMan.get("fluidsynth_misc_interpolation", _domain); + if (interpolation == "none") { + _miscInterpolationPopUp->setSelectedTag(kInterpolationNone); + } else if (interpolation == "linear") { + _miscInterpolationPopUp->setSelectedTag(kInterpolationLinear); + } else if (interpolation == "4th") { + _miscInterpolationPopUp->setSelectedTag(kInterpolation4thOrder); + } else if (interpolation == "7th") { + _miscInterpolationPopUp->setSelectedTag(kInterpolation7thOrder); + } +} + +void FluidSynthSettingsDialog::close() { + if (getResult()) { + if (_chorusOverride->getState()) { + ConfMan.setInt("fluidsynth_chorus_nr", _chorusVoiceCountSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_chorus_level", _chorusLevelSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_chorus_speed", _chorusSpeedSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_chorus_depth", _chorusDepthSlider->getValue(), _domain); + + uint32 waveForm = _chorusWaveFormTypePopUp->getSelectedTag(); + if (waveForm == kWaveFormTypeSine) { + ConfMan.set("fluidsynth_chorus_waveform", "sine", _domain); + } else if (waveForm == kWaveFormTypeTriangle) { + ConfMan.set("fluidsynth_chorus_waveform", "triangle", _domain); + } else { + ConfMan.removeKey("fluidsynth_chorus_waveform", _domain); + } + } else { + ConfMan.removeKey("fluidsynth_chorus_nr", _domain); + ConfMan.removeKey("fluidsynth_chorus_level", _domain); + ConfMan.removeKey("fluidsynth_chorus_speed", _domain); + ConfMan.removeKey("fluidsynth_chorus_depth", _domain); + ConfMan.removeKey("fluidsynth_chorus_waveform", _domain); + } + + if (_reverbOverride->getState()) { + ConfMan.setInt("fluidsynth_reverb_roomsize", _reverbRoomSizeSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_reverb_damping", _reverbDampingSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_reverb_width", _reverbWidthSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_reverb_level", _reverbLevelSlider->getValue(), _domain); + } else { + ConfMan.removeKey("fluidsynth_reverb_roomsize", _domain); + ConfMan.removeKey("fluidsynth_reverb_damping", _domain); + ConfMan.removeKey("fluidsynth_reverb_width", _domain); + ConfMan.removeKey("fluidsynth_reverb_level", _domain); + } + + uint32 interpolation = _miscInterpolationPopUp->getSelectedTag(); + if (interpolation == kInterpolationNone) { + ConfMan.set("fluidsynth_misc_interpolation", "none", _domain); + } else if (interpolation == kInterpolationLinear) { + ConfMan.set("fluidsynth_misc_interpolation", "linear", _domain); + } else if (interpolation == kInterpolation4thOrder) { + ConfMan.set("fluidsynth_misc_interpolation", "4th", _domain); + } else if (interpolation == kInterpolation7thOrder) { + ConfMan.set("fluidsynth_misc_interpolation", "7th", _domain); + } else { + ConfMan.removeKey("fluidsynth_misc_interpolation", _domain); + } + + // The main options dialog is responsible for writing the config file. + } + + Dialog::close(); +} + +void FluidSynthSettingsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { + switch (cmd) { + case kOverrideChorusCmd: + setChorusSettingsState(data); + break; + case kChorusVoiceCountChangedCmd: + _chorusVoiceCountLabel->setLabel(Common::String::format("%d", _chorusVoiceCountSlider->getValue())); + _chorusVoiceCountLabel->draw(); + break; + case kChorusLevelChangedCmd: + _chorusLevelLabel->setLabel(Common::String::format("%.2f", (double)_chorusLevelSlider->getValue() / 100.0)); + _chorusLevelLabel->draw(); + break; + case kChorusSpeedChangedCmd: + _chorusSpeedLabel->setLabel(Common::String::format("%.2f", (double)_chorusSpeedSlider->getValue() / 100.0)); + _chorusSpeedLabel->draw(); + break; + case kChorusDepthChangedCmd: + _chorusDepthLabel->setLabel(Common::String::format("%.2f", (double)_chorusDepthSlider->getValue() / 100.0)); + _chorusDepthLabel->draw(); + break; + case kOverrideReverbCmd: + setReverbSettingsState(data); + break; + case kReverbRoomSizeChangedCmd: + _reverbRoomSizeLabel->setLabel(Common::String::format("%.2f", (double)_reverbRoomSizeSlider->getValue() / 100.0)); + _reverbRoomSizeLabel->draw(); + break; + case kReverbDampingChangedCmd: + _reverbDampingLabel->setLabel(Common::String::format("%.2f", (double)_reverbDampingSlider->getValue() / 100.0)); + _reverbDampingLabel->draw(); + break; + case kReverbWidthChangedCmd: + _reverbWidthLabel->setLabel(Common::String::format("%.1f", (double)_reverbWidthSlider->getValue() / 10.0)); + _reverbWidthLabel->draw(); + break; + case kReverbLevelChangedCmd: + _reverbLevelLabel->setLabel(Common::String::format("%.2f", (double)_reverbLevelSlider->getValue() / 100.0)); + _reverbLevelLabel->draw(); + break; + case kOKCmd: + setResult(1); + close(); + break; + default: + Dialog::handleCommand(sender, cmd, data); + break; + } +} + +void FluidSynthSettingsDialog::setChorusSettingsState(bool enabled) { + _chorusVoiceCountDesc->setEnabled(enabled); + _chorusVoiceCountSlider->setEnabled(enabled); + _chorusVoiceCountLabel->setEnabled(enabled); + _chorusLevelDesc->setEnabled(enabled); + _chorusLevelSlider->setEnabled(enabled); + _chorusLevelLabel->setEnabled(enabled); + _chorusSpeedDesc->setEnabled(enabled); + _chorusSpeedSlider->setEnabled(enabled); + _chorusSpeedLabel->setEnabled(enabled); + _chorusDepthDesc->setEnabled(enabled); + _chorusDepthSlider->setEnabled(enabled); + _chorusDepthLabel->setEnabled(enabled); + _chorusWaveFormTypePopUpDesc->setEnabled(enabled); + _chorusWaveFormTypePopUp->setEnabled(enabled); +} + +void FluidSynthSettingsDialog::setReverbSettingsState(bool enabled) { + _reverbRoomSizeDesc->setEnabled(enabled); + _reverbRoomSizeSlider->setEnabled(enabled); + _reverbRoomSizeLabel->setEnabled(enabled); + _reverbDampingDesc->setEnabled(enabled); + _reverbDampingSlider->setEnabled(enabled); + _reverbDampingLabel->setEnabled(enabled); + _reverbWidthDesc->setEnabled(enabled); + _reverbWidthSlider->setEnabled(enabled); + _reverbWidthLabel->setEnabled(enabled); + _reverbLevelDesc->setEnabled(enabled); + _reverbLevelSlider->setEnabled(enabled); + _reverbLevelLabel->setEnabled(enabled); +} + +} // End of namespace GUI -- cgit v1.2.3 From a188a43da6a8d71a8d317b3c1f404088ce608336 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 27 Dec 2012 21:43:33 +0100 Subject: GUI: Make the FluidSynth settings dialog a bit more like Qsynth To help people familiar with Qsynth (I'm not, but it seems to be one of the more polished FluidSynth front ends), use the same presentation and terminology for the FluidSynth settings. More to follow. --- gui/fluidsynth-dialog.cpp | 147 +++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 81 deletions(-) (limited to 'gui/fluidsynth-dialog.cpp') diff --git a/gui/fluidsynth-dialog.cpp b/gui/fluidsynth-dialog.cpp index c7e646e5f3..3e38c6a17f 100644 --- a/gui/fluidsynth-dialog.cpp +++ b/gui/fluidsynth-dialog.cpp @@ -30,13 +30,13 @@ namespace GUI { enum { - kOverrideChorusCmd = 'ocho', + kActivateChorusCmd = 'acho', kChorusVoiceCountChangedCmd = 'cvcc', kChorusLevelChangedCmd = 'clec', kChorusSpeedChangedCmd = 'cspc', kChorusDepthChangedCmd = 'cdec', - kOverrideReverbCmd = 'orev', + kActivateReverbCmd = 'arev', kReverbRoomSizeChangedCmd = 'rrsc', kReverbDampingChangedCmd = 'rdac', kReverbWidthChangedCmd = 'rwic', @@ -63,34 +63,37 @@ FluidSynthSettingsDialog::FluidSynthSettingsDialog() _tabWidget->addTab(_("Chorus")); - _chorusOverride = new CheckboxWidget(_tabWidget, "FluidSynthSettings_Chorus.EnableTabCheckbox", _("Override chorus settings"), 0, kOverrideChorusCmd); + _chorusActivate = new CheckboxWidget(_tabWidget, "FluidSynthSettings_Chorus.EnableTabCheckbox", _("Active"), 0, kActivateChorusCmd); - _chorusVoiceCountDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.VoiceCountText", _("Voice count:")); + _chorusVoiceCountDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.VoiceCountText", _("N:")); _chorusVoiceCountSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Chorus.VoiceCountSlider", 0, kChorusVoiceCountChangedCmd); + // 0-99, Default: 3 _chorusVoiceCountSlider->setMinValue(0); _chorusVoiceCountSlider->setMaxValue(99); _chorusVoiceCountLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.VoiceCountLabel", "3"); _chorusLevelDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.LevelText", _("Level:")); _chorusLevelSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Chorus.LevelSlider", 0, kChorusLevelChangedCmd); + // 0.00 - 1.00, Default: 1.00 _chorusLevelSlider->setMinValue(0); - _chorusLevelSlider->setMaxValue(1000); - _chorusLevelLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.LevelLabel", "2.00"); + _chorusLevelSlider->setMaxValue(100); + _chorusLevelLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.LevelLabel", "100"); - _chorusSpeedDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.SpeedText", _("Speed (Hz):")); + _chorusSpeedDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.SpeedText", _("Speed:")); _chorusSpeedSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Chorus.SpeedSlider", 0, kChorusSpeedChangedCmd); - _chorusSpeedSlider->setMinValue(29); + // 0.30 - 5.00, Default: 0.30 + _chorusSpeedSlider->setMinValue(30); _chorusSpeedSlider->setMaxValue(500); - _chorusSpeedSlider->setValue(29); - _chorusSpeedLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.SpeedLabel", "0.30"); + _chorusSpeedLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.SpeedLabel", "30"); _chorusDepthDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.DepthText", _("Depth:")); _chorusDepthSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Chorus.DepthSlider", 0, kChorusDepthChangedCmd); + // 0.00 - 21.00, Default: 8.00 _chorusDepthSlider->setMinValue(0); - _chorusDepthSlider->setMaxValue(2100); - _chorusDepthLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.DepthLabel", "8.00"); + _chorusDepthSlider->setMaxValue(210); + _chorusDepthLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.DepthLabel", "80"); - _chorusWaveFormTypePopUpDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.WaveFormTypeText", _("Waveform type:")); + _chorusWaveFormTypePopUpDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Chorus.WaveFormTypeText", _("Type:")); _chorusWaveFormTypePopUp = new PopUpWidget(_tabWidget, "FluidSynthSettings_Chorus.WaveFormType"); _chorusWaveFormTypePopUp->appendEntry(_("Sine"), kWaveFormTypeSine); @@ -98,31 +101,35 @@ FluidSynthSettingsDialog::FluidSynthSettingsDialog() _tabWidget->addTab(_("Reverb")); - _reverbOverride = new CheckboxWidget(_tabWidget, "FluidSynthSettings_Reverb.EnableTabCheckbox", _("Override reverb settings"), 0, kOverrideReverbCmd); + _reverbActivate = new CheckboxWidget(_tabWidget, "FluidSynthSettings_Reverb.EnableTabCheckbox", _("Activate"), 0, kActivateReverbCmd); - _reverbRoomSizeDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeText", _("Room size:")); + _reverbRoomSizeDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeText", _("Room:")); _reverbRoomSizeSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeSlider", 0, kReverbRoomSizeChangedCmd); + // 0.00 - 1.20, Default: 0.20 _reverbRoomSizeSlider->setMinValue(0); _reverbRoomSizeSlider->setMaxValue(120); - _reverbRoomSizeLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeLabel", "0.20"); + _reverbRoomSizeLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeLabel", "20"); - _reverbDampingDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingText", _("Damping:")); + _reverbDampingDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingText", _("Damp:")); _reverbDampingSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingSlider", 0, kReverbDampingChangedCmd); + // 0.00 - 1.00, Default: 0.00 _reverbDampingSlider->setMinValue(0); _reverbDampingSlider->setMaxValue(100); - _reverbDampingLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingLabel", "0.00"); + _reverbDampingLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingLabel", "0"); _reverbWidthDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.WidthText", _("Width:")); _reverbWidthSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.WidthSlider", 0, kReverbWidthChangedCmd); + // 0 - 100, Default: 1 _reverbWidthSlider->setMinValue(0); - _reverbWidthSlider->setMaxValue(1000); - _reverbWidthLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.WidthLabel", "0.5"); + _reverbWidthSlider->setMaxValue(100); + _reverbWidthLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.WidthLabel", "1"); _reverbLevelDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.LevelText", _("Level:")); _reverbLevelSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.LevelSlider", 0, kReverbLevelChangedCmd); + // 0.00 - 1.00, Default: 0.90 _reverbLevelSlider->setMinValue(0); _reverbLevelSlider->setMaxValue(100); - _reverbLevelLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.LevelLabel", "0.90"); + _reverbLevelLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.LevelLabel", "90"); _tabWidget->addTab(_("Misc")); @@ -149,29 +156,14 @@ void FluidSynthSettingsDialog::open() { // Reset result value setResult(0); - bool e; - - e = ConfMan.hasKey("fluidsynth_chorus_nr", _domain) || - ConfMan.hasKey("fluidsynth_chorus_level", _domain) || - ConfMan.hasKey("fluidsynth_chorus_speed", _domain) || - ConfMan.hasKey("fluidsynth_chorus_depth", _domain) || - ConfMan.hasKey("fluidsynth_chorus_waveform", _domain); - _chorusOverride->setState(e); - - e = ConfMan.hasKey("fluidsynth_reverb_roomsize", _domain) || - ConfMan.hasKey("fluidsynth_reverb_damping", _domain) || - ConfMan.hasKey("fluidsynth_reverb_width", _domain) || - ConfMan.hasKey("fluidsynth_reverb_level", _domain); - _reverbOverride->setState(e); - _chorusVoiceCountSlider->setValue(ConfMan.getInt("fluidsynth_chorus_nr", _domain)); _chorusVoiceCountLabel->setLabel(Common::String::format("%d", _chorusVoiceCountSlider->getValue())); _chorusLevelSlider->setValue(ConfMan.getInt("fluidsynth_chorus_level", _domain)); - _chorusLevelLabel->setLabel(Common::String::format("%.2f", (double)_chorusLevelSlider->getValue() / 100.0)); + _chorusLevelLabel->setLabel(Common::String::format("%d", _chorusLevelSlider->getValue())); _chorusSpeedSlider->setValue(ConfMan.getInt("fluidsynth_chorus_speed", _domain)); - _chorusSpeedLabel->setLabel(Common::String::format("%.2f", (double)_chorusSpeedSlider->getValue() / 100.0)); + _chorusSpeedLabel->setLabel(Common::String::format("%d", _chorusSpeedSlider->getValue())); _chorusDepthSlider->setValue(ConfMan.getInt("fluidsynth_chorus_depth", _domain)); - _chorusDepthLabel->setLabel(Common::String::format("%.2f", (double)_chorusDepthSlider->getValue() / 100.0)); + _chorusDepthLabel->setLabel(Common::String::format("%d", _chorusDepthSlider->getValue())); Common::String waveForm = ConfMan.get("fluidsynth_chorus_waveform", _domain); if (waveForm == "sine") { @@ -181,13 +173,13 @@ void FluidSynthSettingsDialog::open() { } _reverbRoomSizeSlider->setValue(ConfMan.getInt("fluidsynth_reverb_roomsize", _domain)); - _reverbRoomSizeLabel->setLabel(Common::String::format("%.2f", (double)_reverbRoomSizeSlider->getValue() / 100.0)); + _reverbRoomSizeLabel->setLabel(Common::String::format("%d", _reverbRoomSizeSlider->getValue())); _reverbDampingSlider->setValue(ConfMan.getInt("fluidsynth_reverb_damping", _domain)); - _reverbDampingLabel->setLabel(Common::String::format("%.2f", (double)_reverbDampingSlider->getValue() / 100.0)); + _reverbDampingLabel->setLabel(Common::String::format("%d", _reverbDampingSlider->getValue())); _reverbWidthSlider->setValue(ConfMan.getInt("fluidsynth_reverb_width", _domain)); - _reverbWidthLabel->setLabel(Common::String::format("%.2f", (double)_reverbWidthSlider->getValue() / 10.0)); + _reverbWidthLabel->setLabel(Common::String::format("%d", _reverbWidthSlider->getValue())); _reverbLevelSlider->setValue(ConfMan.getInt("fluidsynth_reverb_level", _domain)); - _reverbLevelLabel->setLabel(Common::String::format("%.2f", (double)_reverbLevelSlider->getValue() / 100.0)); + _reverbLevelLabel->setLabel(Common::String::format("%d", _reverbLevelSlider->getValue())); Common::String interpolation = ConfMan.get("fluidsynth_misc_interpolation", _domain); if (interpolation == "none") { @@ -199,43 +191,36 @@ void FluidSynthSettingsDialog::open() { } else if (interpolation == "7th") { _miscInterpolationPopUp->setSelectedTag(kInterpolation7thOrder); } + + // This may trigger redrawing, so don't do it until all sliders have + // their proper values. Otherwise, the dialog may crash because of + // invalid slider values. + _chorusActivate->setState(ConfMan.getBool("fluidsynth_chorus_activate", _domain)); + _reverbActivate->setState(ConfMan.getBool("fluidsynth_reverb_activate", _domain)); } void FluidSynthSettingsDialog::close() { if (getResult()) { - if (_chorusOverride->getState()) { - ConfMan.setInt("fluidsynth_chorus_nr", _chorusVoiceCountSlider->getValue(), _domain); - ConfMan.setInt("fluidsynth_chorus_level", _chorusLevelSlider->getValue(), _domain); - ConfMan.setInt("fluidsynth_chorus_speed", _chorusSpeedSlider->getValue(), _domain); - ConfMan.setInt("fluidsynth_chorus_depth", _chorusDepthSlider->getValue(), _domain); - - uint32 waveForm = _chorusWaveFormTypePopUp->getSelectedTag(); - if (waveForm == kWaveFormTypeSine) { - ConfMan.set("fluidsynth_chorus_waveform", "sine", _domain); - } else if (waveForm == kWaveFormTypeTriangle) { - ConfMan.set("fluidsynth_chorus_waveform", "triangle", _domain); - } else { - ConfMan.removeKey("fluidsynth_chorus_waveform", _domain); - } + ConfMan.setBool("fluidsynth_chorus_activate", _chorusActivate->getState()); + ConfMan.setInt("fluidsynth_chorus_nr", _chorusVoiceCountSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_chorus_level", _chorusLevelSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_chorus_speed", _chorusSpeedSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_chorus_depth", _chorusDepthSlider->getValue(), _domain); + + uint32 waveForm = _chorusWaveFormTypePopUp->getSelectedTag(); + if (waveForm == kWaveFormTypeSine) { + ConfMan.set("fluidsynth_chorus_waveform", "sine", _domain); + } else if (waveForm == kWaveFormTypeTriangle) { + ConfMan.set("fluidsynth_chorus_waveform", "triangle", _domain); } else { - ConfMan.removeKey("fluidsynth_chorus_nr", _domain); - ConfMan.removeKey("fluidsynth_chorus_level", _domain); - ConfMan.removeKey("fluidsynth_chorus_speed", _domain); - ConfMan.removeKey("fluidsynth_chorus_depth", _domain); ConfMan.removeKey("fluidsynth_chorus_waveform", _domain); } - if (_reverbOverride->getState()) { - ConfMan.setInt("fluidsynth_reverb_roomsize", _reverbRoomSizeSlider->getValue(), _domain); - ConfMan.setInt("fluidsynth_reverb_damping", _reverbDampingSlider->getValue(), _domain); - ConfMan.setInt("fluidsynth_reverb_width", _reverbWidthSlider->getValue(), _domain); - ConfMan.setInt("fluidsynth_reverb_level", _reverbLevelSlider->getValue(), _domain); - } else { - ConfMan.removeKey("fluidsynth_reverb_roomsize", _domain); - ConfMan.removeKey("fluidsynth_reverb_damping", _domain); - ConfMan.removeKey("fluidsynth_reverb_width", _domain); - ConfMan.removeKey("fluidsynth_reverb_level", _domain); - } + ConfMan.setBool("fluidsynth_reverb_activate", _reverbActivate->getState()); + ConfMan.setInt("fluidsynth_reverb_roomsize", _reverbRoomSizeSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_reverb_damping", _reverbDampingSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_reverb_width", _reverbWidthSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_reverb_level", _reverbLevelSlider->getValue(), _domain); uint32 interpolation = _miscInterpolationPopUp->getSelectedTag(); if (interpolation == kInterpolationNone) { @@ -258,7 +243,7 @@ void FluidSynthSettingsDialog::close() { void FluidSynthSettingsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { - case kOverrideChorusCmd: + case kActivateChorusCmd: setChorusSettingsState(data); break; case kChorusVoiceCountChangedCmd: @@ -266,34 +251,34 @@ void FluidSynthSettingsDialog::handleCommand(CommandSender *sender, uint32 cmd, _chorusVoiceCountLabel->draw(); break; case kChorusLevelChangedCmd: - _chorusLevelLabel->setLabel(Common::String::format("%.2f", (double)_chorusLevelSlider->getValue() / 100.0)); + _chorusLevelLabel->setLabel(Common::String::format("%d", _chorusLevelSlider->getValue())); _chorusLevelLabel->draw(); break; case kChorusSpeedChangedCmd: - _chorusSpeedLabel->setLabel(Common::String::format("%.2f", (double)_chorusSpeedSlider->getValue() / 100.0)); + _chorusSpeedLabel->setLabel(Common::String::format("%d", _chorusSpeedSlider->getValue())); _chorusSpeedLabel->draw(); break; case kChorusDepthChangedCmd: - _chorusDepthLabel->setLabel(Common::String::format("%.2f", (double)_chorusDepthSlider->getValue() / 100.0)); + _chorusDepthLabel->setLabel(Common::String::format("%d", _chorusDepthSlider->getValue())); _chorusDepthLabel->draw(); break; - case kOverrideReverbCmd: + case kActivateReverbCmd: setReverbSettingsState(data); break; case kReverbRoomSizeChangedCmd: - _reverbRoomSizeLabel->setLabel(Common::String::format("%.2f", (double)_reverbRoomSizeSlider->getValue() / 100.0)); + _reverbRoomSizeLabel->setLabel(Common::String::format("%d", _reverbRoomSizeSlider->getValue())); _reverbRoomSizeLabel->draw(); break; case kReverbDampingChangedCmd: - _reverbDampingLabel->setLabel(Common::String::format("%.2f", (double)_reverbDampingSlider->getValue() / 100.0)); + _reverbDampingLabel->setLabel(Common::String::format("%d", _reverbDampingSlider->getValue())); _reverbDampingLabel->draw(); break; case kReverbWidthChangedCmd: - _reverbWidthLabel->setLabel(Common::String::format("%.1f", (double)_reverbWidthSlider->getValue() / 10.0)); + _reverbWidthLabel->setLabel(Common::String::format("%d", _reverbWidthSlider->getValue())); _reverbWidthLabel->draw(); break; case kReverbLevelChangedCmd: - _reverbLevelLabel->setLabel(Common::String::format("%.2f", (double)_reverbLevelSlider->getValue() / 100.0)); + _reverbLevelLabel->setLabel(Common::String::format("%d", _reverbLevelSlider->getValue())); _reverbLevelLabel->draw(); break; case kOKCmd: -- cgit v1.2.3 From 45c1296021bc6c0d816d8652f868e3bff49c32e3 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 27 Dec 2012 21:47:43 +0100 Subject: GUI: Swap Reverb and Chorus tabs in FluidSynth settings Again, this is to be more like Qsynth. --- gui/fluidsynth-dialog.cpp | 64 +++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'gui/fluidsynth-dialog.cpp') diff --git a/gui/fluidsynth-dialog.cpp b/gui/fluidsynth-dialog.cpp index 3e38c6a17f..eefe8c558e 100644 --- a/gui/fluidsynth-dialog.cpp +++ b/gui/fluidsynth-dialog.cpp @@ -61,6 +61,38 @@ FluidSynthSettingsDialog::FluidSynthSettingsDialog() _tabWidget = new TabWidget(this, "FluidSynthSettings.TabWidget"); + _tabWidget->addTab(_("Reverb")); + + _reverbActivate = new CheckboxWidget(_tabWidget, "FluidSynthSettings_Reverb.EnableTabCheckbox", _("Activate"), 0, kActivateReverbCmd); + + _reverbRoomSizeDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeText", _("Room:")); + _reverbRoomSizeSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeSlider", 0, kReverbRoomSizeChangedCmd); + // 0.00 - 1.20, Default: 0.20 + _reverbRoomSizeSlider->setMinValue(0); + _reverbRoomSizeSlider->setMaxValue(120); + _reverbRoomSizeLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeLabel", "20"); + + _reverbDampingDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingText", _("Damp:")); + _reverbDampingSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingSlider", 0, kReverbDampingChangedCmd); + // 0.00 - 1.00, Default: 0.00 + _reverbDampingSlider->setMinValue(0); + _reverbDampingSlider->setMaxValue(100); + _reverbDampingLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingLabel", "0"); + + _reverbWidthDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.WidthText", _("Width:")); + _reverbWidthSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.WidthSlider", 0, kReverbWidthChangedCmd); + // 0 - 100, Default: 1 + _reverbWidthSlider->setMinValue(0); + _reverbWidthSlider->setMaxValue(100); + _reverbWidthLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.WidthLabel", "1"); + + _reverbLevelDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.LevelText", _("Level:")); + _reverbLevelSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.LevelSlider", 0, kReverbLevelChangedCmd); + // 0.00 - 1.00, Default: 0.90 + _reverbLevelSlider->setMinValue(0); + _reverbLevelSlider->setMaxValue(100); + _reverbLevelLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.LevelLabel", "90"); + _tabWidget->addTab(_("Chorus")); _chorusActivate = new CheckboxWidget(_tabWidget, "FluidSynthSettings_Chorus.EnableTabCheckbox", _("Active"), 0, kActivateChorusCmd); @@ -99,38 +131,6 @@ FluidSynthSettingsDialog::FluidSynthSettingsDialog() _chorusWaveFormTypePopUp->appendEntry(_("Sine"), kWaveFormTypeSine); _chorusWaveFormTypePopUp->appendEntry(_("Triangle"), kWaveFormTypeTriangle); - _tabWidget->addTab(_("Reverb")); - - _reverbActivate = new CheckboxWidget(_tabWidget, "FluidSynthSettings_Reverb.EnableTabCheckbox", _("Activate"), 0, kActivateReverbCmd); - - _reverbRoomSizeDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeText", _("Room:")); - _reverbRoomSizeSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeSlider", 0, kReverbRoomSizeChangedCmd); - // 0.00 - 1.20, Default: 0.20 - _reverbRoomSizeSlider->setMinValue(0); - _reverbRoomSizeSlider->setMaxValue(120); - _reverbRoomSizeLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeLabel", "20"); - - _reverbDampingDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingText", _("Damp:")); - _reverbDampingSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingSlider", 0, kReverbDampingChangedCmd); - // 0.00 - 1.00, Default: 0.00 - _reverbDampingSlider->setMinValue(0); - _reverbDampingSlider->setMaxValue(100); - _reverbDampingLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.DampingLabel", "0"); - - _reverbWidthDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.WidthText", _("Width:")); - _reverbWidthSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.WidthSlider", 0, kReverbWidthChangedCmd); - // 0 - 100, Default: 1 - _reverbWidthSlider->setMinValue(0); - _reverbWidthSlider->setMaxValue(100); - _reverbWidthLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.WidthLabel", "1"); - - _reverbLevelDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.LevelText", _("Level:")); - _reverbLevelSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.LevelSlider", 0, kReverbLevelChangedCmd); - // 0.00 - 1.00, Default: 0.90 - _reverbLevelSlider->setMinValue(0); - _reverbLevelSlider->setMaxValue(100); - _reverbLevelLabel = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.LevelLabel", "90"); - _tabWidget->addTab(_("Misc")); _miscInterpolationPopUpDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Misc.InterpolationText", _("Interpolation:")); -- cgit v1.2.3 From c780df51758df99d8eb18513573882a4b1291f21 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 27 Dec 2012 22:11:35 +0100 Subject: GUI: Add "Reset" button to FluidSynth settings dialog This resets the FluidSynth settings to their default values. --- gui/fluidsynth-dialog.cpp | 194 ++++++++++++++++++++++++++++------------------ 1 file changed, 117 insertions(+), 77 deletions(-) (limited to 'gui/fluidsynth-dialog.cpp') diff --git a/gui/fluidsynth-dialog.cpp b/gui/fluidsynth-dialog.cpp index eefe8c558e..eb5bac9645 100644 --- a/gui/fluidsynth-dialog.cpp +++ b/gui/fluidsynth-dialog.cpp @@ -20,6 +20,7 @@ */ #include "gui/fluidsynth-dialog.h" +#include "gui/message.h" #include "gui/widgets/tab.h" #include "gui/widgets/popup.h" @@ -40,7 +41,9 @@ enum { kReverbRoomSizeChangedCmd = 'rrsc', kReverbDampingChangedCmd = 'rdac', kReverbWidthChangedCmd = 'rwic', - kReverbLevelChangedCmd = 'rlec' + kReverbLevelChangedCmd = 'rlec', + + kResetSettingsCmd = 'rese' }; enum { @@ -141,6 +144,8 @@ FluidSynthSettingsDialog::FluidSynthSettingsDialog() _miscInterpolationPopUp->appendEntry(_("Fourth-order"), kInterpolation4thOrder); _miscInterpolationPopUp->appendEntry(_("Seventh-order"), kInterpolation7thOrder); + new ButtonWidget(_tabWidget, "FluidSynthSettings_Misc.ResetSettings", _("Reset"), _("Reset all FluidSynth settings to their default values."), kResetSettingsCmd); + _tabWidget->setActiveTab(0); new ButtonWidget(this, "FluidSynthSettings.Cancel", _("Cancel"), 0, kCloseCmd); @@ -156,86 +161,12 @@ void FluidSynthSettingsDialog::open() { // Reset result value setResult(0); - _chorusVoiceCountSlider->setValue(ConfMan.getInt("fluidsynth_chorus_nr", _domain)); - _chorusVoiceCountLabel->setLabel(Common::String::format("%d", _chorusVoiceCountSlider->getValue())); - _chorusLevelSlider->setValue(ConfMan.getInt("fluidsynth_chorus_level", _domain)); - _chorusLevelLabel->setLabel(Common::String::format("%d", _chorusLevelSlider->getValue())); - _chorusSpeedSlider->setValue(ConfMan.getInt("fluidsynth_chorus_speed", _domain)); - _chorusSpeedLabel->setLabel(Common::String::format("%d", _chorusSpeedSlider->getValue())); - _chorusDepthSlider->setValue(ConfMan.getInt("fluidsynth_chorus_depth", _domain)); - _chorusDepthLabel->setLabel(Common::String::format("%d", _chorusDepthSlider->getValue())); - - Common::String waveForm = ConfMan.get("fluidsynth_chorus_waveform", _domain); - if (waveForm == "sine") { - _chorusWaveFormTypePopUp->setSelectedTag(kWaveFormTypeSine); - } else if (waveForm == "triangle") { - _chorusWaveFormTypePopUp->setSelectedTag(kWaveFormTypeTriangle); - } - - _reverbRoomSizeSlider->setValue(ConfMan.getInt("fluidsynth_reverb_roomsize", _domain)); - _reverbRoomSizeLabel->setLabel(Common::String::format("%d", _reverbRoomSizeSlider->getValue())); - _reverbDampingSlider->setValue(ConfMan.getInt("fluidsynth_reverb_damping", _domain)); - _reverbDampingLabel->setLabel(Common::String::format("%d", _reverbDampingSlider->getValue())); - _reverbWidthSlider->setValue(ConfMan.getInt("fluidsynth_reverb_width", _domain)); - _reverbWidthLabel->setLabel(Common::String::format("%d", _reverbWidthSlider->getValue())); - _reverbLevelSlider->setValue(ConfMan.getInt("fluidsynth_reverb_level", _domain)); - _reverbLevelLabel->setLabel(Common::String::format("%d", _reverbLevelSlider->getValue())); - - Common::String interpolation = ConfMan.get("fluidsynth_misc_interpolation", _domain); - if (interpolation == "none") { - _miscInterpolationPopUp->setSelectedTag(kInterpolationNone); - } else if (interpolation == "linear") { - _miscInterpolationPopUp->setSelectedTag(kInterpolationLinear); - } else if (interpolation == "4th") { - _miscInterpolationPopUp->setSelectedTag(kInterpolation4thOrder); - } else if (interpolation == "7th") { - _miscInterpolationPopUp->setSelectedTag(kInterpolation7thOrder); - } - - // This may trigger redrawing, so don't do it until all sliders have - // their proper values. Otherwise, the dialog may crash because of - // invalid slider values. - _chorusActivate->setState(ConfMan.getBool("fluidsynth_chorus_activate", _domain)); - _reverbActivate->setState(ConfMan.getBool("fluidsynth_reverb_activate", _domain)); + readSettings(); } void FluidSynthSettingsDialog::close() { if (getResult()) { - ConfMan.setBool("fluidsynth_chorus_activate", _chorusActivate->getState()); - ConfMan.setInt("fluidsynth_chorus_nr", _chorusVoiceCountSlider->getValue(), _domain); - ConfMan.setInt("fluidsynth_chorus_level", _chorusLevelSlider->getValue(), _domain); - ConfMan.setInt("fluidsynth_chorus_speed", _chorusSpeedSlider->getValue(), _domain); - ConfMan.setInt("fluidsynth_chorus_depth", _chorusDepthSlider->getValue(), _domain); - - uint32 waveForm = _chorusWaveFormTypePopUp->getSelectedTag(); - if (waveForm == kWaveFormTypeSine) { - ConfMan.set("fluidsynth_chorus_waveform", "sine", _domain); - } else if (waveForm == kWaveFormTypeTriangle) { - ConfMan.set("fluidsynth_chorus_waveform", "triangle", _domain); - } else { - ConfMan.removeKey("fluidsynth_chorus_waveform", _domain); - } - - ConfMan.setBool("fluidsynth_reverb_activate", _reverbActivate->getState()); - ConfMan.setInt("fluidsynth_reverb_roomsize", _reverbRoomSizeSlider->getValue(), _domain); - ConfMan.setInt("fluidsynth_reverb_damping", _reverbDampingSlider->getValue(), _domain); - ConfMan.setInt("fluidsynth_reverb_width", _reverbWidthSlider->getValue(), _domain); - ConfMan.setInt("fluidsynth_reverb_level", _reverbLevelSlider->getValue(), _domain); - - uint32 interpolation = _miscInterpolationPopUp->getSelectedTag(); - if (interpolation == kInterpolationNone) { - ConfMan.set("fluidsynth_misc_interpolation", "none", _domain); - } else if (interpolation == kInterpolationLinear) { - ConfMan.set("fluidsynth_misc_interpolation", "linear", _domain); - } else if (interpolation == kInterpolation4thOrder) { - ConfMan.set("fluidsynth_misc_interpolation", "4th", _domain); - } else if (interpolation == kInterpolation7thOrder) { - ConfMan.set("fluidsynth_misc_interpolation", "7th", _domain); - } else { - ConfMan.removeKey("fluidsynth_misc_interpolation", _domain); - } - - // The main options dialog is responsible for writing the config file. + writeSettings(); } Dialog::close(); @@ -281,6 +212,15 @@ void FluidSynthSettingsDialog::handleCommand(CommandSender *sender, uint32 cmd, _reverbLevelLabel->setLabel(Common::String::format("%d", _reverbLevelSlider->getValue())); _reverbLevelLabel->draw(); break; + case kResetSettingsCmd: { + MessageDialog alert(_("Do you really want to reset all FluidSynth settings to their default values?"), _("Yes"), _("No")); + if (alert.runModal() == GUI::kMessageOK) { + resetSettings(); + readSettings(); + draw(); + } + break; + } case kOKCmd: setResult(1); close(); @@ -323,4 +263,104 @@ void FluidSynthSettingsDialog::setReverbSettingsState(bool enabled) { _reverbLevelLabel->setEnabled(enabled); } +void FluidSynthSettingsDialog::readSettings() { + _chorusVoiceCountSlider->setValue(ConfMan.getInt("fluidsynth_chorus_nr", _domain)); + _chorusVoiceCountLabel->setLabel(Common::String::format("%d", _chorusVoiceCountSlider->getValue())); + _chorusLevelSlider->setValue(ConfMan.getInt("fluidsynth_chorus_level", _domain)); + _chorusLevelLabel->setLabel(Common::String::format("%d", _chorusLevelSlider->getValue())); + _chorusSpeedSlider->setValue(ConfMan.getInt("fluidsynth_chorus_speed", _domain)); + _chorusSpeedLabel->setLabel(Common::String::format("%d", _chorusSpeedSlider->getValue())); + _chorusDepthSlider->setValue(ConfMan.getInt("fluidsynth_chorus_depth", _domain)); + _chorusDepthLabel->setLabel(Common::String::format("%d", _chorusDepthSlider->getValue())); + + Common::String waveForm = ConfMan.get("fluidsynth_chorus_waveform", _domain); + if (waveForm == "sine") { + _chorusWaveFormTypePopUp->setSelectedTag(kWaveFormTypeSine); + } else if (waveForm == "triangle") { + _chorusWaveFormTypePopUp->setSelectedTag(kWaveFormTypeTriangle); + } + + _reverbRoomSizeSlider->setValue(ConfMan.getInt("fluidsynth_reverb_roomsize", _domain)); + _reverbRoomSizeLabel->setLabel(Common::String::format("%d", _reverbRoomSizeSlider->getValue())); + _reverbDampingSlider->setValue(ConfMan.getInt("fluidsynth_reverb_damping", _domain)); + _reverbDampingLabel->setLabel(Common::String::format("%d", _reverbDampingSlider->getValue())); + _reverbWidthSlider->setValue(ConfMan.getInt("fluidsynth_reverb_width", _domain)); + _reverbWidthLabel->setLabel(Common::String::format("%d", _reverbWidthSlider->getValue())); + _reverbLevelSlider->setValue(ConfMan.getInt("fluidsynth_reverb_level", _domain)); + _reverbLevelLabel->setLabel(Common::String::format("%d", _reverbLevelSlider->getValue())); + + Common::String interpolation = ConfMan.get("fluidsynth_misc_interpolation", _domain); + if (interpolation == "none") { + _miscInterpolationPopUp->setSelectedTag(kInterpolationNone); + } else if (interpolation == "linear") { + _miscInterpolationPopUp->setSelectedTag(kInterpolationLinear); + } else if (interpolation == "4th") { + _miscInterpolationPopUp->setSelectedTag(kInterpolation4thOrder); + } else if (interpolation == "7th") { + _miscInterpolationPopUp->setSelectedTag(kInterpolation7thOrder); + } + + // This may trigger redrawing, so don't do it until all sliders have + // their proper values. Otherwise, the dialog may crash because of + // invalid slider values. + _chorusActivate->setState(ConfMan.getBool("fluidsynth_chorus_activate", _domain)); + _reverbActivate->setState(ConfMan.getBool("fluidsynth_reverb_activate", _domain)); +} + +void FluidSynthSettingsDialog::writeSettings() { + ConfMan.setBool("fluidsynth_chorus_activate", _chorusActivate->getState()); + ConfMan.setInt("fluidsynth_chorus_nr", _chorusVoiceCountSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_chorus_level", _chorusLevelSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_chorus_speed", _chorusSpeedSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_chorus_depth", _chorusDepthSlider->getValue(), _domain); + + uint32 waveForm = _chorusWaveFormTypePopUp->getSelectedTag(); + if (waveForm == kWaveFormTypeSine) { + ConfMan.set("fluidsynth_chorus_waveform", "sine", _domain); + } else if (waveForm == kWaveFormTypeTriangle) { + ConfMan.set("fluidsynth_chorus_waveform", "triangle", _domain); + } else { + ConfMan.removeKey("fluidsynth_chorus_waveform", _domain); + } + + ConfMan.setBool("fluidsynth_reverb_activate", _reverbActivate->getState()); + ConfMan.setInt("fluidsynth_reverb_roomsize", _reverbRoomSizeSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_reverb_damping", _reverbDampingSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_reverb_width", _reverbWidthSlider->getValue(), _domain); + ConfMan.setInt("fluidsynth_reverb_level", _reverbLevelSlider->getValue(), _domain); + + uint32 interpolation = _miscInterpolationPopUp->getSelectedTag(); + if (interpolation == kInterpolationNone) { + ConfMan.set("fluidsynth_misc_interpolation", "none", _domain); + } else if (interpolation == kInterpolationLinear) { + ConfMan.set("fluidsynth_misc_interpolation", "linear", _domain); + } else if (interpolation == kInterpolation4thOrder) { + ConfMan.set("fluidsynth_misc_interpolation", "4th", _domain); + } else if (interpolation == kInterpolation7thOrder) { + ConfMan.set("fluidsynth_misc_interpolation", "7th", _domain); + } else { + ConfMan.removeKey("fluidsynth_misc_interpolation", _domain); + } + + // The main options dialog is responsible for writing the config file. + // That's why we don't actually flush the settings to the file here. +} + +void FluidSynthSettingsDialog::resetSettings() { + ConfMan.removeKey("fluidsynth_chorus_activate", _domain); + ConfMan.removeKey("fluidsynth_chorus_nr", _domain); + ConfMan.removeKey("fluidsynth_chorus_level", _domain); + ConfMan.removeKey("fluidsynth_chorus_speed", _domain); + ConfMan.removeKey("fluidsynth_chorus_depth", _domain); + ConfMan.removeKey("fluidsynth_chorus_waveform", _domain); + + ConfMan.removeKey("fluidsynth_reverb_activate", _domain); + ConfMan.removeKey("fluidsynth_reverb_roomsize", _domain); + ConfMan.removeKey("fluidsynth_reverb_damping", _domain); + ConfMan.removeKey("fluidsynth_reverb_width", _domain); + ConfMan.removeKey("fluidsynth_reverb_level", _domain); + + ConfMan.removeKey("fluidsynth_misc_interpolation", _domain); +} + } // End of namespace GUI -- cgit v1.2.3 From 10724365aa320092fa2f5b98d8f9b0ff6e219a0b Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 27 Dec 2012 22:13:45 +0100 Subject: GUI: Misc FluidSynth-related cleanups. --- gui/fluidsynth-dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui/fluidsynth-dialog.cpp') diff --git a/gui/fluidsynth-dialog.cpp b/gui/fluidsynth-dialog.cpp index eb5bac9645..d97b3d75dd 100644 --- a/gui/fluidsynth-dialog.cpp +++ b/gui/fluidsynth-dialog.cpp @@ -66,7 +66,7 @@ FluidSynthSettingsDialog::FluidSynthSettingsDialog() _tabWidget->addTab(_("Reverb")); - _reverbActivate = new CheckboxWidget(_tabWidget, "FluidSynthSettings_Reverb.EnableTabCheckbox", _("Activate"), 0, kActivateReverbCmd); + _reverbActivate = new CheckboxWidget(_tabWidget, "FluidSynthSettings_Reverb.EnableTabCheckbox", _("Active"), 0, kActivateReverbCmd); _reverbRoomSizeDesc = new StaticTextWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeText", _("Room:")); _reverbRoomSizeSlider = new SliderWidget(_tabWidget, "FluidSynthSettings_Reverb.RoomSizeSlider", 0, kReverbRoomSizeChangedCmd); -- cgit v1.2.3 From e4a77aff06645a76b575aaf4b8253760e0cd3710 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 25 Jan 2013 05:30:42 +0100 Subject: GUI: Move the FluidSynth reset button from Misc tab to bottom This should make it clearer that Reset applies to all of the FluidSynth settings, not just the Misc tab. --- gui/fluidsynth-dialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gui/fluidsynth-dialog.cpp') diff --git a/gui/fluidsynth-dialog.cpp b/gui/fluidsynth-dialog.cpp index d97b3d75dd..662518b557 100644 --- a/gui/fluidsynth-dialog.cpp +++ b/gui/fluidsynth-dialog.cpp @@ -144,10 +144,10 @@ FluidSynthSettingsDialog::FluidSynthSettingsDialog() _miscInterpolationPopUp->appendEntry(_("Fourth-order"), kInterpolation4thOrder); _miscInterpolationPopUp->appendEntry(_("Seventh-order"), kInterpolation7thOrder); - new ButtonWidget(_tabWidget, "FluidSynthSettings_Misc.ResetSettings", _("Reset"), _("Reset all FluidSynth settings to their default values."), kResetSettingsCmd); - _tabWidget->setActiveTab(0); + new ButtonWidget(this, "FluidSynthSettings.ResetSettings", _("Reset"), _("Reset all FluidSynth settings to their default values."), kResetSettingsCmd); + new ButtonWidget(this, "FluidSynthSettings.Cancel", _("Cancel"), 0, kCloseCmd); new ButtonWidget(this, "FluidSynthSettings.Ok", _("OK"), 0, kOKCmd); } -- cgit v1.2.3