GUI: Renamed Globals.TabLabelWidth to Globals.PopUpWidget.labelWidth (that's what it really is); changed PopUpWidget to use that value directly

svn-id: r35895
This commit is contained in:
Max Horn 2009-01-18 14:42:26 +00:00
parent 964a451e42
commit 5e1cf1e166
8 changed files with 32 additions and 54 deletions

View File

@ -356,15 +356,13 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) {
// PopUpWidget
//
PopUpWidget::PopUpWidget(GuiObject *boss, const String &name, const String &label, uint labelWidth)
: Widget(boss, name), CommandSender(boss), _label(label), _labelWidth(labelWidth) {
PopUpWidget::PopUpWidget(GuiObject *boss, const String &name, const String &label)
: Widget(boss, name), CommandSender(boss), _label(label), _labelWidth(0) {
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_IGNORE_DRAG);
_type = kPopUpWidget;
_selectedItem = -1;
if (!_label.empty() && _labelWidth == 0)
_labelWidth = g_gui.getStringWidth(_label);
_labelWidth = g_gui.xmlEval()->getVar("Globals.PopUpWidget.labelWidth");
}
void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) {
@ -396,6 +394,7 @@ void PopUpWidget::handleMouseWheel(int x, int y, int direction) {
}
void PopUpWidget::reflowLayout() {
_labelWidth = g_gui.xmlEval()->getVar("Globals.PopUpWidget.labelWidth");
_leftPadding = g_gui.xmlEval()->getVar("Globals.PopUpWidget.Padding.Left", 0);
_rightPadding = g_gui.xmlEval()->getVar("Globals.PopUpWidget.Padding.Right", 0);
_labelSpacing = g_gui.xmlEval()->getVar("Globals.PopUpWidget.labelSpacing", 10);

View File

@ -56,16 +56,14 @@ protected:
int _selectedItem;
String _label;
uint _labelWidth;
int _labelWidth;
int _leftPadding;
int _rightPadding;
int _labelSpacing;
public:
PopUpWidget(GuiObject *boss, const String &name, const String &label, uint labelWidth = 0);
void changeLabelWidth(uint newWidth) { _labelWidth = newWidth; }
PopUpWidget(GuiObject *boss, const String &name, const String &label);
void handleMouseDown(int x, int y, int button, int clickCount);
void handleMouseWheel(int x, int y, int direction);

View File

@ -121,8 +121,6 @@ class EditGameDialog : public OptionsDialog {
public:
EditGameDialog(const String &domain, const String &desc);
virtual void reflowLayout();
void open();
void close();
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
@ -147,8 +145,6 @@ protected:
EditGameDialog::EditGameDialog(const String &domain, const String &desc)
: OptionsDialog(domain, "GameOptions") {
int labelWidth = g_gui.xmlEval()->getVar("Globals.TabLabelWidth");
// GAME: Path to game data (r/o), extra data (r/o), and save data (r/w)
String gamePath(ConfMan.get("path", _domain));
String extraPath(ConfMan.get("extrapath", _domain));
@ -177,7 +173,7 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
_descriptionWidget = new EditTextWidget(tab, "GameOptions_Game.Desc", description);
// Language popup
_langPopUp = new PopUpWidget(tab, "GameOptions_Game.Lang", "Language:", labelWidth);
_langPopUp = new PopUpWidget(tab, "GameOptions_Game.Lang", "Language:");
_langPopUp->appendEntry("<default>");
_langPopUp->appendEntry("");
const Common::LanguageDescription *l = Common::g_languages;
@ -186,7 +182,7 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
}
// Platform popup
_platformPopUp = new PopUpWidget(tab, "GameOptions_Game.Platform", "Platform:", labelWidth);
_platformPopUp = new PopUpWidget(tab, "GameOptions_Game.Platform", "Platform:");
_platformPopUp->appendEntry("<default>");
_platformPopUp->appendEntry("");
const Common::PlatformDescription *p = Common::g_platforms;
@ -260,17 +256,6 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
new ButtonWidget(this, "GameOptions.Ok", "OK", kOKCmd, 0);
}
void EditGameDialog::reflowLayout() {
OptionsDialog::reflowLayout();
int labelWidth = g_gui.xmlEval()->getVar("Globals.TabLabelWidth");
if (_langPopUp)
_langPopUp->changeLabelWidth(labelWidth);
if (_platformPopUp)
_platformPopUp->changeLabelWidth(labelWidth);
}
void EditGameDialog::open() {
OptionsDialog::open();

View File

@ -515,10 +515,8 @@ void OptionsDialog::setSubtitleSettingsState(bool enabled) {
void OptionsDialog::addGraphicControls(GuiObject *boss, const String &prefix) {
const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
int labelWidth = g_gui.xmlEval()->getVar("Globals.TabLabelWidth");
// The GFX mode popup
_gfxPopUp = new PopUpWidget(boss, prefix + "grModePopup", "Graphics mode:", labelWidth);
_gfxPopUp = new PopUpWidget(boss, prefix + "grModePopup", "Graphics mode:");
_gfxPopUp->appendEntry("<default>");
_gfxPopUp->appendEntry("");
@ -528,7 +526,7 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const String &prefix) {
}
// RenderMode popup
_renderModePopUp = new PopUpWidget(boss, prefix + "grRenderPopup", "Render mode:", labelWidth);
_renderModePopUp = new PopUpWidget(boss, prefix + "grRenderPopup", "Render mode:");
_renderModePopUp->appendEntry("<default>", Common::kRenderDefault);
_renderModePopUp->appendEntry("");
const Common::RenderModeDescription *rm = Common::g_renderModes;
@ -546,10 +544,8 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const String &prefix) {
}
void OptionsDialog::addAudioControls(GuiObject *boss, const String &prefix) {
int labelWidth = g_gui.xmlEval()->getVar("Globals.TabLabelWidth");
// The MIDI mode popup & a label
_midiPopUp = new PopUpWidget(boss, prefix + "auMidiPopup", "Music driver:", labelWidth);
_midiPopUp = new PopUpWidget(boss, prefix + "auMidiPopup", "Music driver:");
// Populate it
const MidiDriverDescription *md = MidiDriver::getAvailableMidiDrivers();
@ -559,7 +555,7 @@ void OptionsDialog::addAudioControls(GuiObject *boss, const String &prefix) {
}
// Sample rate settings
_outputRatePopUp = new PopUpWidget(boss, prefix + "auSampleRatePopup", "Output rate:", labelWidth);
_outputRatePopUp = new PopUpWidget(boss, prefix + "auSampleRatePopup", "Output rate:");
for (int i = 0; outputRateLabels[i]; i++) {
_outputRatePopUp->appendEntry(outputRateLabels[i], outputRateValues[i]);
@ -652,19 +648,8 @@ int OptionsDialog::getSubtitleMode(bool subtitles, bool speech_mute) {
void OptionsDialog::reflowLayout() {
Dialog::reflowLayout();
int labelWidth = g_gui.xmlEval()->getVar("Globals.TabLabelWidth");
if (_graphicsTabId != -1 && _tabWidget)
_tabWidget->setTabTitle(_graphicsTabId, g_system->getOverlayWidth() > 320 ? "Graphics" : "GFX");
if (_midiPopUp)
_midiPopUp->changeLabelWidth(labelWidth);
if (_outputRatePopUp)
_outputRatePopUp->changeLabelWidth(labelWidth);
if (_gfxPopUp)
_gfxPopUp->changeLabelWidth(labelWidth);
if (_renderModePopUp)
_renderModePopUp->changeLabelWidth(labelWidth);
}
#pragma mark -
@ -731,14 +716,12 @@ GlobalOptionsDialog::GlobalOptionsDialog()
_curTheme = new StaticTextWidget(tab, "GlobalOptions_Misc.CurTheme", g_gui.theme()->getThemeName());
int labelWidth = g_gui.xmlEval()->getVar("Globals.TabLabelWidth");
_rendererPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.Renderer", "GUI Renderer:", labelWidth);
_rendererPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.Renderer", "GUI Renderer:");
for (uint i = 1; i < GUI::ThemeEngine::_rendererModesSize; ++i)
_rendererPopUp->appendEntry(GUI::ThemeEngine::_rendererModes[i].name, GUI::ThemeEngine::_rendererModes[i].mode);
_autosavePeriodPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.AutosavePeriod", "Autosave:", labelWidth);
_autosavePeriodPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.AutosavePeriod", "Autosave:");
for (int i = 0; savePeriodLabels[i]; i++) {
_autosavePeriodPopUp->appendEntry(savePeriodLabels[i], savePeriodValues[i]);

View File

@ -27,10 +27,10 @@
<globals>
<def var = 'Line.Height' value = '16' />
<def var = 'Font.Height' value = '16' />
<def var = 'TabLabelWidth' value = '110' />
<def var = 'About.OuterBorder' value = '80'/>
<def var = 'PopUpWidget.labelSpacing' value = '10' />
<def var = 'PopUpWidget.labelWidth' value = '110' />
<def var = 'Layout.Spacing' value = '8' />
<def var = 'ShowLauncherLogo' value = '0'/>

View File

@ -27,11 +27,11 @@
<globals>
<def var = 'Line.Height' value = '12' />
<def var = 'Font.Height' value = '10' />
<def var = 'TabLabelWidth' value = '100' />
<def var = 'About.OuterBorder' value = '10'/>
<def var = 'PopUpWidget.labelSpacing' value = '6' />
<def var = 'PopUpWidget.labelWidth' value = '100' />
<def var = 'Layout.Spacing' value = '8'/>
<def var = 'ShowLauncherLogo' value = '0'/>

View File

@ -27,7 +27,6 @@
<globals>
<def var = 'Line.Height' value = '16' />
<def var = 'Font.Height' value = '16' />
<def var = 'TabLabelWidth' value = '110' />
<def var = 'Padding.Bottom' value = '16' />
<def var = 'Padding.Left' value = '16' />
@ -39,6 +38,7 @@
<def var = 'ListWidget.hlLeftPadding' value = '0'/>
<def var = 'ListWidget.hlRightPadding' value = '0'/>
<def var = 'PopUpWidget.labelSpacing' value = '10' />
<def var = 'PopUpWidget.labelWidth' value = '110' />
<def var = 'ShowLauncherLogo' value = '1'/>
<def var = 'ShowGlobalMenuLogo' value = '1'/>
@ -705,4 +705,17 @@
</layout>
</layout>
</dialog>
<dialog name = 'KeyRemapper' overlays = 'screen_center' shading = 'dim'>
<layout type = 'vertical' padding = '8, 8, 32, 8' center = 'true'>
<widget name = 'Popup'
type = 'PopUp'
/>
<widget name = 'KeymapArea'
/>
<widget name = 'Close'
type = 'Button'
/>
</layout>
</dialog>
</layout_info>

View File

@ -27,10 +27,10 @@
<globals>
<def var = 'Line.Height' value = '12' />
<def var = 'Font.Height' value = '10' />
<def var = 'TabLabelWidth' value = '100' />
<def var = 'About.OuterBorder' value = '10'/>
<def var = 'PopUpWidget.labelSpacing' value = '6' />
<def var = 'PopUpWidget.labelWidth' value = '100' />
<def var = 'ShowLauncherLogo' value = '0'/>
<def var = 'ShowGlobalMenuLogo' value = '0'/>