mirror of https://github.com/stella-emu/stella.git
some improvements for RadioButtonGroup
This commit is contained in:
parent
15318c749a
commit
e6b36356a3
|
@ -82,17 +82,14 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font)
|
||||||
VariantList items;
|
VariantList items;
|
||||||
int tabID = myTab->addTab(" Emulation ");
|
int tabID = myTab->addTab(" Emulation ");
|
||||||
|
|
||||||
|
// settings set
|
||||||
mySettingsGroup = new RadioButtonGroup();
|
mySettingsGroup = new RadioButtonGroup();
|
||||||
|
new RadioButtonWidget(myTab, font, HBORDER, ypos + 1, "Player settings", mySettingsGroup, kPlrSettings);
|
||||||
myPlayerSettingsWidget = new RadioButtonWidget(myTab, font, HBORDER, ypos + 1, "Player settings", mySettingsGroup, kPlrSettings);
|
|
||||||
wid.push_back(myPlayerSettingsWidget);
|
|
||||||
ypos += lineHeight + VGAP;
|
ypos += lineHeight + VGAP;
|
||||||
|
new RadioButtonWidget(myTab, font, HBORDER, ypos, "Developer settings", mySettingsGroup, kDevSettings);
|
||||||
|
ypos += lineHeight + VGAP * 2;
|
||||||
|
|
||||||
myDevSettingsWidget = new RadioButtonWidget(myTab, font, HBORDER, ypos, "Developer settings", mySettingsGroup, kDevSettings);
|
myFrameStatsWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 1, ypos, "Frame statistics");
|
||||||
wid.push_back(myDevSettingsWidget);
|
|
||||||
ypos += lineHeight + VGAP;
|
|
||||||
|
|
||||||
myFrameStatsWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 1, ypos, "Show frame statistics");
|
|
||||||
wid.push_back(myFrameStatsWidget);
|
wid.push_back(myFrameStatsWidget);
|
||||||
ypos += lineHeight + VGAP;
|
ypos += lineHeight + VGAP;
|
||||||
|
|
||||||
|
@ -148,17 +145,16 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font)
|
||||||
ypos += lineHeight + VGAP;
|
ypos += lineHeight + VGAP;
|
||||||
|
|
||||||
// TV jitter effect
|
// TV jitter effect
|
||||||
myTVJitterWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT*1, ypos + 1, "Jitter/Roll effect", kTVJitter);
|
myTVJitterWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT*1, ypos + 1, "Jitter/roll effect", kTVJitter);
|
||||||
wid.push_back(myTVJitterWidget);
|
wid.push_back(myTVJitterWidget);
|
||||||
myTVJitterRecWidget = new SliderWidget(myTab, font,
|
myTVJitterRecWidget = new SliderWidget(myTab, font,
|
||||||
myTVJitterWidget->getRight()+ 16, ypos - 1,
|
myTVJitterWidget->getRight() + fontWidth * 3, ypos - 1,
|
||||||
8 * fontWidth, lineHeight, "recovery ",
|
8 * fontWidth, lineHeight, "Recovery ",
|
||||||
font.getStringWidth("recovery "), kTVJitterChanged);
|
font.getStringWidth("Recovery "), kTVJitterChanged);
|
||||||
myTVJitterRecWidget->setMinValue(1); myTVJitterRecWidget->setMaxValue(20);
|
myTVJitterRecWidget->setMinValue(1); myTVJitterRecWidget->setMaxValue(20);
|
||||||
wid.push_back(myTVJitterRecWidget);
|
wid.push_back(myTVJitterRecWidget);
|
||||||
|
|
||||||
myTVJitterRecLabelWidget = new StaticTextWidget(myTab, font,
|
myTVJitterRecLabelWidget = new StaticTextWidget(myTab, font,
|
||||||
myTVJitterRecWidget->getRight() + 4, myTVJitterRecWidget->getTop(),
|
myTVJitterRecWidget->getRight() + 4, myTVJitterRecWidget->getTop() + 2,
|
||||||
5 * fontWidth, fontHeight, "", kTextAlignLeft);
|
5 * fontWidth, fontHeight, "", kTextAlignLeft);
|
||||||
myTVJitterRecLabelWidget->setFlags(WIDGET_CLEARBG);
|
myTVJitterRecLabelWidget->setFlags(WIDGET_CLEARBG);
|
||||||
wid.push_back(myTVJitterRecLabelWidget);
|
wid.push_back(myTVJitterRecLabelWidget);
|
||||||
|
@ -446,14 +442,13 @@ void DeveloperDialog::copySetToState(SettingsSet set)
|
||||||
void DeveloperDialog::loadConfig()
|
void DeveloperDialog::loadConfig()
|
||||||
{
|
{
|
||||||
bool devSettings = instance().settings().getBool("dev.settings");
|
bool devSettings = instance().settings().getBool("dev.settings");
|
||||||
myDevSettingsWidget->setState(devSettings);
|
mySettingsGroup->setSelected(devSettings ? 1 : 0);
|
||||||
myPlayerSettingsWidget->setState(!devSettings);
|
|
||||||
|
|
||||||
// load both setting sets...
|
// load both setting sets...
|
||||||
copySettingsToSet(SettingsSet::player);
|
copySettingsToSet(SettingsSet::player);
|
||||||
copySettingsToSet(SettingsSet::developer);
|
copySettingsToSet(SettingsSet::developer);
|
||||||
// ...and select the current one
|
// ...and select the current one
|
||||||
copySetToState(devSettings ? SettingsSet::developer : SettingsSet::player);
|
copySetToState((SettingsSet)mySettingsGroup->getSelected());
|
||||||
|
|
||||||
myContinuousRewind->setState(instance().settings().getBool(devSettings ? "dev.rewind" : "plr.rewind"));
|
myContinuousRewind->setState(instance().settings().getBool(devSettings ? "dev.rewind" : "plr.rewind"));
|
||||||
myStateSize->setValue(instance().settings().getInt(devSettings ? "dev.rewind.size": "plr.rewind.size"));
|
myStateSize->setValue(instance().settings().getInt(devSettings ? "dev.rewind.size": "plr.rewind.size"));
|
||||||
|
@ -495,10 +490,8 @@ void DeveloperDialog::loadConfig()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void DeveloperDialog::saveConfig()
|
void DeveloperDialog::saveConfig()
|
||||||
{
|
{
|
||||||
bool devSettings = myDevSettingsWidget->getState();
|
instance().settings().setValue("dev.settings", mySettingsGroup->getSelected() == SettingsSet::developer);
|
||||||
|
copyStateToSet((SettingsSet)mySettingsGroup->getSelected());
|
||||||
instance().settings().setValue("dev.settings", devSettings);
|
|
||||||
copyStateToSet(devSettings ? SettingsSet::developer : SettingsSet::player);
|
|
||||||
copySetToSettings(SettingsSet::player);
|
copySetToSettings(SettingsSet::player);
|
||||||
copySetToSettings(SettingsSet::developer);
|
copySetToSettings(SettingsSet::developer);
|
||||||
|
|
||||||
|
@ -572,13 +565,12 @@ void DeveloperDialog::saveConfig()
|
||||||
|
|
||||||
void DeveloperDialog::setDefaults()
|
void DeveloperDialog::setDefaults()
|
||||||
{
|
{
|
||||||
bool devSettings = myDevSettingsWidget->getState();
|
|
||||||
|
|
||||||
switch(myTab->getActiveTab())
|
switch(myTab->getActiveTab())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
SettingsSet set = devSettings ? SettingsSet::developer : SettingsSet::player;
|
bool devSettings = mySettingsGroup->getSelected() == 1;
|
||||||
|
SettingsSet set = (SettingsSet)mySettingsGroup->getSelected();
|
||||||
|
|
||||||
myFrameStats[set] = devSettings ? true : false;
|
myFrameStats[set] = devSettings ? true : false;
|
||||||
myConsole[set] = 0;
|
myConsole[set] = 0;
|
||||||
|
@ -712,8 +704,7 @@ void DeveloperDialog::handleCommand(CommandSender* sender, int cmd, int data, in
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void DeveloperDialog::handleSettings(bool devSettings)
|
void DeveloperDialog::handleSettings(bool devSettings)
|
||||||
{
|
{
|
||||||
myDevSettingsWidget->setState(devSettings );
|
mySettingsGroup->setSelected(devSettings ? 1 : 0);
|
||||||
|
|
||||||
copyStateToSet(devSettings ? SettingsSet::player : SettingsSet::developer);
|
copyStateToSet(devSettings ? SettingsSet::player : SettingsSet::developer);
|
||||||
copySetToState(devSettings ? SettingsSet::developer : SettingsSet::player);
|
copySetToState(devSettings ? SettingsSet::developer : SettingsSet::player);
|
||||||
}
|
}
|
||||||
|
@ -728,7 +719,7 @@ void DeveloperDialog::handleTVJitterChange(bool enable)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void DeveloperDialog::handleDebugColors()
|
void DeveloperDialog::handleDebugColors()
|
||||||
{
|
{
|
||||||
if(instance().hasConsole() && myDevSettingsWidget->getState())
|
if(instance().hasConsole())
|
||||||
{
|
{
|
||||||
bool fixed = instance().console().tia().usingFixedColors();
|
bool fixed = instance().console().tia().usingFixedColors();
|
||||||
if(fixed != myDebugColorsWidget->getState())
|
if(fixed != myDebugColorsWidget->getState())
|
||||||
|
|
|
@ -93,8 +93,6 @@ class DeveloperDialog : public Dialog
|
||||||
TabWidget* myTab;
|
TabWidget* myTab;
|
||||||
// Emulator
|
// Emulator
|
||||||
RadioButtonGroup* mySettingsGroup;
|
RadioButtonGroup* mySettingsGroup;
|
||||||
RadioButtonWidget* myPlayerSettingsWidget;
|
|
||||||
RadioButtonWidget* myDevSettingsWidget;
|
|
||||||
CheckboxWidget* myFrameStatsWidget;
|
CheckboxWidget* myFrameStatsWidget;
|
||||||
PopUpWidget* myConsoleWidget;
|
PopUpWidget* myConsoleWidget;
|
||||||
StaticTextWidget* myLoadingROMLabel;
|
StaticTextWidget* myLoadingROMLabel;
|
||||||
|
|
|
@ -174,13 +174,35 @@ void RadioButtonGroup::addWidget(RadioButtonWidget* widget)
|
||||||
myWidgets.push_back(widget);
|
myWidgets.push_back(widget);
|
||||||
// set first button as default
|
// set first button as default
|
||||||
widget->setState(myWidgets.size() == 1, false);
|
widget->setState(myWidgets.size() == 1, false);
|
||||||
|
mySelected = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void RadioButtonGroup::select(RadioButtonWidget* widget)
|
void RadioButtonGroup::select(RadioButtonWidget* widget)
|
||||||
{
|
{
|
||||||
|
uInt32 i = 0;
|
||||||
|
|
||||||
for(const auto& w : myWidgets)
|
for(const auto& w : myWidgets)
|
||||||
if(w != widget)
|
{
|
||||||
((RadioButtonWidget*)w)->setState(false);
|
if(w == widget)
|
||||||
|
{
|
||||||
|
setSelected(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void RadioButtonGroup::setSelected(uInt32 selected)
|
||||||
|
{
|
||||||
|
uInt32 i = 0;
|
||||||
|
|
||||||
|
mySelected = selected;
|
||||||
|
for(const auto& w : myWidgets)
|
||||||
|
{
|
||||||
|
((RadioButtonWidget*)w)->setState(i == mySelected);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,9 +62,12 @@ class RadioButtonGroup
|
||||||
void addWidget(RadioButtonWidget* widget);
|
void addWidget(RadioButtonWidget* widget);
|
||||||
// tell the group which widget was selected
|
// tell the group which widget was selected
|
||||||
void select(RadioButtonWidget* widget);
|
void select(RadioButtonWidget* widget);
|
||||||
|
void setSelected(uInt32 selected);
|
||||||
|
uInt32 getSelected() { return mySelected; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WidgetArray myWidgets;
|
WidgetArray myWidgets;
|
||||||
|
uInt32 mySelected;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
Loading…
Reference in New Issue