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 /gui | |
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 'gui')
-rw-r--r-- | gui/EditTextWidget.cpp | 5 | ||||
-rw-r--r-- | gui/PopUpWidget.cpp | 2 | ||||
-rw-r--r-- | gui/console.cpp | 7 | ||||
-rw-r--r-- | gui/editable.cpp | 12 | ||||
-rw-r--r-- | gui/editable.h | 2 | ||||
-rw-r--r-- | gui/newgui.cpp | 14 |
6 files changed, 25 insertions, 17 deletions
diff --git a/gui/EditTextWidget.cpp b/gui/EditTextWidget.cpp index 239c4a613a..7df68c1f82 100644 --- a/gui/EditTextWidget.cpp +++ b/gui/EditTextWidget.cpp @@ -32,7 +32,6 @@ EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, cons _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE; _type = kEditTextWidget; - reflowLayout(); setEditString(text); } @@ -42,7 +41,6 @@ EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const String _type = kEditTextWidget; _hints |= THEME_HINT_USE_SHADOW; - reflowLayout(); setEditString(text); } @@ -52,11 +50,12 @@ void EditTextWidget::setEditString(const String &str) { } void EditTextWidget::reflowLayout() { - EditableWidget::reflowLayout(); _leftPadding = g_gui.evaluator()->getVar("EditTextWidget.leftPadding", 0); _rightPadding = g_gui.evaluator()->getVar("EditTextWidget.rightPadding", 0); _font = (Theme::FontStyle)g_gui.evaluator()->getVar("EditTextWidget.font", Theme::kFontStyleNormal); + + EditableWidget::reflowLayout(); } diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp index f7cd8c22e8..14f998d6f8 100644 --- a/gui/PopUpWidget.cpp +++ b/gui/PopUpWidget.cpp @@ -344,8 +344,6 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) { PopUpWidget::PopUpWidget(GuiObject *boss, const String &name, const String &label, uint labelWidth) : Widget(boss, name), CommandSender(boss), _label(label), _labelWidth(labelWidth) { - reflowLayout(); - _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS; setHints(THEME_HINT_SAVE_BACKGROUND); _type = kPopUpWidget; diff --git a/gui/console.cpp b/gui/console.cpp index a8ad636761..ad0c265214 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -157,13 +157,6 @@ void ConsoleDialog::open() { _slideTime = g_system->getMillis(); _slideMode = kDownSlideMode; - // The screen may have changed since the console was created. We have - // to make sure things are properly adjusted, or we may get garbage in - // the console, or even outright crashes. This means _scrollLine is not - // preserved, but that's a tiny sacrifice. - - reflowLayout(); - Dialog::open(); if (_promptStartPos == -1) { print(PROMPT); diff --git a/gui/editable.cpp b/gui/editable.cpp index 67691861bf..10f8c125e8 100644 --- a/gui/editable.cpp +++ b/gui/editable.cpp @@ -50,15 +50,19 @@ void EditableWidget::init() { EditableWidget::~EditableWidget() { } +void EditableWidget::reflowLayout() { + Widget::reflowLayout(); + + _editScrollOffset = g_gui.getStringWidth(_editString, _font) - getEditRect().width(); + if (_editScrollOffset < 0) + _editScrollOffset = 0; +} + void EditableWidget::setEditString(const String &str) { // TODO: We probably should filter the input string here, // e.g. using tryInsertChar. _editString = str; _caretPos = _editString.size(); - - _editScrollOffset = g_gui.getStringWidth(_editString, _font) - getEditRect().width(); - if (_editScrollOffset < 0) - _editScrollOffset = 0; } bool EditableWidget::tryInsertChar(byte c, int pos) { diff --git a/gui/editable.h b/gui/editable.h index 4c6def3731..520c4cf689 100644 --- a/gui/editable.h +++ b/gui/editable.h @@ -62,6 +62,8 @@ public: virtual void handleTickle(); virtual bool handleKeyDown(uint16 ascii, int keycode, int modifiers); + virtual void reflowLayout(); + protected: virtual void startEditMode() = 0; virtual void endEditMode() = 0; diff --git a/gui/newgui.cpp b/gui/newgui.cpp index a4904c5b8c..7cd0708597 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -56,7 +56,6 @@ enum { // HACK. FIXME. This doesn't belong here. But otherwise it creates compilation problems GuiObject::GuiObject(const Common::String &name) : _firstWidget(0) { _name = name; - reflowLayout(); } void GuiObject::reflowLayout() { @@ -318,6 +317,19 @@ void NewGui::restoreState() { void NewGui::openDialog(Dialog *dialog) { _dialogStack.push(dialog); _needRedraw = true; + + // TODO: No need to always reflow everything. Rather, we should + // check for the value of OSystem::getScreenChangeID() and + // only do a full update when that changed... + if (true) { + // reinit the whole theme + _theme->refresh(); + // refresh all dialogs + for (int i = 0; i < _dialogStack.size(); ++i) { + _dialogStack[i]->reflowLayout(); + } + } else + dialog->reflowLayout(); } void NewGui::closeTopDialog() { |