From cec27bb899e63264a56ac2968a7ad702f36ee01e Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 11 Nov 2020 18:24:30 +0100 Subject: [PATCH] removed some superfluous redraws --- src/debugger/gui/DataGridWidget.cxx | 8 ++++---- src/debugger/gui/RomListWidget.cxx | 8 ++++---- src/debugger/gui/TiaZoomWidget.cxx | 8 ++++---- src/debugger/gui/ToggleWidget.cxx | 8 ++++---- src/gui/Dialog.cxx | 29 ++++++++++++++--------------- src/gui/EditTextWidget.cxx | 8 ++++---- src/gui/GuiObject.hxx | 18 ++++++++++++++++-- src/gui/PopUpWidget.cxx | 8 ++++---- src/gui/ScrollBarWidget.cxx | 8 ++++---- src/gui/StringListWidget.cxx | 8 ++++---- src/gui/TabWidget.cxx | 8 ++++---- src/gui/Widget.cxx | 14 +++++++++----- 12 files changed, 75 insertions(+), 58 deletions(-) diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index f3b81676c..32358dd05 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -242,15 +242,15 @@ void DataGridWidget::setRange(int lower, int upper) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DataGridWidget::handleMouseEntered() { - setFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + setFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DataGridWidget::handleMouseLeft() { - clearFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + clearFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 48885f734..20fc53052 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -285,15 +285,15 @@ void RomListWidget::handleMouseWheel(int x, int y, int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RomListWidget::handleMouseEntered() { - setFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + setFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RomListWidget::handleMouseLeft() { - clearFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + clearFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index e4553f361..a008c4444 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -181,15 +181,15 @@ void TiaZoomWidget::handleMouseMoved(int x, int y) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaZoomWidget::handleMouseEntered() { - setFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + setFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaZoomWidget::handleMouseLeft() { - clearFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + clearFlags(Widget::FLAG_HILITED); myMouseMoving = false; } diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index 02ba10146..ea3253d8a 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -43,15 +43,15 @@ ToggleWidget::ToggleWidget(GuiObject* boss, const GUI::Font& font, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ToggleWidget::handleMouseEntered() { - setFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + setFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ToggleWidget::handleMouseLeft() { - clearFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + clearFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 669d7341c..26922f26d 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -438,19 +438,6 @@ void Dialog::drawDialog() clearDirty(); } - Widget* w = _firstWidget; - - // Draw all children - w = _firstWidget; - while(w) - { - - // only redraw changed widgets - if(w->needsRedraw()) - w->draw(); - w = w->_next; - } - // Draw outlines for focused widgets // Don't change focus, since this will trigger lost and received // focus events @@ -458,8 +445,20 @@ void Dialog::drawDialog() { _focusedWidget = Widget::setFocusForChain(this, getFocusList(), _focusedWidget, 0, false); - if(_focusedWidget) - _focusedWidget->draw(); // make sure the highlight color is drawn initially + // if(_focusedWidget) + // _focusedWidget->draw(); // make sure the highlight color is drawn initially + } + + Widget* w = _firstWidget; + + // Draw all children + w = _firstWidget; + while(w) + { + // only redraw changed widgets + if(w->needsRedraw()) + w->draw(); + w = w->_next; } } diff --git a/src/gui/EditTextWidget.cxx b/src/gui/EditTextWidget.cxx index 6105e70d3..c818f3cf0 100644 --- a/src/gui/EditTextWidget.cxx +++ b/src/gui/EditTextWidget.cxx @@ -51,15 +51,15 @@ void EditTextWidget::setText(const string& str, bool changed) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EditTextWidget::handleMouseEntered() { - setFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled() && isEditable()) + setFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EditTextWidget::handleMouseLeft() { - clearFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled() && isEditable()) + clearFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/GuiObject.hxx b/src/gui/GuiObject.hxx index a6cf4e5ca..811f1569b 100644 --- a/src/gui/GuiObject.hxx +++ b/src/gui/GuiObject.hxx @@ -97,8 +97,22 @@ class GuiObject : public CommandReceiver virtual bool isChainDirty() const = 0; virtual bool needsRedraw() { return isDirty() || isChainDirty(); }; - void setFlags(uInt32 flags) { _flags |= flags; setDirty(); } - void clearFlags(uInt32 flags) { _flags &= ~flags; setDirty(); } + void setFlags(uInt32 flags) + { + uInt32 oldFlags = _flags; + + _flags |= flags; + if(oldFlags != _flags) + setDirty(); + } + void clearFlags(uInt32 flags) + { + uInt32 oldFlags = _flags; + + _flags &= ~flags; + if(oldFlags != _flags) + setDirty(); + } uInt32 getFlags() const { return _flags; } bool hasBorder() const { return _flags & FLAG_BORDER; } diff --git a/src/gui/PopUpWidget.cxx b/src/gui/PopUpWidget.cxx index 8540f2df3..cf799dc47 100644 --- a/src/gui/PopUpWidget.cxx +++ b/src/gui/PopUpWidget.cxx @@ -161,15 +161,15 @@ void PopUpWidget::handleMouseWheel(int x, int y, int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PopUpWidget::handleMouseEntered() { - setFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + setFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PopUpWidget::handleMouseLeft() { - clearFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + clearFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/ScrollBarWidget.cxx b/src/gui/ScrollBarWidget.cxx index 451f4a3ee..04a99c732 100644 --- a/src/gui/ScrollBarWidget.cxx +++ b/src/gui/ScrollBarWidget.cxx @@ -243,16 +243,16 @@ void ScrollBarWidget::checkBounds(int old_pos) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ScrollBarWidget::handleMouseEntered() { - setFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + setFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ScrollBarWidget::handleMouseLeft() { _part = Part::None; - clearFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + clearFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/StringListWidget.cxx b/src/gui/StringListWidget.cxx index 4171632cb..5032654e6 100644 --- a/src/gui/StringListWidget.cxx +++ b/src/gui/StringListWidget.cxx @@ -53,15 +53,15 @@ void StringListWidget::setList(const StringList& list) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void StringListWidget::handleMouseEntered() { - setFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + setFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void StringListWidget::handleMouseLeft() { - clearFlags(Widget::FLAG_HILITED); - setDirty(); + if(isEnabled()) + clearFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/TabWidget.cxx b/src/gui/TabWidget.cxx index 61f42b350..5e96338ab 100644 --- a/src/gui/TabWidget.cxx +++ b/src/gui/TabWidget.cxx @@ -216,15 +216,15 @@ void TabWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TabWidget::handleMouseEntered() { - setFlags(Widget::FLAG_HILITED); - setDirty(); + //if(isEnabled()) + // setFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TabWidget::handleMouseLeft() { - clearFlags(Widget::FLAG_HILITED); - setDirty(); + //if(isEnabled()) + // clearFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index c9e0441e7..69c94b3ed 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -157,6 +157,7 @@ void Widget::draw() _x = oldX; _y = oldY; } + clearDirty(); // Draw all children Widget* w = _firstWidget; @@ -166,7 +167,6 @@ void Widget::draw() w->draw(); w = w->_next; } - clearDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -448,13 +448,15 @@ ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ButtonWidget::handleMouseEntered() { - setFlags(Widget::FLAG_HILITED); + if(isEnabled()) + setFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ButtonWidget::handleMouseLeft() { - clearFlags(Widget::FLAG_HILITED); + if(isEnabled()) + clearFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -558,13 +560,15 @@ CheckboxWidget::CheckboxWidget(GuiObject* boss, const GUI::Font& font, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CheckboxWidget::handleMouseEntered() { - setFlags(Widget::FLAG_HILITED); + if(isEnabled()) + setFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CheckboxWidget::handleMouseLeft() { - clearFlags(Widget::FLAG_HILITED); + if(isEnabled()) + clearFlags(Widget::FLAG_HILITED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -