From ccdd167fca19ff8d4f4cac800f2d8154a19cf7e1 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sun, 15 Nov 2020 11:03:55 +0100 Subject: [PATCH] removed duplicate _editMode variable fixed missing redraws when StringListWidgets gain focus prevent focus for disabled widget --- src/gui/Dialog.cxx | 4 ++-- src/gui/DialogContainer.cxx | 6 +----- src/gui/EditableWidget.cxx | 2 -- src/gui/ListWidget.cxx | 2 ++ src/gui/ListWidget.hxx | 1 - src/gui/OptionsDialog.hxx | 2 +- src/gui/StringListWidget.hxx | 3 +++ 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 6a0e96899..18dd20cbf 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -361,7 +361,7 @@ void Dialog::setFocus(Widget* w) { // If the click occured inside a widget which is not the currently // focused one, change the focus to that widget. - if(w && w != _focusedWidget && w->wantsFocus()) + if(w && w != _focusedWidget && w->wantsFocus() && w->isEnabled()) { // Redraw widgets for new focus _focusedWidget = Widget::setFocusForChain(this, getFocusList(), w, 0); @@ -427,10 +427,10 @@ void Dialog::drawDialog() FBSurface& s = surface(); + cerr << endl << "d"; if(isDirty()) { //cerr << "*** draw dialog " << typeid(*this).name() << " ***" << endl; - cerr << "d"; if(clearsBackground()) { diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 0f7713d0d..fcdac91a9 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -122,10 +122,6 @@ void DialogContainer::render() if(myDialogStack.empty()) return; - // Make sure we start in a clean state (with zero'ed buffers) - if(!myOSystem.eventHandler().inTIAMode()) - myOSystem.frameBuffer().clear(); - cerr << "full re-render " << typeid(*this).name() << endl; // Make sure we start in a clean state (with zero'ed buffers) @@ -174,7 +170,7 @@ void DialogContainer::removeDialog() { if(!myDialogStack.empty()) { - cerr << "remove dialog" << endl; + cerr << "remove dialog " << typeid(*myDialogStack.top()).name() << endl; myDialogStack.pop(); // Inform the frame buffer that it has to render all surfaces diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 3e86ea947..d6c35fa55 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -100,8 +100,6 @@ void EditableWidget::receivedFocusWidget() { _caretTimer = 0; _caretEnabled = true; - - Widget::receivedFocusWidget(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/ListWidget.cxx b/src/gui/ListWidget.cxx index d8b0bc458..1cf6c7e0d 100644 --- a/src/gui/ListWidget.cxx +++ b/src/gui/ListWidget.cxx @@ -36,6 +36,8 @@ ListWidget::ListWidget(GuiObject* boss, const GUI::Font& font, _textcolor = kTextColor; _textcolorhi = kTextColor; + _editMode = false; + _cols = w / _fontWidth; _rows = h / _lineHeight; diff --git a/src/gui/ListWidget.hxx b/src/gui/ListWidget.hxx index 96d4f036c..1fba03f01 100644 --- a/src/gui/ListWidget.hxx +++ b/src/gui/ListWidget.hxx @@ -99,7 +99,6 @@ class ListWidget : public EditableWidget int _currentPos{0}; int _selectedItem{-1}; int _highlightedItem{-1}; - bool _editMode{false}; bool _useScrollbar{true}; ScrollBarWidget* _scrollBar{nullptr}; diff --git a/src/gui/OptionsDialog.hxx b/src/gui/OptionsDialog.hxx index 55d4d4b0d..bd13c3f37 100644 --- a/src/gui/OptionsDialog.hxx +++ b/src/gui/OptionsDialog.hxx @@ -52,7 +52,7 @@ class OptionsDialog : public Dialog void handleCommand(CommandSender* sender, int cmd, int data, int id) override; private: - unique_ptr myVideoDialog; + unique_ptr myVideoDialog; unique_ptr myEmulationDialog; unique_ptr myInputDialog; unique_ptr myUIDialog; diff --git a/src/gui/StringListWidget.hxx b/src/gui/StringListWidget.hxx index eed279aeb..ee3b56e97 100644 --- a/src/gui/StringListWidget.hxx +++ b/src/gui/StringListWidget.hxx @@ -35,6 +35,9 @@ class StringListWidget : public ListWidget protected: void handleMouseEntered() override; void handleMouseLeft() override; + // display depends on _hasFocus so we have to redraw when focus changes + void receivedFocusWidget() override { setDirty(); } + void lostFocusWidget() override { setDirty(); } void drawWidget(bool hilite) override; Common::Rect getEditRect() const override;