GUI: Remove Dialog::markAsDirty to expose full GUI redraws

This commit is contained in:
Bastien Bouclet 2018-01-06 16:13:29 +01:00
parent fc37918130
commit 5878c618c9
23 changed files with 84 additions and 89 deletions

View file

@ -451,7 +451,7 @@ void RemapDialog::refreshKeymap() {
}
// need to redraw entire Dialog so that invisible
// widgets disappear
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}

View file

@ -358,7 +358,7 @@ void HelpDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 da
_prevButton->setFlags(WIDGET_ENABLED);
}
displayKeyBindings();
draw();
g_gui.scheduleTopDialogRedraw();
break;
case kPrevCmd:
_page--;
@ -369,7 +369,7 @@ void HelpDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 da
_prevButton->clearFlags(WIDGET_ENABLED);
}
displayKeyBindings();
draw();
g_gui.scheduleTopDialogRedraw();
break;
default:
ScummDialog::handleCommand(sender, cmd, data);
@ -553,7 +553,7 @@ void ValueDisplayDialog::handleKeyDown(Common::KeyState state) {
setResult(_value);
_timer = g_system->getMillis() + kDisplayDelay;
draw();
g_gui.scheduleTopDialogRedraw();
} else {
close();
}
@ -581,7 +581,7 @@ void SubtitleSettingsDialog::handleKeyDown(Common::KeyState state) {
cycleValue();
reflowLayout();
draw();
g_gui.scheduleTopDialogRedraw();
} else {
close();
}
@ -634,7 +634,7 @@ void DebugInputDialog::handleKeyDown(Common::KeyState state) {
buffer.deleteLastChar();
Common::String total = mainText + ' ' + buffer;
setInfoText(total);
draw();
g_gui.scheduleTopDialogRedraw();
reflowLayout();
} else if (state.keycode == Common::KEYCODE_RETURN) {
done = 1;
@ -643,7 +643,7 @@ void DebugInputDialog::handleKeyDown(Common::KeyState state) {
} else if ((state.ascii >= '0' && state.ascii <= '9') || (state.ascii >= 'A' && state.ascii <= 'Z') || (state.ascii >= 'a' && state.ascii <= 'z') || state.ascii == '.' || state.ascii == ' ') {
buffer += state.ascii;
Common::String total = mainText + ' ' + buffer;
draw();
g_gui.scheduleTopDialogRedraw();
reflowLayout();
setInfoText(total);
}

View file

@ -21,6 +21,7 @@
*/
#include "gui/browser.h"
#include "gui/gui-manager.h"
#include "gui/widgets/list.h"
#include "common/config-manager.h"
@ -191,7 +192,7 @@ void BrowserDialog::updateListing() {
_fileList->scrollTo(0);
// Finally, redraw
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
} // End of namespace GUI

View file

@ -214,7 +214,7 @@ void ConsoleDialog::reflowLayout() {
updateScrollBuffer();
Dialog::reflowLayout();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
void ConsoleDialog::handleTickle() {
@ -237,13 +237,13 @@ void ConsoleDialog::handleTickle() {
// End the slide
_slideMode = kNoSlideMode;
_y = 0;
markAsDirty();
g_gui.scheduleTopDialogRedraw();
} else if (_slideMode == kUpSlideMode && _y <= -_h) {
// End the slide
//_slideMode = kNoSlideMode;
close();
} else
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
_scrollBar->handleTickle();
@ -292,7 +292,7 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) {
print(PROMPT);
_promptStartPos = _promptEndPos = _currentPos;
markAsDirty();
g_gui.scheduleTopDialogRedraw();
if (!keepRunning)
slideUpAndClose();
break;
@ -377,7 +377,7 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) {
} else {
_currentPos = _promptEndPos;
}
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
case Common::KEYCODE_KP2:
@ -405,7 +405,7 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) {
_scrollLine = _firstLineInBuffer + _linesPerPage - 1;
}
updateScrollBuffer();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
@ -446,7 +446,7 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) {
} else {
_currentPos = _promptStartPos;
}
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
case Common::KEYCODE_KP8:
@ -471,7 +471,7 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) {
if (_scrollLine < _firstLineInBuffer + _linesPerPage - 1)
_scrollLine = _firstLineInBuffer + _linesPerPage - 1;
updateScrollBuffer();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
@ -508,7 +508,7 @@ void ConsoleDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
int newPos = (int)data + _linesPerPage - 1 + _firstLineInBuffer;
if (newPos != _scrollLine) {
_scrollLine = newPos;
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
}
@ -518,25 +518,25 @@ void ConsoleDialog::specialKeys(int keycode) {
switch (keycode) {
case Common::KEYCODE_a:
_currentPos = _promptStartPos;
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
case Common::KEYCODE_d:
if (_currentPos < _promptEndPos) {
killChar();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
case Common::KEYCODE_e:
_currentPos = _promptEndPos;
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
case Common::KEYCODE_k:
killLine();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
case Common::KEYCODE_w:
killLastWord();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
}
}
@ -626,7 +626,7 @@ void ConsoleDialog::historyScroll(int direction) {
// Ensure once more the caret is visible (in case of very long history entries)
scrollToCurrent();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
void ConsoleDialog::nextLine() {
@ -704,7 +704,7 @@ void ConsoleDialog::print(const char *str) {
while (*str)
printCharIntern(*str++);
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
void ConsoleDialog::drawCaret(bool erase) {
@ -733,7 +733,7 @@ void ConsoleDialog::scrollToCurrent() {
} else if (line > _scrollLine) {
_scrollLine = line;
updateScrollBuffer();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
}

View file

@ -153,14 +153,6 @@ void Dialog::releaseFocus() {
}
}
void Dialog::markAsDirty() {
//TANOKU - FIXME when is this enabled? what does this do?
// Update: called on tab drawing, mainly...
// we can pass this as open a new dialog or something
// g_gui._needRedraw = true;
g_gui._redrawStatus = GUI::GuiManager::kRedrawTopDialog;
}
void Dialog::markWidgetsAsDirty() {
Widget *w = _firstWidget;
while (w) {

View file

@ -88,7 +88,6 @@ protected:
virtual void open();
virtual void close();
void markAsDirty() override;
/** Recursively mark all the widgets in this dialog as dirty so they are redrawn */
void markWidgetsAsDirty();

View file

@ -29,6 +29,7 @@
#include "gui/browser.h"
#include "gui/chooser.h"
#include "gui/editgamedialog.h"
#include "gui/gui-manager.h"
#include "gui/launcher.h"
#include "gui/message.h"
#include "gui/remotebrowser.h"
@ -81,7 +82,7 @@ void DownloadDialog::open() {
if (!selectDirectories())
close();
reflowLayout();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
void DownloadDialog::close() {
@ -101,7 +102,7 @@ void DownloadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
case kDownloadProgressCmd:
if (!_close) {
refreshWidgets();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
case kDownloadEndedCmd:
@ -196,7 +197,7 @@ void DownloadDialog::handleTickle() {
int32 progress = (int32)(100 * CloudMan.getDownloadingProgress());
if (_progressBar->getValue() != progress) {
refreshWidgets();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
Dialog::handleTickle();

View file

@ -28,6 +28,7 @@
#include "common/system.h"
#include "gui/browser.h"
#include "gui/gui-manager.h"
#include "gui/message.h"
#ifdef ENABLE_EVENTRECORDER
#include "gui/onscreendialog.h"
@ -424,26 +425,26 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
switch (cmd) {
case kCmdGlobalGraphicsOverride:
setGraphicSettingsState(data != 0);
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
case kCmdGlobalAudioOverride:
setAudioSettingsState(data != 0);
setSubtitleSettingsState(data != 0);
if (_globalVolumeOverride == NULL)
setVolumeSettingsState(data != 0);
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
case kCmdGlobalMIDIOverride:
setMIDISettingsState(data != 0);
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
case kCmdGlobalMT32Override:
setMT32SettingsState(data != 0);
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
case kCmdGlobalVolumeOverride:
setVolumeSettingsState(data != 0);
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
case kCmdChooseSoundFontCmd:
{
@ -459,7 +460,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
else
_soundFontClearButton->setEnabled(false);
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
}
@ -477,9 +478,9 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
// FSList files = dir.listDir(FSNode::kListFilesOnly);
_gamePathWidget->setLabel(dir.getPath());
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
}
@ -491,9 +492,9 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
// User made his choice...
Common::FSNode dir(browser.getResult());
_extraPathWidget->setLabel(dir.getPath());
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
}
// Change path for stored save game (perm and temp) data
@ -508,9 +509,9 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
MessageDialog warningMessage(_("Saved games sync feature doesn't work with non-default directories. If you want your saved games to sync, use default directory."));
warningMessage.runModal();
#endif
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
}

View file

@ -30,6 +30,7 @@
#include "common/translation.h"
#include "gui/widgets/list.h"
#include "gui/gui-manager.h"
#include "gui/message.h"
namespace GUI {
@ -154,7 +155,7 @@ void FileBrowserDialog::updateListing() {
_fileList->scrollTo(0);
// Finally, redraw
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
} // End of namespace GUI

View file

@ -21,6 +21,7 @@
*/
#include "gui/fluidsynth-dialog.h"
#include "gui/gui-manager.h"
#include "gui/message.h"
#include "gui/widgets/tab.h"
#include "gui/widgets/popup.h"
@ -218,7 +219,7 @@ void FluidSynthSettingsDialog::handleCommand(CommandSender *sender, uint32 cmd,
if (alert.runModal() == GUI::kMessageOK) {
resetSettings();
readSettings();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
}

View file

@ -590,8 +590,8 @@ void GuiManager::processEvent(const Common::Event &event, Dialog *const activeDi
}
}
void GuiManager::doFullRedraw() {
_redrawStatus = kRedrawFull;
void GuiManager::scheduleTopDialogRedraw() {
_redrawStatus = kRedrawTopDialog;
}
void GuiManager::giveFocusToDialog(Dialog *dialog) {

View file

@ -75,7 +75,7 @@ public:
void runLoop();
void processEvent(const Common::Event &event, Dialog *const activeDialog);
void doFullRedraw();
void scheduleTopDialogRedraw();
bool isActive() const { return ! _dialogStack.empty(); }

View file

@ -323,7 +323,7 @@ void LauncherDialog::addGame() {
selectTarget(newTarget);
}
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
// We need to update the buttons here, so "Mass add" will revert to "Add game"
@ -427,7 +427,7 @@ void LauncherDialog::removeGame(int item) {
// Update the ListWidget and force a redraw
updateListing();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
}
@ -452,7 +452,7 @@ void LauncherDialog::editGame(int item) {
// Update the ListWidget, reselect the edited game and force a redraw
updateListing();
selectTarget(editDialog.getDomain());
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
}
@ -614,7 +614,7 @@ bool LauncherDialog::doGameDetection(const Common::String &path) {
// Update the ListWidget, select the new item, and force a redraw
updateListing();
selectTarget(editDialog.getDomain());
markAsDirty();
g_gui.scheduleTopDialogRedraw();
} else {
// User aborted, remove the the new domain again
ConfMan.removeGameDomain(domain);

View file

@ -87,8 +87,6 @@ public:
virtual bool isVisible() const = 0;
virtual void markAsDirty() = 0;
virtual void reflowLayout();
virtual void removeWidget(Widget *widget);

View file

@ -773,7 +773,7 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
case kClearSoundFontCmd:
_soundFont->setLabel(_c("None", "soundfont"));
_soundFontClearButton->setEnabled(false);
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
case kKbdMouseSpeedChanged:
_kbdMouseSpeedLabel->setLabel(_(kbdMouseSpeedLabels[_kbdMouseSpeedSlider->getValue()]));
@ -1936,7 +1936,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
error.runModal();
return;
}
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
}
@ -1946,7 +1946,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
// User made his choice...
Common::FSNode dir(browser.getResult());
_themePath->setLabel(dir.getPath());
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
}
@ -1956,7 +1956,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
// User made his choice...
Common::FSNode dir(browser.getResult());
_extraPath->setLabel(dir.getPath());
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
}
@ -1967,7 +1967,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
// User made his choice...
Common::FSNode dir(browser.getResult());
_pluginsPath->setLabel(dir.getPath());
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
}
@ -1982,7 +1982,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
if (path.empty())
path = "/"; // absolute root
_rootPath->setLabel(path);
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
}
@ -2013,7 +2013,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
else
_soundFontClearButton->setEnabled(false);
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
}
@ -2107,7 +2107,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
if (_serverPort) {
_serverPort->setEditString(Common::String::format("%u", Networking::LocalWebserver::DEFAULT_SERVER_PORT));
}
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
}
#endif // USE_SDL_NET
@ -2144,7 +2144,7 @@ void GlobalOptionsDialog::handleTickle() {
#endif
if (_redrawCloudTab) {
setupCloudTab();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
_redrawCloudTab = false;
}
#endif

View file

@ -21,6 +21,7 @@
*/
#include "gui/remotebrowser.h"
#include "gui/gui-manager.h"
#include "gui/widgets/list.h"
#include "common/config-manager.h"
@ -28,9 +29,9 @@
#include "common/algorithm.h"
#include "common/translation.h"
#include <backends/networking/curl/request.h>
#include <backends/cloud/storage.h>
#include <backends/cloud/cloudmanager.h>
#include "backends/networking/curl/request.h"
#include "backends/cloud/storage.h"
#include "backends/cloud/cloudmanager.h"
#include "message.h"
namespace GUI {
@ -162,7 +163,7 @@ void RemoteBrowserDialog::updateListing() {
_fileList->setEnabled(!_navigationLocked);
// Finally, redraw
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
void RemoteBrowserDialog::goUp() {

View file

@ -60,7 +60,7 @@ SaveLoadCloudSyncProgressDialog::SaveLoadCloudSyncProgressDialog(bool canRunInBa
new ButtonWidget(this, "SaveLoadCloudSyncProgress.Cancel", "Cancel", 0, kCancelSyncCmd, Common::ASCII_ESCAPE); // Cancel dialog
ButtonWidget *backgroundButton = new ButtonWidget(this, "SaveLoadCloudSyncProgress.Background", "Run in background", 0, kBackgroundSyncCmd, Common::ASCII_RETURN); // Confirm dialog
backgroundButton->setEnabled(canRunInBackground);
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
SaveLoadCloudSyncProgressDialog::~SaveLoadCloudSyncProgressDialog() {
@ -601,7 +601,7 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) {
_chooseButton->markAsDirty();
_deleteButton->markAsDirty();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
}
@ -703,7 +703,7 @@ void SaveLoadChooserSimple::updateSaveList() {
else
_chooseButton->setEnabled(false);
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
// SaveLoadChooserGrid implementation
@ -761,13 +761,13 @@ void SaveLoadChooserGrid::handleCommand(CommandSender *sender, uint32 cmd, uint3
case kNextCmd:
++_curPage;
updateSaves();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
case kPrevCmd:
--_curPage;
updateSaves();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
break;
case kNewSaveCmd:
@ -788,13 +788,13 @@ void SaveLoadChooserGrid::handleMouseWheel(int x, int y, int direction) {
if (_nextButton->isEnabled()) {
++_curPage;
updateSaves();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
} else {
if (_prevButton->isEnabled()) {
--_curPage;
updateSaves();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
}
}
@ -802,7 +802,7 @@ void SaveLoadChooserGrid::handleMouseWheel(int x, int y, int direction) {
void SaveLoadChooserGrid::updateSaveList() {
SaveLoadChooserDialog::updateSaveList();
updateSaves();
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
void SaveLoadChooserGrid::open() {

View file

@ -231,7 +231,7 @@ void StorageWizardDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
_codeWidget[i]->setEditString(subcode);
}
handleCommand(sender, kCodeBoxCmd, data);
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
break;
}

View file

@ -115,7 +115,7 @@ void ThemeBrowser::updateListing() {
_fileList->setSelected(currentThemeIndex);
// Finally, redraw
markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
} // End of namespace GUI

View file

@ -206,7 +206,7 @@ void Widget::setEnabled(bool e) {
else
clearFlags(WIDGET_ENABLED);
_boss->markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
}

View file

@ -744,7 +744,7 @@ void ListWidget::setFilter(const String &filter, bool redraw) {
// Such a widget could also (optionally) draw a border (or even different
// kinds of borders) around the objects it groups; and also a 'title'
// (I am borrowing these "ideas" from the NSBox class in Cocoa :).
_boss->markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
}

View file

@ -102,7 +102,7 @@ void ScrollContainerWidget::handleCommand(CommandSender *sender, uint32 cmd, uin
case kSetPositionCmd:
_scrolledY = _verticalScroll->_currentPos;
reflowLayout();
g_gui.doFullRedraw();
g_gui.scheduleTopDialogRedraw();
break;
}
}

View file

@ -154,7 +154,7 @@ void TabWidget::removeTab(int tabID) {
}
// Finally trigger a redraw
_boss->markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
void TabWidget::setActiveTab(int tabID) {
@ -174,7 +174,7 @@ void TabWidget::setActiveTab(int tabID) {
while (_lastVisibleTab < tabID)
setFirstVisible(_firstVisibleTab + 1, false);
_boss->markAsDirty();
g_gui.scheduleTopDialogRedraw();
}
}
@ -246,7 +246,7 @@ void TabWidget::setFirstVisible(int tabID, bool adjustIfRoom) {
computeLastVisibleTab(adjustIfRoom);
_boss->markAsDirty(); // TODO: Necessary?
g_gui.scheduleTopDialogRedraw(); // TODO: Necessary?
}
void TabWidget::reflowLayout() {