diff options
author | Bastien Bouclet | 2018-01-06 14:40:02 +0100 |
---|---|---|
committer | Bastien Bouclet | 2018-01-27 18:12:34 +0100 |
commit | 0496ede62f8b86e1885d594e3aa5320c96b708eb (patch) | |
tree | 6a4453606061a15a5ee3462d1680936c257ae7f5 /gui/widgets | |
parent | 3b50b57f544cb7c719a5f02f061853e10885ae6c (diff) | |
download | scummvm-rg350-0496ede62f8b86e1885d594e3aa5320c96b708eb.tar.gz scummvm-rg350-0496ede62f8b86e1885d594e3aa5320c96b708eb.tar.bz2 scummvm-rg350-0496ede62f8b86e1885d594e3aa5320c96b708eb.zip |
GUI: Implement dirty-checking for widget redraws
Diffstat (limited to 'gui/widgets')
-rw-r--r-- | gui/widgets/editable.cpp | 2 | ||||
-rw-r--r-- | gui/widgets/edittext.cpp | 2 | ||||
-rw-r--r-- | gui/widgets/list.cpp | 22 | ||||
-rw-r--r-- | gui/widgets/popup.cpp | 4 | ||||
-rw-r--r-- | gui/widgets/popup.h | 4 | ||||
-rw-r--r-- | gui/widgets/scrollbar.cpp | 4 | ||||
-rw-r--r-- | gui/widgets/scrollbar.h | 2 | ||||
-rw-r--r-- | gui/widgets/scrollcontainer.cpp | 2 | ||||
-rw-r--r-- | gui/widgets/tab.cpp | 15 | ||||
-rw-r--r-- | gui/widgets/tab.h | 3 |
10 files changed, 35 insertions, 25 deletions
diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp index 02defe9a56..5e7c94b64a 100644 --- a/gui/widgets/editable.cpp +++ b/gui/widgets/editable.cpp @@ -235,7 +235,7 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) { } if (dirty) - draw(); + markAsDirty(); if (forcecaret) makeCaretVisible(); diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp index 0a8725ac9e..97366741d0 100644 --- a/gui/widgets/edittext.cpp +++ b/gui/widgets/edittext.cpp @@ -87,7 +87,7 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) { last = cur; } if (setCaretPos(i)) - draw(); + markAsDirty(); #ifdef TIZEN // Display the virtual keypad to allow text entry. Samsung app-store testers expected diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp index e5690fb6f2..16d91f9a1e 100644 --- a/gui/widgets/list.cpp +++ b/gui/widgets/list.cpp @@ -145,7 +145,7 @@ void ListWidget::setSelected(int item) { _currentPos = _selectedItem - _entriesPerPage / 2; scrollToCurrent(); - draw(); + markAsDirty(); } } @@ -251,7 +251,7 @@ void ListWidget::handleMouseDown(int x, int y, int button, int clickCount) { // TODO: Determine where inside the string the user clicked and place the // caret accordingly. // See _editScrollOffset and EditTextWidget::handleMouseDown. - draw(); + markAsDirty(); } @@ -446,12 +446,12 @@ bool ListWidget::handleKeyDown(Common::KeyState state) { } if (dirty || _selectedItem != oldSelectedItem) - draw(); + markAsDirty(); if (_selectedItem != oldSelectedItem) { sendCommand(kListSelectionChangedCmd, _selectedItem); // also draw scrollbar - _scrollBar->draw(); + _scrollBar->markAsDirty(); } return handled; @@ -467,7 +467,7 @@ void ListWidget::receivedFocusWidget() { _inversion = ThemeEngine::kTextInversionFocus; // Redraw the widget so the selection color will change - draw(); + markAsDirty(); } void ListWidget::lostFocusWidget() { @@ -477,7 +477,7 @@ void ListWidget::lostFocusWidget() { _editMode = false; g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); drawCaret(true); - draw(); + markAsDirty(); } void ListWidget::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { @@ -486,7 +486,7 @@ void ListWidget::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { if (_currentPos != (int)data) { _currentPos = data; checkBounds(); - draw(); + markAsDirty(); // Scrollbar actions cause list focus (which triggers a redraw) // NOTE: ListWidget's boss is always GUI::Dialog @@ -600,7 +600,7 @@ void ListWidget::scrollToEnd() { _scrollBar->_currentPos = _currentPos; _scrollBar->recalc(); - _scrollBar->draw(); + _scrollBar->markAsDirty(); } void ListWidget::startEditMode() { @@ -616,7 +616,7 @@ void ListWidget::startEditMode() { else _editColor = _listColors[_listIndex[_selectedItem]]; } - draw(); + markAsDirty(); g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true); } } @@ -636,7 +636,7 @@ void ListWidget::abortEditMode() { assert(_selectedItem >= 0); _editMode = false; //drawCaret(true); - //draw(); + //markAsDirty(); g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); } @@ -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->draw(); + _boss->markAsDirty(); } } diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp index 74fbc44823..f59a89e543 100644 --- a/gui/widgets/popup.cpp +++ b/gui/widgets/popup.cpp @@ -409,7 +409,7 @@ void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) { if (newSel != -1 && _selectedItem != newSel) { _selectedItem = newSel; sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag); - draw(); + markAsDirty(); } } } @@ -429,7 +429,7 @@ void PopUpWidget::handleMouseWheel(int x, int y, int direction) { (newSelection != _selectedItem)) { _selectedItem = newSelection; sendCommand(kPopUpItemSelectedCmd, _entries[_selectedItem].tag); - draw(); + markAsDirty(); } } } diff --git a/gui/widgets/popup.h b/gui/widgets/popup.h index 37ddc276ad..d2b1f1cb92 100644 --- a/gui/widgets/popup.h +++ b/gui/widgets/popup.h @@ -77,8 +77,8 @@ public: uint32 getSelectedTag() const { return (_selectedItem >= 0) ? _entries[_selectedItem].tag : (uint32)-1; } // const String& getSelectedString() const { return (_selectedItem >= 0) ? _entries[_selectedItem].name : String::emptyString; } - void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); } - void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); draw(); } + void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); markAsDirty(); } + void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); markAsDirty(); } virtual void reflowLayout(); protected: diff --git a/gui/widgets/scrollbar.cpp b/gui/widgets/scrollbar.cpp index d8bcb18336..b0e2576ec1 100644 --- a/gui/widgets/scrollbar.cpp +++ b/gui/widgets/scrollbar.cpp @@ -135,7 +135,7 @@ void ScrollBarWidget::handleMouseMoved(int x, int y, int button) { _part = kSliderPart; if (old_part != _part) - draw(); + markAsDirty(); } } @@ -165,7 +165,7 @@ void ScrollBarWidget::checkBounds(int old_pos) { if (old_pos != _currentPos) { recalc(); - draw(); + markAsDirty(); sendCommand(kSetPositionCmd, _currentPos); } } diff --git a/gui/widgets/scrollbar.h b/gui/widgets/scrollbar.h index de7c13ce03..a1181b9e6c 100644 --- a/gui/widgets/scrollbar.h +++ b/gui/widgets/scrollbar.h @@ -69,7 +69,7 @@ public: void handleMouseWheel(int x, int y, int direction); void handleMouseMoved(int x, int y, int button); void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); } - void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); _part = kNoPart; draw(); } + void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); _part = kNoPart; markAsDirty(); } void handleTickle(); // FIXME - this should be private, but then we also have to add accessors diff --git a/gui/widgets/scrollcontainer.cpp b/gui/widgets/scrollcontainer.cpp index 7c5ab6112c..0f3c96dcb6 100644 --- a/gui/widgets/scrollcontainer.cpp +++ b/gui/widgets/scrollcontainer.cpp @@ -102,7 +102,7 @@ void ScrollContainerWidget::handleCommand(CommandSender *sender, uint32 cmd, uin case kSetPositionCmd: _scrolledY = _verticalScroll->_currentPos; reflowLayout(); - draw(); + markAsDirty(); g_gui.doFullRedraw(); break; } diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp index e2e3e72db0..9b045daf51 100644 --- a/gui/widgets/tab.cpp +++ b/gui/widgets/tab.cpp @@ -154,7 +154,7 @@ void TabWidget::removeTab(int tabID) { } // Finally trigger a redraw - _boss->draw(); + _boss->markAsDirty(); } void TabWidget::setActiveTab(int tabID) { @@ -174,7 +174,7 @@ void TabWidget::setActiveTab(int tabID) { while (_lastVisibleTab < tabID) setFirstVisible(_firstVisibleTab + 1, false); - _boss->draw(); + _boss->markAsDirty(); } } @@ -246,7 +246,7 @@ void TabWidget::setFirstVisible(int tabID, bool adjustIfRoom) { computeLastVisibleTab(adjustIfRoom); - _boss->draw(); // TODO: Necessary? + _boss->markAsDirty(); // TODO: Necessary? } void TabWidget::reflowLayout() { @@ -334,6 +334,15 @@ void TabWidget::draw() { } } +void TabWidget::markAsDirty() { + Widget::markAsDirty(); + + if (_navButtonsVisible) { + _navLeft->markAsDirty(); + _navRight->markAsDirty(); + } +} + bool TabWidget::containsWidget(Widget *w) const { if (w == _navLeft || w == _navRight || _navLeft->containsWidget(w) || _navRight->containsWidget(w)) return true; diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h index fe5e4d82bc..bdd3e56b46 100644 --- a/gui/widgets/tab.h +++ b/gui/widgets/tab.h @@ -111,7 +111,8 @@ public: virtual void reflowLayout(); - virtual void draw(); + void draw() override; + void markAsDirty() override; protected: // We overload getChildY to make sure child widgets are positioned correctly. |