diff options
author | Max Horn | 2006-08-04 15:48:37 +0000 |
---|---|---|
committer | Max Horn | 2006-08-04 15:48:37 +0000 |
commit | 0485f76c8d3e4220dd7977eac829bd85525f2da3 (patch) | |
tree | be6b831af891f1f5621f6ba52f8a25f8c2e2e2cc /engines/scumm/dialogs.cpp | |
parent | 1a10cacfb900c822ef5a53f455af7874675d37c5 (diff) | |
download | scummvm-rg350-0485f76c8d3e4220dd7977eac829bd85525f2da3.tar.gz scummvm-rg350-0485f76c8d3e4220dd7977eac829bd85525f2da3.tar.bz2 scummvm-rg350-0485f76c8d3e4220dd7977eac829bd85525f2da3.zip |
Changed GUI code to do 'lazy'/'just-in-time' reflowing, so that client code doesn't have to forward EVENT_SCREEN_CHANGED to us (this may initially cause some regressions, please report any induced crashes or oddities you observe to me)
svn-id: r23663
Diffstat (limited to 'engines/scumm/dialogs.cpp')
-rw-r--r-- | engines/scumm/dialogs.cpp | 54 |
1 files changed, 17 insertions, 37 deletions
diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 267822a565..d96f840373 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -261,8 +261,6 @@ SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, new GUI::ButtonWidget(this, "scummsaveload_cancel", "Cancel", kCloseCmd, 0); _chooseButton = new GUI::ButtonWidget(this, "scummsaveload_choose", buttonLabel, kChooseCmd, 0); _chooseButton->setEnabled(false); - - reflowLayout(); } SaveLoadChooser::~SaveLoadChooser() { @@ -512,20 +510,6 @@ void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat } } -void MainMenuDialog::reflowLayout() { - ScummDialog::reflowLayout(); - - _optionsDialog->reflowLayout(); - _aboutDialog->reflowLayout(); - - _saveDialog->reflowLayout(); - _loadDialog->reflowLayout(); - -#ifndef DISABLE_HELP - _helpDialog->reflowLayout(); -#endif -} - void MainMenuDialog::save() { int idx; _saveDialog->setList(generateSavegameList(_vm, true)); @@ -555,11 +539,6 @@ void MainMenuDialog::load() { } } -void MainMenuDialog::open() { - reflowLayout(); - Dialog::open(); -} - #pragma mark - enum { @@ -780,8 +759,6 @@ void InfoDialog::setInfoText(const String& message) { // Width and height are dummy _text = new StaticTextWidget(this, 4, 4, 10, 10, _message, kTextAlignCenter); - - reflowLayout(); } void InfoDialog::reflowLayout() { @@ -873,6 +850,22 @@ ValueDisplayDialog::ValueDisplayDialog(const Common::String& label, int minVal, : GUI::Dialog("scummDummyDialog"), _label(label), _min(minVal), _max(maxVal), _value(val), _incKey(incKey), _decKey(decKey) { assert(_min <= _value && _value <= _max); +} + +void ValueDisplayDialog::drawDialog() { + const int labelWidth = _w - 8 - _percentBarWidth; + g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h), GUI::THEME_HINT_SAVE_BACKGROUND | GUI::THEME_HINT_FIRST_DRAW); + g_gui.theme()->drawText(Common::Rect(_x+4, _y+4, _x+labelWidth+4, _y+g_gui.theme()->getFontHeight()+4), _label); + g_gui.theme()->drawSlider(Common::Rect(_x+4+labelWidth, _y+4, _x+_w-4, _y+_h-4), _percentBarWidth * (_value - _min) / (_max - _min)); +} + +void ValueDisplayDialog::handleTickle() { + if (getMillis() > _timer) { + close(); + } +} + +void ValueDisplayDialog::reflowLayout() { const int screenW = g_system->getOverlayWidth(); const int screenH = g_system->getOverlayHeight(); @@ -882,7 +875,7 @@ ValueDisplayDialog::ValueDisplayDialog(const Common::String& label, int minVal, _percentBarWidth = kPercentBarWidth; } - int width = g_gui.getStringWidth(label) + 16 + _percentBarWidth; + int width = g_gui.getStringWidth(_label) + 16 + _percentBarWidth; int height = g_gui.getFontHeight() + 4 * 2; _x = (screenW - width) / 2; @@ -891,19 +884,6 @@ ValueDisplayDialog::ValueDisplayDialog(const Common::String& label, int minVal, _h = height; } -void ValueDisplayDialog::drawDialog() { - const int labelWidth = _w - 8 - _percentBarWidth; - g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h), GUI::THEME_HINT_SAVE_BACKGROUND | GUI::THEME_HINT_FIRST_DRAW); - g_gui.theme()->drawText(Common::Rect(_x+4, _y+4, _x+labelWidth+4, _y+g_gui.theme()->getFontHeight()+4), _label); - g_gui.theme()->drawSlider(Common::Rect(_x+4+labelWidth, _y+4, _x+_w-4, _y+_h-4), _percentBarWidth * (_value - _min) / (_max - _min)); -} - -void ValueDisplayDialog::handleTickle() { - if (getMillis() > _timer) { - close(); - } -} - void ValueDisplayDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { if (ascii == _incKey || ascii == _decKey) { if (ascii == _incKey && _value < _max) |