From d3b9f52b089eb9abf78cb8e340850be668daef57 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 10 Nov 2020 19:53:36 +0100 Subject: [PATCH 01/70] initial commit for #719 --- src/emucore/FrameBuffer.cxx | 2 +- src/gui/ContextMenu.cxx | 2 +- src/gui/Dialog.cxx | 93 +++++++++++++++++------- src/gui/Dialog.hxx | 7 +- src/gui/DialogContainer.cxx | 42 ++++++++--- src/gui/GuiObject.hxx | 5 ++ src/gui/ScrollBarWidget.cxx | 1 + src/gui/TabWidget.cxx | 60 +++++++++------- src/gui/Widget.cxx | 139 ++++++++++++++++++++++-------------- src/gui/Widget.hxx | 2 + 10 files changed, 235 insertions(+), 118 deletions(-) diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 97bbb2153..e922ff390 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -439,7 +439,7 @@ void FrameBuffer::update(bool force) force = force || myOSystem.launcher().needsRedraw(); if(force) { - clear(); + //clear(); myOSystem.launcher().draw(force); } break; // EventHandlerState::LAUNCHER diff --git a/src/gui/ContextMenu.cxx b/src/gui/ContextMenu.cxx index 41f049ba2..9cf626657 100644 --- a/src/gui/ContextMenu.cxx +++ b/src/gui/ContextMenu.cxx @@ -621,5 +621,5 @@ void ContextMenu::drawDialog() s.drawBitmap(_downImg, ((_w-_x)>>1)-4, (_rowHeight>>1)+y-4, _scrollDnColor, _arrowSize); } - setDirty(); + clearDirty(); } diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 85c95349f..6e81535c2 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -149,6 +149,35 @@ void Dialog::center() positionAt(instance().settings().getInt("dialogpos")); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Dialog::setDirty() +{ + _dirty = true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Dialog::isDirty() const +{ + return _dirty; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Dialog::isChainDirty() const +{ + bool dirty = false; + + // Check if widget or any subwidgets are dirty + Widget* w = _firstWidget; + + while(!dirty && w) + { + dirty |= w->needsRedraw(); + w = w->_next; + } + + return dirty; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Dialog::positionAt(uInt32 pos) { @@ -192,7 +221,9 @@ void Dialog::positionAt(uInt32 pos) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Dialog::render() { - if(!_dirty || !isVisible()) + //assert(_dirty); + + if(!isVisible() || !needsRedraw()) return false; // Draw this dialog @@ -207,7 +238,7 @@ bool Dialog::render() surface->render(); }); } - _dirty = false; + //_dirty = false; return true; } @@ -371,37 +402,49 @@ void Dialog::drawDialog() FBSurface& s = surface(); - // Dialog is still on top if e.g a ContextMenu is opened - _onTop = parent().myDialogStack.top() == this - || (parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this - && !parent().myDialogStack.top()->hasTitle()); - - if(_flags & Widget::FLAG_CLEARBG) + if(isDirty()) { - // cerr << "Dialog::drawDialog(): w = " << _w << ", h = " << _h << " @ " << &s << endl << endl; - s.fillRect(_x, _y + _th, _w, _h - _th, _onTop ? kDlgColor : kBGColorLo); - if(_th) - { - s.fillRect(_x, _y, _w, _th, _onTop ? kColorTitleBar : kColorTitleBarLo); - s.drawString(_font, _title, _x + _font.getMaxCharWidth() * 1.25, _y + _font.getFontHeight() / 6, - _font.getStringWidth(_title), - _onTop ? kColorTitleText : kColorTitleTextLo); - } - } - else - s.invalidate(); - if(_flags & Widget::FLAG_BORDER) // currently only used by Dialog itself - s.frameRect(_x, _y, _w, _h, _onTop ? kColor : kShadowColor); + //cerr << "*** draw dialog " << typeid(*this).name() << " ***" << endl; + + // Dialog is still on top if e.g a ContextMenu is opened + _onTop = parent().myDialogStack.top() == this + || (parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this + && !parent().myDialogStack.top()->hasTitle()); + + if(_flags & Widget::FLAG_CLEARBG) + { + // cerr << "Dialog::drawDialog(): w = " << _w << ", h = " << _h << " @ " << &s << endl << endl; + s.fillRect(_x, _y + _th, _w, _h - _th, _onTop ? kDlgColor : kBGColorLo); + if(_th) + { + s.fillRect(_x, _y, _w, _th, _onTop ? kColorTitleBar : kColorTitleBarLo); + s.drawString(_font, _title, _x + _font.getMaxCharWidth() * 1.25, _y + _font.getFontHeight() / 6, + _font.getStringWidth(_title), + _onTop ? kColorTitleText : kColorTitleTextLo); + } + } + else { + s.invalidate(); + cerr << "invalidate " << typeid(*this).name() << endl; + } + if(_flags & Widget::FLAG_BORDER) // currently only used by Dialog itself + s.frameRect(_x, _y, _w, _h, _onTop ? kColor : kShadowColor); + + // Make all child widgets dirty + Widget::setDirtyInChain(_firstWidget); + + clearDirty(); + } - // Make all child widget dirty Widget* w = _firstWidget; - Widget::setDirtyInChain(w); // Draw all children w = _firstWidget; while(w) { - w->draw(); + // only redraw changed widgets + if(w->needsRedraw()) + w->draw(); w = w->_next; } diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index 1f6bbec60..805522c42 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -64,8 +64,9 @@ class Dialog : public GuiObject // A dialog being dirty indicates that its underlying surface needs to be // redrawn and then re-rendered; this is taken care of in ::render() - void setDirty() override { _dirty = true; } - bool isDirty() const { return _dirty; } + void setDirty() override; + bool isDirty() const override; + bool isChainDirty() const override; bool render(); void addFocusWidget(Widget* w) override; @@ -235,7 +236,7 @@ class Dialog : public GuiObject int _tabID{0}; int _flags{0}; - bool _dirty{false}; + //bool _dirty{false}; uInt32 _max_w{0}; // maximum wanted width uInt32 _max_h{0}; // maximum wanted height diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 950d71c06..af353f452 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -91,21 +91,32 @@ void DialogContainer::updateTime(uInt64 time) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool DialogContainer::draw(bool full) { + cerr << "draw " << full << endl; if(myDialogStack.empty()) return false; // Make the top dialog dirty if a full redraw is requested - if(full) - myDialogStack.top()->setDirty(); + //if(full) + // myDialogStack.top()->setDirty(); // If the top dialog is dirty, then all below it must be redrawn too const bool dirty = needsRedraw(); + //if(dirty) + // myDialogStack.top()->setDirty(); - myDialogStack.applyAll([&](Dialog*& d){ - if(dirty) - d->setDirty(); - full |= d->render(); - }); + //myDialogStack.applyAll([&](Dialog*& d){ + // if(dirty) + // d->setDirty(); + // full |= d->render(); + //}); + //if(dirty) + { + myDialogStack.applyAll([&](Dialog*& d) { + if(d->needsRedraw()) + //d->setDirty(); + full |= d->render(); + }); + } return full; } @@ -113,7 +124,9 @@ bool DialogContainer::draw(bool full) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool DialogContainer::needsRedraw() const { - return !myDialogStack.empty() ? myDialogStack.top()->isDirty() : false; + return !myDialogStack.empty() + ? myDialogStack.top()->needsRedraw() + : false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -133,6 +146,9 @@ int DialogContainer::addDialog(Dialog* d) "Unable to show dialog box; FIX THE CODE"); else { + // fade out current top dialog + if(!myDialogStack.empty()) + myDialogStack.top()->setDirty(); d->setDirty(); myDialogStack.push(d); } @@ -145,8 +161,16 @@ void DialogContainer::removeDialog() if(!myDialogStack.empty()) { myDialogStack.pop(); + // necessary as long as all dialogs share the same surface if(!myDialogStack.empty()) - myDialogStack.top()->setDirty(); + { + //myDialogStack.top()->setDirty(); + + // Mark all dialogs for redraw + myDialogStack.applyAll([&](Dialog*& d){ + d->setDirty(); + }); + } } } diff --git a/src/gui/GuiObject.hxx b/src/gui/GuiObject.hxx index 77392209c..2f4a5c1ca 100644 --- a/src/gui/GuiObject.hxx +++ b/src/gui/GuiObject.hxx @@ -78,6 +78,10 @@ class GuiObject : public CommandReceiver virtual bool isVisible() const = 0; virtual void setDirty() = 0; + virtual void clearDirty() { _dirty = false; } + virtual bool isDirty() const { return _dirty; } + virtual bool isChainDirty() const = 0; + virtual bool needsRedraw() const { return isDirty() || isChainDirty(); }; /** Add given widget(s) to the focus list */ virtual void addFocusWidget(Widget* w) = 0; @@ -104,6 +108,7 @@ class GuiObject : public CommandReceiver protected: int _x{0}, _y{0}, _w{0}, _h{0}; + bool _dirty{false}; Widget* _firstWidget{nullptr}; WidgetArray _focusList; diff --git a/src/gui/ScrollBarWidget.cxx b/src/gui/ScrollBarWidget.cxx index 335b716de..451f4a3ee 100644 --- a/src/gui/ScrollBarWidget.cxx +++ b/src/gui/ScrollBarWidget.cxx @@ -315,6 +315,7 @@ void ScrollBarWidget::drawWidget(bool hilite) s.fillRect(_x + 1, _y + _sliderPos - 1, _w - 2, _sliderHeight + 2, onTop ? (hilite && _part == Part::Slider) ? kScrollColorHi : kScrollColor : kColor); } + clearDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/TabWidget.cxx b/src/gui/TabWidget.cxx index f1b92b876..61f42b350 100644 --- a/src/gui/TabWidget.cxx +++ b/src/gui/TabWidget.cxx @@ -275,39 +275,45 @@ void TabWidget::drawWidget(bool hilite) // The tab widget is strange in that it acts as both a widget (obviously) // and a dialog (it contains other widgets). Because of the latter, // it must assume responsibility for refreshing all its children. - Widget::setDirtyInChain(_tabs[_activeTab].firstWidget); - FBSurface& s = dialog().surface(); - bool onTop = _boss->dialog().isOnTop(); - - // Iterate over all tabs and draw them - int i, x = _x + kTabLeftOffset; - for (i = 0; i < int(_tabs.size()); ++i) + if(isDirty()) { - int tabWidth = _tabs[i].tabWidth ? _tabs[i].tabWidth : _tabWidth; - ColorId fontcolor = _tabs[i].enabled && onTop? kTextColor : kColor; - int yOffset = (i == _activeTab) ? 0 : 1; - s.fillRect(x, _y + 1, tabWidth, _tabHeight - 1, - (i == _activeTab) - ? onTop ? kDlgColor : kBGColorLo - : onTop ? kBGColorHi : kDlgColor); // ? kWidColor : kDlgColor - s.drawString(_font, _tabs[i].title, x + kTabPadding + yOffset, - _y + yOffset + (_tabHeight - _lineHeight - 1), - tabWidth - 2 * kTabPadding, fontcolor, TextAlign::Center); - if(i == _activeTab) + FBSurface& s = dialog().surface(); + bool onTop = _boss->dialog().isOnTop(); + + // Iterate over all tabs and draw them + int i, x = _x + kTabLeftOffset; + for(i = 0; i < int(_tabs.size()); ++i) { - s.hLine(x, _y, x + tabWidth - 1, onTop ? kWidColor : kDlgColor); - s.vLine(x + tabWidth, _y + 1, _y + _tabHeight - 1, onTop ? kBGColorLo : kColor); + int tabWidth = _tabs[i].tabWidth ? _tabs[i].tabWidth : _tabWidth; + ColorId fontcolor = _tabs[i].enabled && onTop ? kTextColor : kColor; + int yOffset = (i == _activeTab) ? 0 : 1; + s.fillRect(x, _y + 1, tabWidth, _tabHeight - 1, + (i == _activeTab) + ? onTop ? kDlgColor : kBGColorLo + : onTop ? kBGColorHi : kDlgColor); // ? kWidColor : kDlgColor + s.drawString(_font, _tabs[i].title, x + kTabPadding + yOffset, + _y + yOffset + (_tabHeight - _lineHeight - 1), + tabWidth - 2 * kTabPadding, fontcolor, TextAlign::Center); + if(i == _activeTab) + { + s.hLine(x, _y, x + tabWidth - 1, onTop ? kWidColor : kDlgColor); + s.vLine(x + tabWidth, _y + 1, _y + _tabHeight - 1, onTop ? kBGColorLo : kColor); + } + else + s.hLine(x, _y + _tabHeight, x + tabWidth, onTop ? kWidColor : kDlgColor); + + x += tabWidth + kTabSpacing; } - else - s.hLine(x, _y + _tabHeight, x + tabWidth, onTop ? kWidColor : kDlgColor); - x += tabWidth + kTabSpacing; + // fill empty right space + s.hLine(x - kTabSpacing + 1, _y + _tabHeight, _x + _w - 1, onTop ? kWidColor : kDlgColor); + s.hLine(_x, _y + _h - 1, _x + _w - 1, onTop ? kBGColorLo : kColor); + + clearDirty(); + // Make all child widgets of currently active tab dirty + Widget::setDirtyInChain(_tabs[_activeTab].firstWidget); } - - // fill empty right space - s.hLine(x - kTabSpacing + 1, _y + _tabHeight, _x + _w - 1, onTop ? kWidColor : kDlgColor); - s.hLine(_x, _y + _h - 1, _x + _w - 1, onTop ? kBGColorLo : kColor); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index a54d9e45c..33f6b632d 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -56,7 +56,41 @@ void Widget::setDirty() { // A widget being dirty indicates that its parent dialog is dirty // So we inform the parent about it - _boss->dialog().setDirty(); + //_boss->dialog().setDirty(); + //cerr << "set dirty " << typeid(*this).name() << endl; + + _dirty = true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Widget::isDirty() const +{ + string name = typeid(*this).name(); + if(_dirty && name == "class TabWidget") + cerr << "is dirty " << typeid(*this).name() << endl; + + return _dirty; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Widget::isChainDirty() const +{ + string name = typeid(*this).name(); + if(_dirty && name == "class TabWidget") + cerr << "is chain dirty " << typeid(*this).name() << endl; + + bool dirty = false; + + // Check if widget or any subwidgets are dirty + Widget* w = _firstWidget; + + while(!dirty && w) + { + dirty |= w->isDirty(); + w = w->_next; + } + + return dirty; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -65,60 +99,67 @@ void Widget::draw() if(!isVisible() || !_boss->isVisible()) return; - FBSurface& s = _boss->dialog().surface(); - - bool onTop = _boss->dialog().isOnTop(); - - bool hasBorder = _flags & Widget::FLAG_BORDER; // currently only used by Dialog widget - int oldX = _x, oldY = _y; - - // Account for our relative position in the dialog - _x = getAbsX(); - _y = getAbsY(); - - // Clear background (unless alpha blending is enabled) - if(_flags & Widget::FLAG_CLEARBG) + if(isDirty()) { - int x = _x, y = _y, w = _w, h = _h; + //cerr << " *** draw widget " << typeid(*this).name() << " ***" << endl; + + FBSurface& s = _boss->dialog().surface(); + + bool onTop = _boss->dialog().isOnTop(); + + bool hasBorder = _flags & Widget::FLAG_BORDER; // currently only used by Dialog widget + int oldX = _x, oldY = _y; + + // Account for our relative position in the dialog + _x = getAbsX(); + _y = getAbsY(); + + // Clear background (unless alpha blending is enabled) + if(_flags & Widget::FLAG_CLEARBG) + { + int x = _x, y = _y, w = _w, h = _h; + if(hasBorder) + { + x++; y++; w -= 2; h -= 2; + } + s.fillRect(x, y, w, h, !onTop ? _bgcolorlo : (_flags & Widget::FLAG_HILITED) && isEnabled() ? _bgcolorhi : _bgcolor); + } + + // Draw border if(hasBorder) { - x++; y++; w-=2; h-=2; + s.frameRect(_x, _y, _w, _h, !onTop ? kColor : (_flags & Widget::FLAG_HILITED) && isEnabled() ? kWidColorHi : kColor); + _x += 4; + _y += 4; + _w -= 8; + _h -= 8; } - s.fillRect(x, y, w, h, !onTop ? _bgcolorlo : (_flags & Widget::FLAG_HILITED) && isEnabled() ? _bgcolorhi : _bgcolor); + + // Now perform the actual widget draw + drawWidget((_flags & Widget::FLAG_HILITED) ? true : false); + + // Restore x/y + if(hasBorder) + { + _x -= 4; + _y -= 4; + _w += 8; + _h += 8; + } + + _x = oldX; + _y = oldY; } - // Draw border - if(hasBorder) - { - s.frameRect(_x, _y, _w, _h, !onTop ? kColor : (_flags & Widget::FLAG_HILITED) && isEnabled() ? kWidColorHi : kColor); - _x += 4; - _y += 4; - _w -= 8; - _h -= 8; - } - - // Now perform the actual widget draw - drawWidget((_flags & Widget::FLAG_HILITED) ? true : false); - - // Restore x/y - if (hasBorder) - { - _x -= 4; - _y -= 4; - _w += 8; - _h += 8; - } - - _x = oldX; - _y = oldY; - // Draw all children Widget* w = _firstWidget; while(w) { - w->draw(); + if(w->needsRedraw()) + w->draw(); w = w->_next; } + clearDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -290,6 +331,7 @@ void Widget::setDirtyInChain(Widget* start) { while(start) { + //cerr << "setDirtyInChain " << typeid(*start).name() << endl; start->setDirty(); start = start->_next; } @@ -345,8 +387,6 @@ void StaticTextWidget::drawWidget(bool hilite) bool onTop = _boss->dialog().isOnTop(); s.drawString(_font, _label, _x, _y, _w, isEnabled() && onTop ? _textcolor : kColor, _align, 0, true, _shadowcolor); - - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -454,6 +494,7 @@ void ButtonWidget::setBitmap(const uInt32* bitmap, int bmw, int bmh) _bmh = bmh; _bmw = bmw; + cerr << "setBitmap" << endl; setDirty(); } @@ -474,8 +515,6 @@ void ButtonWidget::drawWidget(bool hilite) !(isEnabled() && onTop) ? _textcolorlo : hilite ? _textcolorhi : _textcolor, _bmw, _bmh); - - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -635,8 +674,6 @@ void CheckboxWidget::drawWidget(bool hilite) // Finally draw the label s.drawString(_font, _label, _x + prefixSize(_font), _y + _textY, _w, onTop && isEnabled() ? kTextColor : kColor); - - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -652,7 +689,7 @@ SliderWidget::SliderWidget(GuiObject* boss, const GUI::Font& font, _valueLabelWidth(valueLabelWidth), _forceLabelSign(forceLabelSign) { - _flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE; + _flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE | Widget::FLAG_CLEARBG;; _bgcolor = kDlgColor; _bgcolorhi = kDlgColor; @@ -870,8 +907,6 @@ void SliderWidget::drawWidget(bool hilite) if(_valueLabelWidth > 0) s.drawString(_font, _valueLabel + _valueUnit, _x + _w - _valueLabelWidth, _y + 2, _valueLabelWidth, isEnabled() ? kTextColor : kColor); - - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 50e71681e..c5fd8dced 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -83,6 +83,8 @@ class Widget : public GuiObject virtual bool handleEvent(Event::Type event) { return false; } void setDirty() override; + bool isDirty() const override; + bool isChainDirty() const override; void draw() override; void receivedFocus(); void lostFocus(); From de5233d63b3bd8d24e5f9b96d4291036cb024ae4 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 10 Nov 2020 23:29:56 +0100 Subject: [PATCH 02/70] added support of transparent widgets (for TimeMachineDialog) --- src/common/FBSurfaceSDL2.cxx | 16 ++++++++++++++++ src/common/FBSurfaceSDL2.hxx | 2 ++ src/emucore/FBSurface.hxx | 11 +++++++++++ src/gui/Dialog.cxx | 8 ++++++-- src/gui/DialogContainer.cxx | 2 +- src/gui/TimeLineWidget.cxx | 18 +++++++++++------- src/gui/TimeMachineDialog.cxx | 3 +++ src/gui/Widget.cxx | 13 ++++++++----- src/gui/Widget.hxx | 4 +++- 9 files changed, 61 insertions(+), 16 deletions(-) diff --git a/src/common/FBSurfaceSDL2.cxx b/src/common/FBSurfaceSDL2.cxx index 543195165..398c773ba 100644 --- a/src/common/FBSurfaceSDL2.cxx +++ b/src/common/FBSurfaceSDL2.cxx @@ -176,6 +176,22 @@ void FBSurfaceSDL2::invalidate() SDL_FillRect(mySurface, nullptr, 0); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FBSurfaceSDL2::invalidateRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h) +{ + ASSERT_MAIN_THREAD; + + // Clear the rectangle + SDL_Rect tmp; + tmp.x = x; + tmp.y = y; + tmp.w = w; + tmp.h = h; + // Note: Transparency has to be 0 to clear the rectangle foreground + // without affecting the background display. + SDL_FillRect(mySurface, &tmp, 0); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurfaceSDL2::free() { diff --git a/src/common/FBSurfaceSDL2.hxx b/src/common/FBSurfaceSDL2.hxx index f446bb17b..c19808f27 100644 --- a/src/common/FBSurfaceSDL2.hxx +++ b/src/common/FBSurfaceSDL2.hxx @@ -55,6 +55,8 @@ class FBSurfaceSDL2 : public FBSurface void translateCoords(Int32& x, Int32& y) const override; bool render() override; void invalidate() override; + void invalidateRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h) override; + void free() override; void reload() override; void resize(uInt32 width, uInt32 height) override; diff --git a/src/emucore/FBSurface.hxx b/src/emucore/FBSurface.hxx index a018ac2c9..67eaa86d2 100644 --- a/src/emucore/FBSurface.hxx +++ b/src/emucore/FBSurface.hxx @@ -325,6 +325,17 @@ class FBSurface */ virtual void invalidate() = 0; + /** + This method should be called to reset a surface area to empty + + @param x The x coordinate + @param y The y coordinate + @param w The width of the area + @param h The height of the area + */ + virtual void invalidateRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h) = 0; + + /** This method should be called to free any resources being used by the surface. diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 6e81535c2..c691c545a 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -404,7 +404,7 @@ void Dialog::drawDialog() if(isDirty()) { - //cerr << "*** draw dialog " << typeid(*this).name() << " ***" << endl; + cerr << "*** draw dialog " << typeid(*this).name() << " ***" << endl; // Dialog is still on top if e.g a ContextMenu is opened _onTop = parent().myDialogStack.top() == this @@ -414,7 +414,11 @@ void Dialog::drawDialog() if(_flags & Widget::FLAG_CLEARBG) { // cerr << "Dialog::drawDialog(): w = " << _w << ", h = " << _h << " @ " << &s << endl << endl; - s.fillRect(_x, _y + _th, _w, _h - _th, _onTop ? kDlgColor : kBGColorLo); + + if(_flags & Widget::FLAG_TRANSPARENT) + s.invalidateRect(_x, _y + _th, _w, _h - _th); + else + s.fillRect(_x, _y + _th, _w, _h - _th, _onTop ? kDlgColor : kBGColorLo); if(_th) { s.fillRect(_x, _y, _w, _th, _onTop ? kColorTitleBar : kColorTitleBarLo); diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index af353f452..8577eb50f 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -91,7 +91,7 @@ void DialogContainer::updateTime(uInt64 time) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool DialogContainer::draw(bool full) { - cerr << "draw " << full << endl; + //cerr << "draw " << full << endl; if(myDialogStack.empty()) return false; diff --git a/src/gui/TimeLineWidget.cxx b/src/gui/TimeLineWidget.cxx index 053d7bccf..94c4d3ef9 100644 --- a/src/gui/TimeLineWidget.cxx +++ b/src/gui/TimeLineWidget.cxx @@ -35,8 +35,11 @@ TimeLineWidget::TimeLineWidget(GuiObject* boss, const GUI::Font& font, : ButtonWidget(boss, font, x, y, w, h, label, cmd), _labelWidth(labelWidth) { - _flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE; + _flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE + | Widget::FLAG_CLEARBG | Widget::FLAG_TRANSPARENT; + _bgcolor = kDlgColor; + //_bgcolor = kBGColor; _bgcolorhi = kDlgColor; if(!_label.empty() && _labelWidth == 0) @@ -84,7 +87,7 @@ void TimeLineWidget::setStepValues(const IntArray& steps) if(steps.size() > _stepValue.capacity()) _stepValue.reserve(2 * steps.size()); - double scale = (_w - _labelWidth - 2 - HANDLE_W*0) / double(steps.back()); + double scale = (_w - _labelWidth - 2 - HANDLE_W) / double(steps.back()); // Skip the very last value; we take care of it outside the end of the loop for(uInt32 i = 0; i < steps.size() - 1; ++i) @@ -92,7 +95,7 @@ void TimeLineWidget::setStepValues(const IntArray& steps) // Due to integer <-> double conversion, the last value is sometimes // slightly less than the maximum value; we assign it manually to fix this - _stepValue.push_back(_w - _labelWidth - 2 - HANDLE_W*0); + _stepValue.push_back(_w - _labelWidth - 2 - HANDLE_W); } else _stepValue.push_back(0); @@ -141,17 +144,18 @@ void TimeLineWidget::drawWidget(bool hilite) { FBSurface& s = _boss->dialog().surface(); + cerr << "TimeLineWidget::drawWidget " << typeid(s).name() << endl; + // Draw the label, if any if(_labelWidth > 0) s.drawString(_font, _label, _x, _y + 2, _labelWidth, isEnabled() ? kTextColor : kColor, TextAlign::Left); - int p = valueToPos(_value), - x = _x + _labelWidth, - w = _w - _labelWidth; - // Frame the handle const int HANDLE_W2 = (HANDLE_W + 1) / 2; + int p = valueToPos(_value), + x = _x + _labelWidth + HANDLE_W2, + w = _w - _labelWidth - HANDLE_W; s.hLine(x + p - HANDLE_W2, _y + 0, x + p - HANDLE_W2 + HANDLE_W, kColorInfo); s.vLine(x + p - HANDLE_W2, _y + 1, _y + _h - 2, kColorInfo); s.hLine(x + p - HANDLE_W2 + 1, _y + _h - 1, x + p - HANDLE_W2 + 1 + HANDLE_W, kBGColor); diff --git a/src/gui/TimeMachineDialog.cxx b/src/gui/TimeMachineDialog.cxx index 3b591a62d..5982ba693 100644 --- a/src/gui/TimeMachineDialog.cxx +++ b/src/gui/TimeMachineDialog.cxx @@ -225,6 +225,7 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent, // Add index info myCurrentIdxWidget = new StaticTextWidget(this, font, xpos, ypos, "1000", TextAlign::Left, kBGColor); myCurrentIdxWidget->setTextColor(kColorInfo); + myCurrentIdxWidget->setFlags(Widget::FLAG_CLEARBG | Widget::FLAG_TRANSPARENT); myLastIdxWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("1000"), ypos, "1000", TextAlign::Right, kBGColor); myLastIdxWidget->setTextColor(kColorInfo); @@ -241,6 +242,7 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent, // Add time info int ypos_s = ypos + (buttonHeight - font.getFontHeight() + 1) / 2; // align to button vertical center myCurrentTimeWidget = new StaticTextWidget(this, font, xpos, ypos_s, "00:00.00", TextAlign::Left, kBGColor); + myCurrentTimeWidget->setFlags(Widget::FLAG_CLEARBG | Widget::FLAG_TRANSPARENT); myCurrentTimeWidget->setTextColor(kColorInfo); myLastTimeWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("00:00.00"), ypos_s, "00:00.00", TextAlign::Right, kBGColor); @@ -287,6 +289,7 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent, // Add message myMessageWidget = new StaticTextWidget(this, font, xpos, ypos_s, " ", TextAlign::Left, kBGColor); + myMessageWidget->setFlags(Widget::FLAG_CLEARBG | Widget::FLAG_TRANSPARENT); myMessageWidget->setTextColor(kColorInfo); } diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 33f6b632d..3c0252688 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -65,9 +65,9 @@ void Widget::setDirty() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Widget::isDirty() const { - string name = typeid(*this).name(); - if(_dirty && name == "class TabWidget") - cerr << "is dirty " << typeid(*this).name() << endl; + //string name = typeid(*this).name(); + //if(_dirty && name == "class TabWidget") + // cerr << "is dirty " << typeid(*this).name() << endl; return _dirty; } @@ -101,7 +101,7 @@ void Widget::draw() if(isDirty()) { - //cerr << " *** draw widget " << typeid(*this).name() << " ***" << endl; + cerr << " *** draw widget " << typeid(*this).name() << " ***" << endl; FBSurface& s = _boss->dialog().surface(); @@ -122,7 +122,10 @@ void Widget::draw() { x++; y++; w -= 2; h -= 2; } - s.fillRect(x, y, w, h, !onTop ? _bgcolorlo : (_flags & Widget::FLAG_HILITED) && isEnabled() ? _bgcolorhi : _bgcolor); + if(isTransparent()) + s.invalidateRect(x, y, w, h); + else + s.fillRect(x, y, w, h, !onTop ? _bgcolorlo : (_flags & Widget::FLAG_HILITED) && isEnabled() ? _bgcolorhi : _bgcolor); } // Draw border diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index c5fd8dced..15e7a1d9c 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -52,7 +52,8 @@ class Widget : public GuiObject FLAG_TRACK_MOUSE = 1 << 5, FLAG_RETAIN_FOCUS = 1 << 6, FLAG_WANTS_TAB = 1 << 7, - FLAG_WANTS_RAWDATA = 1 << 8 + FLAG_WANTS_RAWDATA = 1 << 8, + FLAG_TRANSPARENT = 1 << 9 }; public: @@ -105,6 +106,7 @@ class Widget : public GuiObject virtual bool wantsFocus() const { return _flags & FLAG_RETAIN_FOCUS; } bool wantsTab() const { return _flags & FLAG_WANTS_TAB; } bool wantsRaw() const { return _flags & FLAG_WANTS_RAWDATA; } + bool isTransparent() const { return _flags & FLAG_TRANSPARENT; } void setID(uInt32 id) { _id = id; } uInt32 getID() const { return _id; } From 49fcb524fd1cb1e3794ecdf1d1f9ada6a0a3ae83 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 11 Nov 2020 08:56:11 +0100 Subject: [PATCH 03/70] move Widget flags into GuiObject --- src/emucore/FBSurface.hxx | 2 +- src/gui/Dialog.cxx | 14 +++++++------- src/gui/Dialog.hxx | 6 ------ src/gui/GuiObject.hxx | 29 ++++++++++++++++++++++++++--- src/gui/TimeLineWidget.cxx | 3 +-- src/gui/TimeMachineDialog.cxx | 9 ++++++--- src/gui/Widget.cxx | 27 ++++++++++++++++----------- src/gui/Widget.hxx | 20 -------------------- src/libretro/FBSurfaceLIBRETRO.hxx | 1 + 9 files changed, 58 insertions(+), 53 deletions(-) diff --git a/src/emucore/FBSurface.hxx b/src/emucore/FBSurface.hxx index 67eaa86d2..d72ffdd64 100644 --- a/src/emucore/FBSurface.hxx +++ b/src/emucore/FBSurface.hxx @@ -323,7 +323,7 @@ class FBSurface This method should be called to reset the surface to empty pixels / colour black. */ - virtual void invalidate() = 0; + virtual void invalidate() {}; /** This method should be called to reset a surface area to empty diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index c691c545a..f519cdadc 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -49,9 +49,9 @@ Dialog::Dialog(OSystem& instance, DialogContainer& parent, const GUI::Font& font const string& title, int x, int y, int w, int h) : GuiObject(instance, parent, *this, x, y, w, h), _font(font), - _title(title), - _flags(Widget::FLAG_ENABLED | Widget::FLAG_BORDER | Widget::FLAG_CLEARBG) + _title(title) { + _flags = Widget::FLAG_ENABLED | Widget::FLAG_BORDER | Widget::FLAG_CLEARBG; setTitle(title); } @@ -411,14 +411,14 @@ void Dialog::drawDialog() || (parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this && !parent().myDialogStack.top()->hasTitle()); - if(_flags & Widget::FLAG_CLEARBG) + if(clearsBackground()) { // cerr << "Dialog::drawDialog(): w = " << _w << ", h = " << _h << " @ " << &s << endl << endl; - if(_flags & Widget::FLAG_TRANSPARENT) - s.invalidateRect(_x, _y + _th, _w, _h - _th); - else + if(hasBackground()) s.fillRect(_x, _y + _th, _w, _h - _th, _onTop ? kDlgColor : kBGColorLo); + else + s.invalidateRect(_x, _y + _th, _w, _h - _th); if(_th) { s.fillRect(_x, _y, _w, _th, _onTop ? kColorTitleBar : kColorTitleBarLo); @@ -431,7 +431,7 @@ void Dialog::drawDialog() s.invalidate(); cerr << "invalidate " << typeid(*this).name() << endl; } - if(_flags & Widget::FLAG_BORDER) // currently only used by Dialog itself + if(hasBorder()) // currently only used by Dialog itself s.frameRect(_x, _y, _w, _h, _onTop ? kColor : kShadowColor); // Make all child widgets dirty diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index 805522c42..d9b750ab6 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -90,10 +90,6 @@ class Dialog : public GuiObject */ void addSurface(const shared_ptr& surface); - void setFlags(int flags) { _flags |= flags; setDirty(); } - void clearFlags(int flags) { _flags &= ~flags; setDirty(); } - int getFlags() const { return _flags; } - void setTitle(const string& title); bool hasTitle() { return !_title.empty(); } @@ -235,8 +231,6 @@ class Dialog : public GuiObject shared_ptr _surface; int _tabID{0}; - int _flags{0}; - //bool _dirty{false}; uInt32 _max_w{0}; // maximum wanted width uInt32 _max_h{0}; // maximum wanted height diff --git a/src/gui/GuiObject.hxx b/src/gui/GuiObject.hxx index 2f4a5c1ca..3bb510a6b 100644 --- a/src/gui/GuiObject.hxx +++ b/src/gui/GuiObject.hxx @@ -41,6 +41,20 @@ class GuiObject : public CommandReceiver friend class Widget; friend class DialogContainer; + public: + enum : uInt32 { + FLAG_ENABLED = 1 << 0, + FLAG_INVISIBLE = 1 << 1, + FLAG_HILITED = 1 << 2, + FLAG_BORDER = 1 << 3, + FLAG_CLEARBG = 1 << 4, + FLAG_TRACK_MOUSE = 1 << 5, + FLAG_RETAIN_FOCUS = 1 << 6, + FLAG_WANTS_TAB = 1 << 7, + FLAG_WANTS_RAWDATA = 1 << 8, + FLAG_NOBG = 1 << 9 + }; + public: // The commands generated by various widgets enum { @@ -83,6 +97,14 @@ class GuiObject : public CommandReceiver virtual bool isChainDirty() const = 0; virtual bool needsRedraw() const { return isDirty() || isChainDirty(); }; + void setFlags(uInt32 flags) { _flags |= flags; setDirty(); } + void clearFlags(uInt32 flags) { _flags &= ~flags; setDirty(); } + uInt32 getFlags() const { return _flags; } + + bool hasBorder() const { return _flags & FLAG_BORDER; } + bool clearsBackground() const { return _flags & FLAG_CLEARBG; } + bool hasBackground() const { return !(_flags & FLAG_NOBG); } + /** Add given widget(s) to the focus list */ virtual void addFocusWidget(Widget* w) = 0; virtual void addToFocusList(WidgetArray& list) = 0; @@ -107,10 +129,11 @@ class GuiObject : public CommandReceiver Dialog& myDialog; protected: - int _x{0}, _y{0}, _w{0}, _h{0}; - bool _dirty{false}; + int _x{0}, _y{0}, _w{0}, _h{0}; + bool _dirty{false}; + uInt32 _flags{0}; - Widget* _firstWidget{nullptr}; + Widget* _firstWidget{nullptr}; WidgetArray _focusList; private: diff --git a/src/gui/TimeLineWidget.cxx b/src/gui/TimeLineWidget.cxx index 94c4d3ef9..4e6b9e9a0 100644 --- a/src/gui/TimeLineWidget.cxx +++ b/src/gui/TimeLineWidget.cxx @@ -36,10 +36,9 @@ TimeLineWidget::TimeLineWidget(GuiObject* boss, const GUI::Font& font, _labelWidth(labelWidth) { _flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE - | Widget::FLAG_CLEARBG | Widget::FLAG_TRANSPARENT; + | Widget::FLAG_CLEARBG | Widget::FLAG_NOBG; _bgcolor = kDlgColor; - //_bgcolor = kBGColor; _bgcolorhi = kDlgColor; if(!_label.empty() && _labelWidth == 0) diff --git a/src/gui/TimeMachineDialog.cxx b/src/gui/TimeMachineDialog.cxx index 5982ba693..e822504a9 100644 --- a/src/gui/TimeMachineDialog.cxx +++ b/src/gui/TimeMachineDialog.cxx @@ -218,6 +218,7 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent, this->clearFlags(Widget::FLAG_CLEARBG); // does only work combined with blending (0..100)! this->clearFlags(Widget::FLAG_BORDER); + this->setFlags(Widget::FLAG_NOBG); xpos = H_BORDER; ypos = V_BORDER; @@ -225,9 +226,10 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent, // Add index info myCurrentIdxWidget = new StaticTextWidget(this, font, xpos, ypos, "1000", TextAlign::Left, kBGColor); myCurrentIdxWidget->setTextColor(kColorInfo); - myCurrentIdxWidget->setFlags(Widget::FLAG_CLEARBG | Widget::FLAG_TRANSPARENT); + myCurrentIdxWidget->setFlags(Widget::FLAG_CLEARBG | Widget::FLAG_NOBG); myLastIdxWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("1000"), ypos, "1000", TextAlign::Right, kBGColor); + myLastIdxWidget->setFlags(Widget::FLAG_CLEARBG | Widget::FLAG_NOBG); myLastIdxWidget->setTextColor(kColorInfo); // Add timeline @@ -242,10 +244,11 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent, // Add time info int ypos_s = ypos + (buttonHeight - font.getFontHeight() + 1) / 2; // align to button vertical center myCurrentTimeWidget = new StaticTextWidget(this, font, xpos, ypos_s, "00:00.00", TextAlign::Left, kBGColor); - myCurrentTimeWidget->setFlags(Widget::FLAG_CLEARBG | Widget::FLAG_TRANSPARENT); + myCurrentTimeWidget->setFlags(Widget::FLAG_CLEARBG | Widget::FLAG_NOBG); myCurrentTimeWidget->setTextColor(kColorInfo); myLastTimeWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("00:00.00"), ypos_s, "00:00.00", TextAlign::Right, kBGColor); + myLastTimeWidget->setFlags(Widget::FLAG_CLEARBG | Widget::FLAG_NOBG); myLastTimeWidget->setTextColor(kColorInfo); xpos = myCurrentTimeWidget->getRight() + BUTTON_GAP * 4; @@ -289,7 +292,7 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent, // Add message myMessageWidget = new StaticTextWidget(this, font, xpos, ypos_s, " ", TextAlign::Left, kBGColor); - myMessageWidget->setFlags(Widget::FLAG_CLEARBG | Widget::FLAG_TRANSPARENT); + myMessageWidget->setFlags(Widget::FLAG_CLEARBG | Widget::FLAG_NOBG); myMessageWidget->setTextColor(kColorInfo); } diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 3c0252688..6358808e7 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -106,8 +106,6 @@ void Widget::draw() FBSurface& s = _boss->dialog().surface(); bool onTop = _boss->dialog().isOnTop(); - - bool hasBorder = _flags & Widget::FLAG_BORDER; // currently only used by Dialog widget int oldX = _x, oldY = _y; // Account for our relative position in the dialog @@ -115,23 +113,29 @@ void Widget::draw() _y = getAbsY(); // Clear background (unless alpha blending is enabled) - if(_flags & Widget::FLAG_CLEARBG) + if(clearsBackground()) { int x = _x, y = _y, w = _w, h = _h; - if(hasBorder) + if(hasBorder()) { x++; y++; w -= 2; h -= 2; } - if(isTransparent()) - s.invalidateRect(x, y, w, h); + if(hasBackground()) + s.fillRect(x, y, w, h, !onTop + ? _bgcolorlo + : (_flags & Widget::FLAG_HILITED) && isEnabled() + ? _bgcolorhi : _bgcolor); else - s.fillRect(x, y, w, h, !onTop ? _bgcolorlo : (_flags & Widget::FLAG_HILITED) && isEnabled() ? _bgcolorhi : _bgcolor); + s.invalidateRect(x, y, w, h); } // Draw border - if(hasBorder) + if(hasBorder()) { - s.frameRect(_x, _y, _w, _h, !onTop ? kColor : (_flags & Widget::FLAG_HILITED) && isEnabled() ? kWidColorHi : kColor); + s.frameRect(_x, _y, _w, _h, !onTop + ? kColor + : (_flags & Widget::FLAG_HILITED) && isEnabled() + ? kWidColorHi : kColor); _x += 4; _y += 4; _w -= 8; @@ -142,7 +146,7 @@ void Widget::draw() drawWidget((_flags & Widget::FLAG_HILITED) ? true : false); // Restore x/y - if(hasBorder) + if(hasBorder()) { _x -= 4; _y -= 4; @@ -350,6 +354,7 @@ StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font, _align(align) { _flags = Widget::FLAG_ENABLED; + _bgcolor = kDlgColor; _bgcolorhi = kDlgColor; _textcolor = kTextColor; @@ -692,7 +697,7 @@ SliderWidget::SliderWidget(GuiObject* boss, const GUI::Font& font, _valueLabelWidth(valueLabelWidth), _forceLabelSign(forceLabelSign) { - _flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE | Widget::FLAG_CLEARBG;; + _flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE | Widget::FLAG_CLEARBG; _bgcolor = kDlgColor; _bgcolorhi = kDlgColor; diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 15e7a1d9c..270f1eb32 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -42,20 +42,6 @@ class Widget : public GuiObject { friend class Dialog; - public: - enum : uInt32 { - FLAG_ENABLED = 1 << 0, - FLAG_INVISIBLE = 1 << 1, - FLAG_HILITED = 1 << 2, - FLAG_BORDER = 1 << 3, - FLAG_CLEARBG = 1 << 4, - FLAG_TRACK_MOUSE = 1 << 5, - FLAG_RETAIN_FOCUS = 1 << 6, - FLAG_WANTS_TAB = 1 << 7, - FLAG_WANTS_RAWDATA = 1 << 8, - FLAG_TRANSPARENT = 1 << 9 - }; - public: Widget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h); ~Widget() override; @@ -97,16 +83,11 @@ class Widget : public GuiObject /** Set/clear FLAG_ENABLED */ void setEnabled(bool e); - void setFlags(uInt32 flags) { _flags |= flags; setDirty(); } - void clearFlags(uInt32 flags) { _flags &= ~flags; setDirty(); } - uInt32 getFlags() const { return _flags; } - bool isEnabled() const { return _flags & FLAG_ENABLED; } bool isVisible() const override { return !(_flags & FLAG_INVISIBLE); } virtual bool wantsFocus() const { return _flags & FLAG_RETAIN_FOCUS; } bool wantsTab() const { return _flags & FLAG_WANTS_TAB; } bool wantsRaw() const { return _flags & FLAG_WANTS_RAWDATA; } - bool isTransparent() const { return _flags & FLAG_TRANSPARENT; } void setID(uInt32 id) { _id = id; } uInt32 getID() const { return _id; } @@ -140,7 +121,6 @@ class Widget : public GuiObject const GUI::Font& _font; Widget* _next{nullptr}; uInt32 _id{0}; - uInt32 _flags{0}; bool _hasFocus{false}; int _fontWidth{0}; int _lineHeight{0}; diff --git a/src/libretro/FBSurfaceLIBRETRO.hxx b/src/libretro/FBSurfaceLIBRETRO.hxx index 646d2c46c..3918ff673 100644 --- a/src/libretro/FBSurfaceLIBRETRO.hxx +++ b/src/libretro/FBSurfaceLIBRETRO.hxx @@ -51,6 +51,7 @@ class FBSurfaceLIBRETRO : public FBSurface void translateCoords(Int32& x, Int32& y) const override { } bool render() override { return true; } void invalidate() override { } + void invalidateRect(uInt32, uInt32, uInt32, uInt32) override { } void free() override { } void reload() override { } void resize(uInt32 width, uInt32 height) override { } From 7a1a5e9c17d71f191ec6b37cc9daf30aad6cb673 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 11 Nov 2020 13:00:44 +0100 Subject: [PATCH 04/70] added individual size to each save state (fixes #727) --- src/common/RewindManager.cxx | 24 ++++++++++++++---------- src/common/RewindManager.hxx | 2 -- src/emucore/Serializer.cxx | 2 ++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/common/RewindManager.cxx b/src/common/RewindManager.cxx index 70fa481d7..bc6b70813 100644 --- a/src/common/RewindManager.cxx +++ b/src/common/RewindManager.cxx @@ -37,7 +37,6 @@ RewindManager::RewindManager(OSystem& system, StateManager& statemgr) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RewindManager::setup() { - myStateSize = 0; myLastTimeMachineAdd = false; const string& prefix = myOSystem.settings().getBool("dev.settings") ? "dev." : "plr."; @@ -138,7 +137,6 @@ bool RewindManager::addState(const string& message, bool timeMachine) s.rewind(); // rewind Serializer internal buffers if(myStateManager.saveState(s) && myOSystem.console().tia().saveDisplay(s)) { - myStateSize = std::max(myStateSize, uInt32(s.size())); state.message = message; state.cycles = myOSystem.console().tia().cycles(); myLastTimeMachineAdd = timeMachine; @@ -256,18 +254,22 @@ string RewindManager::saveAllStates() buf.str(""); out.putString(STATE_HEADER); out.putShort(numStates); - out.putInt(myStateSize); - unique_ptr buffer = make_unique(myStateSize); for (uInt32 i = 0; i < numStates; ++i) { RewindState& state = myStateList.current(); Serializer& s = state.data; + uInt32 stateSize = uInt32(s.size()); + unique_ptr buffer = make_unique(stateSize); + + out.putInt(stateSize); + // Rewind Serializer internal buffers s.rewind(); + // Save state - s.getByteArray(buffer.get(), myStateSize); - out.putByteArray(buffer.get(), myStateSize); + s.getByteArray(buffer.get(), stateSize); + out.putByteArray(buffer.get(), stateSize); out.putString(state.message); out.putLong(state.cycles); @@ -310,25 +312,27 @@ string RewindManager::loadAllStates() if (in.getString() != STATE_HEADER) return "Incompatible all states file"; numStates = in.getShort(); - myStateSize = in.getInt(); - unique_ptr buffer = make_unique(myStateSize); for (uInt32 i = 0; i < numStates; ++i) { if (myStateList.full()) compressStates(); + uInt32 stateSize = in.getInt(); + unique_ptr buffer = make_unique(stateSize); + // Add new state at the end of the list (queue adds at end) // This updates the 'current' iterator inside the list myStateList.addLast(); RewindState& state = myStateList.current(); Serializer& s = state.data; + // Rewind Serializer internal buffers s.rewind(); // Fill new state with saved values - in.getByteArray(buffer.get(), myStateSize); - s.putByteArray(buffer.get(), myStateSize); + in.getByteArray(buffer.get(), stateSize); + s.putByteArray(buffer.get(), stateSize); state.message = in.getString(); state.cycles = in.getLong(); } diff --git a/src/common/RewindManager.hxx b/src/common/RewindManager.hxx index 619af7264..5f53083f7 100644 --- a/src/common/RewindManager.hxx +++ b/src/common/RewindManager.hxx @@ -144,7 +144,6 @@ class RewindManager bool atLast() const { return myStateList.atLast(); } void resize(uInt32 size) { myStateList.resize(size); } void clear() { - myStateSize = 0; myStateList.clear(); } @@ -176,7 +175,6 @@ class RewindManager uInt64 myHorizon{0}; double myFactor{0.0}; bool myLastTimeMachineAdd{false}; - uInt32 myStateSize{0}; struct RewindState { Serializer data; // actual save state diff --git a/src/emucore/Serializer.cxx b/src/emucore/Serializer.cxx index 80282bdc2..7f94dced2 100644 --- a/src/emucore/Serializer.cxx +++ b/src/emucore/Serializer.cxx @@ -91,6 +91,8 @@ void Serializer::rewind() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - size_t Serializer::size() const { + myStream->seekp(0, std::ios::end); + return myStream->tellp(); } From 113ee123986166e099efb046b5f3410c8a8723d4 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 11 Nov 2020 15:37:32 +0100 Subject: [PATCH 05/70] activated enhanced "full" redraw logic --- src/emucore/FrameBuffer.cxx | 32 ++++++++++++++++---------------- src/gui/DialogContainer.cxx | 29 ++++++++--------------------- 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index e922ff390..828c14e8f 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -323,13 +323,14 @@ void FrameBuffer::update(bool force) // last, since they are always drawn on top of everything else). // Full rendering is required when messages are enabled - force = force || myMsg.counter >= 0; + force |= (myMsg.counter >= 0); // Detect when a message has been turned off; one last redraw is required // in this case, to draw over the area that the message occupied if(myMsg.counter == 0) myMsg.counter = -1; + bool redraw = false; switch(myOSystem.eventHandler().state()) { case EventHandlerState::NONE: @@ -354,8 +355,8 @@ void FrameBuffer::update(bool force) #ifdef GUI_SUPPORT case EventHandlerState::OPTIONSMENU: { - force = force || myOSystem.menu().needsRedraw(); - if(force) + redraw = myOSystem.menu().needsRedraw(); + if(force || redraw) { clear(); myTIASurface->render(); @@ -366,8 +367,8 @@ void FrameBuffer::update(bool force) case EventHandlerState::CMDMENU: { - force = force || myOSystem.commandMenu().needsRedraw(); - if(force) + redraw = myOSystem.commandMenu().needsRedraw(); + if(force || redraw) { clear(); myTIASurface->render(); @@ -378,8 +379,8 @@ void FrameBuffer::update(bool force) case EventHandlerState::MESSAGEMENU: { - force = force || myOSystem.messageMenu().needsRedraw(); - if (force) + redraw = myOSystem.messageMenu().needsRedraw(); + if(force || redraw) { clear(); myTIASurface->render(); @@ -390,8 +391,8 @@ void FrameBuffer::update(bool force) case EventHandlerState::TIMEMACHINE: { - force = force || myOSystem.timeMachine().needsRedraw(); - if(force) + redraw = myOSystem.timeMachine().needsRedraw(); + if(force || redraw) { clear(); myTIASurface->render(); @@ -436,10 +437,9 @@ void FrameBuffer::update(bool force) case EventHandlerState::LAUNCHER: { - force = force || myOSystem.launcher().needsRedraw(); - if(force) + redraw = myOSystem.launcher().needsRedraw(); + if(force || redraw) { - //clear(); myOSystem.launcher().draw(force); } break; // EventHandlerState::LAUNCHER @@ -449,10 +449,10 @@ void FrameBuffer::update(bool force) #ifdef DEBUGGER_SUPPORT case EventHandlerState::DEBUGGER: { - force = force || myOSystem.debugger().needsRedraw(); - if(force) + redraw = myOSystem.debugger().needsRedraw(); + if(force || redraw) { - clear(); + myOSystem.debugger().draw(force); } break; // EventHandlerState::DEBUGGER @@ -471,7 +471,7 @@ void FrameBuffer::update(bool force) drawMessage(); // Push buffers to screen only when necessary - if(force) + if(force || redraw) myBackend->renderToScreen(); } diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 8577eb50f..60bc9b32d 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -91,32 +91,19 @@ void DialogContainer::updateTime(uInt64 time) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool DialogContainer::draw(bool full) { - //cerr << "draw " << full << endl; + cerr << "draw " << full << " " << typeid(*this).name() << endl; if(myDialogStack.empty()) return false; // Make the top dialog dirty if a full redraw is requested - //if(full) - // myDialogStack.top()->setDirty(); + if(full) + myDialogStack.top()->setDirty(); - // If the top dialog is dirty, then all below it must be redrawn too - const bool dirty = needsRedraw(); - //if(dirty) - // myDialogStack.top()->setDirty(); - - //myDialogStack.applyAll([&](Dialog*& d){ - // if(dirty) - // d->setDirty(); - // full |= d->render(); - //}); - //if(dirty) - { - myDialogStack.applyAll([&](Dialog*& d) { - if(d->needsRedraw()) - //d->setDirty(); - full |= d->render(); - }); - } + // Render all dirty dialogs + myDialogStack.applyAll([&](Dialog*& d) { + if(d->needsRedraw()) + full |= d->render(); + }); return full; } From 250a1634de40c312cb835c3e55d15fa1b5aee6de Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 11 Nov 2020 16:50:49 +0100 Subject: [PATCH 06/70] fixed RomInfoWidget drawing --- src/gui/RomInfoWidget.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/RomInfoWidget.cxx b/src/gui/RomInfoWidget.cxx index 01b30015b..c2068a4d1 100644 --- a/src/gui/RomInfoWidget.cxx +++ b/src/gui/RomInfoWidget.cxx @@ -172,6 +172,8 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node) myRomInfo.push_back("Controllers: " + (left + " (left), " + right + " (right)")); if (bsDetected != "") myRomInfo.push_back("Type: " + Bankswitch::typeToDesc(Bankswitch::nameToType(bsDetected))); + + setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -227,4 +229,5 @@ void RomInfoWidget::drawWidget(bool hilite) onTop ? _textcolor : _shadowcolor); ypos += _font.getLineHeight() + (lines - 1) * _font.getFontHeight(); } + clearDirty(); } From 678892e8c7fdbe36a5c133dd2a70e42c9eceb24b Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 11 Nov 2020 17:26:40 +0100 Subject: [PATCH 07/70] added blinking cursor --- src/gui/Dialog.cxx | 7 +++-- src/gui/Dialog.hxx | 2 +- src/gui/EditableWidget.cxx | 55 +++++++++++++++++++++++++++++++------- src/gui/EditableWidget.hxx | 4 +++ src/gui/GuiObject.hxx | 4 +-- src/gui/Widget.cxx | 4 +-- src/gui/Widget.hxx | 2 +- 7 files changed, 58 insertions(+), 20 deletions(-) diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index f519cdadc..669d7341c 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -156,7 +156,7 @@ void Dialog::setDirty() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Dialog::isDirty() const +bool Dialog::isDirty() { return _dirty; } @@ -221,8 +221,6 @@ void Dialog::positionAt(uInt32 pos) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Dialog::render() { - //assert(_dirty); - if(!isVisible() || !needsRedraw()) return false; @@ -404,7 +402,7 @@ void Dialog::drawDialog() if(isDirty()) { - cerr << "*** draw dialog " << typeid(*this).name() << " ***" << endl; + //cerr << "*** draw dialog " << typeid(*this).name() << " ***" << endl; // Dialog is still on top if e.g a ContextMenu is opened _onTop = parent().myDialogStack.top() == this @@ -446,6 +444,7 @@ void Dialog::drawDialog() w = _firstWidget; while(w) { + // only redraw changed widgets if(w->needsRedraw()) w->draw(); diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index d9b750ab6..68a71608c 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -65,7 +65,7 @@ class Dialog : public GuiObject // A dialog being dirty indicates that its underlying surface needs to be // redrawn and then re-rendered; this is taken care of in ::render() void setDirty() override; - bool isDirty() const override; + bool isDirty() override; // TODO: remove bool isChainDirty() const override; bool render(); diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 16b371813..b1783c10c 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -62,6 +62,23 @@ void EditableWidget::setText(const string& str, bool) setDirty(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool EditableWidget::isDirty() +{ + if(_hasFocus && _editable && isVisible() && _boss->isVisible()) + { + _caretTimer++; + if(_caretTimer > 40) // switch every 2/3rd seconds + { + _caretTimer = 0; + _caretEnabled = !_caretEnabled; + _dirty = true; + } + cerr << "."; + } + + return _dirty; +} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EditableWidget::setEditable(bool editable, bool hiliteBG) @@ -79,6 +96,15 @@ void EditableWidget::setEditable(bool editable, bool hiliteBG) } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void EditableWidget::receivedFocusWidget() +{ + _caretTimer = 0; + _caretEnabled = true; + + Widget::receivedFocusWidget(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EditableWidget::lostFocusWidget() { @@ -316,22 +342,31 @@ void EditableWidget::drawCaretSelection() if (!_editable || !isVisible() || !_boss->isVisible() || !_hasFocus) return; - const Common::Rect& editRect = getEditRect(); - int x = editRect.x(); - int y = editRect.y(); + if(_caretEnabled) + { + FBSurface& s = _boss->dialog().surface(); + const Common::Rect& editRect = getEditRect(); + int x = editRect.x(); + int y = editRect.y(); + x += getCaretOffset(); - x += getCaretOffset(); + x += _x; + y += _y; - x += _x; - y += _y; - - FBSurface& s = _boss->dialog().surface(); - s.vLine(x, y + 2, y + editRect.h() - 2, kTextColorHi); - s.vLine(x-1, y + 2, y + editRect.h() - 2, kTextColorHi); + s.vLine(x, y + 2, y + editRect.h() - 2, kTextColorHi); + s.vLine(x-1, y + 2, y + editRect.h() - 2, kTextColorHi); + clearDirty(); + } if(_selectSize) { + FBSurface& s = _boss->dialog().surface(); + const Common::Rect& editRect = getEditRect(); + int x = editRect.x(); + int y = editRect.y(); + string text = selectString(); + x = editRect.x(); y = editRect.y(); int w = editRect.w(); diff --git a/src/gui/EditableWidget.hxx b/src/gui/EditableWidget.hxx index fda92ccdf..e4dfbc2f7 100644 --- a/src/gui/EditableWidget.hxx +++ b/src/gui/EditableWidget.hxx @@ -65,7 +65,9 @@ class EditableWidget : public Widget, public CommandSender void setTextFilter(const TextFilter& filter) { _filter = filter; } protected: + void receivedFocusWidget() override; void lostFocusWidget() override; + bool isDirty() override; virtual void startEditMode() { setFlags(Widget::FLAG_WANTS_RAWDATA); } virtual void endEditMode() { clearFlags(Widget::FLAG_WANTS_RAWDATA); } @@ -110,6 +112,8 @@ class EditableWidget : public Widget, public CommandSender unique_ptr myUndoHandler; int _caretPos{0}; + int _caretTimer{0}; + bool _caretEnabled{true}; // Size of current selected text // 0 = no selection diff --git a/src/gui/GuiObject.hxx b/src/gui/GuiObject.hxx index 3bb510a6b..a6cf4e5ca 100644 --- a/src/gui/GuiObject.hxx +++ b/src/gui/GuiObject.hxx @@ -93,9 +93,9 @@ class GuiObject : public CommandReceiver virtual bool isVisible() const = 0; virtual void setDirty() = 0; virtual void clearDirty() { _dirty = false; } - virtual bool isDirty() const { return _dirty; } + virtual bool isDirty() { return _dirty; } virtual bool isChainDirty() const = 0; - virtual bool needsRedraw() const { return isDirty() || isChainDirty(); }; + virtual bool needsRedraw() { return isDirty() || isChainDirty(); }; void setFlags(uInt32 flags) { _flags |= flags; setDirty(); } void clearFlags(uInt32 flags) { _flags &= ~flags; setDirty(); } diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 6358808e7..c9e0441e7 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -63,7 +63,7 @@ void Widget::setDirty() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Widget::isDirty() const +bool Widget::isDirty() { //string name = typeid(*this).name(); //if(_dirty && name == "class TabWidget") @@ -353,7 +353,7 @@ StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font, _label(text), _align(align) { - _flags = Widget::FLAG_ENABLED; + _flags = Widget::FLAG_ENABLED | FLAG_CLEARBG; _bgcolor = kDlgColor; _bgcolorhi = kDlgColor; diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 270f1eb32..3e70523c0 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -70,7 +70,7 @@ class Widget : public GuiObject virtual bool handleEvent(Event::Type event) { return false; } void setDirty() override; - bool isDirty() const override; + bool isDirty() override; // TODO: remove bool isChainDirty() const override; void draw() override; void receivedFocus(); From bec842b9d72379e80ec7d5f45d8442362df6e16b Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 11 Nov 2020 18:24:30 +0100 Subject: [PATCH 08/70] 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); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From cc21f75b958444ee0dc27c2d8d38251efbc0c2c8 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 11 Nov 2020 19:54:44 +0100 Subject: [PATCH 09/70] improved blinking cursor --- src/gui/EditableWidget.cxx | 52 +++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index b1783c10c..0b78c8952 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -133,7 +133,7 @@ bool EditableWidget::handleText(char text) if(tryInsertChar(text, _caretPos)) { - _caretPos++; + setCaretPos(_caretPos + 1); sendCommand(EditableWidget::kChangedCmd, 0, _id); setDirty(); return true; @@ -291,7 +291,7 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod) { // Put caret at last difference myUndoHandler->lastDiff(_editString, oldString); - _caretPos = myUndoHandler->lastDiff(_editString, oldString); + setCaretPos(myUndoHandler->lastDiff(_editString, oldString)); _selectSize = 0; sendCommand(EditableWidget::kChangedCmd, key, _id); } @@ -342,22 +342,7 @@ void EditableWidget::drawCaretSelection() if (!_editable || !isVisible() || !_boss->isVisible() || !_hasFocus) return; - if(_caretEnabled) - { - FBSurface& s = _boss->dialog().surface(); - const Common::Rect& editRect = getEditRect(); - int x = editRect.x(); - int y = editRect.y(); - x += getCaretOffset(); - - x += _x; - y += _y; - - s.vLine(x, y + 2, y + editRect.h() - 2, kTextColorHi); - s.vLine(x-1, y + 2, y + editRect.h() - 2, kTextColorHi); - clearDirty(); - } - + // Draw the selection if(_selectSize) { FBSurface& s = _boss->dialog().surface(); @@ -393,6 +378,24 @@ void EditableWidget::drawCaretSelection() s.drawString(_font, text, x, y + 1, w, h, kTextColorInv, TextAlign::Left, 0, false); } + + // Draw the caret + if(_caretEnabled ^ (_selectSize != 0)) + { + FBSurface& s = _boss->dialog().surface(); + const Common::Rect& editRect = getEditRect(); + int x = editRect.x(); + int y = editRect.y(); + ColorId color = _caretEnabled ? kTextColorHi : kTextColorInv; + + x += getCaretOffset(); + x += _x; + y += _y; + + s.vLine(x, y + 1, y + editRect.h() - 3, color); + s.vLine(x - 1, y + 1, y + editRect.h() - 3, color); + clearDirty(); + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -401,6 +404,9 @@ bool EditableWidget::setCaretPos(int newPos) assert(newPos >= 0 && newPos <= int(_editString.size())); _caretPos = newPos; + _caretTimer = 0; + _caretEnabled = true; + return adjustOffset(); } @@ -410,6 +416,8 @@ bool EditableWidget::moveCaretPos(int direction) if(setCaretPos(_caretPos + direction)) { _selectSize -= direction; + _caretTimer = 0; + _caretEnabled = true; return true; } return false; @@ -487,6 +495,7 @@ bool EditableWidget::killChar(int direction, bool addEdit) { myUndoHandler->endChars(_editString); _editString.erase(_caretPos, 1); + setCaretPos(_caretPos); if(addEdit) myUndoHandler->doo(_editString); @@ -591,7 +600,7 @@ bool EditableWidget::moveWord(int direction, bool select) if(select) _selectSize++; } - _caretPos = currentPos; + setCaretPos(currentPos); handled = true; } else if(direction == +1) // move to first character of next word @@ -610,7 +619,7 @@ bool EditableWidget::moveWord(int direction, bool select) if(select) _selectSize--; } - _caretPos = currentPos; + setCaretPos(currentPos); handled = true; } @@ -665,6 +674,7 @@ bool EditableWidget::killSelectedText(bool addEdit) _selectSize = -_selectSize; } _editString.erase(_caretPos, _selectSize); + setCaretPos(_caretPos); _selectSize = 0; if(addEdit) myUndoHandler->doo(_editString); @@ -724,7 +734,7 @@ bool EditableWidget::pasteSelectedText() _editString.insert(_caretPos, buf.str()); // position cursor at the end of pasted text - _caretPos += int(buf.str().length()); + setCaretPos(_caretPos + int(buf.str().length())); if(selected || !pasted.empty()) { From f64285425ac7f6bccbf39cb32f69056150f4865e Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 11 Nov 2020 23:32:00 +0100 Subject: [PATCH 10/70] split Dialog drawing and rendering and skip drawing render when possible --- src/gui/Dialog.cxx | 17 ++++++++++------- src/gui/Dialog.hxx | 3 ++- src/gui/DialogContainer.cxx | 20 ++++++++++---------- src/gui/DialogContainer.hxx | 4 +--- src/gui/EditableWidget.cxx | 1 - src/gui/PopUpWidget.cxx | 2 +- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 26922f26d..9cb5accb2 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -128,7 +128,6 @@ void Dialog::close() _visible = false; parent().removeDialog(); - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -219,26 +218,30 @@ void Dialog::positionAt(uInt32 pos) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Dialog::render() +void Dialog::redraw() { if(!isVisible() || !needsRedraw()) - return false; + return;// false; // Draw this dialog center(); drawDialog(); + render(); +// return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Dialog::render() +{ // Update dialog surface; also render any extra surfaces // Extra surfaces must be rendered afterwards, so they are drawn on top if(_surface->render()) { - mySurfaceStack.applyAll([](shared_ptr& surface){ + mySurfaceStack.applyAll([](shared_ptr& surface) { surface->render(); }); } - //_dirty = false; - - return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index 68a71608c..b9a924b55 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -67,7 +67,8 @@ class Dialog : public GuiObject void setDirty() override; bool isDirty() override; // TODO: remove bool isChainDirty() const override; - bool render(); + void redraw(); + void render(); void addFocusWidget(Widget* w) override; void addToFocusList(WidgetArray& list) override; diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 60bc9b32d..9649e447c 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -89,11 +89,11 @@ void DialogContainer::updateTime(uInt64 time) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool DialogContainer::draw(bool full) +void DialogContainer::draw(bool full) { cerr << "draw " << full << " " << typeid(*this).name() << endl; if(myDialogStack.empty()) - return false; + return; // Make the top dialog dirty if a full redraw is requested if(full) @@ -102,10 +102,8 @@ bool DialogContainer::draw(bool full) // Render all dirty dialogs myDialogStack.applyAll([&](Dialog*& d) { if(d->needsRedraw()) - full |= d->render(); + d->redraw(); }); - - return full; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -133,7 +131,7 @@ int DialogContainer::addDialog(Dialog* d) "Unable to show dialog box; FIX THE CODE"); else { - // fade out current top dialog + // "darken" current top dialog if(!myDialogStack.empty()) myDialogStack.top()->setDirty(); d->setDirty(); @@ -148,14 +146,16 @@ void DialogContainer::removeDialog() if(!myDialogStack.empty()) { myDialogStack.pop(); - // necessary as long as all dialogs share the same surface + if(!myDialogStack.empty()) { - //myDialogStack.top()->setDirty(); + // this "undarkens" the top dialog + myDialogStack.top()->setDirty(); - // Mark all dialogs for redraw + // Rerender all dialogs (TODO: top dialog is rendered twice) myDialogStack.applyAll([&](Dialog*& d){ - d->setDirty(); + //d->setDirty(); + d->render(); }); } } diff --git a/src/gui/DialogContainer.hxx b/src/gui/DialogContainer.hxx index cc50e23b6..1f6cce8f6 100644 --- a/src/gui/DialogContainer.hxx +++ b/src/gui/DialogContainer.hxx @@ -121,10 +121,8 @@ class DialogContainer /** Draw the stack of menus (full indicates to redraw all items). - - @return Answers whether any drawing actually occurred. */ - bool draw(bool full = false); + void draw(bool full = false); /** Answers whether a full redraw is required. diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 0b78c8952..4032daae3 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -74,7 +74,6 @@ bool EditableWidget::isDirty() _caretEnabled = !_caretEnabled; _dirty = true; } - cerr << "."; } return _dirty; diff --git a/src/gui/PopUpWidget.cxx b/src/gui/PopUpWidget.cxx index cf799dc47..ccf6af1aa 100644 --- a/src/gui/PopUpWidget.cxx +++ b/src/gui/PopUpWidget.cxx @@ -277,7 +277,7 @@ void PopUpWidget::drawWidget(bool hilite) // Fill the background ColorId bgCol = isEditable() ? kWidColor : kDlgColor; - s.fillRect(x + 1, _y + 1, w - (_arrowWidth * 2 - 0), _h - 2, + s.fillRect(x + 1, _y + 1, w - (_arrowWidth * 2 - 1), _h - 2, onTop ? _changed ? kDbgChangedColor : bgCol : kDlgColor); s.fillRect(x + w - (_arrowWidth * 2 - 2), _y + 1, (_arrowWidth * 2 - 3), _h - 2, onTop ? isEnabled() && hilite ? kBtnColorHi : bgCol : kBGColorLo); From a643b3d239dbe5af0464b3da53cde0ac56d9217d Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 12 Nov 2020 10:43:04 +0100 Subject: [PATCH 11/70] minimized UI redraws and renderings when message is displayed refactored message creation --- src/common/PNGLibrary.cxx | 6 +- src/common/PaletteHandler.cxx | 8 +- src/common/RewindManager.cxx | 4 +- src/common/SoundSDL2.cxx | 4 +- src/common/StateManager.cxx | 18 +- src/debugger/gui/RomWidget.cxx | 2 +- src/debugger/gui/TiaOutputWidget.cxx | 8 +- src/debugger/gui/TiaZoomWidget.cxx | 4 +- src/emucore/Console.cxx | 42 ++-- src/emucore/EventHandler.cxx | 46 ++--- src/emucore/FrameBuffer.cxx | 295 +++++++++++++-------------- src/emucore/FrameBuffer.hxx | 25 ++- src/emucore/OSystem.cxx | 6 +- src/emucore/QuadTari.cxx | 2 +- src/emucore/TIASurface.cxx | 10 +- src/gui/DialogContainer.cxx | 4 +- src/gui/GameInfoDialog.cxx | 6 +- src/gui/LauncherDialog.cxx | 2 +- src/gui/LoggerDialog.cxx | 4 +- src/gui/TimeMachineDialog.cxx | 4 +- 20 files changed, 252 insertions(+), 248 deletions(-) diff --git a/src/common/PNGLibrary.cxx b/src/common/PNGLibrary.cxx index 901d42478..2a6f84d6a 100644 --- a/src/common/PNGLibrary.cxx +++ b/src/common/PNGLibrary.cxx @@ -267,7 +267,7 @@ void PNGLibrary::toggleContinuousSnapshots(bool perFrame) buf << "Enabling snapshots in " << interval << " second intervals"; interval *= uInt32(myOSystem.frameRate()); } - myOSystem.frameBuffer().showMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.str()); setContinuousSnapInterval(interval); } else @@ -276,7 +276,7 @@ void PNGLibrary::toggleContinuousSnapshots(bool perFrame) buf << "Disabling snapshots, generated " << (mySnapCounter / mySnapInterval) << " files"; - myOSystem.frameBuffer().showMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.str()); setContinuousSnapInterval(0); } } @@ -378,7 +378,7 @@ void PNGLibrary::takeSnapshot(uInt32 number) // Re-enable old messages myOSystem.frameBuffer().enableMessages(true); } - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/PaletteHandler.cxx b/src/common/PaletteHandler.cxx index db6961af8..f13c18ab1 100644 --- a/src/common/PaletteHandler.cxx +++ b/src/common/PaletteHandler.cxx @@ -69,7 +69,7 @@ void PaletteHandler::cyclePalette(int direction) const string palette = toPaletteName(PaletteType(type)); const string message = MESSAGES[type] + " palette"; - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); setPalette(palette); } @@ -112,7 +112,7 @@ void PaletteHandler::showAdjustableMessage() const float value = myOSystem.console().timing() == ConsoleTiming::pal ? myPhasePAL : myPhaseNTSC; buf << std::fixed << std::setprecision(1) << value << DEGREE; - myOSystem.frameBuffer().showMessage( + myOSystem.frameBuffer().showGaugeMessage( "Palette phase shift", buf.str(), value, (isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) - MAX_PHASE_SHIFT, (isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) + MAX_PHASE_SHIFT); @@ -122,7 +122,7 @@ void PaletteHandler::showAdjustableMessage() const float value = *myAdjustables[myCurrentAdjustable].value; buf << std::fixed << std::setprecision(1) << value << DEGREE; - myOSystem.frameBuffer().showMessage( + myOSystem.frameBuffer().showGaugeMessage( msg.str(), buf.str(), value, -MAX_RGB_SHIFT, +MAX_RGB_SHIFT); } else @@ -131,7 +131,7 @@ void PaletteHandler::showAdjustableMessage() ? scaleRGBTo100(*myAdjustables[myCurrentAdjustable].value) : scaleTo100(*myAdjustables[myCurrentAdjustable].value); buf << value << "%"; - myOSystem.frameBuffer().showMessage( + myOSystem.frameBuffer().showGaugeMessage( msg.str(), buf.str(), value); } } diff --git a/src/common/RewindManager.cxx b/src/common/RewindManager.cxx index bc6b70813..044bc57e9 100644 --- a/src/common/RewindManager.cxx +++ b/src/common/RewindManager.cxx @@ -181,7 +181,7 @@ uInt32 RewindManager::rewindStates(uInt32 numStates) if(myOSystem.eventHandler().state() != EventHandlerState::TIMEMACHINE && myOSystem.eventHandler().state() != EventHandlerState::PLAYBACK) - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); return i; } @@ -216,7 +216,7 @@ uInt32 RewindManager::unwindStates(uInt32 numStates) if(myOSystem.eventHandler().state() != EventHandlerState::TIMEMACHINE && myOSystem.eventHandler().state() != EventHandlerState::PLAYBACK) - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); return i; } diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index 6caabc72e..40b95b0f0 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -224,7 +224,7 @@ bool SoundSDL2::toggleMute() string message = "Sound "; message += enabled ? "unmuted" : "muted"; - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); //ostringstream strval; //uInt32 volume; @@ -282,7 +282,7 @@ void SoundSDL2::adjustVolume(int direction) strval << percent << "%"; else strval << "Off"; - myOSystem.frameBuffer().showMessage("Volume", strval.str(), percent); + myOSystem.frameBuffer().showGaugeMessage("Volume", strval.str(), percent); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/StateManager.cxx b/src/common/StateManager.cxx index a4add0889..956f62409 100644 --- a/src/common/StateManager.cxx +++ b/src/common/StateManager.cxx @@ -132,9 +132,9 @@ void StateManager::toggleTimeMachine() myActiveMode = myActiveMode == Mode::TimeMachine ? Mode::Off : Mode::TimeMachine; if(myActiveMode == Mode::TimeMachine) - myOSystem.frameBuffer().showMessage("Time Machine enabled"); + myOSystem.frameBuffer().showTextMessage("Time Machine enabled"); else - myOSystem.frameBuffer().showMessage("Time Machine disabled"); + myOSystem.frameBuffer().showTextMessage("Time Machine disabled"); myOSystem.settings().setValue(devSettings ? "dev.timemachine" : "plr.timemachine", myActiveMode == Mode::TimeMachine); } @@ -215,7 +215,7 @@ void StateManager::loadState(int slot) { buf.str(""); buf << "Can't open/load from state file " << slot; - myOSystem.frameBuffer().showMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.str()); return; } @@ -239,7 +239,7 @@ void StateManager::loadState(int slot) buf << "Invalid data in state " << slot << " file"; } - myOSystem.frameBuffer().showMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.str()); } } @@ -261,7 +261,7 @@ void StateManager::saveState(int slot) { buf.str(""); buf << "Can't open/save to state file " << slot; - myOSystem.frameBuffer().showMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.str()); return; } @@ -274,7 +274,7 @@ void StateManager::saveState(int slot) catch(...) { buf << "Error saving state " << slot; - myOSystem.frameBuffer().showMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.str()); return; } @@ -292,7 +292,7 @@ void StateManager::saveState(int slot) else buf << "Error saving state " << slot; - myOSystem.frameBuffer().showMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.str()); } } @@ -307,7 +307,7 @@ void StateManager::changeState(int direction) buf << "Changed to state slot " << myCurrentSlot; else buf << "State slot " << myCurrentSlot; - myOSystem.frameBuffer().showMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.str()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -318,7 +318,7 @@ void StateManager::toggleAutoSlot() // Print appropriate message ostringstream buf; buf << "Automatic slot change " << (autoSlot ? "enabled" : "disabled"); - myOSystem.frameBuffer().showMessage(buf.str()); + myOSystem.frameBuffer().showTextMessage(buf.str()); myOSystem.settings().setValue("autoslot", autoSlot); } diff --git a/src/debugger/gui/RomWidget.cxx b/src/debugger/gui/RomWidget.cxx index 9b387d69f..87572d6ed 100644 --- a/src/debugger/gui/RomWidget.cxx +++ b/src/debugger/gui/RomWidget.cxx @@ -199,7 +199,7 @@ void RomWidget::runtoPC(int disasm_line) ostringstream command; command << "runtopc #" << address; string msg = instance().debugger().run(command.str()); - instance().frameBuffer().showMessage(msg); + instance().frameBuffer().showTextMessage(msg); } } diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index 01d6d094b..2062bd436 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -92,10 +92,10 @@ void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix) message = e.what(); } if (execDepth == 0) { - instance().frameBuffer().showMessage(message); + instance().frameBuffer().showTextMessage(message); } #else - instance().frameBuffer().showMessage("PNG image saving not supported"); + instance().frameBuffer().showTextMessage("PNG image saving not supported"); #endif } @@ -135,7 +135,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in { command << "scanline #" << lines; string message = instance().debugger().parser().run(command.str()); - instance().frameBuffer().showMessage(message); + instance().frameBuffer().showTextMessage(message); } } else if(rmb == "bp") @@ -144,7 +144,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in int scanline = myClickY + startLine; command << "breakif _scan==#" << scanline; string message = instance().debugger().parser().run(command.str()); - instance().frameBuffer().showMessage(message); + instance().frameBuffer().showTextMessage(message); } else if(rmb == "zoom") { diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index a008c4444..759e95516 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -262,7 +262,7 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int { command << "scanline #" << lines; string message = instance().debugger().parser().run(command.str()); - instance().frameBuffer().showMessage(message); + instance().frameBuffer().showTextMessage(message); } } else if(rmb == "bp") @@ -271,7 +271,7 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int int scanline = myClickY / myZoomLevel + myOffY + startLine; command << "breakif _scan==#" << scanline; string message = instance().debugger().parser().run(command.str()); - instance().frameBuffer().showMessage(message); + instance().frameBuffer().showTextMessage(message); } else { diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 099773989..bb292859e 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -476,7 +476,7 @@ void Console::setFormat(uInt32 format, bool force) initializeAudio(); // ensure that audio synthesis is set up to match emulation rate myOSystem.resetFps(); // Reset FPS measurement - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); // Let the other devices know about the console change mySystem->consoleChanged(myConsoleTiming); @@ -493,10 +493,10 @@ void Console::toggleColorLoss(bool toggle) string message = string("PAL color-loss ") + (colorloss ? "enabled" : "disabled"); - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); } else - myOSystem.frameBuffer().showMessage( + myOSystem.frameBuffer().showTextMessage( "PAL color-loss not available in non PAL modes"); } @@ -521,7 +521,7 @@ void Console::toggleInter(bool toggle) ostringstream ss; ss << "Interpolation " << (enabled ? "enabled" : "disabled"); - myOSystem.frameBuffer().showMessage(ss.str()); + myOSystem.frameBuffer().showTextMessage(ss.str()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -539,7 +539,7 @@ void Console::toggleTurbo() ostringstream ss; ss << "Turbo mode " << (!enabled ? "enabled" : "disabled"); - myOSystem.frameBuffer().showMessage(ss.str()); + myOSystem.frameBuffer().showTextMessage(ss.str()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -564,7 +564,7 @@ void Console::changeSpeed(int direction) ostringstream val; val << formatSpeed(speed) << "%"; - myOSystem.frameBuffer().showMessage("Emulation speed", val.str(), speed, MIN_SPEED, MAX_SPEED); + myOSystem.frameBuffer().showGaugeMessage("Emulation speed", val.str(), speed, MIN_SPEED, MAX_SPEED); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -574,13 +574,13 @@ void Console::togglePhosphor() { myProperties.set(PropType::Display_Phosphor, "NO"); myOSystem.frameBuffer().tiaSurface().enablePhosphor(false); - myOSystem.frameBuffer().showMessage("Phosphor effect disabled"); + myOSystem.frameBuffer().showTextMessage("Phosphor effect disabled"); } else { myProperties.set(PropType::Display_Phosphor, "YES"); myOSystem.frameBuffer().tiaSurface().enablePhosphor(true); - myOSystem.frameBuffer().showMessage("Phosphor effect enabled"); + myOSystem.frameBuffer().showTextMessage("Phosphor effect enabled"); } } @@ -605,7 +605,7 @@ void Console::changePhosphor(int direction) val.str(""); val << "Off"; } - myOSystem.frameBuffer().showMessage("Phosphor blend", val.str(), blend); + myOSystem.frameBuffer().showGaugeMessage("Phosphor blend", val.str(), blend); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -699,7 +699,7 @@ void Console::changeVerticalCenter(int direction) if (vcenter != myTIA->vcenter()) myTIA->setVcenter(vcenter); val << (vcenter ? vcenter > 0 ? "+" : "" : " ") << vcenter << "px"; - myOSystem.frameBuffer().showMessage("V-Center", val.str(), vcenter, + myOSystem.frameBuffer().showGaugeMessage("V-Center", val.str(), vcenter, myTIA->minVcenter(), myTIA->maxVcenter()); } @@ -729,7 +729,7 @@ void Console::changeVSizeAdjust(int direction) val << (newAdjustVSize ? newAdjustVSize > 0 ? "+" : "" : " ") << newAdjustVSize << "%"; - myOSystem.frameBuffer().showMessage("V-Size", val.str(), newAdjustVSize, -5, 5); + myOSystem.frameBuffer().showGaugeMessage("V-Size", val.str(), newAdjustVSize, -5, 5); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -746,7 +746,7 @@ void Console::toggleCorrectAspectRatio(bool toggle) const string& message = string("Correct aspect ratio ") + (enabled ? "enabled" : "disabled"); - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -920,7 +920,7 @@ unique_ptr Console::getControllerPort(const Controller::Type type, Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) { bool devSettings = os.settings().getBool("dev.settings"); if(os.settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess")) - os.frameBuffer().showMessage(msg); + os.frameBuffer().showTextMessage(msg); }; controller = make_unique(port, myEvent, *mySystem, myOSystem.settings().getString("avoxport"), nvramfile, callback); @@ -933,7 +933,7 @@ unique_ptr Console::getControllerPort(const Controller::Type type, Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) { bool devSettings = os.settings().getBool("dev.settings"); if(os.settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess")) - os.frameBuffer().showMessage(msg); + os.frameBuffer().showTextMessage(msg); }; controller = make_unique(port, myEvent, *mySystem, nvramfile, callback); break; @@ -987,7 +987,7 @@ void Console::changeAutoFireRate(int direction) else val << "Off"; - myOSystem.frameBuffer().showMessage("Autofire rate", val.str(), rate, 0, isNTSC ? 30 : 25); + myOSystem.frameBuffer().showGaugeMessage("Autofire rate", val.str(), rate, 0, isNTSC ? 30 : 25); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1012,7 +1012,7 @@ void Console::toggleTIABit(TIABit bit, const string& bitname, bool show, bool to bool result = myTIA->toggleBit(bit, toggle ? 2 : 3); const string message = bitname + (result ? " enabled" : " disabled"); - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1021,7 +1021,7 @@ void Console::toggleBits(bool toggle) const bool enabled = myTIA->toggleBits(toggle); const string message = string("TIA bits ") + (enabled ? "enabled" : "disabled"); - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1030,7 +1030,7 @@ void Console::toggleTIACollision(TIABit bit, const string& bitname, bool show, b bool result = myTIA->toggleCollision(bit, toggle ? 2 : 3); const string message = bitname + (result ? " collision enabled" : " collision disabled"); - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1039,7 +1039,7 @@ void Console::toggleCollisions(bool toggle) const bool enabled = myTIA->toggleCollisions(toggle); const string message = string("TIA collisions ") + (enabled ? "enabled" : "disabled"); - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1048,7 +1048,7 @@ void Console::toggleFixedColors(bool toggle) const bool enabled = toggle ? myTIA->toggleFixedColors() : myTIA->usingFixedColors(); const string message = string("Fixed debug colors ") + (enabled ? "enabled" : "disabled"); - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1057,7 +1057,7 @@ void Console::toggleJitter(bool toggle) const bool enabled = myTIA->toggleJitter(toggle ? 2 : 3); const string message = string("TV scanline jitter ") + (enabled ? "enabled" : "disabled"); - myOSystem.frameBuffer().showMessage(message); + myOSystem.frameBuffer().showTextMessage(message); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 871d6cd73..9e7c9ea5f 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -191,12 +191,12 @@ void EventHandler::toggleSAPortOrder() if(saport == "lr") { mapStelladaptors("rl"); - myOSystem.frameBuffer().showMessage("Stelladaptor ports right/left"); + myOSystem.frameBuffer().showTextMessage("Stelladaptor ports right/left"); } else { mapStelladaptors("lr"); - myOSystem.frameBuffer().showMessage("Stelladaptor ports left/right"); + myOSystem.frameBuffer().showTextMessage("Stelladaptor ports left/right"); } #endif } @@ -214,7 +214,7 @@ void EventHandler::set7800Mode() void EventHandler::handleMouseControl() { if(myMouseControl) - myOSystem.frameBuffer().showMessage(myMouseControl->next()); + myOSystem.frameBuffer().showTextMessage(myMouseControl->next()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -550,7 +550,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) default: break; } - myOSystem.frameBuffer().showMessage(msg + " settings"); + myOSystem.frameBuffer().showTextMessage(msg + " settings"); myAdjustActive = false; } break; @@ -1210,7 +1210,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) case Event::SaveAllStates: if (pressed && !repeated) - myOSystem.frameBuffer().showMessage(myOSystem.state().rewindManager().saveAllStates()); + myOSystem.frameBuffer().showTextMessage(myOSystem.state().rewindManager().saveAllStates()); return; case Event::PreviousState: @@ -1243,7 +1243,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) case Event::LoadAllStates: if (pressed && !repeated) - myOSystem.frameBuffer().showMessage(myOSystem.state().rewindManager().loadAllStates()); + myOSystem.frameBuffer().showTextMessage(myOSystem.state().rewindManager().loadAllStates()); return; case Event::RewindPause: @@ -1476,7 +1476,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) { myEvent.set(Event::ConsoleBlackWhite, 0); myEvent.set(Event::ConsoleColor, 1); - myOSystem.frameBuffer().showMessage(myIs7800 ? "Pause released" : "Color Mode"); + myOSystem.frameBuffer().showTextMessage(myIs7800 ? "Pause released" : "Color Mode"); myOSystem.console().switches().update(); } return; @@ -1485,7 +1485,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) { myEvent.set(Event::ConsoleBlackWhite, 1); myEvent.set(Event::ConsoleColor, 0); - myOSystem.frameBuffer().showMessage(myIs7800 ? "Pause pushed" : "B/W Mode"); + myOSystem.frameBuffer().showTextMessage(myIs7800 ? "Pause pushed" : "B/W Mode"); myOSystem.console().switches().update(); } return; @@ -1496,13 +1496,13 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) { myEvent.set(Event::ConsoleBlackWhite, 1); myEvent.set(Event::ConsoleColor, 0); - myOSystem.frameBuffer().showMessage(myIs7800 ? "Pause pushed" : "B/W Mode"); + myOSystem.frameBuffer().showTextMessage(myIs7800 ? "Pause pushed" : "B/W Mode"); } else { myEvent.set(Event::ConsoleBlackWhite, 0); myEvent.set(Event::ConsoleColor, 1); - myOSystem.frameBuffer().showMessage(myIs7800 ? "Pause released" : "Color Mode"); + myOSystem.frameBuffer().showTextMessage(myIs7800 ? "Pause released" : "Color Mode"); } myOSystem.console().switches().update(); } @@ -1514,7 +1514,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) myEvent.set(Event::ConsoleBlackWhite, 0); myEvent.set(Event::ConsoleColor, 0); if (myIs7800) - myOSystem.frameBuffer().showMessage("Pause pressed"); + myOSystem.frameBuffer().showTextMessage("Pause pressed"); myOSystem.console().switches().update(); } return; @@ -1524,7 +1524,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) { myEvent.set(Event::ConsoleLeftDiffA, 1); myEvent.set(Event::ConsoleLeftDiffB, 0); - myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " A"); + myOSystem.frameBuffer().showTextMessage(GUI::LEFT_DIFFICULTY + " A"); myOSystem.console().switches().update(); } return; @@ -1533,7 +1533,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) { myEvent.set(Event::ConsoleLeftDiffA, 0); myEvent.set(Event::ConsoleLeftDiffB, 1); - myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " B"); + myOSystem.frameBuffer().showTextMessage(GUI::LEFT_DIFFICULTY + " B"); myOSystem.console().switches().update(); } return; @@ -1544,13 +1544,13 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) { myEvent.set(Event::ConsoleLeftDiffA, 0); myEvent.set(Event::ConsoleLeftDiffB, 1); - myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " B"); + myOSystem.frameBuffer().showTextMessage(GUI::LEFT_DIFFICULTY + " B"); } else { myEvent.set(Event::ConsoleLeftDiffA, 1); myEvent.set(Event::ConsoleLeftDiffB, 0); - myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " A"); + myOSystem.frameBuffer().showTextMessage(GUI::LEFT_DIFFICULTY + " A"); } myOSystem.console().switches().update(); } @@ -1561,7 +1561,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) { myEvent.set(Event::ConsoleRightDiffA, 1); myEvent.set(Event::ConsoleRightDiffB, 0); - myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " A"); + myOSystem.frameBuffer().showTextMessage(GUI::RIGHT_DIFFICULTY + " A"); myOSystem.console().switches().update(); } return; @@ -1570,7 +1570,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) { myEvent.set(Event::ConsoleRightDiffA, 0); myEvent.set(Event::ConsoleRightDiffB, 1); - myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " B"); + myOSystem.frameBuffer().showTextMessage(GUI::RIGHT_DIFFICULTY + " B"); myOSystem.console().switches().update(); } return; @@ -1581,13 +1581,13 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) { myEvent.set(Event::ConsoleRightDiffA, 0); myEvent.set(Event::ConsoleRightDiffB, 1); - myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " B"); + myOSystem.frameBuffer().showTextMessage(GUI::RIGHT_DIFFICULTY + " B"); } else { myEvent.set(Event::ConsoleRightDiffA, 1); myEvent.set(Event::ConsoleRightDiffB, 0); - myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " A"); + myOSystem.frameBuffer().showTextMessage(GUI::RIGHT_DIFFICULTY + " A"); } myOSystem.console().switches().update(); } @@ -2312,15 +2312,15 @@ bool EventHandler::enterDebugMode() myOSystem.debugger().setQuitState(); setState(EventHandlerState::EMULATION); if(fbstatus == FBInitStatus::FailTooLarge) - myOSystem.frameBuffer().showMessage("Debugger window too large for screen", - MessagePosition::BottomCenter, true); + myOSystem.frameBuffer().showTextMessage("Debugger window too large for screen", + MessagePosition::BottomCenter, true); return false; } myOverlay->reStack(); myOSystem.sound().mute(true); #else - myOSystem.frameBuffer().showMessage("Debugger support not included", - MessagePosition::BottomCenter, true); + myOSystem.frameBuffer().showTextMessage("Debugger support not included", + MessagePosition::BottomCenter, true); #endif return true; diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 828c14e8f..66747b2a3 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -322,13 +322,8 @@ void FrameBuffer::update(bool force) // - at the bottom of ::update(), to actually draw them (this must come // last, since they are always drawn on top of everything else). - // Full rendering is required when messages are enabled - force |= (myMsg.counter >= 0); - - // Detect when a message has been turned off; one last redraw is required - // in this case, to draw over the area that the message occupied - if(myMsg.counter == 0) - myMsg.counter = -1; + // Forced full rendering is required when messages are being disabled + force |= (myMsg.enabled && myMsg.counter == 0); bool redraw = false; switch(myOSystem.eventHandler().state()) @@ -344,7 +339,7 @@ void FrameBuffer::update(bool force) if(myPausedCount-- <= 0) { myPausedCount = uInt32(7 * myOSystem.frameRate()); - showMessage("Paused", MessagePosition::MiddleCenter); + showTextMessage("Paused", MessagePosition::MiddleCenter); } if(force) myTIASurface->render(); @@ -422,12 +417,12 @@ void FrameBuffer::update(bool force) } force = force || success; - if (force) + if(force) myTIASurface->render(); // Stop playback mode at the end of the state buffer // and switch to Time Machine or Pause mode - if (!success) + if(!success) { frames = 0; myOSystem.eventHandler().enterMenuMode(EventHandlerState::TIMEMACHINE); @@ -468,7 +463,7 @@ void FrameBuffer::update(bool force) // indicates that, and then the code at the top of this method sees // the change and redraws everything if(myMsg.enabled) - drawMessage(); + redraw |= drawMessage(); // Push buffers to screen only when necessary if(force || redraw) @@ -501,19 +496,15 @@ void FrameBuffer::updateInEmulationMode(float framesPerSecond) myBackend->renderToScreen(); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBuffer::showMessage(const string& message, MessagePosition position, - bool force) -{ #ifdef GUI_SUPPORT +void FrameBuffer::createMessage(const string& message, MessagePosition position, bool force) +{ // Only show messages if they've been enabled if(myMsg.surface == nullptr || !(force || myOSystem.settings().getBool("uimessages"))) return; - const int fontWidth = font().getMaxCharWidth(), - fontHeight = font().getFontHeight(); + const int fontHeight = font().getFontHeight(); const int VBORDER = fontHeight / 4; - const int HBORDER = fontWidth * 1.25 / 2.0; myMsg.counter = uInt32(myOSystem.frameRate()) * 2; // Show message for 2 seconds if(myMsg.counter == 0) @@ -522,39 +513,41 @@ void FrameBuffer::showMessage(const string& message, MessagePosition position, // Precompute the message coordinates myMsg.text = message; myMsg.color = kBtnTextColor; - myMsg.showGauge = false; - myMsg.w = std::min(fontWidth * (MESSAGE_WIDTH) - HBORDER * 2, - font().getStringWidth(myMsg.text) + HBORDER * 2); myMsg.h = fontHeight + VBORDER * 2; myMsg.position = position; myMsg.enabled = true; + myMsg.dirty = true; + myMsg.surface->setSrcSize(myMsg.w, myMsg.h); myMsg.surface->setDstSize(myMsg.w * hidpiScaleFactor(), myMsg.h * hidpiScaleFactor()); +} +#endif + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrameBuffer::showTextMessage(const string& message, MessagePosition position, + bool force) +{ +#ifdef GUI_SUPPORT + const int fontWidth = font().getMaxCharWidth(); + const int HBORDER = fontWidth * 1.25 / 2.0; + + myMsg.showGauge = false; + myMsg.w = std::min(fontWidth * (MESSAGE_WIDTH) - HBORDER * 2, + font().getStringWidth(message) + HBORDER * 2); + + createMessage(message, position, force); #endif } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBuffer::showMessage(const string& message, const string& valueText, - float value, float minValue, float maxValue) +void FrameBuffer::showGaugeMessage(const string& message, const string& valueText, + float value, float minValue, float maxValue) { #ifdef GUI_SUPPORT - // Only show messages if they've been enabled - if(myMsg.surface == nullptr || !myOSystem.settings().getBool("uimessages")) - return; - - const int fontWidth = font().getMaxCharWidth(), - fontHeight = font().getFontHeight(); - const int VBORDER = fontHeight / 4; + const int fontWidth = font().getMaxCharWidth(); const int HBORDER = fontWidth * 1.25 / 2.0; - myMsg.counter = uInt32(myOSystem.frameRate()) * 2; // Show message for 2 seconds - if(myMsg.counter == 0) - myMsg.counter = 120; - - // Precompute the message coordinates - myMsg.text = message; - myMsg.color = kBtnTextColor; myMsg.showGauge = true; if(maxValue - minValue != 0) myMsg.value = (value - minValue) / (maxValue - minValue) * 100.F; @@ -562,16 +555,12 @@ void FrameBuffer::showMessage(const string& message, const string& valueText, myMsg.value = 100.F; myMsg.valueText = valueText; myMsg.w = std::min(fontWidth * MESSAGE_WIDTH, - font().getStringWidth(myMsg.text) + font().getStringWidth(message) + fontWidth * (GAUGEBAR_WIDTH + 2) - + font().getStringWidth(myMsg.valueText)) - + HBORDER * 2; - myMsg.h = fontHeight + VBORDER * 2; - myMsg.position = MessagePosition::BottomCenter; - myMsg.enabled = true; + + font().getStringWidth(valueText)) + + HBORDER * 2; - myMsg.surface->setSrcSize(myMsg.w, myMsg.h); - myMsg.surface->setDstSize(myMsg.w * hidpiScaleFactor(), myMsg.h * hidpiScaleFactor()); + createMessage(message, MessagePosition::BottomCenter); #endif } @@ -652,8 +641,8 @@ void FrameBuffer::toggleFrameStats(bool toggle) myOSystem.settings().setValue( myOSystem.settings().getBool("dev.settings") ? "dev.stats" : "plr.stats", myStatsEnabled); - myOSystem.frameBuffer().showMessage(string("Console info ") + - (myStatsEnabled ? "enabled" : "disabled")); + myOSystem.frameBuffer().showTextMessage(string("Console info ") + + (myStatsEnabled ? "enabled" : "disabled")); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -676,7 +665,6 @@ void FrameBuffer::enableMessages(bool enable) myStatsMsg.enabled = false; // Erase old messages on the screen - myMsg.enabled = false; myMsg.counter = 0; update(true); // Force update immediately } @@ -689,116 +677,120 @@ inline bool FrameBuffer::drawMessage() // Either erase the entire message (when time is reached), // or show again this frame if(myMsg.counter == 0) - { - myMsg.enabled = false; - return true; - } - else if(myMsg.counter < 0) { myMsg.enabled = false; return false; } - // Draw the bounded box and text - const Common::Rect& dst = myMsg.surface->dstRect(); - const int fontWidth = font().getMaxCharWidth(), - fontHeight = font().getFontHeight(); - const int VBORDER = fontHeight / 4; - const int HBORDER = fontWidth * 1.25 / 2.0; - constexpr int BORDER = 1; - - switch(myMsg.position) + if(myMsg.dirty) { - case MessagePosition::TopLeft: - myMsg.x = 5; - myMsg.y = 5; - break; + cerr << "--- draw message ---" << endl; - case MessagePosition::TopCenter: - myMsg.x = (imageRect().w() - dst.w()) >> 1; - myMsg.y = 5; - break; + // Draw the bounded box and text + const Common::Rect& dst = myMsg.surface->dstRect(); + const int fontWidth = font().getMaxCharWidth(), + fontHeight = font().getFontHeight(); + const int VBORDER = fontHeight / 4; + const int HBORDER = fontWidth * 1.25 / 2.0; + constexpr int BORDER = 1; - case MessagePosition::TopRight: - myMsg.x = imageRect().w() - dst.w() - 5; - myMsg.y = 5; - break; - - case MessagePosition::MiddleLeft: - myMsg.x = 5; - myMsg.y = (imageRect().h() - dst.h()) >> 1; - break; - - case MessagePosition::MiddleCenter: - myMsg.x = (imageRect().w() - dst.w()) >> 1; - myMsg.y = (imageRect().h() - dst.h()) >> 1; - break; - - case MessagePosition::MiddleRight: - myMsg.x = imageRect().w() - dst.w() - 5; - myMsg.y = (imageRect().h() - dst.h()) >> 1; - break; - - case MessagePosition::BottomLeft: - myMsg.x = 5; - myMsg.y = imageRect().h() - dst.h() - 5; - break; - - case MessagePosition::BottomCenter: - myMsg.x = (imageRect().w() - dst.w()) >> 1; - myMsg.y = imageRect().h() - dst.h() - 5; - break; - - case MessagePosition::BottomRight: - myMsg.x = imageRect().w() - dst.w() - 5; - myMsg.y = imageRect().h() - dst.h() - 5; - break; - } - - myMsg.surface->setDstPos(myMsg.x + imageRect().x(), myMsg.y + imageRect().y()); - myMsg.surface->fillRect(0, 0, myMsg.w, myMsg.h, kColor); - myMsg.surface->fillRect(BORDER, BORDER, myMsg.w - BORDER * 2, myMsg.h - BORDER * 2, kBtnColor); - myMsg.surface->drawString(font(), myMsg.text, HBORDER, VBORDER, - myMsg.w, myMsg.color); - - if(myMsg.showGauge) - { - constexpr int NUM_TICKMARKS = 4; - // limit gauge bar width if texts are too long - const int swidth = std::min(fontWidth * GAUGEBAR_WIDTH, - fontWidth * (MESSAGE_WIDTH - 2) - - font().getStringWidth(myMsg.text) - - font().getStringWidth(myMsg.valueText)); - const int bwidth = swidth * myMsg.value / 100.F; - const int bheight = fontHeight >> 1; - const int x = HBORDER + font().getStringWidth(myMsg.text) + fontWidth; - // align bar with bottom of text - const int y = VBORDER + font().desc().ascent - bheight; - - // draw gauge bar - myMsg.surface->fillRect(x - BORDER, y, swidth + BORDER * 2, bheight, kSliderBGColor); - myMsg.surface->fillRect(x, y + BORDER, bwidth, bheight - BORDER * 2, kSliderColor); - // draw tickmark in the middle of the bar - for(int i = 1; i < NUM_TICKMARKS; ++i) + switch(myMsg.position) { - ColorId color; - int xt = x + swidth * i / NUM_TICKMARKS; - if(bwidth < xt - x) - color = kCheckColor; // kSliderColor; - else - color = kSliderBGColor; - myMsg.surface->vLine(xt, y + bheight / 2, y + bheight - 1, color); + case MessagePosition::TopLeft: + myMsg.x = 5; + myMsg.y = 5; + break; + + case MessagePosition::TopCenter: + myMsg.x = (imageRect().w() - dst.w()) >> 1; + myMsg.y = 5; + break; + + case MessagePosition::TopRight: + myMsg.x = imageRect().w() - dst.w() - 5; + myMsg.y = 5; + break; + + case MessagePosition::MiddleLeft: + myMsg.x = 5; + myMsg.y = (imageRect().h() - dst.h()) >> 1; + break; + + case MessagePosition::MiddleCenter: + myMsg.x = (imageRect().w() - dst.w()) >> 1; + myMsg.y = (imageRect().h() - dst.h()) >> 1; + break; + + case MessagePosition::MiddleRight: + myMsg.x = imageRect().w() - dst.w() - 5; + myMsg.y = (imageRect().h() - dst.h()) >> 1; + break; + + case MessagePosition::BottomLeft: + myMsg.x = 5; + myMsg.y = imageRect().h() - dst.h() - 5; + break; + + case MessagePosition::BottomCenter: + myMsg.x = (imageRect().w() - dst.w()) >> 1; + myMsg.y = imageRect().h() - dst.h() - 5; + break; + + case MessagePosition::BottomRight: + myMsg.x = imageRect().w() - dst.w() - 5; + myMsg.y = imageRect().h() - dst.h() - 5; + break; } - // draw value text - myMsg.surface->drawString(font(), myMsg.valueText, - x + swidth + fontWidth, VBORDER, + + myMsg.surface->setDstPos(myMsg.x + imageRect().x(), myMsg.y + imageRect().y()); + myMsg.surface->fillRect(0, 0, myMsg.w, myMsg.h, kColor); + myMsg.surface->fillRect(BORDER, BORDER, myMsg.w - BORDER * 2, myMsg.h - BORDER * 2, kBtnColor); + myMsg.surface->drawString(font(), myMsg.text, HBORDER, VBORDER, myMsg.w, myMsg.color); + + if(myMsg.showGauge) + { + constexpr int NUM_TICKMARKS = 4; + // limit gauge bar width if texts are too long + const int swidth = std::min(fontWidth * GAUGEBAR_WIDTH, + fontWidth * (MESSAGE_WIDTH - 2) + - font().getStringWidth(myMsg.text) + - font().getStringWidth(myMsg.valueText)); + const int bwidth = swidth * myMsg.value / 100.F; + const int bheight = fontHeight >> 1; + const int x = HBORDER + font().getStringWidth(myMsg.text) + fontWidth; + // align bar with bottom of text + const int y = VBORDER + font().desc().ascent - bheight; + + // draw gauge bar + myMsg.surface->fillRect(x - BORDER, y, swidth + BORDER * 2, bheight, kSliderBGColor); + myMsg.surface->fillRect(x, y + BORDER, bwidth, bheight - BORDER * 2, kSliderColor); + // draw tickmark in the middle of the bar + for(int i = 1; i < NUM_TICKMARKS; ++i) + { + ColorId color; + int xt = x + swidth * i / NUM_TICKMARKS; + if(bwidth < xt - x) + color = kCheckColor; // kSliderColor; + else + color = kSliderBGColor; + myMsg.surface->vLine(xt, y + bheight / 2, y + bheight - 1, color); + } + // draw value text + myMsg.surface->drawString(font(), myMsg.valueText, + x + swidth + fontWidth, VBORDER, + myMsg.w, myMsg.color); + } + myMsg.dirty = false; + myMsg.surface->render(); + return true; } - myMsg.surface->render(); + myMsg.counter--; + myMsg.surface->render(); #endif - return true; + return false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -898,7 +890,6 @@ void FrameBuffer::setUIPalette() void FrameBuffer::stateChanged(EventHandlerState state) { // Make sure any onscreen messages are removed - myMsg.enabled = false; myMsg.counter = 0; update(true); // force full update @@ -1010,7 +1001,7 @@ void FrameBuffer::toggleFullscreen(bool toggle) msg << "disabled ("; msg << "Zoom " << myActiveVidMode.zoom * 100 << "%)"; - showMessage(msg.str()); + showTextMessage(msg.str()); } break; } @@ -1043,7 +1034,7 @@ void FrameBuffer::toggleAdaptRefresh(bool toggle) msg << (isAdaptRefresh ? "enabled" : "disabled"); msg << " (" << myBackend->refreshRate() << " Hz)"; - showMessage(msg.str()); + showTextMessage(msg.str()); } } #endif @@ -1069,7 +1060,7 @@ void FrameBuffer::changeOverscan(int direction) val << (overscan > 0 ? "+" : "" ) << overscan << "%"; else val << "Off"; - myOSystem.frameBuffer().showMessage("Overscan", val.str(), overscan, 0, 10); + myOSystem.frameBuffer().showGaugeMessage("Overscan", val.str(), overscan, 0, 10); } } @@ -1106,9 +1097,9 @@ void FrameBuffer::switchVideoMode(int direction) if(applyVideoMode() == FBInitStatus::Success) { if(fullScreen()) - showMessage(myActiveVidMode.description); + showTextMessage(myActiveVidMode.description); else - showMessage("Zoom", myActiveVidMode.description, myActiveVidMode.zoom, + showGaugeMessage("Zoom", myActiveVidMode.description, myActiveVidMode.zoom, supportedTIAMinZoom(), myTIAMaxZoom); } } @@ -1248,9 +1239,9 @@ void FrameBuffer::toggleGrabMouse() myGrabMouse = !myGrabMouse; setCursorState(); myOSystem.settings().setValue("grabmouse", myGrabMouse); - myOSystem.frameBuffer().showMessage(oldState != myGrabMouse ? myGrabMouse - ? "Grab mouse enabled" : "Grab mouse disabled" - : "Grab mouse not allowed while cursor shown"); + myOSystem.frameBuffer().showTextMessage(oldState != myGrabMouse ? myGrabMouse + ? "Grab mouse enabled" : "Grab mouse disabled" + : "Grab mouse not allowed while cursor shown"); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index c084c9cf6..8cda8d25c 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -92,15 +92,15 @@ class FrameBuffer void updateInEmulationMode(float framesPerSecond); /** - Shows a message onscreen. + Shows a text message onscreen. @param message The message to be shown @param position Onscreen position for the message @param force Force showing this message, even if messages are disabled */ - void showMessage(const string& message, - MessagePosition position = MessagePosition::BottomCenter, - bool force = false); + void showTextMessage(const string& message, + MessagePosition position = MessagePosition::BottomCenter, + bool force = false); /** Shows a message with a gauge bar onscreen. @@ -110,8 +110,8 @@ class FrameBuffer @param minValue The minimal value of the gauge bar @param maxValue The maximal value of the gauge bar */ - void showMessage(const string& message, const string& valueText, - float value, float minValue = 0.F, float maxValue = 100.F); + void showGaugeMessage(const string& message, const string& valueText, + float value, float minValue = 0.F, float maxValue = 100.F); bool messageShown() const; @@ -375,6 +375,18 @@ class FrameBuffer */ void resetSurfaces(); + #ifdef GUI_SUPPORT + /** + Helps to create a basic message onscreen. + + @param message The message to be shown + @param position Onscreen position for the message + @param force Force showing this message, even if messages are disabled + */ + void createMessage(const string& message, MessagePosition position, + bool force = false); + #endif + /** Draw pending messages. @@ -478,6 +490,7 @@ class FrameBuffer ColorId color{kNone}; shared_ptr surface; bool enabled{false}; + bool dirty{false}; bool showGauge{false}; float value{0.0F}; string valueText; diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 611439e45..e659c1e5c 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -475,9 +475,9 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum, { const string& id = myConsole->cartridge().multiCartID(); if(id == "") - myFrameBuffer->showMessage("New console created"); + myFrameBuffer->showTextMessage("New console created"); else - myFrameBuffer->showMessage("Multicart " + + myFrameBuffer->showTextMessage("Multicart " + myConsole->cartridge().detectedType() + ", loading ROM" + id); } buf << "Game console created:" << endl @@ -506,7 +506,7 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum, msg << myConsole->leftController().name() << "/" << myConsole->rightController().name() << " - " << myConsole->cartridge().detectedType() << " - " << myConsole->getFormatString(); - myFrameBuffer->showMessage(msg.str()); + myFrameBuffer->showTextMessage(msg.str()); } } diff --git a/src/emucore/QuadTari.cxx b/src/emucore/QuadTari.cxx index 64c0cf027..f3fb00cdf 100644 --- a/src/emucore/QuadTari.cxx +++ b/src/emucore/QuadTari.cxx @@ -71,7 +71,7 @@ unique_ptr QuadTari::addController(const Controller::Type type, bool Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) { bool devSettings = os.settings().getBool("dev.settings"); if(os.settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess")) - os.frameBuffer().showMessage(msg); + os.frameBuffer().showTextMessage(msg); }; switch(type) diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index 3858817a7..ec9dfe020 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -184,7 +184,7 @@ void TIASurface::setNTSC(NTSCFilter::Preset preset, bool show) } myOSystem.settings().setValue("tv.filter", int(preset)); - if(show) myFB.showMessage(buf.str()); + if(show) myFB.showTextMessage(buf.str()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -221,7 +221,7 @@ void TIASurface::setNTSCAdjustable(int direction) setNTSC(NTSCFilter::Preset::CUSTOM); ntsc().selectAdjustable(direction, text, valueText, value); - myOSystem.frameBuffer().showMessage(text, valueText, value); + myOSystem.frameBuffer().showGaugeMessage(text, valueText, value); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -232,7 +232,7 @@ void TIASurface::changeNTSCAdjustable(int adjustable, int direction) setNTSC(NTSCFilter::Preset::CUSTOM); ntsc().changeAdjustable(adjustable, direction, text, valueText, newValue); - myOSystem.frameBuffer().showMessage(text, valueText, newValue); + myOSystem.frameBuffer().showGaugeMessage(text, valueText, newValue); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -243,7 +243,7 @@ void TIASurface::changeCurrentNTSCAdjustable(int direction) setNTSC(NTSCFilter::Preset::CUSTOM); ntsc().changeCurrentAdjustable(direction, text, valueText, newValue); - myOSystem.frameBuffer().showMessage(text, valueText, newValue); + myOSystem.frameBuffer().showGaugeMessage(text, valueText, newValue); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -259,7 +259,7 @@ void TIASurface::setScanlineIntensity(int direction) buf << intensity << "%"; else buf << "Off"; - myFB.showMessage("Scanline intensity", buf.str(), intensity); + myFB.showGaugeMessage("Scanline intensity", buf.str(), intensity); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 9649e447c..d4f4c165b 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -127,8 +127,8 @@ int DialogContainer::addDialog(Dialog* d) const uInt32 scale = myOSystem.frameBuffer().hidpiScaleFactor(); if(uInt32(d->getWidth() * scale) > r.w() || uInt32(d->getHeight() * scale) > r.h()) - myOSystem.frameBuffer().showMessage( - "Unable to show dialog box; FIX THE CODE"); + myOSystem.frameBuffer().showTextMessage( + "Unable to show dialog box; FIX THE CODE", MessagePosition::BottomCenter, true); else { // "darken" current top dialog diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index 5a3c4b1b5..57ad900d2 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -855,12 +855,12 @@ void GameInfoDialog::saveCurrentPropertiesToDisk() propfile /= myGameFile.getNameWithExt(".pro"); propfile.write(out); - instance().frameBuffer().showMessage("Properties saved to " + - propfile.getShortPath()); + instance().frameBuffer().showTextMessage("Properties saved to " + + propfile.getShortPath()); } catch(...) { - instance().frameBuffer().showMessage("Error saving properties"); + instance().frameBuffer().showTextMessage("Error saving properties"); } } diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 3f6ddcec8..8018bcb44 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -662,7 +662,7 @@ void LauncherDialog::loadRom() instance().settings().setValue("romdir", currentNode().getParent().getShortPath()); } else - instance().frameBuffer().showMessage(result, MessagePosition::MiddleCenter, true); + instance().frameBuffer().showTextMessage(result, MessagePosition::MiddleCenter, true); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/LoggerDialog.cxx b/src/gui/LoggerDialog.cxx index bf53d80a0..3f94e093e 100644 --- a/src/gui/LoggerDialog.cxx +++ b/src/gui/LoggerDialog.cxx @@ -123,12 +123,12 @@ void LoggerDialog::saveLogFile() { stringstream out; out << Logger::instance().logMessages(); - instance().frameBuffer().showMessage("Saving log file to " + node.getShortPath()); + instance().frameBuffer().showTextMessage("Saving log file to " + node.getShortPath()); node.write(out); } catch(...) { - instance().frameBuffer().showMessage("Error saving log file to " + node.getShortPath()); + instance().frameBuffer().showTextMessage("Error saving log file to " + node.getShortPath()); } } diff --git a/src/gui/TimeMachineDialog.cxx b/src/gui/TimeMachineDialog.cxx index e822504a9..1e983eb92 100644 --- a/src/gui/TimeMachineDialog.cxx +++ b/src/gui/TimeMachineDialog.cxx @@ -440,11 +440,11 @@ void TimeMachineDialog::handleCommand(CommandSender* sender, int cmd, break; case kSaveAll: - instance().frameBuffer().showMessage(instance().state().rewindManager().saveAllStates()); + instance().frameBuffer().showTextMessage(instance().state().rewindManager().saveAllStates()); break; case kLoadAll: - instance().frameBuffer().showMessage(instance().state().rewindManager().loadAllStates()); + instance().frameBuffer().showTextMessage(instance().state().rewindManager().loadAllStates()); initBar(); break; From e5f1e47f5df549de81301bd63b1fddc0a658f190 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 12 Nov 2020 11:50:26 +0100 Subject: [PATCH 12/70] further minimized UI redraws when message is displayed --- src/emucore/FrameBuffer.cxx | 53 ++++++++++++++++++------------------- src/gui/DialogContainer.cxx | 19 +++++++++++-- src/gui/DialogContainer.hxx | 5 ++++ 3 files changed, 48 insertions(+), 29 deletions(-) diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 66747b2a3..3af48cd15 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -322,10 +322,11 @@ void FrameBuffer::update(bool force) // - at the bottom of ::update(), to actually draw them (this must come // last, since they are always drawn on top of everything else). - // Forced full rendering is required when messages are being disabled - force |= (myMsg.enabled && myMsg.counter == 0); + // Forced rendering without drawing is required when messages are being disabled + // Only relevant for LAUNCHER, PAUSE and DEBUGGER modes + bool rerender = force || (myMsg.enabled && myMsg.counter == 0); - bool redraw = false; + bool redraw = force; switch(myOSystem.eventHandler().state()) { case EventHandlerState::NONE: @@ -341,7 +342,7 @@ void FrameBuffer::update(bool force) myPausedCount = uInt32(7 * myOSystem.frameRate()); showTextMessage("Paused", MessagePosition::MiddleCenter); } - if(force) + if(rerender) myTIASurface->render(); break; // EventHandlerState::PAUSE @@ -350,8 +351,8 @@ void FrameBuffer::update(bool force) #ifdef GUI_SUPPORT case EventHandlerState::OPTIONSMENU: { - redraw = myOSystem.menu().needsRedraw(); - if(force || redraw) + redraw |= myOSystem.menu().needsRedraw(); + if(redraw) { clear(); myTIASurface->render(); @@ -362,8 +363,8 @@ void FrameBuffer::update(bool force) case EventHandlerState::CMDMENU: { - redraw = myOSystem.commandMenu().needsRedraw(); - if(force || redraw) + redraw |= myOSystem.commandMenu().needsRedraw(); + if(redraw) { clear(); myTIASurface->render(); @@ -374,8 +375,8 @@ void FrameBuffer::update(bool force) case EventHandlerState::MESSAGEMENU: { - redraw = myOSystem.messageMenu().needsRedraw(); - if(force || redraw) + redraw |= myOSystem.messageMenu().needsRedraw(); + if(redraw) { clear(); myTIASurface->render(); @@ -386,8 +387,8 @@ void FrameBuffer::update(bool force) case EventHandlerState::TIMEMACHINE: { - redraw = myOSystem.timeMachine().needsRedraw(); - if(force || redraw) + redraw |= myOSystem.timeMachine().needsRedraw(); + if(redraw) { clear(); myTIASurface->render(); @@ -416,8 +417,8 @@ void FrameBuffer::update(bool force) r.rewindStates(1); } - force = force || success; - if(force) + redraw |= success; + if(redraw) myTIASurface->render(); // Stop playback mode at the end of the state buffer @@ -432,11 +433,11 @@ void FrameBuffer::update(bool force) case EventHandlerState::LAUNCHER: { - redraw = myOSystem.launcher().needsRedraw(); - if(force || redraw) - { + redraw |= myOSystem.launcher().needsRedraw(); + if(redraw) myOSystem.launcher().draw(force); - } + else if(rerender) + myOSystem.launcher().render(); break; // EventHandlerState::LAUNCHER } #endif @@ -444,12 +445,11 @@ void FrameBuffer::update(bool force) #ifdef DEBUGGER_SUPPORT case EventHandlerState::DEBUGGER: { - redraw = myOSystem.debugger().needsRedraw(); - if(force || redraw) - { - + redraw |= myOSystem.debugger().needsRedraw(); + if(redraw) myOSystem.debugger().draw(force); - } + else if(rerender) + myOSystem.debugger().render(); break; // EventHandlerState::DEBUGGER } #endif @@ -466,7 +466,7 @@ void FrameBuffer::update(bool force) redraw |= drawMessage(); // Push buffers to screen only when necessary - if(force || redraw) + if(redraw || rerender) myBackend->renderToScreen(); } @@ -518,7 +518,6 @@ void FrameBuffer::createMessage(const string& message, MessagePosition position, myMsg.enabled = true; myMsg.dirty = true; - myMsg.surface->setSrcSize(myMsg.w, myMsg.h); myMsg.surface->setDstSize(myMsg.w * hidpiScaleFactor(), myMsg.h * hidpiScaleFactor()); } @@ -666,7 +665,7 @@ void FrameBuffer::enableMessages(bool enable) // Erase old messages on the screen myMsg.counter = 0; - update(true); // Force update immediately + update(); // update immediately } } @@ -892,7 +891,7 @@ void FrameBuffer::stateChanged(EventHandlerState state) // Make sure any onscreen messages are removed myMsg.counter = 0; - update(true); // force full update + update(); // update immediately } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index d4f4c165b..77e163e83 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -91,21 +91,36 @@ void DialogContainer::updateTime(uInt64 time) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DialogContainer::draw(bool full) { - cerr << "draw " << full << " " << typeid(*this).name() << endl; if(myDialogStack.empty()) return; + cerr << "draw " << full << " " << typeid(*this).name() << endl; + // Make the top dialog dirty if a full redraw is requested if(full) myDialogStack.top()->setDirty(); - // Render all dirty dialogs + // Draw and render all dirty dialogs myDialogStack.applyAll([&](Dialog*& d) { if(d->needsRedraw()) d->redraw(); }); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DialogContainer::render() +{ + if(myDialogStack.empty()) + return; + + cerr << "render " << typeid(*this).name() << endl; + + // Render all dirty dialogs + myDialogStack.applyAll([&](Dialog*& d) { + d->render(); + }); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool DialogContainer::needsRedraw() const { diff --git a/src/gui/DialogContainer.hxx b/src/gui/DialogContainer.hxx index 1f6cce8f6..70950606d 100644 --- a/src/gui/DialogContainer.hxx +++ b/src/gui/DialogContainer.hxx @@ -124,6 +124,11 @@ class DialogContainer */ void draw(bool full = false); + /** + Render the stack of menus. + */ + void render(); + /** Answers whether a full redraw is required. */ From 9819118b5934cab775c4da0414bd99c1386597e4 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 12 Nov 2020 14:04:29 +0100 Subject: [PATCH 13/70] replaced shaded UI redraws with shading surface --- src/gui/Dialog.cxx | 26 +++++++++++++++++++++++--- src/gui/Dialog.hxx | 1 + src/gui/DialogContainer.cxx | 13 ++++++++----- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 9cb5accb2..6f8867cfb 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -227,8 +227,6 @@ void Dialog::redraw() center(); drawDialog(); render(); - -// return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -242,6 +240,28 @@ void Dialog::render() surface->render(); }); } + if(parent().myDialogStack.top() != this) + { + if(_shadeSurface == nullptr) + { + uInt32 data = 0xff000000; + + _shadeSurface = instance().frameBuffer().allocateSurface( + 1, 1, ScalingInterpolation::sharp, &data); + + FBSurface::Attributes& attr = _shadeSurface->attributes(); + + attr.blending = true; + attr.blendalpha = 25; // darken background dialogs by 25% + _shadeSurface->applyAttributes(); + } + + const Common::Rect& rect = _surface->dstRect(); + _shadeSurface->setDstPos(rect.x(), rect.y()); + _shadeSurface->setDstSize(rect.w(), rect.h()); + + _shadeSurface->render(); + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -408,7 +428,7 @@ void Dialog::drawDialog() //cerr << "*** draw dialog " << typeid(*this).name() << " ***" << endl; // Dialog is still on top if e.g a ContextMenu is opened - _onTop = parent().myDialogStack.top() == this + _onTop = true/*parent().myDialogStack.top() == this*/ || (parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this && !parent().myDialogStack.top()->hasTitle()); diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index b9a924b55..d5405ef70 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -230,6 +230,7 @@ class Dialog : public GuiObject WidgetArray _buttonGroup; shared_ptr _surface; + shared_ptr _shadeSurface; int _tabID{0}; uInt32 _max_w{0}; // maximum wanted width diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 77e163e83..98deae834 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -146,9 +146,10 @@ int DialogContainer::addDialog(Dialog* d) "Unable to show dialog box; FIX THE CODE", MessagePosition::BottomCenter, true); else { - // "darken" current top dialog - if(!myDialogStack.empty()) - myDialogStack.top()->setDirty(); + //// "shade" current top dialog + //if(!myDialogStack.empty()) + // myDialogStack.top()->setDirty(); + d->setDirty(); myDialogStack.push(d); } @@ -164,14 +165,16 @@ void DialogContainer::removeDialog() if(!myDialogStack.empty()) { - // this "undarkens" the top dialog - myDialogStack.top()->setDirty(); + //// this "unshades" the top dialog + //myDialogStack.top()->setDirty(); // Rerender all dialogs (TODO: top dialog is rendered twice) myDialogStack.applyAll([&](Dialog*& d){ //d->setDirty(); d->render(); }); + // TODO: the screen is not updated until an event happens + // FrameBuffer::myBackend->renderToScreen() doesn't help } } } From 907fc4edf3d743213b0f101ba023a2903de5771d Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 12 Nov 2020 14:37:50 +0100 Subject: [PATCH 14/70] minimized ContextMenu redraws fixed shading caused by ContextMenu --- src/gui/ContextMenu.cxx | 8 ++++++-- src/gui/Dialog.cxx | 11 ++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/gui/ContextMenu.cxx b/src/gui/ContextMenu.cxx index 9cf626657..a53f1c4ae 100644 --- a/src/gui/ContextMenu.cxx +++ b/src/gui/ContextMenu.cxx @@ -346,8 +346,12 @@ int ContextMenu::findItem(int x, int y) const void ContextMenu::drawCurrentSelection(int item) { // Change selection - _selectedOffset = item; - setDirty(); + if(_selectedOffset != item) + { + _selectedOffset = item; + cerr << "ContextMenu" << endl; + setDirty(); + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 6f8867cfb..fe0d06d37 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -240,7 +240,15 @@ void Dialog::render() surface->render(); }); } - if(parent().myDialogStack.top() != this) + + //cerr << "is ContextMenu " + // << (typeid(*parent().myDialogStack.top()) == typeid(ContextMenu)) << endl; + + // Dialog is still on top if e.g a ContextMenu is opened + if(!(parent().myDialogStack.top() == this) + && !((parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this + //&& !(typeid(*parent().myDialogStack.top()) == typeid(ContextMenu))) + && !parent().myDialogStack.top()->hasTitle()))) { if(_shadeSurface == nullptr) { @@ -432,6 +440,7 @@ void Dialog::drawDialog() || (parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this && !parent().myDialogStack.top()->hasTitle()); + cerr << "on top " << isOnTop() << endl; if(clearsBackground()) { // cerr << "Dialog::drawDialog(): w = " << _w << ", h = " << _h << " @ " << &s << endl << endl; From 42817a61171194c480ba7216e6a18cbbbf8a501d Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 12 Nov 2020 15:41:40 +0100 Subject: [PATCH 15/70] Allow first click detection when Stella lost focus. --- src/common/EventHandlerSDL2.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/EventHandlerSDL2.cxx b/src/common/EventHandlerSDL2.cxx index e5900cfba..39b3469f5 100644 --- a/src/common/EventHandlerSDL2.cxx +++ b/src/common/EventHandlerSDL2.cxx @@ -45,6 +45,8 @@ EventHandlerSDL2::EventHandlerSDL2(OSystem& osystem) } Logger::debug("EventHandlerSDL2::EventHandlerSDL2 SDL_INIT_JOYSTICK"); #endif + + SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -91,6 +93,7 @@ void EventHandlerSDL2::pollEvent() while(SDL_PollEvent(&myEvent)) { + cerr << myEvent.type << endl; switch(myEvent.type) { // keyboard events @@ -198,6 +201,7 @@ void EventHandlerSDL2::pollEvent() } case SDL_WINDOWEVENT: + cerr << myEvent.window.event << endl; switch(myEvent.window.event) { case SDL_WINDOWEVENT_SHOWN: From f0d6b672eaf1a4c63c7c32dba09ac1420f0c3d0c Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 12 Nov 2020 15:48:00 +0100 Subject: [PATCH 16/70] removed debug code --- src/common/EventHandlerSDL2.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/common/EventHandlerSDL2.cxx b/src/common/EventHandlerSDL2.cxx index 39b3469f5..86d4dad89 100644 --- a/src/common/EventHandlerSDL2.cxx +++ b/src/common/EventHandlerSDL2.cxx @@ -93,7 +93,6 @@ void EventHandlerSDL2::pollEvent() while(SDL_PollEvent(&myEvent)) { - cerr << myEvent.type << endl; switch(myEvent.type) { // keyboard events @@ -201,7 +200,6 @@ void EventHandlerSDL2::pollEvent() } case SDL_WINDOWEVENT: - cerr << myEvent.window.event << endl; switch(myEvent.window.event) { case SDL_WINDOWEVENT_SHOWN: From c390b40a6d6cb2670dc4425969ac0e2418efd1a4 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 12 Nov 2020 18:14:26 +0100 Subject: [PATCH 17/70] refactored UI ticks --- src/debugger/gui/DebuggerDialog.hxx | 2 +- src/debugger/gui/RomListSettings.cxx | 2 +- src/debugger/gui/RomListSettings.hxx | 4 +-- src/emucore/FrameBuffer.cxx | 6 ++++ src/gui/ContextMenu.cxx | 2 +- src/gui/ContextMenu.hxx | 4 +-- src/gui/Dialog.cxx | 35 +++++++++++----------- src/gui/Dialog.hxx | 7 ++--- src/gui/DialogContainer.cxx | 7 +++++ src/gui/DialogContainer.hxx | 5 ++++ src/gui/EditableWidget.cxx | 6 ++-- src/gui/EditableWidget.hxx | 2 +- src/gui/GuiObject.hxx | 10 +++++-- src/gui/InputTextDialog.cxx | 4 +-- src/gui/InputTextDialog.hxx | 2 +- src/gui/LauncherDialog.hxx | 2 +- src/gui/TimeMachineDialog.cxx | 2 +- src/gui/TimeMachineDialog.hxx | 4 +-- src/gui/Widget.cxx | 44 ++++++++++------------------ src/gui/Widget.hxx | 3 +- 20 files changed, 80 insertions(+), 73 deletions(-) diff --git a/src/debugger/gui/DebuggerDialog.hxx b/src/debugger/gui/DebuggerDialog.hxx index 0affa5160..51633c825 100644 --- a/src/debugger/gui/DebuggerDialog.hxx +++ b/src/debugger/gui/DebuggerDialog.hxx @@ -76,7 +76,7 @@ class DebuggerDialog : public Dialog void saveConfig() override; private: - void center() override { positionAt(0); } + void setPosition() override { positionAt(0); } void loadConfig() override; void handleKeyDown(StellaKey key, StellaMod mod, bool repeated) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override; diff --git a/src/debugger/gui/RomListSettings.cxx b/src/debugger/gui/RomListSettings.cxx index 9c3baf3d2..93b555631 100644 --- a/src/debugger/gui/RomListSettings.cxx +++ b/src/debugger/gui/RomListSettings.cxx @@ -100,7 +100,7 @@ void RomListSettings::show(uInt32 x, uInt32 y, const Common::Rect& bossRect, int } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void RomListSettings::center() +void RomListSettings::setPosition() { // First set position according to original coordinates surface().setDstPos(_xorig, _yorig); diff --git a/src/debugger/gui/RomListSettings.hxx b/src/debugger/gui/RomListSettings.hxx index 0845dd8ab..a589b0334 100644 --- a/src/debugger/gui/RomListSettings.hxx +++ b/src/debugger/gui/RomListSettings.hxx @@ -38,8 +38,8 @@ class RomListSettings : public Dialog, public CommandSender ('data' will be the currently selected line number in RomListWidget) */ void show(uInt32 x, uInt32 y, const Common::Rect& bossRect, int data = -1); - /** This dialog uses its own positioning, so we override Dialog::center() */ - void center() override; + /** This dialog uses its own positioning, so we override Dialog::setPosition() */ + void setPosition() override; private: uInt32 _xorig{0}, _yorig{0}; diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 3af48cd15..a151084d1 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -351,6 +351,7 @@ void FrameBuffer::update(bool force) #ifdef GUI_SUPPORT case EventHandlerState::OPTIONSMENU: { + myOSystem.menu().tick(); redraw |= myOSystem.menu().needsRedraw(); if(redraw) { @@ -363,6 +364,7 @@ void FrameBuffer::update(bool force) case EventHandlerState::CMDMENU: { + myOSystem.commandMenu().tick(); redraw |= myOSystem.commandMenu().needsRedraw(); if(redraw) { @@ -375,6 +377,7 @@ void FrameBuffer::update(bool force) case EventHandlerState::MESSAGEMENU: { + myOSystem.messageMenu().tick(); redraw |= myOSystem.messageMenu().needsRedraw(); if(redraw) { @@ -387,6 +390,7 @@ void FrameBuffer::update(bool force) case EventHandlerState::TIMEMACHINE: { + myOSystem.timeMachine().tick(); redraw |= myOSystem.timeMachine().needsRedraw(); if(redraw) { @@ -433,6 +437,7 @@ void FrameBuffer::update(bool force) case EventHandlerState::LAUNCHER: { + myOSystem.launcher().tick(); redraw |= myOSystem.launcher().needsRedraw(); if(redraw) myOSystem.launcher().draw(force); @@ -445,6 +450,7 @@ void FrameBuffer::update(bool force) #ifdef DEBUGGER_SUPPORT case EventHandlerState::DEBUGGER: { + myOSystem.debugger().tick(); redraw |= myOSystem.debugger().needsRedraw(); if(redraw) myOSystem.debugger().draw(force); diff --git a/src/gui/ContextMenu.cxx b/src/gui/ContextMenu.cxx index a53f1c4ae..ae1ee09be 100644 --- a/src/gui/ContextMenu.cxx +++ b/src/gui/ContextMenu.cxx @@ -77,7 +77,7 @@ void ContextMenu::show(uInt32 x, uInt32 y, const Common::Rect& bossRect, int ite } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ContextMenu::center() +void ContextMenu::setPosition() { // First set position according to original coordinates surface().setDstPos(_xorig, _yorig); diff --git a/src/gui/ContextMenu.hxx b/src/gui/ContextMenu.hxx index 423ef3074..f1736e517 100644 --- a/src/gui/ContextMenu.hxx +++ b/src/gui/ContextMenu.hxx @@ -71,8 +71,8 @@ class ContextMenu : public Dialog, public CommandSender const string& getSelectedName() const; const Variant& getSelectedTag() const; - /** This dialog uses its own positioning, so we override Dialog::center() */ - void center() override; + /** This dialog uses its own positioning, so we override Dialog::setPosition() */ + void setPosition() override; /** The following methods are used when we want to select *and* send a command for the new selection. They are only to be used diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index fe0d06d37..e58920e89 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -91,7 +91,7 @@ void Dialog::open() const uInt32 scale = instance().frameBuffer().hidpiScaleFactor(); _surface->setDstSize(_w * scale, _h * scale); - center(); + setPosition(); if(_myTabList.size()) // (Re)-build the focus list to use for all widgets of all tabs @@ -143,32 +143,20 @@ void Dialog::setTitle(const string& title) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Dialog::center() +void Dialog::setPosition() { positionAt(instance().settings().getInt("dialogpos")); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Dialog::setDirty() -{ - _dirty = true; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Dialog::isDirty() -{ - return _dirty; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Dialog::isChainDirty() const { bool dirty = false; - // Check if widget or any subwidgets are dirty + // Recursively check if dialog or any chick dialogs or widgets are dirty Widget* w = _firstWidget; - while(!dirty && w) + while(w && !dirty) { dirty |= w->needsRedraw(); w = w->_next; @@ -177,6 +165,19 @@ bool Dialog::isChainDirty() const return dirty; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Dialog::tick() +{ + // Recursively tick dialog and all child dialogs and widgets + Widget* w = _firstWidget; + + while(w) + { + w->tick(); + w = w->_next; + } +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Dialog::positionAt(uInt32 pos) { @@ -224,7 +225,7 @@ void Dialog::redraw() return;// false; // Draw this dialog - center(); + setPosition(); drawDialog(); render(); } diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index d5405ef70..c594d93cd 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -56,16 +56,13 @@ class Dialog : public GuiObject bool isVisible() const override { return _visible; } bool isOnTop() const { return _onTop; } - virtual void center(); + virtual void setPosition(); virtual void drawDialog(); virtual void loadConfig() { } virtual void saveConfig() { } virtual void setDefaults() { } - // A dialog being dirty indicates that its underlying surface needs to be - // redrawn and then re-rendered; this is taken care of in ::render() - void setDirty() override; - bool isDirty() override; // TODO: remove + void tick() override; bool isChainDirty() const override; void redraw(); void render(); diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 98deae834..1210e5d7c 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -107,6 +107,13 @@ void DialogContainer::draw(bool full) }); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DialogContainer::tick() +{ + if(!myDialogStack.empty()) + myDialogStack.top()->tick(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DialogContainer::render() { diff --git a/src/gui/DialogContainer.hxx b/src/gui/DialogContainer.hxx index 70950606d..134d82e55 100644 --- a/src/gui/DialogContainer.hxx +++ b/src/gui/DialogContainer.hxx @@ -119,6 +119,11 @@ class DialogContainer */ void handleJoyHatEvent(int stick, int hat, JoyHatDir hdir, int button); + /** + Tick the dialog and all its widgets. + */ + void tick(); + /** Draw the stack of menus (full indicates to redraw all items). */ diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 4032daae3..4c3928052 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -62,8 +62,9 @@ void EditableWidget::setText(const string& str, bool) setDirty(); } + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool EditableWidget::isDirty() +void EditableWidget::tick() { if(_hasFocus && _editable && isVisible() && _boss->isVisible()) { @@ -75,8 +76,7 @@ bool EditableWidget::isDirty() _dirty = true; } } - - return _dirty; + Widget::tick(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/EditableWidget.hxx b/src/gui/EditableWidget.hxx index e4dfbc2f7..345a4c618 100644 --- a/src/gui/EditableWidget.hxx +++ b/src/gui/EditableWidget.hxx @@ -67,7 +67,7 @@ class EditableWidget : public Widget, public CommandSender protected: void receivedFocusWidget() override; void lostFocusWidget() override; - bool isDirty() override; + void tick() override; virtual void startEditMode() { setFlags(Widget::FLAG_WANTS_RAWDATA); } virtual void endEditMode() { clearFlags(Widget::FLAG_WANTS_RAWDATA); } diff --git a/src/gui/GuiObject.hxx b/src/gui/GuiObject.hxx index 811f1569b..581d498aa 100644 --- a/src/gui/GuiObject.hxx +++ b/src/gui/GuiObject.hxx @@ -91,11 +91,15 @@ class GuiObject : public CommandReceiver virtual void setHeight(int h) { _h = h; } virtual bool isVisible() const = 0; - virtual void setDirty() = 0; + virtual void setDirty() { _dirty = true; } virtual void clearDirty() { _dirty = false; } - virtual bool isDirty() { return _dirty; } + + virtual void tick() = 0; + virtual bool isDirty() const { return _dirty; } virtual bool isChainDirty() const = 0; - virtual bool needsRedraw() { return isDirty() || isChainDirty(); }; + // The GUI indicates if its underlying surface needs to be redrawn + // and then re-rendered + virtual bool needsRedraw() { return isDirty() || isChainDirty(); } void setFlags(uInt32 flags) { diff --git a/src/gui/InputTextDialog.cxx b/src/gui/InputTextDialog.cxx index 12e7a66d4..54b656a67 100644 --- a/src/gui/InputTextDialog.cxx +++ b/src/gui/InputTextDialog.cxx @@ -130,7 +130,7 @@ void InputTextDialog::show(uInt32 x, uInt32 y, const Common::Rect& bossRect) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void InputTextDialog::center() +void InputTextDialog::setPosition() { if(!myEnableCenter) { @@ -144,7 +144,7 @@ void InputTextDialog::center() surface().setDstPos(myXOrig, myYOrig); } else - Dialog::center(); + Dialog::setPosition(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/InputTextDialog.hxx b/src/gui/InputTextDialog.hxx index e89e00651..a06ca4446 100644 --- a/src/gui/InputTextDialog.hxx +++ b/src/gui/InputTextDialog.hxx @@ -58,7 +58,7 @@ class InputTextDialog : public Dialog, public CommandSender void handleCommand(CommandSender* sender, int cmd, int data, int id) override; /** This dialog uses its own positioning, so we override Dialog::center() */ - void center() override; + void setPosition() override; private: vector myInput; diff --git a/src/gui/LauncherDialog.hxx b/src/gui/LauncherDialog.hxx index 0dd9b898d..cc265928b 100644 --- a/src/gui/LauncherDialog.hxx +++ b/src/gui/LauncherDialog.hxx @@ -101,7 +101,7 @@ class LauncherDialog : public Dialog static constexpr int MIN_ROMINFO_ROWS = 7; // full lines static constexpr int MIN_ROMINFO_LINES = 4; // extra lines - void center() override { positionAt(0); } + void setPosition() override { positionAt(0); } void handleKeyDown(StellaKey key, StellaMod mod, bool repeated) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override; diff --git a/src/gui/TimeMachineDialog.cxx b/src/gui/TimeMachineDialog.cxx index 1e983eb92..8e550d2a9 100644 --- a/src/gui/TimeMachineDialog.cxx +++ b/src/gui/TimeMachineDialog.cxx @@ -297,7 +297,7 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TimeMachineDialog::center() +void TimeMachineDialog::setPosition() { // Place on the bottom of the screen, centered horizontally const Common::Size& screen = instance().frameBuffer().screenSize(); diff --git a/src/gui/TimeMachineDialog.hxx b/src/gui/TimeMachineDialog.hxx index a4a489b79..1d15d6b15 100644 --- a/src/gui/TimeMachineDialog.hxx +++ b/src/gui/TimeMachineDialog.hxx @@ -44,8 +44,8 @@ class TimeMachineDialog : public Dialog /** initialize timeline bar */ void initBar(); - /** This dialog uses its own positioning, so we override Dialog::center() */ - void center() override; + /** This dialog uses its own positioning, so we override Dialog::setPosition() */ + void setPosition() override; /** convert cycles into time */ string getTimeString(uInt64 cycles); diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 69c94b3ed..951a60282 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -51,48 +51,36 @@ Widget::~Widget() _focusList.clear(); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Widget::setDirty() -{ - // A widget being dirty indicates that its parent dialog is dirty - // So we inform the parent about it - //_boss->dialog().setDirty(); - //cerr << "set dirty " << typeid(*this).name() << endl; - - _dirty = true; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Widget::isDirty() -{ - //string name = typeid(*this).name(); - //if(_dirty && name == "class TabWidget") - // cerr << "is dirty " << typeid(*this).name() << endl; - - return _dirty; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Widget::isChainDirty() const { - string name = typeid(*this).name(); - if(_dirty && name == "class TabWidget") - cerr << "is chain dirty " << typeid(*this).name() << endl; - bool dirty = false; - // Check if widget or any subwidgets are dirty + // Recursively check if widget or any child dialogs or widgets are dirty Widget* w = _firstWidget; - while(!dirty && w) + while(w && !dirty) { - dirty |= w->isDirty(); + dirty |= w->needsRedraw(); w = w->_next; } return dirty; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Widget::tick() +{ + // Recursively tick widget and all child dialogs and widgets + Widget* w = _firstWidget; + + while(w) + { + w->tick(); + w = w->_next; + } +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Widget::draw() { diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 3e70523c0..6a505e8df 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -69,8 +69,7 @@ class Widget : public GuiObject virtual bool handleJoyHat(int stick, int hat, JoyHatDir hdir, int button = JOY_CTRL_NONE) { return false; } virtual bool handleEvent(Event::Type event) { return false; } - void setDirty() override; - bool isDirty() override; // TODO: remove + void tick() override; bool isChainDirty() const override; void draw() override; void receivedFocus(); From 1a5a0b5286cfd67a403a9ccbd16d2e7fa85f77fd Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 12 Nov 2020 19:46:28 +0100 Subject: [PATCH 18/70] fixed AboutDialog widget overlapping --- src/gui/AboutDialog.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/AboutDialog.cxx b/src/gui/AboutDialog.cxx index db088d923..426adbeeb 100644 --- a/src/gui/AboutDialog.cxx +++ b/src/gui/AboutDialog.cxx @@ -67,11 +67,12 @@ AboutDialog::AboutDialog(OSystem& osystem, DialogContainer& parent, addCancelWidget(b); xpos = HBORDER; ypos = _th + VBORDER + (buttonHeight - fontHeight) / 2; - myTitle = new StaticTextWidget(this, font, xpos, ypos, _w - xpos * 2, fontHeight, - "", TextAlign::Center); + int bwidth = font.getStringWidth("What's New" + ELLIPSIS) + fontWidth * 2.5; + + myTitle = new StaticTextWidget(this, font, xpos + bwidth, ypos, _w - (xpos + bwidth) * 2, + fontHeight, "", TextAlign::Center); myTitle->setTextColor(kTextColorEm); - int bwidth = font.getStringWidth("What's New" + ELLIPSIS) + fontWidth * 2.5; myWhatsNewButton = new ButtonWidget(this, font, _w - HBORDER - bwidth, ypos - (buttonHeight - fontHeight) / 2, bwidth, buttonHeight, "What's New" + ELLIPSIS, kWhatsNew); From ebd88377296ea101afa6bc7a6f6d8d1b0258efe5 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Thu, 12 Nov 2020 18:04:56 -0330 Subject: [PATCH 19/70] Fix compile warning. --- src/emucore/FBSurface.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emucore/FBSurface.hxx b/src/emucore/FBSurface.hxx index d72ffdd64..ea851e6e6 100644 --- a/src/emucore/FBSurface.hxx +++ b/src/emucore/FBSurface.hxx @@ -323,7 +323,7 @@ class FBSurface This method should be called to reset the surface to empty pixels / colour black. */ - virtual void invalidate() {}; + virtual void invalidate() {} /** This method should be called to reset a surface area to empty From c787e940f2fa57df69665b66d8d6542322cb4dbf Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 13 Nov 2020 08:58:19 +0100 Subject: [PATCH 20/70] fixed rendering, all dialogs are always re-rendered --- src/emucore/FrameBuffer.hxx | 7 +++++- src/gui/Dialog.cxx | 22 ++++++++-------- src/gui/Dialog.hxx | 5 ++++ src/gui/DialogContainer.cxx | 26 ++++++++----------- src/gui/ToolTip.cxx | 40 ++++++++++++++++++++++++++++++ src/gui/ToolTip.hxx | 39 +++++++++++++++++++++++++++++ src/gui/Widget.cxx | 21 +++++++++++----- src/gui/Widget.hxx | 4 +++ src/windows/Stella.vcxproj | 2 ++ src/windows/Stella.vcxproj.filters | 6 +++++ 10 files changed, 139 insertions(+), 33 deletions(-) create mode 100644 src/gui/ToolTip.cxx create mode 100644 src/gui/ToolTip.hxx diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index 8cda8d25c..9d6f3e930 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -88,9 +88,14 @@ class FrameBuffer /** There is a dedicated update method for emulation mode. - */ + */ void updateInEmulationMode(float framesPerSecond); + /** + Render backend to screen. + */ + void renderToScreen() { myBackend->renderToScreen(); } + /** Shows a text message onscreen. diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index e58920e89..b483d6e96 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -110,8 +110,6 @@ void Dialog::open() loadConfig(); // has to be done AFTER (re)building the focus list _visible = true; - - setDirty(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -227,12 +225,14 @@ void Dialog::redraw() // Draw this dialog setPosition(); drawDialog(); - render(); + // full rendering is caused in dialog container } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Dialog::render() { + cerr << " render " << typeid(*this).name() << endl; + // Update dialog surface; also render any extra surfaces // Extra surfaces must be rendered afterwards, so they are drawn on top if(_surface->render()) @@ -242,15 +242,17 @@ void Dialog::render() }); } - //cerr << "is ContextMenu " - // << (typeid(*parent().myDialogStack.top()) == typeid(ContextMenu)) << endl; + // Dialog is still on top if e.g a dialog without title is opened + // (e.g. ContextMenu) + bool onTop = parent().myDialogStack.top() == this + || (parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this + && !parent().myDialogStack.top()->hasTitle()); + //&& typeid(*parent().myDialogStack.top()) == typeid(ContextMenu)) - // Dialog is still on top if e.g a ContextMenu is opened - if(!(parent().myDialogStack.top() == this) - && !((parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this - //&& !(typeid(*parent().myDialogStack.top()) == typeid(ContextMenu))) - && !parent().myDialogStack.top()->hasTitle()))) + if(!onTop) { + cerr << " shade " << typeid(*this).name() << endl; + if(_shadeSurface == nullptr) { uInt32 data = 0xff000000; diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index c594d93cd..4fc48b7fc 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -119,6 +119,10 @@ class Dialog : public GuiObject */ bool shouldResize(uInt32& w, uInt32& h) const; + //bool enableToolTip(); + //void showToolTip(int x, int y); + //void hideToolTip(); + protected: void draw() override { } void releaseFocus() override; @@ -197,6 +201,7 @@ class Dialog : public GuiObject string _title; int _th{0}; int _layer{0}; + int _toolTipTimer{0}; Common::FixedStack> mySurfaceStack; diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 1210e5d7c..50db35d3f 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -97,14 +97,16 @@ void DialogContainer::draw(bool full) cerr << "draw " << full << " " << typeid(*this).name() << endl; // Make the top dialog dirty if a full redraw is requested - if(full) - myDialogStack.top()->setDirty(); + //if(full) + // myDialogStack.top()->setDirty(); // Draw and render all dirty dialogs myDialogStack.applyAll([&](Dialog*& d) { if(d->needsRedraw()) d->redraw(); }); + // Always render all surfaces, bottom to top + render(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -120,9 +122,9 @@ void DialogContainer::render() if(myDialogStack.empty()) return; - cerr << "render " << typeid(*this).name() << endl; + cerr << "full re-render " << typeid(*this).name() << endl; - // Render all dirty dialogs + // Render all dialogs myDialogStack.applyAll([&](Dialog*& d) { d->render(); }); @@ -153,10 +155,6 @@ int DialogContainer::addDialog(Dialog* d) "Unable to show dialog box; FIX THE CODE", MessagePosition::BottomCenter, true); else { - //// "shade" current top dialog - //if(!myDialogStack.empty()) - // myDialogStack.top()->setDirty(); - d->setDirty(); myDialogStack.push(d); } @@ -168,20 +166,16 @@ void DialogContainer::removeDialog() { if(!myDialogStack.empty()) { + cerr << "remove dialog" << endl; myDialogStack.pop(); if(!myDialogStack.empty()) { - //// this "unshades" the top dialog - //myDialogStack.top()->setDirty(); - - // Rerender all dialogs (TODO: top dialog is rendered twice) + // Rerender all dialogs myDialogStack.applyAll([&](Dialog*& d){ - //d->setDirty(); - d->render(); + d->render(); }); - // TODO: the screen is not updated until an event happens - // FrameBuffer::myBackend->renderToScreen() doesn't help + myOSystem.frameBuffer().renderToScreen(); } } } diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx new file mode 100644 index 000000000..53cbea0c3 --- /dev/null +++ b/src/gui/ToolTip.cxx @@ -0,0 +1,40 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#include "OSystem.hxx" +#include "Font.hxx" +#include "Dialog.hxx" +#include "DialogContainer.hxx" + +#include "ToolTip.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ToolTip::ToolTip(OSystem& instance, DialogContainer& parent, + const GUI::Font& font) + : Dialog(instance, parent, font) +{ + const int lineHeight = font.getLineHeight(), + fontWidth = font.getMaxCharWidth(), + fontHeight = font.getFontHeight(), + buttonWidth = font.getStringWidth("Previous") + fontWidth * 2.5, + buttonHeight = font.getLineHeight() * 1.25; + const int VBORDER = fontHeight / 2; + const int HBORDER = fontWidth * 1.25; + const int VGAP = fontHeight / 4; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/ToolTip.hxx b/src/gui/ToolTip.hxx new file mode 100644 index 000000000..2066bd3df --- /dev/null +++ b/src/gui/ToolTip.hxx @@ -0,0 +1,39 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#ifndef TOOL_TIP_HXX +#define TOOL_TIP_HXX + +class OSystem; +class DialogContainer; + +/** + * Class for providing tooltip functionality + * + * @author Thomas Jentzsch + */ +class ToolTip : public Dialog +{ + public: + + public: + ToolTip(OSystem& instance, DialogContainer& parent, + const GUI::Font& font); + ~ToolTip() override = default; +}; + +#endif diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 951a60282..1cacda9d6 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -71,13 +71,22 @@ bool Widget::isChainDirty() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Widget::tick() { - // Recursively tick widget and all child dialogs and widgets - Widget* w = _firstWidget; - - while(w) + if(isEnabled()) { - w->tick(); - w = w->_next; + //if(_hasFocus && hasToolTip()) + //{ + // if(dialog().enableToolTip()) + // dialog().showToolTip(10, 10); + //} + + // Recursively tick widget and all child dialogs and widgets + Widget* w = _firstWidget; + + while(w) + { + w->tick(); + w = w->_next; + } } } diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 6a505e8df..13eefdbf7 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -99,6 +99,9 @@ class Widget : public GuiObject void setBGColorHi(ColorId color) { _bgcolorhi = color; setDirty(); } void setShadowColor(ColorId color) { _shadowcolor = color; setDirty(); } + void setToolTip(const string& text) { _toolTipText = text; } + bool hasToolTip() const { return !_toolTipText.empty(); } + virtual void loadConfig() { } protected: @@ -130,6 +133,7 @@ class Widget : public GuiObject ColorId _textcolorhi{kTextColorHi}; ColorId _textcolorlo{kBGColorLo}; ColorId _shadowcolor{kShadowColor}; + string _toolTipText; public: static Widget* findWidgetInChain(Widget* start, int x, int y); diff --git a/src/windows/Stella.vcxproj b/src/windows/Stella.vcxproj index 5f0bd9126..f9b5d3499 100644 --- a/src/windows/Stella.vcxproj +++ b/src/windows/Stella.vcxproj @@ -786,6 +786,7 @@ + @@ -1838,6 +1839,7 @@ + diff --git a/src/windows/Stella.vcxproj.filters b/src/windows/Stella.vcxproj.filters index 8dca2be2e..550419e9a 100644 --- a/src/windows/Stella.vcxproj.filters +++ b/src/windows/Stella.vcxproj.filters @@ -1032,6 +1032,9 @@ Source Files\gui + + Source Files\gui + @@ -2123,6 +2126,9 @@ Header Files\gui + + Header Files\gui + From 15576fe6b1ea6626d6405fa8b34462ae7e7be1d1 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 13 Nov 2020 09:36:57 +0100 Subject: [PATCH 21/70] fixed forced full redraws force full UI redraw when UI palette changes --- src/emucore/FrameBuffer.cxx | 2 ++ src/gui/Dialog.cxx | 9 ++++++--- src/gui/Dialog.hxx | 2 +- src/gui/DialogContainer.cxx | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index a151084d1..2622b8fe9 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -889,6 +889,8 @@ void FrameBuffer::setUIPalette() myFullPalette[j] = mapRGB(r, g, b); } FBSurface::setPalette(myFullPalette); + if(&myOSystem.eventHandler()) + update(true); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index b483d6e96..e1bf15f3e 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -217,10 +217,13 @@ void Dialog::positionAt(uInt32 pos) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Dialog::redraw() +void Dialog::redraw(bool force) { - if(!isVisible() || !needsRedraw()) - return;// false; + if(!isVisible()) + return; + + if(force) + setDirty(); // Draw this dialog setPosition(); diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index 4fc48b7fc..abb22911a 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -64,7 +64,7 @@ class Dialog : public GuiObject void tick() override; bool isChainDirty() const override; - void redraw(); + void redraw(bool force = false); void render(); void addFocusWidget(Widget* w) override; diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 50db35d3f..7b001cb06 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -102,8 +102,8 @@ void DialogContainer::draw(bool full) // Draw and render all dirty dialogs myDialogStack.applyAll([&](Dialog*& d) { - if(d->needsRedraw()) - d->redraw(); + if(full || d->needsRedraw()) + d->redraw(full); }); // Always render all surfaces, bottom to top render(); From 7c962fbfe7c80d602b3524a5fe2bd7ed5f52b2c4 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 13 Nov 2020 10:03:03 +0100 Subject: [PATCH 22/70] avoid full update when window gets exposed (test) --- src/emucore/EventHandler.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 9e7c9ea5f..cb372c7f9 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -323,7 +323,8 @@ void EventHandler::handleSystemEvent(SystemEvent e, int, int) { case SystemEvent::WINDOW_EXPOSED: case SystemEvent::WINDOW_RESIZED: - myOSystem.frameBuffer().update(true); // force full update + //myOSystem.frameBuffer().update(true); // force full update + myOSystem.frameBuffer().update(); break; #ifdef BSPF_UNIX case SystemEvent::WINDOW_FOCUS_GAINED: From 36f3810e405829d994e5ad1056f3be721d5045d9 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 13 Nov 2020 11:18:25 +0100 Subject: [PATCH 23/70] fixed missing render when a stacked dialog was closed in emulation --- src/emucore/FrameBuffer.cxx | 30 +++++++++++++++++++----------- src/emucore/FrameBuffer.hxx | 9 ++++++--- src/gui/DialogContainer.cxx | 10 ++-------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 2622b8fe9..ffc827ba9 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -311,7 +311,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, BufferType type, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBuffer::update(bool force) +void FrameBuffer::update(bool forceRedraw) { // Onscreen messages are a special case and require different handling than // other objects; they aren't UI dialogs in the normal sense nor are they @@ -322,11 +322,12 @@ void FrameBuffer::update(bool force) // - at the bottom of ::update(), to actually draw them (this must come // last, since they are always drawn on top of everything else). - // Forced rendering without drawing is required when messages are being disabled - // Only relevant for LAUNCHER, PAUSE and DEBUGGER modes - bool rerender = force || (myMsg.enabled && myMsg.counter == 0); + // Forced render without draw required if messages or dialogs were closed + // Note: For dialogs only relevant when two or more dialogs were stacked + bool rerender = forceRedraw || myPendingRender; + myPendingRender = false; - bool redraw = force; + bool redraw = forceRedraw; switch(myOSystem.eventHandler().state()) { case EventHandlerState::NONE: @@ -357,7 +358,13 @@ void FrameBuffer::update(bool force) { clear(); myTIASurface->render(); - myOSystem.menu().draw(force); + myOSystem.menu().draw(forceRedraw); + } + else if(rerender) + { + clear(); + myTIASurface->render(); + myOSystem.menu().render(); } break; // EventHandlerState::OPTIONSMENU } @@ -370,7 +377,7 @@ void FrameBuffer::update(bool force) { clear(); myTIASurface->render(); - myOSystem.commandMenu().draw(force); + myOSystem.commandMenu().draw(forceRedraw); } break; // EventHandlerState::CMDMENU } @@ -383,7 +390,7 @@ void FrameBuffer::update(bool force) { clear(); myTIASurface->render(); - myOSystem.messageMenu().draw(force); + myOSystem.messageMenu().draw(forceRedraw); } break; // EventHandlerState::MESSAGEMENU } @@ -396,7 +403,7 @@ void FrameBuffer::update(bool force) { clear(); myTIASurface->render(); - myOSystem.timeMachine().draw(force); + myOSystem.timeMachine().draw(forceRedraw); } break; // EventHandlerState::TIMEMACHINE } @@ -440,7 +447,7 @@ void FrameBuffer::update(bool force) myOSystem.launcher().tick(); redraw |= myOSystem.launcher().needsRedraw(); if(redraw) - myOSystem.launcher().draw(force); + myOSystem.launcher().draw(forceRedraw); else if(rerender) myOSystem.launcher().render(); break; // EventHandlerState::LAUNCHER @@ -453,7 +460,7 @@ void FrameBuffer::update(bool force) myOSystem.debugger().tick(); redraw |= myOSystem.debugger().needsRedraw(); if(redraw) - myOSystem.debugger().draw(force); + myOSystem.debugger().draw(forceRedraw); else if(rerender) myOSystem.debugger().render(); break; // EventHandlerState::DEBUGGER @@ -684,6 +691,7 @@ inline bool FrameBuffer::drawMessage() if(myMsg.counter == 0) { myMsg.enabled = false; + myPendingRender = true; return false; } diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index 9d6f3e930..78106f8c0 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -84,7 +84,7 @@ class FrameBuffer Updates the display, which depending on the current mode could mean drawing the TIA, any pending menus, etc. */ - void update(bool force = false); + void update(bool forceRedraw = false); /** There is a dedicated update method for emulation mode. @@ -92,9 +92,9 @@ class FrameBuffer void updateInEmulationMode(float framesPerSecond); /** - Render backend to screen. + Set pending rendering flag. */ - void renderToScreen() { myBackend->renderToScreen(); } + void setPendingRender() { myPendingRender = true; } /** Shows a text message onscreen. @@ -460,6 +460,9 @@ class FrameBuffer // Supported renderers VariantList myRenderers; + // Flag for pending render + bool myPendingRender{false}; + // The VideoModeHandler class takes responsibility for all video // mode functionality VideoModeHandler myVidModeHandler; diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 7b001cb06..c2011e7e0 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -169,14 +169,8 @@ void DialogContainer::removeDialog() cerr << "remove dialog" << endl; myDialogStack.pop(); - if(!myDialogStack.empty()) - { - // Rerender all dialogs - myDialogStack.applyAll([&](Dialog*& d){ - d->render(); - }); - myOSystem.frameBuffer().renderToScreen(); - } + // Inform the frame buffer that it has to render all surfaces + myOSystem.frameBuffer().setPendingRender(); } } From 9900564862698914980e6c6a23617ac4e160d467 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 13 Nov 2020 11:19:48 +0100 Subject: [PATCH 24/70] disabled palette display if without console --- src/gui/VideoAudioDialog.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gui/VideoAudioDialog.cxx b/src/gui/VideoAudioDialog.cxx index f68be6df8..ba141cbeb 100644 --- a/src/gui/VideoAudioDialog.cxx +++ b/src/gui/VideoAudioDialog.cxx @@ -1157,10 +1157,11 @@ void VideoAudioDialog::addPalette(int x, int y, int w, int h) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void VideoAudioDialog::colorPalette() { + constexpr int NUM_LUMA = 8; + constexpr int NUM_CHROMA = 16; + if(instance().hasConsole()) { - constexpr int NUM_LUMA = 8; - constexpr int NUM_CHROMA = 16; const int order[2][NUM_CHROMA] = { {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, @@ -1176,11 +1177,14 @@ void VideoAudioDialog::colorPalette() ss << Common::Base::HEX1 << std::uppercase << color; myColorLbl[idx]->setLabel(ss.str()); for(int lum = 0; lum < NUM_LUMA; ++lum) - { myColor[idx][lum]->setColor(color * NUM_CHROMA + lum * 2); // skip grayscale colors - } } } + else + // disable palette + for(int idx = 0; idx < NUM_CHROMA; ++idx) + for(int lum = 0; lum < NUM_LUMA; ++lum) + myColor[idx][lum]->setEnabled(false); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From bcbf0072eafbecc6c7e9a69beae9c2cfb0cb4c0a Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 13 Nov 2020 14:24:52 +0100 Subject: [PATCH 25/70] fixed initial focus display --- src/emucore/EventHandler.cxx | 1 + src/gui/Dialog.cxx | 22 +++++++++++----------- src/gui/Widget.cxx | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index cb372c7f9..59c17c8a8 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -324,6 +324,7 @@ void EventHandler::handleSystemEvent(SystemEvent e, int, int) case SystemEvent::WINDOW_EXPOSED: case SystemEvent::WINDOW_RESIZED: //myOSystem.frameBuffer().update(true); // force full update + // TODO: test and maybe force a render update instead myOSystem.frameBuffer().update(); break; #ifdef BSPF_UNIX diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index e1bf15f3e..95379398a 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -476,17 +476,6 @@ void Dialog::drawDialog() clearDirty(); } - // Draw outlines for focused widgets - // Don't change focus, since this will trigger lost and received - // focus events - if(_focusedWidget) - { - _focusedWidget = Widget::setFocusForChain(this, getFocusList(), - _focusedWidget, 0, false); - // if(_focusedWidget) - // _focusedWidget->draw(); // make sure the highlight color is drawn initially - } - Widget* w = _firstWidget; // Draw all children @@ -498,6 +487,17 @@ void Dialog::drawDialog() w->draw(); w = w->_next; } + + // Draw outlines for focused widgets + // Don't change focus, since this will trigger lost and received + // focus events + if(_focusedWidget) + { + _focusedWidget = Widget::setFocusForChain(this, getFocusList(), + _focusedWidget, 0, false); + //if(_focusedWidget) + // _focusedWidget->draw(); // make sure the highlight color is drawn initially + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 1cacda9d6..93331cea1 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -269,7 +269,7 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr, s.frameRect(x, y, w, h, onTop ? kDlgColor : kBGColorLo); - tmp->setDirty(); + //tmp->setDirty(); } } @@ -325,7 +325,7 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr, if (onTop) s.frameRect(x, y, w, h, kWidFrameColor, FrameStyle::Dashed); - tmp->setDirty(); + //tmp->setDirty(); return tmp; } From d656598fa34184afca2b761a44b5553f9640da96 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Fri, 13 Nov 2020 10:05:11 -0330 Subject: [PATCH 26/70] Update Xcode for class addition. Comment out code that causes a crash on Mac. --- src/emucore/FrameBuffer.cxx | 4 ++-- src/macos/stella.xcodeproj/project.pbxproj | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index ffc827ba9..de1156200 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -897,8 +897,8 @@ void FrameBuffer::setUIPalette() myFullPalette[j] = mapRGB(r, g, b); } FBSurface::setPalette(myFullPalette); - if(&myOSystem.eventHandler()) - update(true); +// if(&myOSystem.eventHandler()) +// update(true); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/macos/stella.xcodeproj/project.pbxproj b/src/macos/stella.xcodeproj/project.pbxproj index 4452ddce2..a23a0b173 100644 --- a/src/macos/stella.xcodeproj/project.pbxproj +++ b/src/macos/stella.xcodeproj/project.pbxproj @@ -531,6 +531,8 @@ DCBDDE9B1D6A5F0E009DF1E9 /* Cart3EPlusWidget.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCBDDE991D6A5F0E009DF1E9 /* Cart3EPlusWidget.hxx */; }; DCBDDE9E1D6A5F2F009DF1E9 /* Cart3EPlus.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DCBDDE9C1D6A5F2F009DF1E9 /* Cart3EPlus.cxx */; }; DCBDDE9F1D6A5F2F009DF1E9 /* Cart3EPlus.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCBDDE9D1D6A5F2F009DF1E9 /* Cart3EPlus.hxx */; }; + DCC2FDF5255EB82500FA5E81 /* ToolTip.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCC2FDF3255EB82500FA5E81 /* ToolTip.hxx */; }; + DCC2FDF6255EB82500FA5E81 /* ToolTip.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DCC2FDF4255EB82500FA5E81 /* ToolTip.cxx */; }; DCC527D110B9DA19005E1287 /* Device.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCC527C910B9DA19005E1287 /* Device.hxx */; }; DCC527D210B9DA19005E1287 /* M6502.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DCC527CA10B9DA19005E1287 /* M6502.cxx */; }; DCC527D310B9DA19005E1287 /* M6502.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCC527CB10B9DA19005E1287 /* M6502.hxx */; }; @@ -1298,6 +1300,8 @@ DCBDDE991D6A5F0E009DF1E9 /* Cart3EPlusWidget.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Cart3EPlusWidget.hxx; sourceTree = ""; }; DCBDDE9C1D6A5F2F009DF1E9 /* Cart3EPlus.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cart3EPlus.cxx; sourceTree = ""; }; DCBDDE9D1D6A5F2F009DF1E9 /* Cart3EPlus.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Cart3EPlus.hxx; sourceTree = ""; }; + DCC2FDF3255EB82500FA5E81 /* ToolTip.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ToolTip.hxx; sourceTree = ""; }; + DCC2FDF4255EB82500FA5E81 /* ToolTip.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ToolTip.cxx; sourceTree = ""; }; DCC527C910B9DA19005E1287 /* Device.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Device.hxx; sourceTree = ""; }; DCC527CA10B9DA19005E1287 /* M6502.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = M6502.cxx; sourceTree = ""; }; DCC527CB10B9DA19005E1287 /* M6502.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = M6502.hxx; sourceTree = ""; }; @@ -2167,6 +2171,8 @@ DCA82C6E1FEB4E780059340F /* TimeMachine.hxx */, DCA82C6F1FEB4E780059340F /* TimeMachineDialog.cxx */, DCA82C701FEB4E780059340F /* TimeMachineDialog.hxx */, + DCC2FDF4255EB82500FA5E81 /* ToolTip.cxx */, + DCC2FDF3255EB82500FA5E81 /* ToolTip.hxx */, DC8078E60B4BD697005E9305 /* UIDialog.cxx */, DC8078E70B4BD697005E9305 /* UIDialog.hxx */, DCBA539825557E2800087DD7 /* UndoHandler.cxx */, @@ -2651,6 +2657,7 @@ DC5D1AA7102C6FC900E59AC1 /* Stack.hxx in Headers */, DCF7B0DE10A762FC007A2870 /* CartF0.hxx in Headers */, DCF7B0E010A762FC007A2870 /* CartFA.hxx in Headers */, + DCC2FDF5255EB82500FA5E81 /* ToolTip.hxx in Headers */, DCC527D110B9DA19005E1287 /* Device.hxx in Headers */, DC6F394E21B897F300897AD8 /* ThreadDebugging.hxx in Headers */, DCC527D310B9DA19005E1287 /* M6502.hxx in Headers */, @@ -3205,6 +3212,7 @@ DCAACB0E188D636F00A4D282 /* Cart4KSCWidget.cxx in Sources */, DCB60AD02543100900A5C1D2 /* FBBackendSDL2.cxx in Sources */, DCAACB10188D636F00A4D282 /* CartBFSCWidget.cxx in Sources */, + DCC2FDF6255EB82500FA5E81 /* ToolTip.cxx in Sources */, DCAACB12188D636F00A4D282 /* CartBFWidget.cxx in Sources */, DCAACB14188D636F00A4D282 /* CartDFSCWidget.cxx in Sources */, DCAACB16188D636F00A4D282 /* CartDFWidget.cxx in Sources */, From 2505201b4b3125d0251356ae09036d21f498c0d7 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 13 Nov 2020 16:00:19 +0100 Subject: [PATCH 27/70] fixed UI palette update crash fixed garbage when switching state in fullscreen modes --- src/emucore/EventHandler.cxx | 1 + src/emucore/FrameBuffer.cxx | 20 +++++++++++++------- src/emucore/FrameBuffer.hxx | 5 +++++ src/gui/DialogContainer.cxx | 3 +++ src/gui/StellaSettingsDialog.cxx | 1 + src/gui/UIDialog.cxx | 1 + 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 59c17c8a8..3164a92a4 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -2320,6 +2320,7 @@ bool EventHandler::enterDebugMode() } myOverlay->reStack(); myOSystem.sound().mute(true); + #else myOSystem.frameBuffer().showTextMessage("Debugger support not included", MessagePosition::BottomCenter, true); diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index de1156200..c51cdbbce 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -270,7 +270,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, BufferType type, #ifdef GUI_SUPPORT // Erase any messages from a previous run - myMsg.counter = 0; + myMsg.enabled = false; // Create surfaces for TIA statistics and general messages const GUI::Font& f = hidpiEnabled() ? infoFont() : font(); @@ -677,11 +677,19 @@ void FrameBuffer::enableMessages(bool enable) myStatsMsg.enabled = false; // Erase old messages on the screen - myMsg.counter = 0; + hideMessage(); + update(); // update immediately } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrameBuffer::hideMessage() +{ + myPendingRender = myMsg.enabled; + myMsg.enabled = false; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - inline bool FrameBuffer::drawMessage() { @@ -690,8 +698,7 @@ inline bool FrameBuffer::drawMessage() // or show again this frame if(myMsg.counter == 0) { - myMsg.enabled = false; - myPendingRender = true; + hideMessage(); return false; } @@ -897,15 +904,13 @@ void FrameBuffer::setUIPalette() myFullPalette[j] = mapRGB(r, g, b); } FBSurface::setPalette(myFullPalette); -// if(&myOSystem.eventHandler()) -// update(true); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBuffer::stateChanged(EventHandlerState state) { // Make sure any onscreen messages are removed - myMsg.counter = 0; + hideMessage(); update(); // update immediately } @@ -1169,6 +1174,7 @@ FBInitStatus FrameBuffer::applyVideoMode() resetSurfaces(); setCursorState(); + myPendingRender = true; } else Logger::error("ERROR: Couldn't initialize video subsystem"); diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index 78106f8c0..e5e6bd1b6 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -399,6 +399,11 @@ class FrameBuffer */ bool drawMessage(); + /** + Hide pending messages. + */ + void hideMessage(); + /** Draws the frame stats overlay. */ diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index c2011e7e0..1c75273b4 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -181,6 +181,9 @@ void DialogContainer::reStack() while(!myDialogStack.empty()) myDialogStack.top()->close(); + // Make sure that all surfaces are cleared + myOSystem.frameBuffer().clear(); + baseDialog()->open(); // Reset all continuous events diff --git a/src/gui/StellaSettingsDialog.cxx b/src/gui/StellaSettingsDialog.cxx index fc3d3e4d9..dbd2ac09c 100644 --- a/src/gui/StellaSettingsDialog.cxx +++ b/src/gui/StellaSettingsDialog.cxx @@ -268,6 +268,7 @@ void StellaSettingsDialog::saveConfig() settings.setValue("uipalette", myThemePopup->getSelectedTag().toString()); instance().frameBuffer().setUIPalette(); + instance().frameBuffer().update(true); // Dialog position settings.setValue("dialogpos", myPositionPopup->getSelectedTag().toString()); diff --git a/src/gui/UIDialog.cxx b/src/gui/UIDialog.cxx index 1b64d73f2..1a75ee440 100644 --- a/src/gui/UIDialog.cxx +++ b/src/gui/UIDialog.cxx @@ -441,6 +441,7 @@ void UIDialog::saveConfig() settings.setValue("uipalette", myPalettePopup->getSelectedTag().toString()); instance().frameBuffer().setUIPalette(); + instance().frameBuffer().update(true); // Dialog font settings.setValue("dialogfont", From db55dc44208a87dbc8806ea2b347dba7495f3e12 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 13 Nov 2020 16:12:33 +0100 Subject: [PATCH 28/70] improved fullscreen message in debugger mode --- src/emucore/FrameBuffer.cxx | 38 ++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index c51cdbbce..823b864c1 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -927,10 +927,10 @@ string FrameBuffer::getDisplayKey() case BufferType::Emulator: return "display"; - #ifdef DEBUGGER_SUPPORT + #ifdef DEBUGGER_SUPPORT case BufferType::Debugger: return "dbg.display"; - #endif + #endif default: return ""; @@ -949,10 +949,10 @@ string FrameBuffer::getPositionKey() case BufferType::Emulator: return "windowedpos"; - #ifdef DEBUGGER_SUPPORT + #ifdef DEBUGGER_SUPPORT case BufferType::Debugger: return "dbg.pos"; - #endif + #endif default: return ""; @@ -963,10 +963,10 @@ string FrameBuffer::getPositionKey() void FrameBuffer::saveCurrentWindowPosition() { myOSystem.settings().setValue( - getDisplayKey(), myBackend->getCurrentDisplayIndex()); + getDisplayKey(), myBackend->getCurrentDisplayIndex()); if(myBackend->isCurrentWindowPositioned()) myOSystem.settings().setValue( - getPositionKey(), myBackend->getCurrentWindowPos()); + getPositionKey(), myBackend->getCurrentWindowPos()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1001,7 +1001,9 @@ void FrameBuffer::setFullscreen(bool enable) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBuffer::toggleFullscreen(bool toggle) { - switch(myOSystem.eventHandler().state()) + EventHandlerState state = myOSystem.eventHandler().state(); + + switch(state) { case EventHandlerState::LAUNCHER: case EventHandlerState::EMULATION: @@ -1011,16 +1013,26 @@ void FrameBuffer::toggleFullscreen(bool toggle) const bool isFullscreen = toggle ? !fullScreen() : fullScreen(); setFullscreen(isFullscreen); - if(myBufferType != BufferType::Launcher) + if(state != EventHandlerState::LAUNCHER) { ostringstream msg; msg << "Fullscreen "; - if(isFullscreen) - msg << "enabled (" << myBackend->refreshRate() << " Hz, "; - else - msg << "disabled ("; - msg << "Zoom " << myActiveVidMode.zoom * 100 << "%)"; + if(state != EventHandlerState::DEBUGGER) + { + if(isFullscreen) + msg << "enabled (" << myBackend->refreshRate() << " Hz, "; + else + msg << "disabled ("; + msg << "Zoom " << myActiveVidMode.zoom * 100 << "%)"; + } + else + { + if(isFullscreen) + msg << "enabled"; + else + msg << "disabled"; + } showTextMessage(msg.str()); } break; From ed13b214026675e087a44f8c805461642429d5e3 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 13 Nov 2020 19:53:19 +0100 Subject: [PATCH 29/70] added a full render when event WINDOW_EXPOSED and WINDOW_RESIZED are handled stopped screen from changing frames when 'Pause' is displayed --- src/emucore/EventHandler.cxx | 5 ++--- src/emucore/FrameBuffer.cxx | 13 ++++++++----- src/emucore/FrameBuffer.hxx | 8 +++++++- src/gui/StellaSettingsDialog.cxx | 2 +- src/gui/UIDialog.cxx | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 3164a92a4..7d241101e 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -323,9 +323,8 @@ void EventHandler::handleSystemEvent(SystemEvent e, int, int) { case SystemEvent::WINDOW_EXPOSED: case SystemEvent::WINDOW_RESIZED: - //myOSystem.frameBuffer().update(true); // force full update - // TODO: test and maybe force a render update instead - myOSystem.frameBuffer().update(); + // Force full render update + myOSystem.frameBuffer().update(FrameBuffer::UpdateMode::RERENDER); break; #ifdef BSPF_UNIX case SystemEvent::WINDOW_FOCUS_GAINED: diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 823b864c1..fce9cdae4 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -311,7 +311,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, BufferType type, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBuffer::update(bool forceRedraw) +void FrameBuffer::update(UpdateMode mode) { // Onscreen messages are a special case and require different handling than // other objects; they aren't UI dialogs in the normal sense nor are they @@ -322,12 +322,15 @@ void FrameBuffer::update(bool forceRedraw) // - at the bottom of ::update(), to actually draw them (this must come // last, since they are always drawn on top of everything else). + bool forceRedraw = mode & UpdateMode::REDRAW; + bool redraw = forceRedraw; + // Forced render without draw required if messages or dialogs were closed // Note: For dialogs only relevant when two or more dialogs were stacked - bool rerender = forceRedraw || myPendingRender; + bool rerender = (mode & (UpdateMode::REDRAW | UpdateMode::RERENDER)) + || myPendingRender; myPendingRender = false; - bool redraw = forceRedraw; switch(myOSystem.eventHandler().state()) { case EventHandlerState::NONE: @@ -342,10 +345,10 @@ void FrameBuffer::update(bool forceRedraw) { myPausedCount = uInt32(7 * myOSystem.frameRate()); showTextMessage("Paused", MessagePosition::MiddleCenter); + myTIASurface->render(); } if(rerender) myTIASurface->render(); - break; // EventHandlerState::PAUSE } @@ -857,7 +860,7 @@ void FrameBuffer::resetSurfaces() freeSurfaces(); reloadSurfaces(); - update(true); // force full update + update(UpdateMode::REDRAW); // force full update } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index e5e6bd1b6..0971873f2 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -55,6 +55,12 @@ class FrameBuffer // Zoom level step interval static constexpr float ZOOM_STEPS = 0.25; + enum UpdateMode { + NONE = 0, + REDRAW = 1, + RERENDER = 2 + }; + public: FrameBuffer(OSystem& osystem); ~FrameBuffer(); @@ -84,7 +90,7 @@ class FrameBuffer Updates the display, which depending on the current mode could mean drawing the TIA, any pending menus, etc. */ - void update(bool forceRedraw = false); + void update(UpdateMode mode = UpdateMode::NONE); /** There is a dedicated update method for emulation mode. diff --git a/src/gui/StellaSettingsDialog.cxx b/src/gui/StellaSettingsDialog.cxx index dbd2ac09c..06ff03b3e 100644 --- a/src/gui/StellaSettingsDialog.cxx +++ b/src/gui/StellaSettingsDialog.cxx @@ -268,7 +268,7 @@ void StellaSettingsDialog::saveConfig() settings.setValue("uipalette", myThemePopup->getSelectedTag().toString()); instance().frameBuffer().setUIPalette(); - instance().frameBuffer().update(true); + instance().frameBuffer().update(FrameBuffer::UpdateMode::REDRAW); // Dialog position settings.setValue("dialogpos", myPositionPopup->getSelectedTag().toString()); diff --git a/src/gui/UIDialog.cxx b/src/gui/UIDialog.cxx index 1a75ee440..12f710bc0 100644 --- a/src/gui/UIDialog.cxx +++ b/src/gui/UIDialog.cxx @@ -441,7 +441,7 @@ void UIDialog::saveConfig() settings.setValue("uipalette", myPalettePopup->getSelectedTag().toString()); instance().frameBuffer().setUIPalette(); - instance().frameBuffer().update(true); + instance().frameBuffer().update(FrameBuffer::UpdateMode::REDRAW); // Dialog font settings.setValue("dialogfont", From f52e834455955d7c906dd180cc8afa7edd9d4513 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sat, 14 Nov 2020 09:43:41 +0100 Subject: [PATCH 30/70] fixed breakpoints setting in RomListWidget improved drawing of breakpoints in RomListWidget made RomListWidget redraw regularly only if in edit mode --- src/debugger/gui/RomListWidget.cxx | 32 +++++++++++++++--------------- src/debugger/gui/RomListWidget.hxx | 1 - src/debugger/gui/RomWidget.cxx | 4 ---- src/gui/Dialog.cxx | 10 +++++++--- src/gui/Dialog.hxx | 1 + src/gui/EditableWidget.cxx | 2 +- src/gui/EditableWidget.hxx | 1 + src/gui/GuiObject.hxx | 11 ++++++---- src/gui/Widget.cxx | 7 +++++++ src/gui/Widget.hxx | 1 + 10 files changed, 41 insertions(+), 29 deletions(-) diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 20fc53052..3504b2b37 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -39,6 +39,8 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, _textcolor = kTextColor; _textcolorhi = kTextColor; + _editMode = false; + _cols = w / _fontWidth; _rows = h / _lineHeight; @@ -480,20 +482,18 @@ void RomListWidget::drawWidget(bool hilite) codeDisasmW = actualWidth; xpos = _x + CheckboxWidget::boxSize(_font) + 10; ypos = _y + 2; - for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++, ypos += _lineHeight) + for(i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++, ypos += _lineHeight) { ColorId bytesColor = textColor; - // Draw checkboxes for correct lines (takes scrolling into account) + // Mark checkboxes dirty for correct lines (takes scrolling into account) myCheckList[i]->setState(instance().debugger(). checkBreakPoint(dlist[pos].address, instance().debugger().cartDebug().getBank(dlist[pos].address))); - myCheckList[i]->setDirty(); - myCheckList[i]->draw(); // Draw highlighted item in a frame - if (_highlightedItem == pos) + if(_highlightedItem == pos) s.frameRect(_x + l.x() - 3, ypos - 1, _w - l.x(), _lineHeight, onTop ? kWidColorHi : kBGColorLo); // Draw the selected item inverted, on a highlighted background. @@ -510,31 +510,31 @@ void RomListWidget::drawWidget(bool hilite) // Draw labels s.drawString(_font, dlist[pos].label, xpos, ypos, _labelWidth, - dlist[pos].hllabel ? textColor : kColor); + dlist[pos].hllabel ? textColor : kColor); // Bytes are only editable if they represent code, graphics, or accessible data // Otherwise, the disassembly should get all remaining space - if(dlist[pos].type & (Device::CODE|Device::GFX|Device::PGFX| - Device::COL|Device::PCOL|Device::BCOL|Device::DATA)) + if(dlist[pos].type & (Device::CODE | Device::GFX | Device::PGFX | + Device::COL | Device::PCOL | Device::BCOL | Device::DATA)) { if(dlist[pos].type == Device::CODE) { // Draw mnemonic s.drawString(_font, dlist[pos].disasm.substr(0, 7), xpos + _labelWidth, ypos, - 7 * _fontWidth, textColor); + 7 * _fontWidth, textColor); // Draw operand - if (dlist[pos].disasm.length() > 8) + if(dlist[pos].disasm.length() > 8) s.drawString(_font, dlist[pos].disasm.substr(8), xpos + _labelWidth + 7 * _fontWidth, ypos, - codeDisasmW - 7 * _fontWidth, textColor); + codeDisasmW - 7 * _fontWidth, textColor); // Draw cycle count s.drawString(_font, dlist[pos].ccount, xpos + _labelWidth + codeDisasmW, ypos, - cycleCountW, textColor); + cycleCountW, textColor); } else { // Draw disassembly only s.drawString(_font, dlist[pos].disasm, xpos + _labelWidth, ypos, - noCodeDisasmW - 4, kTextColor); + noCodeDisasmW - 4, kTextColor); } // Draw separator @@ -542,11 +542,11 @@ void RomListWidget::drawWidget(bool hilite) // Draw bytes { - if (_selectedItem == pos && _editMode) + if(_selectedItem == pos && _editMode) { adjustOffset(); s.drawString(_font, editString(), _x + r.x(), ypos, r.w(), textColor, - TextAlign::Left, -_editScrollOffset, false); + TextAlign::Left, -_editScrollOffset, false); drawCaretSelection(); } @@ -560,7 +560,7 @@ void RomListWidget::drawWidget(bool hilite) { // Draw disassembly, giving it all remaining horizontal space s.drawString(_font, dlist[pos].disasm, xpos + _labelWidth, ypos, - noTypeDisasmW, textColor); + noTypeDisasmW, textColor); } } } diff --git a/src/debugger/gui/RomListWidget.hxx b/src/debugger/gui/RomListWidget.hxx index 40abb0adf..ec557f606 100644 --- a/src/debugger/gui/RomListWidget.hxx +++ b/src/debugger/gui/RomListWidget.hxx @@ -96,7 +96,6 @@ class RomListWidget : public EditableWidget int _currentPos{0}; // position of first line in visible window int _selectedItem{-1}; int _highlightedItem{-1}; - bool _editMode{false}; StellaKey _currentKeyDown{KBDK_UNKNOWN}; Common::Base::Fmt _base{Common::Base::Fmt::_DEFAULT}; // base used during editing diff --git a/src/debugger/gui/RomWidget.cxx b/src/debugger/gui/RomWidget.cxx index 87572d6ed..0454ef16d 100644 --- a/src/debugger/gui/RomWidget.cxx +++ b/src/debugger/gui/RomWidget.cxx @@ -90,10 +90,6 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) case RomListWidget::kBPointChangedCmd: // 'data' is the line in the disassemblylist to be accessed toggleBreak(data); - // Refresh the romlist, since the breakpoint may not have - // actually changed - myRomList->setDirty(); - myRomList->draw(); break; case RomListWidget::kRomChangedCmd: diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 95379398a..215289771 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -476,13 +476,17 @@ void Dialog::drawDialog() clearDirty(); } + // Draw all children + drawChain(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Dialog::drawChain() +{ 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/Dialog.hxx b/src/gui/Dialog.hxx index abb22911a..de81b4a1d 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -65,6 +65,7 @@ class Dialog : public GuiObject void tick() override; bool isChainDirty() const override; void redraw(bool force = false); + void drawChain() override; void render(); void addFocusWidget(Widget* w) override; diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 4c3928052..8e19cb0a2 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -66,7 +66,7 @@ void EditableWidget::setText(const string& str, bool) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EditableWidget::tick() { - if(_hasFocus && _editable && isVisible() && _boss->isVisible()) + if(_hasFocus && isEditable() && _editMode && isVisible() && _boss->isVisible()) { _caretTimer++; if(_caretTimer > 40) // switch every 2/3rd seconds diff --git a/src/gui/EditableWidget.hxx b/src/gui/EditableWidget.hxx index 345a4c618..8ebf1791c 100644 --- a/src/gui/EditableWidget.hxx +++ b/src/gui/EditableWidget.hxx @@ -123,6 +123,7 @@ class EditableWidget : public Widget, public CommandSender protected: int _editScrollOffset{0}; + bool _editMode{true}; private: TextFilter _filter; diff --git a/src/gui/GuiObject.hxx b/src/gui/GuiObject.hxx index 581d498aa..893686e5f 100644 --- a/src/gui/GuiObject.hxx +++ b/src/gui/GuiObject.hxx @@ -91,16 +91,18 @@ class GuiObject : public CommandReceiver virtual void setHeight(int h) { _h = h; } virtual bool isVisible() const = 0; - virtual void setDirty() { _dirty = true; } - virtual void clearDirty() { _dirty = false; } - virtual void tick() = 0; - virtual bool isDirty() const { return _dirty; } + void setDirty() { _dirty = true; } + void clearDirty() { _dirty = false; } + bool isDirty() const { return _dirty; } virtual bool isChainDirty() const = 0; + // The GUI indicates if its underlying surface needs to be redrawn // and then re-rendered virtual bool needsRedraw() { return isDirty() || isChainDirty(); } + virtual void tick() = 0; + void setFlags(uInt32 flags) { uInt32 oldFlags = _flags; @@ -140,6 +142,7 @@ class GuiObject : public CommandReceiver protected: virtual void releaseFocus() = 0; virtual void draw() = 0; + virtual void drawChain() = 0; private: OSystem& myOSystem; diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 93331cea1..e04da70d9 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -157,7 +157,14 @@ void Widget::draw() clearDirty(); // Draw all children + drawChain(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Widget::drawChain() +{ Widget* w = _firstWidget; + while(w) { if(w->needsRedraw()) diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 13eefdbf7..38f8fecfa 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -72,6 +72,7 @@ class Widget : public GuiObject void tick() override; bool isChainDirty() const override; void draw() override; + void drawChain() override; void receivedFocus(); void lostFocus(); void addFocusWidget(Widget* w) override { _focusList.push_back(w); } From a81ab40f5845cf212a4786b8118f53ae9668586b Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sat, 14 Nov 2020 10:03:29 +0100 Subject: [PATCH 31/70] removed special colors and drawing for Dialog in background --- src/emucore/FrameBuffer.cxx | 10 ++++------ src/emucore/FrameBufferConstants.hxx | 4 +--- src/gui/Dialog.cxx | 15 ++++----------- src/gui/Dialog.hxx | 3 +-- 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index fce9cdae4..91cabfe3e 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -1326,8 +1326,6 @@ void FrameBuffer::toggleGrabMouse() kColorInfo TIA output position color kColorTitleBar Title bar color kColorTitleText Title text color - kColorTitleBarLo Disabled title bar color - kColorTitleTextLo Disabled title text color */ UIPaletteArray FrameBuffer::ourStandardUIPalette = { { 0x686868, 0x000000, 0xa38c61, 0xdccfa5, 0x404040, // base @@ -1338,7 +1336,7 @@ UIPaletteArray FrameBuffer::ourStandardUIPalette = { 0xac3410, 0xd55941, // scrollbar 0xc80000, 0xffff80, 0xc8c8ff, 0xc80000, // debugger 0xac3410, 0xd55941, 0xdccfa5, 0xf0f0cf, 0xa38c61, // slider - 0xffffff, 0xac3410, 0xf0f0cf, 0x686868, 0xdccfa5 // other + 0xffffff, 0xac3410, 0xf0f0cf // other } }; @@ -1351,7 +1349,7 @@ UIPaletteArray FrameBuffer::ourClassicUIPalette = { 0x20a020, 0x00ff00, // scrollbar 0xc80000, 0x00ff00, 0xc8c8ff, 0xc80000, // debugger 0x20a020, 0x00ff00, 0x404040, 0x686868, 0x404040, // slider - 0x00ff00, 0x20a020, 0x000000, 0x686868, 0x404040 // other + 0x00ff00, 0x20a020, 0x000000 // other } }; @@ -1364,7 +1362,7 @@ UIPaletteArray FrameBuffer::ourLightUIPalette = { 0xc0c0c0, 0x808080, // scrollbar 0xffc0c0, 0x000000, 0xe00000, 0xc00000, // debugger 0x333333, 0x0078d7, 0xc0c0c0, 0xffffff, 0xc0c0c0, // slider 0xBDDEF9| 0xe1e1e1 | 0xffffff - 0xffffff, 0x333333, 0xf0f0f0, 0x808080, 0xc0c0c0 // other + 0xffffff, 0x333333, 0xf0f0f0 // other } }; @@ -1377,6 +1375,6 @@ UIPaletteArray FrameBuffer::ourDarkUIPalette = { 0x3c3c3c, 0x646464, // scrollbar 0x7f2020, 0xc0c0c0, 0xe00000, 0xc00000, // debugger 0x989898, 0x0059a3, 0x3c3c3c, 0x000000, 0x3c3c3c, // slider - 0x000000, 0x989898, 0x202020, 0x646464, 0x3c3c3c // other + 0x000000, 0x989898, 0x202020 // other } }; diff --git a/src/emucore/FrameBufferConstants.hxx b/src/emucore/FrameBufferConstants.hxx index 134086a0a..7896fd04c 100644 --- a/src/emucore/FrameBufferConstants.hxx +++ b/src/emucore/FrameBufferConstants.hxx @@ -109,9 +109,7 @@ static constexpr ColorId kColorInfo = 287, kColorTitleBar = 288, kColorTitleText = 289, - kColorTitleBarLo = 290, - kColorTitleTextLo = 291, - kNumColors = 292, + kNumColors = 290, kNone = 0 // placeholder to represent default/no color ; diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 215289771..a2b9c14e3 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -441,26 +441,19 @@ void Dialog::drawDialog() { //cerr << "*** draw dialog " << typeid(*this).name() << " ***" << endl; - // Dialog is still on top if e.g a ContextMenu is opened - _onTop = true/*parent().myDialogStack.top() == this*/ - || (parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this - && !parent().myDialogStack.top()->hasTitle()); - - cerr << "on top " << isOnTop() << endl; if(clearsBackground()) { // cerr << "Dialog::drawDialog(): w = " << _w << ", h = " << _h << " @ " << &s << endl << endl; if(hasBackground()) - s.fillRect(_x, _y + _th, _w, _h - _th, _onTop ? kDlgColor : kBGColorLo); + s.fillRect(_x, _y + _th, _w, _h - _th, kDlgColor); else s.invalidateRect(_x, _y + _th, _w, _h - _th); if(_th) { - s.fillRect(_x, _y, _w, _th, _onTop ? kColorTitleBar : kColorTitleBarLo); + s.fillRect(_x, _y, _w, _th, kColorTitleBar); s.drawString(_font, _title, _x + _font.getMaxCharWidth() * 1.25, _y + _font.getFontHeight() / 6, - _font.getStringWidth(_title), - _onTop ? kColorTitleText : kColorTitleTextLo); + _font.getStringWidth(_title), kColorTitleText); } } else { @@ -468,7 +461,7 @@ void Dialog::drawDialog() cerr << "invalidate " << typeid(*this).name() << endl; } if(hasBorder()) // currently only used by Dialog itself - s.frameRect(_x, _y, _w, _h, _onTop ? kColor : kShadowColor); + s.frameRect(_x, _y, _w, _h, kColor); // Make all child widgets dirty Widget::setDirtyInChain(_firstWidget); diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index de81b4a1d..3966e5db9 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -54,7 +54,7 @@ class Dialog : public GuiObject void close(); bool isVisible() const override { return _visible; } - bool isOnTop() const { return _onTop; } + bool isOnTop() const { return true; } // TODO: remove virtual void setPosition(); virtual void drawDialog(); @@ -197,7 +197,6 @@ class Dialog : public GuiObject Widget* _cancelWidget{nullptr}; bool _visible{false}; - bool _onTop{true}; bool _processCancel{false}; string _title; int _th{0}; From 1c5d31db6004bc4e17dad2b42e57c51ae64f739c Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sat, 14 Nov 2020 12:07:44 +0100 Subject: [PATCH 32/70] improved dirty chain detection --- src/gui/Dialog.cxx | 52 +++++++++++++++++++------------------- src/gui/Dialog.hxx | 6 +++-- src/gui/EditableWidget.cxx | 2 +- src/gui/GuiObject.hxx | 7 +++-- src/gui/Widget.cxx | 29 ++++++++++++--------- src/gui/Widget.hxx | 4 ++- 6 files changed, 56 insertions(+), 44 deletions(-) diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index a2b9c14e3..84c4c9dac 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -147,20 +147,15 @@ void Dialog::setPosition() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Dialog::isChainDirty() const +void Dialog::setDirty() { - bool dirty = false; + _dirty = true; +} - // Recursively check if dialog or any chick dialogs or widgets are dirty - Widget* w = _firstWidget; - - while(w && !dirty) - { - dirty |= w->needsRedraw(); - w = w->_next; - } - - return dirty; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Dialog::setDirtyChain() +{ + _dirtyChain = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -440,6 +435,7 @@ void Dialog::drawDialog() if(isDirty()) { //cerr << "*** draw dialog " << typeid(*this).name() << " ***" << endl; + cerr << "d"; if(clearsBackground()) { @@ -458,7 +454,7 @@ void Dialog::drawDialog() } else { s.invalidate(); - cerr << "invalidate " << typeid(*this).name() << endl; + //cerr << "invalidate " << typeid(*this).name() << endl; } if(hasBorder()) // currently only used by Dialog itself s.frameRect(_x, _y, _w, _h, kColor); @@ -471,19 +467,6 @@ void Dialog::drawDialog() // Draw all children drawChain(); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Dialog::drawChain() -{ - Widget* w = _firstWidget; - - while(w) - { - if(w->needsRedraw()) - w->draw(); - w = w->_next; - } // Draw outlines for focused widgets // Don't change focus, since this will trigger lost and received @@ -497,6 +480,23 @@ void Dialog::drawChain() } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Dialog::drawChain() +{ + // Clear chain *before* drawing, because some widgets may set it again when + // being drawn (e.g. RomListWidget) + clearDirtyChain(); + + Widget* w = _firstWidget; + + while(w) + { + if(w->needsRedraw()) + w->draw(); + w = w->_next; + } +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Dialog::handleText(char text) { diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index 3966e5db9..0d0c57bc3 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -62,12 +62,14 @@ class Dialog : public GuiObject virtual void saveConfig() { } virtual void setDefaults() { } - void tick() override; - bool isChainDirty() const override; + void setDirty() override; + void setDirtyChain() override; void redraw(bool force = false); void drawChain() override; void render(); + void tick() override; + void addFocusWidget(Widget* w) override; void addToFocusList(WidgetArray& list) override; void addToFocusList(WidgetArray& list, TabWidget* w, int tabId); diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 8e19cb0a2..3e86ea947 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -73,7 +73,7 @@ void EditableWidget::tick() { _caretTimer = 0; _caretEnabled = !_caretEnabled; - _dirty = true; + setDirty(); } } Widget::tick(); diff --git a/src/gui/GuiObject.hxx b/src/gui/GuiObject.hxx index 893686e5f..c276698f8 100644 --- a/src/gui/GuiObject.hxx +++ b/src/gui/GuiObject.hxx @@ -92,10 +92,12 @@ class GuiObject : public CommandReceiver virtual bool isVisible() const = 0; - void setDirty() { _dirty = true; } + virtual void setDirty() = 0; + virtual void setDirtyChain() = 0; void clearDirty() { _dirty = false; } + void clearDirtyChain() { _dirtyChain = false; } bool isDirty() const { return _dirty; } - virtual bool isChainDirty() const = 0; + bool isChainDirty() const { return _dirtyChain; } // The GUI indicates if its underlying surface needs to be redrawn // and then re-rendered @@ -152,6 +154,7 @@ class GuiObject : public CommandReceiver protected: int _x{0}, _y{0}, _w{0}, _h{0}; bool _dirty{false}; + bool _dirtyChain{false}; uInt32 _flags{0}; Widget* _firstWidget{nullptr}; diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index e04da70d9..f33d27146 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -52,20 +52,21 @@ Widget::~Widget() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Widget::isChainDirty() const +void Widget::setDirty() { - bool dirty = false; + _dirty = true; - // Recursively check if widget or any child dialogs or widgets are dirty - Widget* w = _firstWidget; + // Inform the parent object that its children chain is dirty + _boss->setDirtyChain(); +} - while(w && !dirty) - { - dirty |= w->needsRedraw(); - w = w->_next; - } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Widget::setDirtyChain() +{ + _dirtyChain = true; - return dirty; + // Inform the parent object that its children chain is dirty + _boss->setDirtyChain(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -98,7 +99,8 @@ void Widget::draw() if(isDirty()) { - cerr << " *** draw widget " << typeid(*this).name() << " ***" << endl; + //cerr << " *** draw widget " << typeid(*this).name() << " ***" << endl; + cerr << "w"; FBSurface& s = _boss->dialog().surface(); @@ -163,6 +165,10 @@ void Widget::draw() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Widget::drawChain() { + // Clear chain *before* drawing, because some widgets may set it again when + // being drawn (e.g. RomListWidget) + clearDirtyChain(); + Widget* w = _firstWidget; while(w) @@ -508,7 +514,6 @@ void ButtonWidget::setBitmap(const uInt32* bitmap, int bmw, int bmh) _bmh = bmh; _bmw = bmw; - cerr << "setBitmap" << endl; setDirty(); } diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 38f8fecfa..5ee8ef0b1 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -70,7 +70,9 @@ class Widget : public GuiObject virtual bool handleEvent(Event::Type event) { return false; } void tick() override; - bool isChainDirty() const override; + + void setDirty() override; + void setDirtyChain() override; void draw() override; void drawChain() override; void receivedFocus(); From eca862b2403fd48a2a06b3c4dcc87bd2f979a31c Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sat, 14 Nov 2020 20:41:06 -0330 Subject: [PATCH 33/70] Eliminate graphical garbage in background in fullscreen mode for Linux/Mac. --- src/gui/DialogContainer.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 1c75273b4..e7fb0b81d 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -124,6 +124,10 @@ void DialogContainer::render() cerr << "full re-render " << typeid(*this).name() << endl; + // Make sure we start in a clean state (with zero'ed buffers) + if(!myOSystem.eventHandler().inTIAMode()) + myOSystem.frameBuffer().clear(); + // Render all dialogs myDialogStack.applyAll([&](Dialog*& d) { d->render(); From a030bc30b890d1252a60b25720e2e335a97fc552 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sat, 14 Nov 2020 22:35:05 -0330 Subject: [PATCH 34/70] Optimize/simplify dialog shading slightly - move creation to c'tor - apply position and size with one method instead of two --- src/common/FBSurfaceSDL2.cxx | 40 ++++++++++++++---------- src/common/FBSurfaceSDL2.hxx | 49 ++++++++++++++++++++++-------- src/emucore/FBSurface.hxx | 3 ++ src/gui/Dialog.cxx | 33 +++++++++----------- src/libretro/FBSurfaceLIBRETRO.hxx | 3 ++ 5 files changed, 80 insertions(+), 48 deletions(-) diff --git a/src/common/FBSurfaceSDL2.cxx b/src/common/FBSurfaceSDL2.cxx index 398c773ba..7f0ddb7d7 100644 --- a/src/common/FBSurfaceSDL2.cxx +++ b/src/common/FBSurfaceSDL2.cxx @@ -104,41 +104,49 @@ const Common::Rect& FBSurfaceSDL2::dstRect() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurfaceSDL2::setSrcPos(uInt32 x, uInt32 y) { - if(x != static_cast(mySrcR.x) || y != static_cast(mySrcR.y)) - { - setSrcPosInternal(x, y); + if(setSrcPosInternal(x, y)) reinitializeBlitter(); - } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurfaceSDL2::setSrcSize(uInt32 w, uInt32 h) { - if(w != static_cast(mySrcR.w) || h != static_cast(mySrcR.h)) - { - setSrcSizeInternal(w, h); + if(setSrcSizeInternal(w, h)) + reinitializeBlitter(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FBSurfaceSDL2::setSrcRect(const Common::Rect& r) +{ + const bool posChanged = setSrcPosInternal(r.x(), r.y()), + sizeChanged = setSrcSizeInternal(r.w(), r.h()); + + if(posChanged || sizeChanged) reinitializeBlitter(); - } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurfaceSDL2::setDstPos(uInt32 x, uInt32 y) { - if(x != static_cast(myDstR.x) || y != static_cast(myDstR.y)) - { - setDstPosInternal(x, y); + if(setDstPosInternal(x, y)) reinitializeBlitter(); - } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FBSurfaceSDL2::setDstSize(uInt32 w, uInt32 h) { - if(w != static_cast(myDstR.w) || h != static_cast(myDstR.h)) - { - setDstSizeInternal(w, h); + if(setDstSizeInternal(w, h)) + reinitializeBlitter(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FBSurfaceSDL2::setDstRect(const Common::Rect& r) +{ + const bool posChanged = setDstPosInternal(r.x(), r.y()), + sizeChanged = setDstSizeInternal(r.w(), r.h()); + + if(posChanged || sizeChanged) reinitializeBlitter(); - } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/FBSurfaceSDL2.hxx b/src/common/FBSurfaceSDL2.hxx index c19808f27..d8bfa0029 100644 --- a/src/common/FBSurfaceSDL2.hxx +++ b/src/common/FBSurfaceSDL2.hxx @@ -48,8 +48,11 @@ class FBSurfaceSDL2 : public FBSurface const Common::Rect& dstRect() const override; void setSrcPos(uInt32 x, uInt32 y) override; void setSrcSize(uInt32 w, uInt32 h) override; + void setSrcRect(const Common::Rect& r) override; void setDstPos(uInt32 x, uInt32 y) override; void setDstSize(uInt32 w, uInt32 h) override; + void setDstRect(const Common::Rect& r) override; + void setVisible(bool visible) override; void translateCoords(Int32& x, Int32& y) const override; @@ -67,21 +70,41 @@ class FBSurfaceSDL2 : public FBSurface void applyAttributes() override; private: - inline void setSrcPosInternal(uInt32 x, uInt32 y) { - mySrcR.x = x; mySrcR.y = y; - mySrcGUIR.moveTo(x, y); + inline bool setSrcPosInternal(uInt32 x, uInt32 y) { + if(x != static_cast(mySrcR.x) || y != static_cast(mySrcR.y)) + { + mySrcR.x = x; mySrcR.y = y; + mySrcGUIR.moveTo(x, y); + return true; + } + return false; } - inline void setSrcSizeInternal(uInt32 w, uInt32 h) { - mySrcR.w = w; mySrcR.h = h; - mySrcGUIR.setWidth(w); mySrcGUIR.setHeight(h); + inline bool setSrcSizeInternal(uInt32 w, uInt32 h) { + if(w != static_cast(mySrcR.w) || h != static_cast(mySrcR.h)) + { + mySrcR.w = w; mySrcR.h = h; + mySrcGUIR.setWidth(w); mySrcGUIR.setHeight(h); + return true; + } + return false; } - inline void setDstPosInternal(uInt32 x, uInt32 y) { - myDstR.x = x; myDstR.y = y; - myDstGUIR.moveTo(x, y); + inline bool setDstPosInternal(uInt32 x, uInt32 y) { + if(x != static_cast(myDstR.x) || y != static_cast(myDstR.y)) + { + myDstR.x = x; myDstR.y = y; + myDstGUIR.moveTo(x, y); + return true; + } + return false; } - inline void setDstSizeInternal(uInt32 w, uInt32 h) { - myDstR.w = w; myDstR.h = h; - myDstGUIR.setWidth(w); myDstGUIR.setHeight(h); + inline bool setDstSizeInternal(uInt32 w, uInt32 h) { + if(w != static_cast(myDstR.w) || h != static_cast(myDstR.h)) + { + myDstR.w = w; myDstR.h = h; + myDstGUIR.setWidth(w); myDstGUIR.setHeight(h); + return true; + } + return false; } void createSurface(uInt32 width, uInt32 height, const uInt32* data); @@ -103,7 +126,7 @@ class FBSurfaceSDL2 : public FBSurface {ScalingInterpolation::none}; SDL_Surface* mySurface{nullptr}; - SDL_Rect mySrcR{0, 0, 0, 0}, myDstR{0, 0, 0, 0}; + SDL_Rect mySrcR{-1, -1, -1, -1}, myDstR{-1, -1, -1, -1}; bool myIsVisible{true}; bool myIsStatic{false}; diff --git a/src/emucore/FBSurface.hxx b/src/emucore/FBSurface.hxx index ea851e6e6..71bddc289 100644 --- a/src/emucore/FBSurface.hxx +++ b/src/emucore/FBSurface.hxx @@ -292,11 +292,14 @@ class FBSurface These methods set the origin point and width/height for the specified service. They are defined as separate x/y and w/h methods since these items are sometimes set separately. + Other times they are set together, so we can use a Rect instead. */ virtual void setSrcPos(uInt32 x, uInt32 y) = 0; virtual void setSrcSize(uInt32 w, uInt32 h) = 0; + virtual void setSrcRect(const Common::Rect& r) = 0; virtual void setDstPos(uInt32 x, uInt32 y) = 0; virtual void setDstSize(uInt32 w, uInt32 h) = 0; + virtual void setDstRect(const Common::Rect& r) = 0; /** This method should be called to enable/disable showing the surface diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 84c4c9dac..6a0e96899 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -53,6 +53,18 @@ Dialog::Dialog(OSystem& instance, DialogContainer& parent, const GUI::Font& font { _flags = Widget::FLAG_ENABLED | Widget::FLAG_BORDER | Widget::FLAG_CLEARBG; setTitle(title); + + // Create shading surface + uInt32 data = 0xff000000; + + _shadeSurface = instance.frameBuffer().allocateSurface( + 1, 1, ScalingInterpolation::sharp, &data); + + FBSurface::Attributes& attr = _shadeSurface->attributes(); + + attr.blending = true; + attr.blendalpha = 25; // darken background dialogs by 25% + _shadeSurface->applyAttributes(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -223,7 +235,7 @@ void Dialog::redraw(bool force) // Draw this dialog setPosition(); drawDialog(); - // full rendering is caused in dialog container + // full rendering is caused in dialog container } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -251,24 +263,7 @@ void Dialog::render() { cerr << " shade " << typeid(*this).name() << endl; - if(_shadeSurface == nullptr) - { - uInt32 data = 0xff000000; - - _shadeSurface = instance().frameBuffer().allocateSurface( - 1, 1, ScalingInterpolation::sharp, &data); - - FBSurface::Attributes& attr = _shadeSurface->attributes(); - - attr.blending = true; - attr.blendalpha = 25; // darken background dialogs by 25% - _shadeSurface->applyAttributes(); - } - - const Common::Rect& rect = _surface->dstRect(); - _shadeSurface->setDstPos(rect.x(), rect.y()); - _shadeSurface->setDstSize(rect.w(), rect.h()); - + _shadeSurface->setDstRect(_surface->dstRect()); _shadeSurface->render(); } } diff --git a/src/libretro/FBSurfaceLIBRETRO.hxx b/src/libretro/FBSurfaceLIBRETRO.hxx index 3918ff673..f6bf3320b 100644 --- a/src/libretro/FBSurfaceLIBRETRO.hxx +++ b/src/libretro/FBSurfaceLIBRETRO.hxx @@ -44,8 +44,11 @@ class FBSurfaceLIBRETRO : public FBSurface const Common::Rect& dstRect() const override { return myDstGUIR; } void setSrcPos(uInt32 x, uInt32 y) override { } void setSrcSize(uInt32 w, uInt32 h) override { } + void setSrcRect(const Common::Rect& r) override { } void setDstPos(uInt32 x, uInt32 y) override { } void setDstSize(uInt32 w, uInt32 h) override { } + void setDstRect(const Common::Rect& r) override { } + void setVisible(bool visible) override { } void translateCoords(Int32& x, Int32& y) const override { } From a65e6eab99066fccf1dd062a758e63973202afb8 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sun, 15 Nov 2020 08:59:18 +0100 Subject: [PATCH 35/70] fixed garbage in fullscreen mode fixed breakpoints flickering in RomListWidget fixed palette update in VideoAudioDialog --- src/debugger/gui/RomListWidget.cxx | 2 ++ src/gui/DialogContainer.cxx | 4 ++++ src/gui/VideoAudioDialog.cxx | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 3504b2b37..473df388e 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -491,6 +491,8 @@ void RomListWidget::drawWidget(bool hilite) checkBreakPoint(dlist[pos].address, instance().debugger().cartDebug().getBank(dlist[pos].address))); myCheckList[i]->setDirty(); + // draw immediately, because chain order is not deterministic + myCheckList[i]->draw(); // Draw highlighted item in a frame if(_highlightedItem == pos) diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index e7fb0b81d..0f7713d0d 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -122,6 +122,10 @@ 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) diff --git a/src/gui/VideoAudioDialog.cxx b/src/gui/VideoAudioDialog.cxx index ba141cbeb..86db273b9 100644 --- a/src/gui/VideoAudioDialog.cxx +++ b/src/gui/VideoAudioDialog.cxx @@ -959,7 +959,16 @@ void VideoAudioDialog::handlePaletteUpdate() instance().frameBuffer().tiaSurface().paletteHandler().setAdjustables(paletteAdj); if(instance().hasConsole()) + { instance().frameBuffer().tiaSurface().paletteHandler().setPalette(); + + constexpr int NUM_LUMA = 8; + constexpr int NUM_CHROMA = 16; + + for(int idx = 0; idx < NUM_CHROMA; ++idx) + for(int lum = 0; lum < NUM_LUMA; ++lum) + myColor[idx][lum]->setDirty(); + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From ccdd167fca19ff8d4f4cac800f2d8154a19cf7e1 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sun, 15 Nov 2020 11:03:55 +0100 Subject: [PATCH 36/70] 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; From f4b23967975d643e8f8ffd89b07a5125aaa2aab4 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sun, 15 Nov 2020 16:41:01 +0100 Subject: [PATCH 37/70] attempt to fix 'shifting' dialogs (OptionsDialog) --- src/emucore/EventHandler.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 7d241101e..5eced0d94 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -2288,6 +2288,7 @@ void EventHandler::enterMenuMode(EventHandlerState state) void EventHandler::leaveMenuMode() { #ifdef GUI_SUPPORT + myOverlay->removeDialog(); // remove the base dialog from dialog stack setState(EventHandlerState::EMULATION); myOSystem.sound().mute(false); #endif From c3530863b5b4e5639aaa52bc359cccf296773966 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sun, 15 Nov 2020 15:16:06 -0330 Subject: [PATCH 38/70] Some simplifications to Point/Size/Rect classes. --- src/common/Rect.hxx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/common/Rect.hxx b/src/common/Rect.hxx index faf6677b6..708de9d86 100644 --- a/src/common/Rect.hxx +++ b/src/common/Rect.hxx @@ -44,8 +44,8 @@ struct Point if(c != 'x') x = y = 0; } - bool operator==(const Point & p) const { return x == p.x && y == p.y; } - bool operator!=(const Point & p) const { return x != p.x || y != p.y; } + bool operator==(const Point& p) const { return x == p.x && y == p.y; } + bool operator!=(const Point& p) const { return !(*this == p); } friend ostream& operator<<(ostream& os, const Point& p) { os << p.x << "x" << p.y; @@ -75,11 +75,11 @@ struct Size } bool operator==(const Size& s) const { return w == s.w && h == s.h; } - bool operator!=(const Size& s) const { return w != s.w || h != s.h; } - bool operator<(const Size& s) const { return w < s.w && h < s.h; } - bool operator<=(const Size& s) const { return w <= s.w && h <= s.h; } - bool operator>(const Size& s) const { return w > s.w || h > s.h; } - bool operator>=(const Size& s) const { return w >= s.w || h >= s.h; } + bool operator< (const Size& s) const { return w < s.w && h < s.h; } + bool operator> (const Size& s) const { return w > s.w || h > s.h; } + bool operator!=(const Size& s) const { return !(*this == s); } + bool operator<=(const Size& s) const { return !(*this > s); } + bool operator>=(const Size& s) const { return !(*this < s); } friend ostream& operator<<(ostream& os, const Size& s) { os << s.w << "x" << s.h; @@ -175,6 +175,11 @@ struct Rect return r.left != x || r.top != y; } + bool operator==(const Rect& r) const { + return top == r.top && left == r.left && bottom == r.bottom && right == r.right; + } + bool operator!=(const Rect& r) const { return !(*this == r); } + friend ostream& operator<<(ostream& os, const Rect& r) { os << r.point() << "," << r.size(); return os; From 7144ff496493248b2306e43324d291cacd5f9d7b Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Sun, 15 Nov 2020 19:55:35 +0100 Subject: [PATCH 39/70] Enable rtti in makefile. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 168ae178d..021e802dc 100644 --- a/Makefile +++ b/Makefile @@ -48,11 +48,11 @@ endif CXXFLAGS+= -Wall -Wextra -Wno-unused-parameter ifdef HAVE_GCC - CXXFLAGS+= -Wno-multichar -Wunused -fno-rtti -Woverloaded-virtual -Wnon-virtual-dtor -std=c++14 + CXXFLAGS+= -Wno-multichar -Wunused -fno-rtti -Woverloaded-virtual -Wnon-virtual-dtor -std=c++14 -frtti endif ifdef HAVE_CLANG - CXXFLAGS+= -Wno-multichar -Wunused -fno-rtti -Woverloaded-virtual -Wnon-virtual-dtor -std=c++14 + CXXFLAGS+= -Wno-multichar -Wunused -fno-rtti -Woverloaded-virtual -Wnon-virtual-dtor -std=c++14 -frtti endif ifdef CLANG_WARNINGS From d9e23fd9ebdfe94d76a3196413b5304b4b1fb007 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Sun, 15 Nov 2020 23:16:26 +0100 Subject: [PATCH 40/70] Remove overkill. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 021e802dc..90279a56a 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,7 @@ ifdef HAVE_GCC endif ifdef HAVE_CLANG - CXXFLAGS+= -Wno-multichar -Wunused -fno-rtti -Woverloaded-virtual -Wnon-virtual-dtor -std=c++14 -frtti + CXXFLAGS+= -Wno-multichar -Wunused -frtti -Woverloaded-virtual -Wnon-virtual-dtor -std=c++14 endif ifdef CLANG_WARNINGS From 120c3062864f208ddbb2f385e50deeef3dbbcd1b Mon Sep 17 00:00:00 2001 From: thrust26 Date: Mon, 16 Nov 2020 12:26:01 +0100 Subject: [PATCH 41/70] added initial tool tip functionality removed duplicate _editMode in DataGridWidget --- src/debugger/gui/DataGridWidget.cxx | 1 + src/debugger/gui/DataGridWidget.hxx | 1 - src/gui/Dialog.cxx | 8 +++ src/gui/Dialog.hxx | 4 +- src/gui/EditTextWidget.cxx | 1 + src/gui/LauncherDialog.cxx | 3 ++ src/gui/ToolTip.cxx | 79 ++++++++++++++++++++++++----- src/gui/ToolTip.hxx | 60 ++++++++++++++++++---- src/gui/Widget.cxx | 12 ++++- src/gui/Widget.hxx | 4 +- 10 files changed, 147 insertions(+), 26 deletions(-) diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 32358dd05..877d96c6a 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -45,6 +45,7 @@ DataGridWidget::DataGridWidget(GuiObject* boss, const GUI::Font& font, _base(base) { _flags = Widget::FLAG_ENABLED | Widget::FLAG_RETAIN_FOCUS | Widget::FLAG_WANTS_RAWDATA; + _editMode = false; // Make sure all lists contain some default values _hiliteList.clear(); diff --git a/src/debugger/gui/DataGridWidget.hxx b/src/debugger/gui/DataGridWidget.hxx index 114097b01..82eca7fbc 100644 --- a/src/debugger/gui/DataGridWidget.hxx +++ b/src/debugger/gui/DataGridWidget.hxx @@ -128,7 +128,6 @@ class DataGridWidget : public EditableWidget BoolArray _changedList; BoolArray _hiliteList; - bool _editMode{false}; int _selectedItem{0}; StellaKey _currentKeyDown{KBDK_UNKNOWN}; string _backupString; diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 18dd20cbf..f58d98536 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -27,6 +27,7 @@ #include "Dialog.hxx" #include "Widget.hxx" #include "TabWidget.hxx" +#include "ToolTip.hxx" #include "ContextMenu.hxx" #include "PopUpWidget.hxx" @@ -65,6 +66,8 @@ Dialog::Dialog(OSystem& instance, DialogContainer& parent, const GUI::Font& font attr.blending = true; attr.blendalpha = 25; // darken background dialogs by 25% _shadeSurface->applyAttributes(); + + _toolTip = make_unique(instance, *this, font); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -266,6 +269,8 @@ void Dialog::render() _shadeSurface->setDstRect(_surface->dstRect()); _shadeSurface->render(); } + + _toolTip->render(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -588,6 +593,9 @@ void Dialog::handleMouseMoved(int x, int y) { Widget* w; + // Update mouse coordinates for tooltips + _toolTip->update(x, y); + if(_focusedWidget && !_dragWidget) { w = _focusedWidget; diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index 0d0c57bc3..b92b8e383 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -26,6 +26,7 @@ class OSystem; class DialogContainer; class TabWidget; class CommandSender; +class ToolTip; #include "Stack.hxx" #include "Widget.hxx" @@ -122,6 +123,7 @@ class Dialog : public GuiObject */ bool shouldResize(uInt32& w, uInt32& h) const; + ToolTip& tooltip() { return *_toolTip; }; //bool enableToolTip(); //void showToolTip(int x, int y); //void hideToolTip(); @@ -203,7 +205,7 @@ class Dialog : public GuiObject string _title; int _th{0}; int _layer{0}; - int _toolTipTimer{0}; + unique_ptr _toolTip; Common::FixedStack> mySurfaceStack; diff --git a/src/gui/EditTextWidget.cxx b/src/gui/EditTextWidget.cxx index c818f3cf0..d3e4587a5 100644 --- a/src/gui/EditTextWidget.cxx +++ b/src/gui/EditTextWidget.cxx @@ -18,6 +18,7 @@ #include "OSystem.hxx" #include "FBSurface.hxx" #include "Dialog.hxx" +#include "ToolTip.hxx" #include "Font.hxx" #include "EditTextWidget.hxx" diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 8018bcb44..abae25742 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -120,12 +120,14 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent, // Show the filter input field xpos -= fwidth + LBL_GAP; myPattern = new EditTextWidget(this, font, xpos, ypos - 2, fwidth, lineHeight, ""); + myPattern->setToolTip("Enter a filter text to reduce file list."); // Show the "Filter" label xpos -= lwidth3 + LBL_GAP; new StaticTextWidget(this, font, xpos, ypos, lblFilter); // Show the checkbox for all files xpos -= lwidth2 + LBL_GAP * 3; myAllFiles = new CheckboxWidget(this, font, xpos, ypos, lblAllFiles, kAllfilesCmd); + myAllFiles->setToolTip("Uncheck to show ROM files only."); wid.push_back(myAllFiles); wid.push_back(myPattern); } @@ -178,6 +180,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent, #ifndef BSPF_MACOS myStartButton = new ButtonWidget(this, font, xpos, ypos, (buttonWidth + 0) / 4, buttonHeight, "Select", kLoadROMCmd); + myStartButton->setToolTip("Start emulation of selected ROM."); wid.push_back(myStartButton); xpos += (buttonWidth + 0) / 4 + BUTTON_GAP; diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index 53cbea0c3..72ecb47ad 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -16,25 +16,80 @@ //============================================================================ #include "OSystem.hxx" +#include "FrameBuffer.hxx" +#include "FBSurface.hxx" + #include "Font.hxx" #include "Dialog.hxx" -#include "DialogContainer.hxx" +#include "Widget.hxx" #include "ToolTip.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -ToolTip::ToolTip(OSystem& instance, DialogContainer& parent, - const GUI::Font& font) - : Dialog(instance, parent, font) +ToolTip::ToolTip(OSystem& instance, Dialog& dialog, const GUI::Font& font) + : myDialog(dialog), + myFont(font) { - const int lineHeight = font.getLineHeight(), - fontWidth = font.getMaxCharWidth(), - fontHeight = font.getFontHeight(), - buttonWidth = font.getStringWidth("Previous") + fontWidth * 2.5, - buttonHeight = font.getLineHeight() * 1.25; - const int VBORDER = fontHeight / 2; - const int HBORDER = fontWidth * 1.25; - const int VGAP = fontHeight / 4; + const int fontWidth = font.getMaxCharWidth(), + fontHeight = font.getFontHeight(); + + myTextXOfs = fontHeight < 24 ? 5 : 8; //3 : 5; + myWidth = myTextXOfs * 2 + fontWidth * MAX_LEN; + myHeight = fontHeight + TEXT_Y_OFS * 2; + mySurface = instance.frameBuffer().allocateSurface(myWidth, myHeight); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ToolTip::request(Widget* widget) +{ + if(myWidget != widget) + { + release(); + } + if(myTimer == DELAY_TIME) + { + string text = widget->getToolTip(); + int width = std::min(myWidth, myFont.getStringWidth(text) + myTextXOfs * 2); + int yOffset = 20; // TODO: query cursor height + + myWidget = widget; + // TODO: limit to app or screen size + mySurface->setSrcSize(width, myHeight); + mySurface->setDstSize(width, myHeight); + mySurface->setDstPos(myPos.x, myPos.y + yOffset); + + mySurface->frameRect(0, 0, width, myHeight, kColor); + mySurface->fillRect(1, 1, width - 2, myHeight - 2, kWidColor); + mySurface->drawString(myFont, text, myTextXOfs, TEXT_Y_OFS, + width - myTextXOfs * 2, myHeight - TEXT_Y_OFS * 2, kTextColor); + myDialog.setDirtyChain(); + } + myTimer++; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ToolTip::release() +{ + if(myWidget != nullptr) + { + myTimer = 0; + myWidget = nullptr; + myDialog.setDirtyChain(); + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ToolTip::render() +{ + if(myWidget != nullptr) + mySurface->render(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ToolTip::update(int x, int y) +{ + if(myWidget != nullptr && x != myPos.x || y != myPos.y) + release(); + myPos.x = x; + myPos.y = y; +} diff --git a/src/gui/ToolTip.hxx b/src/gui/ToolTip.hxx index 2066bd3df..7ba4dc044 100644 --- a/src/gui/ToolTip.hxx +++ b/src/gui/ToolTip.hxx @@ -18,22 +18,62 @@ #ifndef TOOL_TIP_HXX #define TOOL_TIP_HXX -class OSystem; -class DialogContainer; - /** * Class for providing tooltip functionality * * @author Thomas Jentzsch */ -class ToolTip : public Dialog -{ - public: - public: - ToolTip(OSystem& instance, DialogContainer& parent, - const GUI::Font& font); - ~ToolTip() override = default; +class OSystem; +class FBSurface; +class Widget; + +#include "Rect.hxx" + +class ToolTip +{ +public: + // Maximum tooltip length + static constexpr int MAX_LEN = 60; + + ToolTip(OSystem& instance, Dialog& dialog, const GUI::Font& font); + ~ToolTip() = default; + + /** + Request a tooltip display + */ + void request(Widget* widget); + + + /** + Hide an existing tooltip (if displayed) + */ + void release(); + + /** + Update with current mouse position + */ + void update(int x, int y); + + /* + Render the tooltip + */ + void render(); + +private: + static constexpr uInt32 DELAY_TIME = 45; // display delay + static constexpr int TEXT_Y_OFS = 2; + + const GUI::Font& myFont; + Dialog& myDialog; + + Widget* myWidget{nullptr}; + uInt32 myTimer{0}; + Common::Point myPos; + int myWidth{0}; + int myHeight{0}; + int myTextXOfs{0}; + shared_ptr mySurface; }; #endif diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index f33d27146..f37f8840c 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -21,6 +21,7 @@ #include "bspf.hxx" #include "Command.hxx" #include "Dialog.hxx" +#include "ToolTip.hxx" #include "FBSurface.hxx" #include "GuiObject.hxx" #include "OSystem.hxx" @@ -74,7 +75,8 @@ void Widget::tick() { if(isEnabled()) { - //if(_hasFocus && hasToolTip()) + if(isHighlighted() && hasToolTip()) + dialog().tooltip().request(this); //{ // if(dialog().enableToolTip()) // dialog().showToolTip(10, 10); @@ -208,6 +210,14 @@ void Widget::setEnabled(bool e) else clearFlags(Widget::FLAG_ENABLED); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Widget::setToolTip(const string& text) +{ + assert(text.length() <= ToolTip::MAX_LEN); + + _toolTipText = text; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Widget* Widget::findWidgetInChain(Widget* w, int x, int y) { diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 5ee8ef0b1..98e36863f 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -87,6 +87,7 @@ class Widget : public GuiObject bool isEnabled() const { return _flags & FLAG_ENABLED; } bool isVisible() const override { return !(_flags & FLAG_INVISIBLE); } + bool isHighlighted() const { return _flags & FLAG_HILITED; } virtual bool wantsFocus() const { return _flags & FLAG_RETAIN_FOCUS; } bool wantsTab() const { return _flags & FLAG_WANTS_TAB; } bool wantsRaw() const { return _flags & FLAG_WANTS_RAWDATA; } @@ -102,7 +103,8 @@ class Widget : public GuiObject void setBGColorHi(ColorId color) { _bgcolorhi = color; setDirty(); } void setShadowColor(ColorId color) { _shadowcolor = color; setDirty(); } - void setToolTip(const string& text) { _toolTipText = text; } + void setToolTip(const string& text); + const string& getToolTip() const { return _toolTipText; } bool hasToolTip() const { return !_toolTipText.empty(); } virtual void loadConfig() { } From f55931f2e002b49002e42736de173427fca02366 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Mon, 16 Nov 2020 09:50:50 -0330 Subject: [PATCH 42/70] Fix warning, and add ToolTip to Linux build. --- src/gui/Dialog.hxx | 2 +- src/gui/module.mk | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index b92b8e383..b134d7d37 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -123,7 +123,7 @@ class Dialog : public GuiObject */ bool shouldResize(uInt32& w, uInt32& h) const; - ToolTip& tooltip() { return *_toolTip; }; + ToolTip& tooltip() { return *_toolTip; } //bool enableToolTip(); //void showToolTip(int x, int y); //void hideToolTip(); diff --git a/src/gui/module.mk b/src/gui/module.mk index a2f8489fd..4be9b66ad 100644 --- a/src/gui/module.mk +++ b/src/gui/module.mk @@ -49,6 +49,7 @@ MODULE_OBJS := \ src/gui/TimeLineWidget.o \ src/gui/TimeMachineDialog.o \ src/gui/TimeMachine.o \ + src/gui/ToolTip.o \ src/gui/UndoHandler.o \ src/gui/UIDialog.o \ src/gui/VideoAudioDialog.o \ From b68a6fa600826817bd27ab0d61014d78d6a653f7 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Mon, 16 Nov 2020 17:41:24 +0100 Subject: [PATCH 43/70] fixed tool tips for HiDPI added tool tip repositioning if exceeding surface --- src/gui/ToolTip.cxx | 34 +++++++++++++++++++++++++--------- src/gui/ToolTip.hxx | 14 ++++++++------ src/gui/VideoAudioDialog.cxx | 1 + 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index 72ecb47ad..30100009a 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -16,11 +16,10 @@ //============================================================================ #include "OSystem.hxx" +#include "Dialog.hxx" +#include "Font.hxx" #include "FrameBuffer.hxx" #include "FBSurface.hxx" - -#include "Font.hxx" -#include "Dialog.hxx" #include "Widget.hxx" #include "ToolTip.hxx" @@ -36,7 +35,8 @@ ToolTip::ToolTip(OSystem& instance, Dialog& dialog, const GUI::Font& font) myTextXOfs = fontHeight < 24 ? 5 : 8; //3 : 5; myWidth = myTextXOfs * 2 + fontWidth * MAX_LEN; myHeight = fontHeight + TEXT_Y_OFS * 2; - mySurface = instance.frameBuffer().allocateSurface(myWidth, myHeight); + mySurface = myDialog.instance().frameBuffer().allocateSurface(myWidth, myHeight); + myScale = myDialog.instance().frameBuffer().hidpiScaleFactor(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -48,15 +48,31 @@ void ToolTip::request(Widget* widget) } if(myTimer == DELAY_TIME) { + const uInt32 VGAP = 1; + const uInt32 hCursor = 19; // TODO: query cursor height string text = widget->getToolTip(); - int width = std::min(myWidth, myFont.getStringWidth(text) + myTextXOfs * 2); - int yOffset = 20; // TODO: query cursor height + uInt32 width = std::min(myWidth, myFont.getStringWidth(text) + myTextXOfs * 2); + // Note: These include HiDPI scaling: + const Common::Rect imageRect = myDialog.instance().frameBuffer().imageRect(); + const Common::Rect dialogRect = myDialog.surface().dstRect(); + // Limit to app or screen size and adjust position + const Int32 xAbs = myPos.x + dialogRect.x() / myScale; + const uInt32 yAbs = myPos.y + dialogRect.y() / myScale; + Int32 x = std::min(xAbs, Int32(imageRect.w() / myScale - width)); + const uInt32 y = (yAbs + myHeight + hCursor > imageRect.h() / myScale) + ? yAbs - myHeight - VGAP + : yAbs + hCursor / myScale + VGAP; + + if(x < 0) + { + x = 0; + width = imageRect.w() / myScale; + } myWidget = widget; - // TODO: limit to app or screen size mySurface->setSrcSize(width, myHeight); - mySurface->setDstSize(width, myHeight); - mySurface->setDstPos(myPos.x, myPos.y + yOffset); + mySurface->setDstSize(width * myScale, myHeight * myScale); + mySurface->setDstPos(x * myScale, y * myScale); mySurface->frameRect(0, 0, width, myHeight, kColor); mySurface->fillRect(1, 1, width - 2, myHeight - 2, kWidColor); diff --git a/src/gui/ToolTip.hxx b/src/gui/ToolTip.hxx index 7ba4dc044..d3164a09d 100644 --- a/src/gui/ToolTip.hxx +++ b/src/gui/ToolTip.hxx @@ -25,8 +25,9 @@ */ class OSystem; -class FBSurface; +class Dialog; class Widget; +class FBSurface; #include "Rect.hxx" @@ -34,7 +35,7 @@ class ToolTip { public: // Maximum tooltip length - static constexpr int MAX_LEN = 60; + static constexpr uInt32 MAX_LEN = 80; ToolTip(OSystem& instance, Dialog& dialog, const GUI::Font& font); ~ToolTip() = default; @@ -64,15 +65,16 @@ private: static constexpr uInt32 DELAY_TIME = 45; // display delay static constexpr int TEXT_Y_OFS = 2; - const GUI::Font& myFont; Dialog& myDialog; + const GUI::Font& myFont; Widget* myWidget{nullptr}; uInt32 myTimer{0}; Common::Point myPos; - int myWidth{0}; - int myHeight{0}; - int myTextXOfs{0}; + uInt32 myWidth{0}; + uInt32 myHeight{0}; + uInt32 myScale{1}; + uInt32 myTextXOfs{0}; shared_ptr mySurface; }; diff --git a/src/gui/VideoAudioDialog.cxx b/src/gui/VideoAudioDialog.cxx index 86db273b9..8d2c3be6d 100644 --- a/src/gui/VideoAudioDialog.cxx +++ b/src/gui/VideoAudioDialog.cxx @@ -122,6 +122,7 @@ void VideoAudioDialog::addDisplayTab() myRenderer = new PopUpWidget(myTab, _font, xpos, ypos, pwidth, lineHeight, instance().frameBuffer().supportedRenderers(), "Renderer ", lwidth); + myRenderer->setToolTip("Select renderer used for displaying screen."); wid.push_back(myRenderer); const int swidth = myRenderer->getWidth() - lwidth; ypos += lineHeight + VGAP; From c6068104d937a573abd7269decc318c7268c438b Mon Sep 17 00:00:00 2001 From: thrust26 Date: Mon, 16 Nov 2020 18:59:01 +0100 Subject: [PATCH 44/70] added a separate flag for mouse focus --- src/debugger/gui/DataGridWidget.cxx | 14 --------- src/debugger/gui/DataGridWidget.hxx | 2 -- src/debugger/gui/RomListWidget.cxx | 14 --------- src/debugger/gui/RomListWidget.hxx | 2 -- src/debugger/gui/TiaZoomWidget.cxx | 10 +----- src/debugger/gui/TiaZoomWidget.hxx | 3 -- src/debugger/gui/ToggleWidget.cxx | 14 --------- src/debugger/gui/ToggleWidget.hxx | 2 -- src/gui/CheckListWidget.cxx | 14 --------- src/gui/CheckListWidget.hxx | 4 --- src/gui/EditTextWidget.cxx | 14 --------- src/gui/EditTextWidget.hxx | 2 -- src/gui/GuiObject.hxx | 3 +- src/gui/PopUpWidget.cxx | 14 --------- src/gui/PopUpWidget.hxx | 2 -- src/gui/ScrollBarWidget.cxx | 10 +----- src/gui/ScrollBarWidget.hxx | 1 - src/gui/StringListWidget.cxx | 14 --------- src/gui/StringListWidget.hxx | 2 -- src/gui/TabWidget.cxx | 14 --------- src/gui/TabWidget.hxx | 4 +-- src/gui/Widget.cxx | 48 +++++++++-------------------- src/gui/Widget.hxx | 9 ++---- 23 files changed, 24 insertions(+), 192 deletions(-) diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 877d96c6a..63c637ecd 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -240,20 +240,6 @@ void DataGridWidget::setRange(int lower, int upper) _upperBound = std::min(1 << _bits, upper); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DataGridWidget::handleMouseEntered() -{ - if(isEnabled()) - setFlags(Widget::FLAG_HILITED); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DataGridWidget::handleMouseLeft() -{ - if(isEnabled()) - clearFlags(Widget::FLAG_HILITED); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DataGridWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) { diff --git a/src/debugger/gui/DataGridWidget.hxx b/src/debugger/gui/DataGridWidget.hxx index 82eca7fbc..9096879f3 100644 --- a/src/debugger/gui/DataGridWidget.hxx +++ b/src/debugger/gui/DataGridWidget.hxx @@ -101,8 +101,6 @@ class DataGridWidget : public EditableWidget void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; void handleMouseWheel(int x, int y, int direction) override; - void handleMouseEntered() override; - void handleMouseLeft() override; bool handleText(char text) override; bool handleKeyDown(StellaKey key, StellaMod mod) override; bool handleKeyUp(StellaKey key, StellaMod mod) override; diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 473df388e..58d392ee9 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -284,20 +284,6 @@ void RomListWidget::handleMouseWheel(int x, int y, int direction) myScrollBar->handleMouseWheel(x, y, direction); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void RomListWidget::handleMouseEntered() -{ - if(isEnabled()) - setFlags(Widget::FLAG_HILITED); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void RomListWidget::handleMouseLeft() -{ - if(isEnabled()) - clearFlags(Widget::FLAG_HILITED); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool RomListWidget::handleText(char text) { diff --git a/src/debugger/gui/RomListWidget.hxx b/src/debugger/gui/RomListWidget.hxx index ec557f606..37473d12f 100644 --- a/src/debugger/gui/RomListWidget.hxx +++ b/src/debugger/gui/RomListWidget.hxx @@ -60,8 +60,6 @@ class RomListWidget : public EditableWidget void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; void handleMouseWheel(int x, int y, int direction) override; - void handleMouseEntered() override; - void handleMouseLeft() override; bool handleText(char text) override; bool handleKeyDown(StellaKey key, StellaMod mod) override; bool handleKeyUp(StellaKey key, StellaMod mod) override; diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index 759e95516..0895c51a8 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -178,19 +178,11 @@ void TiaZoomWidget::handleMouseMoved(int x, int y) } } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TiaZoomWidget::handleMouseEntered() -{ - if(isEnabled()) - setFlags(Widget::FLAG_HILITED); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaZoomWidget::handleMouseLeft() { - if(isEnabled()) - clearFlags(Widget::FLAG_HILITED); myMouseMoving = false; + Widget::handleMouseLeft(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/TiaZoomWidget.hxx b/src/debugger/gui/TiaZoomWidget.hxx index d4d3a9835..7169645bf 100644 --- a/src/debugger/gui/TiaZoomWidget.hxx +++ b/src/debugger/gui/TiaZoomWidget.hxx @@ -34,9 +34,6 @@ class TiaZoomWidget : public Widget, public CommandSender void loadConfig() override; void setPos(int x, int y); - protected: - void handleMouseEntered() override; - private: void zoom(int level); void recalc(); diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index ea3253d8a..4f9ddccfa 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -40,20 +40,6 @@ ToggleWidget::ToggleWidget(GuiObject* boss, const GUI::Font& font, Widget::FLAG_WANTS_RAWDATA; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ToggleWidget::handleMouseEntered() -{ - if(isEnabled()) - setFlags(Widget::FLAG_HILITED); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ToggleWidget::handleMouseLeft() -{ - if(isEnabled()) - clearFlags(Widget::FLAG_HILITED); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ToggleWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) { diff --git a/src/debugger/gui/ToggleWidget.hxx b/src/debugger/gui/ToggleWidget.hxx index 67777a13a..0d6759467 100644 --- a/src/debugger/gui/ToggleWidget.hxx +++ b/src/debugger/gui/ToggleWidget.hxx @@ -68,8 +68,6 @@ class ToggleWidget : public Widget, public CommandSender void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; - void handleMouseEntered() override; - void handleMouseLeft() override; bool handleKeyDown(StellaKey key, StellaMod mod) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override; diff --git a/src/gui/CheckListWidget.cxx b/src/gui/CheckListWidget.cxx index 079989376..6d80fcc07 100644 --- a/src/gui/CheckListWidget.cxx +++ b/src/gui/CheckListWidget.cxx @@ -46,20 +46,6 @@ CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font, } } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CheckListWidget::handleMouseEntered() -{ - setFlags(Widget::FLAG_HILITED); - setDirty(); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CheckListWidget::handleMouseLeft() -{ - clearFlags(Widget::FLAG_HILITED); - setDirty(); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CheckListWidget::setList(const StringList& list, const BoolArray& state) { diff --git a/src/gui/CheckListWidget.hxx b/src/gui/CheckListWidget.hxx index 625875a9d..2ebec0d5d 100644 --- a/src/gui/CheckListWidget.hxx +++ b/src/gui/CheckListWidget.hxx @@ -42,10 +42,6 @@ class CheckListWidget : public ListWidget bool getState(int line); bool getSelectedState() { return getState(_selectedItem); } - protected: - void handleMouseEntered() override; - void handleMouseLeft() override; - private: bool handleEvent(Event::Type e) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override; diff --git a/src/gui/EditTextWidget.cxx b/src/gui/EditTextWidget.cxx index d3e4587a5..61785bd78 100644 --- a/src/gui/EditTextWidget.cxx +++ b/src/gui/EditTextWidget.cxx @@ -49,20 +49,6 @@ void EditTextWidget::setText(const string& str, bool changed) _changed = changed; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void EditTextWidget::handleMouseEntered() -{ - if(isEnabled() && isEditable()) - setFlags(Widget::FLAG_HILITED); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void EditTextWidget::handleMouseLeft() -{ - if(isEnabled() && isEditable()) - clearFlags(Widget::FLAG_HILITED); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EditTextWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) { diff --git a/src/gui/EditTextWidget.hxx b/src/gui/EditTextWidget.hxx index fe063e042..e7c21beff 100644 --- a/src/gui/EditTextWidget.hxx +++ b/src/gui/EditTextWidget.hxx @@ -54,8 +54,6 @@ class EditTextWidget : public EditableWidget Common::Rect getEditRect() const override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; - void handleMouseEntered() override; - void handleMouseLeft() override; protected: string _backupString; diff --git a/src/gui/GuiObject.hxx b/src/gui/GuiObject.hxx index c276698f8..490df4344 100644 --- a/src/gui/GuiObject.hxx +++ b/src/gui/GuiObject.hxx @@ -52,7 +52,8 @@ class GuiObject : public CommandReceiver FLAG_RETAIN_FOCUS = 1 << 6, FLAG_WANTS_TAB = 1 << 7, FLAG_WANTS_RAWDATA = 1 << 8, - FLAG_NOBG = 1 << 9 + FLAG_NOBG = 1 << 9, + FLAG_MOUSE_FOCUS = 1 << 10 }; public: diff --git a/src/gui/PopUpWidget.cxx b/src/gui/PopUpWidget.cxx index ccf6af1aa..06c726779 100644 --- a/src/gui/PopUpWidget.cxx +++ b/src/gui/PopUpWidget.cxx @@ -158,20 +158,6 @@ void PopUpWidget::handleMouseWheel(int x, int y, int direction) } } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PopUpWidget::handleMouseEntered() -{ - if(isEnabled()) - setFlags(Widget::FLAG_HILITED); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void PopUpWidget::handleMouseLeft() -{ - if(isEnabled()) - clearFlags(Widget::FLAG_HILITED); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool PopUpWidget::handleEvent(Event::Type e) { diff --git a/src/gui/PopUpWidget.hxx b/src/gui/PopUpWidget.hxx index deb0af30c..babe28686 100644 --- a/src/gui/PopUpWidget.hxx +++ b/src/gui/PopUpWidget.hxx @@ -70,8 +70,6 @@ class PopUpWidget : public EditableWidget protected: void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; void handleMouseWheel(int x, int y, int direction) override; - void handleMouseEntered() override; - void handleMouseLeft() override; bool handleEvent(Event::Type e) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override; diff --git a/src/gui/ScrollBarWidget.cxx b/src/gui/ScrollBarWidget.cxx index 04a99c732..73e89bc78 100644 --- a/src/gui/ScrollBarWidget.cxx +++ b/src/gui/ScrollBarWidget.cxx @@ -240,19 +240,11 @@ void ScrollBarWidget::checkBounds(int old_pos) } } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ScrollBarWidget::handleMouseEntered() -{ - if(isEnabled()) - setFlags(Widget::FLAG_HILITED); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ScrollBarWidget::handleMouseLeft() { _part = Part::None; - if(isEnabled()) - clearFlags(Widget::FLAG_HILITED); + Widget::handleMouseLeft(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/ScrollBarWidget.hxx b/src/gui/ScrollBarWidget.hxx index 1d1b4c34a..0c29fde17 100644 --- a/src/gui/ScrollBarWidget.hxx +++ b/src/gui/ScrollBarWidget.hxx @@ -49,7 +49,6 @@ class ScrollBarWidget : public Widget, public CommandSender void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; void handleMouseMoved(int x, int y) override; bool handleMouseClicks(int x, int y, MouseButton b) override; - void handleMouseEntered() override; void handleMouseLeft() override; void setArrows(); diff --git a/src/gui/StringListWidget.cxx b/src/gui/StringListWidget.cxx index 5032654e6..ad5f1e7ec 100644 --- a/src/gui/StringListWidget.cxx +++ b/src/gui/StringListWidget.cxx @@ -50,20 +50,6 @@ void StringListWidget::setList(const StringList& list) ListWidget::recalc(); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void StringListWidget::handleMouseEntered() -{ - if(isEnabled()) - setFlags(Widget::FLAG_HILITED); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void StringListWidget::handleMouseLeft() -{ - if(isEnabled()) - clearFlags(Widget::FLAG_HILITED); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void StringListWidget::drawWidget(bool hilite) { diff --git a/src/gui/StringListWidget.hxx b/src/gui/StringListWidget.hxx index ee3b56e97..ed5874b91 100644 --- a/src/gui/StringListWidget.hxx +++ b/src/gui/StringListWidget.hxx @@ -33,8 +33,6 @@ class StringListWidget : public ListWidget bool wantsFocus() const override { return true; } 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(); } diff --git a/src/gui/TabWidget.cxx b/src/gui/TabWidget.cxx index 5e96338ab..28b383f6c 100644 --- a/src/gui/TabWidget.cxx +++ b/src/gui/TabWidget.cxx @@ -213,20 +213,6 @@ void TabWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) } } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TabWidget::handleMouseEntered() -{ - //if(isEnabled()) - // setFlags(Widget::FLAG_HILITED); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TabWidget::handleMouseLeft() -{ - //if(isEnabled()) - // clearFlags(Widget::FLAG_HILITED); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TabWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) { diff --git a/src/gui/TabWidget.hxx b/src/gui/TabWidget.hxx index 1f581df5c..141b29497 100644 --- a/src/gui/TabWidget.hxx +++ b/src/gui/TabWidget.hxx @@ -63,8 +63,8 @@ class TabWidget : public Widget, public CommandSender protected: void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; - void handleMouseEntered() override; - void handleMouseLeft() override; + void handleMouseEntered() override {} + void handleMouseLeft() override {} void handleCommand(CommandSender* sender, int cmd, int data, int id) override; bool handleEvent(Event::Type event) override; diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index f37f8840c..991207655 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -75,12 +75,8 @@ void Widget::tick() { if(isEnabled()) { - if(isHighlighted() && hasToolTip()) + if(hasMouseFocus() && hasToolTip()) dialog().tooltip().request(this); - //{ - // if(dialog().enableToolTip()) - // dialog().showToolTip(10, 10); - //} // Recursively tick widget and all child dialogs and widgets Widget* w = _firstWidget; @@ -181,6 +177,20 @@ void Widget::drawChain() } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Widget::handleMouseEntered() +{ + if(isEnabled()) + setFlags(Widget::FLAG_HILITED | Widget::FLAG_MOUSE_FOCUS); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Widget::handleMouseLeft() +{ + if(isEnabled()) + clearFlags(Widget::FLAG_HILITED | Widget::FLAG_MOUSE_FOCUS); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Widget::receivedFocus() { @@ -465,20 +475,6 @@ ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font, _bmh = bmh; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ButtonWidget::handleMouseEntered() -{ - if(isEnabled()) - setFlags(Widget::FLAG_HILITED); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ButtonWidget::handleMouseLeft() -{ - if(isEnabled()) - clearFlags(Widget::FLAG_HILITED); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool ButtonWidget::handleEvent(Event::Type e) { @@ -576,20 +572,6 @@ CheckboxWidget::CheckboxWidget(GuiObject* boss, const GUI::Font& font, setFill(CheckboxWidget::FillType::Normal); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CheckboxWidget::handleMouseEntered() -{ - if(isEnabled()) - setFlags(Widget::FLAG_HILITED); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CheckboxWidget::handleMouseLeft() -{ - if(isEnabled()) - clearFlags(Widget::FLAG_HILITED); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CheckboxWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount) { diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 98e36863f..bf831a5eb 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -58,8 +58,8 @@ class Widget : public GuiObject virtual bool handleKeyUp(StellaKey key, StellaMod mod) { return false; } virtual void handleMouseDown(int x, int y, MouseButton b, int clickCount) { } virtual void handleMouseUp(int x, int y, MouseButton b, int clickCount) { } - virtual void handleMouseEntered() { } - virtual void handleMouseLeft() { } + virtual void handleMouseEntered(); + virtual void handleMouseLeft(); virtual void handleMouseMoved(int x, int y) { } virtual void handleMouseWheel(int x, int y, int direction) { } virtual bool handleMouseClicks(int x, int y, MouseButton b) { return false; } @@ -88,6 +88,7 @@ class Widget : public GuiObject bool isEnabled() const { return _flags & FLAG_ENABLED; } bool isVisible() const override { return !(_flags & FLAG_INVISIBLE); } bool isHighlighted() const { return _flags & FLAG_HILITED; } + bool hasMouseFocus() const { return _flags & FLAG_MOUSE_FOCUS; } virtual bool wantsFocus() const { return _flags & FLAG_RETAIN_FOCUS; } bool wantsTab() const { return _flags & FLAG_WANTS_TAB; } bool wantsRaw() const { return _flags & FLAG_WANTS_RAWDATA; } @@ -231,8 +232,6 @@ class ButtonWidget : public StaticTextWidget, public CommandSender bool handleMouseClicks(int x, int y, MouseButton b) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; - void handleMouseEntered() override; - void handleMouseLeft() override; bool handleEvent(Event::Type event) override; void drawWidget(bool hilite) override; @@ -273,8 +272,6 @@ class CheckboxWidget : public ButtonWidget bool getState() const { return _state; } void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; - void handleMouseEntered() override; - void handleMouseLeft() override; static int boxSize(const GUI::Font& font) { From 004b34f51e5e61305cec92f90f335df73ce292b3 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Mon, 16 Nov 2020 20:00:51 +0100 Subject: [PATCH 45/70] fixed tool tip font for Launcher added a few more tool tips --- src/gui/LauncherDialog.cxx | 3 ++- src/gui/ToolTip.cxx | 5 +++-- src/gui/VideoAudioDialog.cxx | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index abae25742..93361b9f5 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -56,7 +56,8 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent, int x, int y, int w, int h) - : Dialog(osystem, parent, x, y, w, h) + : Dialog(osystem, parent, osystem.frameBuffer().launcherFont(), "", + x, y, w, h) { myUseMinimalUI = instance().settings().getBool("minimal_ui"); diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index 30100009a..82c0df10b 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -48,8 +48,10 @@ void ToolTip::request(Widget* widget) } if(myTimer == DELAY_TIME) { + myWidget = widget; + const uInt32 VGAP = 1; - const uInt32 hCursor = 19; // TODO: query cursor height + const uInt32 hCursor = 18; string text = widget->getToolTip(); uInt32 width = std::min(myWidth, myFont.getStringWidth(text) + myTextXOfs * 2); // Note: These include HiDPI scaling: @@ -69,7 +71,6 @@ void ToolTip::request(Widget* widget) width = imageRect.w() / myScale; } - myWidget = widget; mySurface->setSrcSize(width, myHeight); mySurface->setDstSize(width * myScale, myHeight * myScale); mySurface->setDstPos(x * myScale, y * myScale); diff --git a/src/gui/VideoAudioDialog.cxx b/src/gui/VideoAudioDialog.cxx index 8d2c3be6d..d34f0a330 100644 --- a/src/gui/VideoAudioDialog.cxx +++ b/src/gui/VideoAudioDialog.cxx @@ -129,6 +129,7 @@ void VideoAudioDialog::addDisplayTab() // TIA interpolation myTIAInterpolate = new CheckboxWidget(myTab, _font, xpos, ypos + 1, "Interpolation "); + myTIAInterpolate->setToolTip("Blur the emulated display."); wid.push_back(myTIAInterpolate); ypos += lineHeight + VGAP * 4; @@ -146,12 +147,14 @@ void VideoAudioDialog::addDisplayTab() // FS stretch myUseStretch = new CheckboxWidget(myTab, _font, xpos + INDENT, ypos + 1, "Stretch"); + myUseStretch->setToolTip("Stretch the emulated display to fill the whole screen."); wid.push_back(myUseStretch); #ifdef ADAPTABLE_REFRESH_SUPPORT // Adapt refresh rate ypos += lineHeight + VGAP; myRefreshAdapt = new CheckboxWidget(myTab, _font, xpos + INDENT, ypos + 1, "Adapt display refresh rate"); + myRefreshAdapt->setToolTip("Select the optimal display refresh rate for each ROM."); wid.push_back(myRefreshAdapt); #else myRefreshAdapt = nullptr; @@ -168,6 +171,7 @@ void VideoAudioDialog::addDisplayTab() // Aspect ratio correction ypos += lineHeight + VGAP * 4; myCorrectAspect = new CheckboxWidget(myTab, _font, xpos, ypos + 1, "Correct aspect ratio (*)"); + myCorrectAspect->setToolTip("Uncheck to disable real world aspect ratio correction."); wid.push_back(myCorrectAspect); // Vertical size @@ -177,6 +181,7 @@ void VideoAudioDialog::addDisplayTab() "V-Size adjust", lwidth, kVSizeChanged, fontWidth * 7, "%", 0, true); myVSizeAdjust->setMinValue(-5); myVSizeAdjust->setMaxValue(5); myVSizeAdjust->setTickmarkIntervals(2); + myVSizeAdjust->setToolTip("Adapt vertical size to emulated TV display."); wid.push_back(myVSizeAdjust); From 99c0cd66bc94648b1a2ee741739a29cd127d3081 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Mon, 16 Nov 2020 23:50:10 +0100 Subject: [PATCH 46/70] added value tool tips to debugger (DataGridWiget, ToogleWidget) --- src/debugger/gui/CpuWidget.cxx | 4 ++-- src/debugger/gui/DataGridWidget.cxx | 17 +++++++++++++++++ src/debugger/gui/DataGridWidget.hxx | 3 +++ src/debugger/gui/ToggleWidget.cxx | 26 ++++++++++++++++++++++++++ src/debugger/gui/ToggleWidget.hxx | 3 +++ src/gui/Dialog.cxx | 2 +- src/gui/Dialog.hxx | 3 --- src/gui/ToolTip.cxx | 29 +++++++++++++++++++---------- src/gui/ToolTip.hxx | 11 ++++++----- src/gui/Widget.hxx | 8 ++++++-- 10 files changed, 83 insertions(+), 23 deletions(-) diff --git a/src/debugger/gui/CpuWidget.cxx b/src/debugger/gui/CpuWidget.cxx index 31f939f01..ea6fbb96f 100644 --- a/src/debugger/gui/CpuWidget.cxx +++ b/src/debugger/gui/CpuWidget.cxx @@ -109,10 +109,10 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n { new StaticTextWidget(boss, lfont, myCpuGridDecValue->getLeft() - fontWidth, ypos + row * lineHeight + 2, - lwidth - 2, fontHeight, "#"); + fontWidth, fontHeight, "#"); new StaticTextWidget(boss, lfont, myCpuGridBinValue->getLeft() - fontWidth, ypos + row * lineHeight + 2, - lwidth - 2, fontHeight, "%"); + fontWidth, fontHeight, "%"); } // Create a bitfield widget for changing the processor status diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 63c637ecd..f6898b6c8 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -570,6 +570,23 @@ void DataGridWidget::handleCommand(CommandSender* sender, int cmd, } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string DataGridWidget::getToolTip(int x, int y) const +{ + const int col = (x - getAbsX()) / _colWidth; + const int row = (y - getAbsY()) / _rowHeight; + const int pos = row * _cols + col; + const Int32 val = _valueList[pos]; + const string hex = Common::Base::toString(val, Common::Base::Fmt::_16); + const string dec = Common::Base::toString(val, Common::Base::Fmt::_10); + const string bin = Common::Base::toString(val, Common::Base::Fmt::_2); + ostringstream buf; + + // TODO: time leading spaces and zeroes + buf << "$" << hex << " = #" << dec << " = %" << bin; + return buf.str(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DataGridWidget::drawWidget(bool hilite) { diff --git a/src/debugger/gui/DataGridWidget.hxx b/src/debugger/gui/DataGridWidget.hxx index 9096879f3..f50270f4f 100644 --- a/src/debugger/gui/DataGridWidget.hxx +++ b/src/debugger/gui/DataGridWidget.hxx @@ -84,6 +84,9 @@ class DataGridWidget : public EditableWidget void setCrossed(bool enable) { _crossGrid = enable; } + string getToolTip(int x = 0, int y = 0) const override; + bool hasToolTip() const override { return true; } + protected: void drawWidget(bool hilite) override; diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index 4f9ddccfa..346c51121 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -16,6 +16,7 @@ //============================================================================ #include "OSystem.hxx" +#include "Base.hxx" #include "StellaKeys.hxx" #include "Widget.hxx" #include "ToggleWidget.hxx" @@ -209,3 +210,28 @@ void ToggleWidget::handleCommand(CommandSender* sender, int cmd, } } } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string ToggleWidget::getToolTip(int x, int y) const +{ + const int row = (y - getAbsY()) / _rowHeight; + const int pos = row * _cols;// +col; + Int32 val = 0; + + for(int col = 0; col < _cols; ++col) + { + val <<= 1; + val += _stateList[pos + col]; + } + + const string hex = Common::Base::toString(val, Common::Base::Fmt::_16); + const string dec = Common::Base::toString(val, Common::Base::Fmt::_10); + const string bin = Common::Base::toString(val, Common::Base::Fmt::_2); + ostringstream buf; + + // TODO: time leading spaces and zeroes + buf << "$" << hex << " = #" << dec << " = %" << bin; + return buf.str(); +} + + diff --git a/src/debugger/gui/ToggleWidget.hxx b/src/debugger/gui/ToggleWidget.hxx index 0d6759467..a671f53e9 100644 --- a/src/debugger/gui/ToggleWidget.hxx +++ b/src/debugger/gui/ToggleWidget.hxx @@ -46,6 +46,9 @@ class ToggleWidget : public Widget, public CommandSender void setEditable(bool editable) { _editable = editable; } bool isEditable() const { return _editable; } + string getToolTip(int x = 0, int y = 0) const override; + bool hasToolTip() const override { return true; } + protected: protected: diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index f58d98536..b9678182e 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -67,7 +67,7 @@ Dialog::Dialog(OSystem& instance, DialogContainer& parent, const GUI::Font& font attr.blendalpha = 25; // darken background dialogs by 25% _shadeSurface->applyAttributes(); - _toolTip = make_unique(instance, *this, font); + _toolTip = make_unique(*this, font); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index b134d7d37..f628ec792 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -124,9 +124,6 @@ class Dialog : public GuiObject bool shouldResize(uInt32& w, uInt32& h) const; ToolTip& tooltip() { return *_toolTip; } - //bool enableToolTip(); - //void showToolTip(int x, int y); - //void hideToolTip(); protected: void draw() override { } diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index 82c0df10b..9531ee5ef 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -24,35 +24,44 @@ #include "ToolTip.hxx" +// TODO: +// - disable when in edit mode +// - option to disable tips +// - multi line tips +// - nicer formating of DataDridWidget tip +// - allow reversing ToogleWidget (TooglePixelWidget) + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -ToolTip::ToolTip(OSystem& instance, Dialog& dialog, const GUI::Font& font) +ToolTip::ToolTip(Dialog& dialog, const GUI::Font& font) : myDialog(dialog), myFont(font) { const int fontWidth = font.getMaxCharWidth(), fontHeight = font.getFontHeight(); - myTextXOfs = fontHeight < 24 ? 5 : 8; //3 : 5; - myWidth = myTextXOfs * 2 + fontWidth * MAX_LEN; - myHeight = fontHeight + TEXT_Y_OFS * 2; + myTextXOfs = fontHeight < 24 ? 5 : 8; // 3 : 5; + myTextYOfs = fontHeight < 24 ? 2 : 3; + myWidth = fontWidth * MAX_LEN + myTextXOfs * 2; + myHeight = fontHeight + myTextYOfs * 2; + mySurface = myDialog.instance().frameBuffer().allocateSurface(myWidth, myHeight); myScale = myDialog.instance().frameBuffer().hidpiScaleFactor(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ToolTip::request(Widget* widget) +void ToolTip::request(const Widget* widget) { if(myWidget != widget) - { release(); - } + if(myTimer == DELAY_TIME) { myWidget = widget; const uInt32 VGAP = 1; const uInt32 hCursor = 18; - string text = widget->getToolTip(); + string text = widget->getToolTip(myPos.x, myPos.y); uInt32 width = std::min(myWidth, myFont.getStringWidth(text) + myTextXOfs * 2); // Note: These include HiDPI scaling: const Common::Rect imageRect = myDialog.instance().frameBuffer().imageRect(); @@ -77,8 +86,8 @@ void ToolTip::request(Widget* widget) mySurface->frameRect(0, 0, width, myHeight, kColor); mySurface->fillRect(1, 1, width - 2, myHeight - 2, kWidColor); - mySurface->drawString(myFont, text, myTextXOfs, TEXT_Y_OFS, - width - myTextXOfs * 2, myHeight - TEXT_Y_OFS * 2, kTextColor); + mySurface->drawString(myFont, text, myTextXOfs, myTextYOfs, + width - myTextXOfs * 2, myHeight - myTextYOfs * 2, kTextColor); myDialog.setDirtyChain(); } myTimer++; diff --git a/src/gui/ToolTip.hxx b/src/gui/ToolTip.hxx index d3164a09d..125343294 100644 --- a/src/gui/ToolTip.hxx +++ b/src/gui/ToolTip.hxx @@ -19,7 +19,7 @@ #define TOOL_TIP_HXX /** - * Class for providing tooltip functionality + * Class for providing tool tip functionality * * @author Thomas Jentzsch */ @@ -37,13 +37,13 @@ public: // Maximum tooltip length static constexpr uInt32 MAX_LEN = 80; - ToolTip(OSystem& instance, Dialog& dialog, const GUI::Font& font); + ToolTip(Dialog& dialog, const GUI::Font& font); ~ToolTip() = default; /** Request a tooltip display */ - void request(Widget* widget); + void request(const Widget* widget); /** @@ -63,18 +63,19 @@ public: private: static constexpr uInt32 DELAY_TIME = 45; // display delay - static constexpr int TEXT_Y_OFS = 2; + //static constexpr int TEXT_Y_OFS = 2; Dialog& myDialog; const GUI::Font& myFont; - Widget* myWidget{nullptr}; + const Widget* myWidget{nullptr}; uInt32 myTimer{0}; Common::Point myPos; uInt32 myWidth{0}; uInt32 myHeight{0}; uInt32 myScale{1}; uInt32 myTextXOfs{0}; + uInt32 myTextYOfs{0}; shared_ptr mySurface; }; diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index bf831a5eb..42612cc99 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -105,8 +105,8 @@ class Widget : public GuiObject void setShadowColor(ColorId color) { _shadowcolor = color; setDirty(); } void setToolTip(const string& text); - const string& getToolTip() const { return _toolTipText; } - bool hasToolTip() const { return !_toolTipText.empty(); } + virtual string getToolTip(int x = 0, int y = 0) const { return _toolTipText; } + virtual bool hasToolTip() const { return !_toolTipText.empty(); } virtual void loadConfig() { } @@ -181,6 +181,10 @@ class StaticTextWidget : public Widget const string& text = "", TextAlign align = TextAlign::Left, ColorId shadowColor = kNone); ~StaticTextWidget() override = default; + + void handleMouseEntered() override {} + void handleMouseLeft() override {} + void setValue(int value); void setLabel(const string& label); void setAlign(TextAlign align) { _align = align; setDirty(); } From f1f5938b79d76eef7df5cd769b15f28516c3006d Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 17 Nov 2020 08:34:39 +0100 Subject: [PATCH 47/70] fixed bug which removed highlighting for most widgets --- src/debugger/gui/ToggleWidget.cxx | 2 +- src/gui/ToolTip.cxx | 3 ++- src/gui/ToolTip.hxx | 2 +- src/gui/Widget.cxx | 14 ++++++++++++++ src/gui/Widget.hxx | 2 ++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index 346c51121..a73bc25dc 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -212,7 +212,7 @@ void ToggleWidget::handleCommand(CommandSender* sender, int cmd, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string ToggleWidget::getToolTip(int x, int y) const +string ToggleWidget::getToolTip(int, int y) const { const int row = (y - getAbsY()) / _rowHeight; const int pos = row * _cols;// +col; diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index 9531ee5ef..ece2f1ccc 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -30,7 +30,8 @@ // - multi line tips // - nicer formating of DataDridWidget tip // - allow reversing ToogleWidget (TooglePixelWidget) - +// - shift checkbox bits +// - RomListWidget (hex codes, maybe disassembly operands) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ToolTip::ToolTip(Dialog& dialog, const GUI::Font& font) diff --git a/src/gui/ToolTip.hxx b/src/gui/ToolTip.hxx index 125343294..efcf3bafe 100644 --- a/src/gui/ToolTip.hxx +++ b/src/gui/ToolTip.hxx @@ -19,7 +19,7 @@ #define TOOL_TIP_HXX /** - * Class for providing tool tip functionality + * Class for providing tooltip functionality * * @author Thomas Jentzsch */ diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 991207655..a7fb55561 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -475,6 +475,20 @@ ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font, _bmh = bmh; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ButtonWidget::handleMouseEntered() +{ + if(isEnabled()) + setFlags(Widget::FLAG_HILITED | Widget::FLAG_MOUSE_FOCUS); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ButtonWidget::handleMouseLeft() +{ + if(isEnabled()) + clearFlags(Widget::FLAG_HILITED | Widget::FLAG_MOUSE_FOCUS); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool ButtonWidget::handleEvent(Event::Type e) { diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 42612cc99..33c6a3e20 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -236,6 +236,8 @@ class ButtonWidget : public StaticTextWidget, public CommandSender bool handleMouseClicks(int x, int y, MouseButton b) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; + void handleMouseEntered() override; + void handleMouseLeft() override; bool handleEvent(Event::Type event) override; void drawWidget(bool hilite) override; From d7fe5510bb50c9cff4304d72c6a1c04d58d93e0f Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 17 Nov 2020 12:33:47 +0100 Subject: [PATCH 48/70] keep tooltips visible while mouse moves in focus show tooltips faster when moving from one to another update tooltip when mouse moves over different widget items disable tooltip when editing --- src/debugger/gui/DataGridWidget.cxx | 22 ++++- src/debugger/gui/DataGridWidget.hxx | 8 +- src/debugger/gui/ToggleWidget.cxx | 22 ++++- src/debugger/gui/ToggleWidget.hxx | 7 +- src/gui/Dialog.cxx | 6 +- src/gui/EditableWidget.cxx | 8 ++ src/gui/EditableWidget.hxx | 1 + src/gui/LauncherDialog.cxx | 2 +- src/gui/PopUpWidget.cxx | 3 + src/gui/ToolTip.cxx | 139 +++++++++++++++++----------- src/gui/ToolTip.hxx | 79 +++++++++------- src/gui/VideoAudioDialog.cxx | 8 +- src/gui/Widget.cxx | 4 +- src/gui/Widget.hxx | 8 +- 14 files changed, 205 insertions(+), 112 deletions(-) diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index f6898b6c8..d11375d29 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -571,12 +571,18 @@ void DataGridWidget::handleCommand(CommandSender* sender, int cmd, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string DataGridWidget::getToolTip(int x, int y) const +int DataGridWidget::getToolTipIndex(Common::Point pos) const { - const int col = (x - getAbsX()) / _colWidth; - const int row = (y - getAbsY()) / _rowHeight; - const int pos = row * _cols + col; - const Int32 val = _valueList[pos]; + const int col = (pos.x - getAbsX()) / _colWidth; + const int row = (pos.y - getAbsY()) / _rowHeight; + + return row * _cols + col; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string DataGridWidget::getToolTip(Common::Point pos) const +{ + const Int32 val = _valueList[getToolTipIndex(pos)]; const string hex = Common::Base::toString(val, Common::Base::Fmt::_16); const string dec = Common::Base::toString(val, Common::Base::Fmt::_10); const string bin = Common::Base::toString(val, Common::Base::Fmt::_2); @@ -587,6 +593,12 @@ string DataGridWidget::getToolTip(int x, int y) const return buf.str(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool DataGridWidget::changedToolTip(Common::Point oldPos, Common::Point newPos) const +{ + return getToolTipIndex(oldPos) != getToolTipIndex(newPos); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DataGridWidget::drawWidget(bool hilite) { diff --git a/src/debugger/gui/DataGridWidget.hxx b/src/debugger/gui/DataGridWidget.hxx index f50270f4f..1a402659d 100644 --- a/src/debugger/gui/DataGridWidget.hxx +++ b/src/debugger/gui/DataGridWidget.hxx @@ -84,8 +84,8 @@ class DataGridWidget : public EditableWidget void setCrossed(bool enable) { _crossGrid = enable; } - string getToolTip(int x = 0, int y = 0) const override; - bool hasToolTip() const override { return true; } + string getToolTip(Common::Point pos) const override; + bool changedToolTip(Common::Point oldPos, Common::Point newPos) const override; protected: void drawWidget(bool hilite) override; @@ -101,6 +101,8 @@ class DataGridWidget : public EditableWidget void receivedFocusWidget() override; void lostFocusWidget() override; + bool hasToolTip() const override { return true; } + void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; void handleMouseWheel(int x, int y, int direction) override; @@ -148,6 +150,8 @@ class DataGridWidget : public EditableWidget void enableEditMode(bool state) { _editMode = state; } + int getToolTipIndex(Common::Point pos) const; + private: // Following constructors and assignment operators not supported DataGridWidget() = delete; diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index a73bc25dc..3d2fca262 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -212,16 +212,23 @@ void ToggleWidget::handleCommand(CommandSender* sender, int cmd, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string ToggleWidget::getToolTip(int, int y) const +int ToggleWidget::getToolTipIndex(Common::Point pos) const { - const int row = (y - getAbsY()) / _rowHeight; - const int pos = row * _cols;// +col; + const int row = (pos.y - getAbsY()) / _rowHeight; + + return row * _cols; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string ToggleWidget::getToolTip(Common::Point pos) const +{ + const int idx = getToolTipIndex(pos); Int32 val = 0; for(int col = 0; col < _cols; ++col) { val <<= 1; - val += _stateList[pos + col]; + val += _stateList[idx + col]; } const string hex = Common::Base::toString(val, Common::Base::Fmt::_16); @@ -234,4 +241,11 @@ string ToggleWidget::getToolTip(int, int y) const return buf.str(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool ToggleWidget::changedToolTip(Common::Point oldPos, Common::Point newPos) const +{ + return getToolTipIndex(oldPos) != getToolTipIndex(newPos); +} + + diff --git a/src/debugger/gui/ToggleWidget.hxx b/src/debugger/gui/ToggleWidget.hxx index a671f53e9..060a52e13 100644 --- a/src/debugger/gui/ToggleWidget.hxx +++ b/src/debugger/gui/ToggleWidget.hxx @@ -46,10 +46,11 @@ class ToggleWidget : public Widget, public CommandSender void setEditable(bool editable) { _editable = editable; } bool isEditable() const { return _editable; } - string getToolTip(int x = 0, int y = 0) const override; - bool hasToolTip() const override { return true; } + string getToolTip(Common::Point pos) const override; + bool changedToolTip(Common::Point oldPos, Common::Point newPos) const override; protected: + bool hasToolTip() const override { return true; } protected: int _rows; @@ -74,6 +75,8 @@ class ToggleWidget : public Widget, public CommandSender bool handleKeyDown(StellaKey key, StellaMod mod) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override; + int getToolTipIndex(Common::Point pos) const; + // Following constructors and assignment operators not supported ToggleWidget() = delete; ToggleWidget(const ToggleWidget&) = delete; diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index b9678182e..a33b4ffa1 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -593,9 +593,6 @@ void Dialog::handleMouseMoved(int x, int y) { Widget* w; - // Update mouse coordinates for tooltips - _toolTip->update(x, y); - if(_focusedWidget && !_dragWidget) { w = _focusedWidget; @@ -639,6 +636,9 @@ void Dialog::handleMouseMoved(int x, int y) if (w && (w->getFlags() & Widget::FLAG_TRACK_MOUSE)) w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y)); + + // Update mouse coordinates for tooltips + _toolTip->update(_mouseWidget, Common::Point(x, y)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index d6c35fa55..39a4b519f 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -22,6 +22,7 @@ #include "OSystem.hxx" #include "EventHandler.hxx" #include "UndoHandler.hxx" +#include "ToolTip.hxx" #include "EditableWidget.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -79,6 +80,12 @@ void EditableWidget::tick() Widget::tick(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool EditableWidget::wantsToolTip() const +{ + return !(_hasFocus && isEditable() && _editMode) && Widget::wantsToolTip(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EditableWidget::setEditable(bool editable, bool hiliteBG) { @@ -100,6 +107,7 @@ void EditableWidget::receivedFocusWidget() { _caretTimer = 0; _caretEnabled = true; + dialog().tooltip().release(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/EditableWidget.hxx b/src/gui/EditableWidget.hxx index 8ebf1791c..6e55cf541 100644 --- a/src/gui/EditableWidget.hxx +++ b/src/gui/EditableWidget.hxx @@ -68,6 +68,7 @@ class EditableWidget : public Widget, public CommandSender void receivedFocusWidget() override; void lostFocusWidget() override; void tick() override; + bool wantsToolTip() const override; virtual void startEditMode() { setFlags(Widget::FLAG_WANTS_RAWDATA); } virtual void endEditMode() { clearFlags(Widget::FLAG_WANTS_RAWDATA); } diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 93361b9f5..9c140e15c 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -121,7 +121,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent, // Show the filter input field xpos -= fwidth + LBL_GAP; myPattern = new EditTextWidget(this, font, xpos, ypos - 2, fwidth, lineHeight, ""); - myPattern->setToolTip("Enter a filter text to reduce file list."); + myPattern->setToolTip("Enter filter text to reduce file list."); // Show the "Filter" label xpos -= lwidth3 + LBL_GAP; new StaticTextWidget(this, font, xpos, ypos, lblFilter); diff --git a/src/gui/PopUpWidget.cxx b/src/gui/PopUpWidget.cxx index 06c726779..45f79e55b 100644 --- a/src/gui/PopUpWidget.cxx +++ b/src/gui/PopUpWidget.cxx @@ -20,6 +20,8 @@ #include "FBSurface.hxx" #include "Font.hxx" #include "ContextMenu.hxx" +#include "Dialog.hxx" +#include "ToolTip.hxx" #include "DialogContainer.hxx" #include "PopUpWidget.hxx" @@ -122,6 +124,7 @@ void PopUpWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) { if(isEnabled() && !myMenu->isVisible()) { + dialog().tooltip().hide(); // Add menu just underneath parent widget myMenu->show(getAbsX() + _labelWidth, getAbsY() + getHeight(), dialog().surface().dstRect(), myMenu->getSelected()); diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index ece2f1ccc..36c8b1b20 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -24,8 +24,12 @@ #include "ToolTip.hxx" -// TODO: -// - disable when in edit mode +// TODOs: +// + keep enabled when mouse moves over same widget +// + static position and text for normal widgets +// + moving position and text over e.g. DataGridWidget +// + reenable tip faster +// + disable when in edit mode // - option to disable tips // - multi line tips // - nicer formating of DataDridWidget tip @@ -41,7 +45,7 @@ ToolTip::ToolTip(Dialog& dialog, const GUI::Font& font) const int fontWidth = font.getMaxCharWidth(), fontHeight = font.getFontHeight(); - myTextXOfs = fontHeight < 24 ? 5 : 8; // 3 : 5; + myTextXOfs = fontHeight < 24 ? 5 : 8; myTextYOfs = fontHeight < 24 ? 2 : 3; myWidth = fontWidth * MAX_LEN + myTextXOfs * 2; myHeight = fontHeight + myTextYOfs * 2; @@ -51,72 +55,103 @@ ToolTip::ToolTip(Dialog& dialog, const GUI::Font& font) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ToolTip::request(const Widget* widget) +void ToolTip::update(const Widget* widget, Common::Point pos) { - if(myWidget != widget) - release(); - - if(myTimer == DELAY_TIME) + if(myTipWidget != widget) { - myWidget = widget; + myFocusWidget = widget; + release(); + } + if(myTipShown && myTipWidget->changedToolTip(myPos, pos)) + myPos = pos, show(); + else + myPos = pos; +} - const uInt32 VGAP = 1; - const uInt32 hCursor = 18; - string text = widget->getToolTip(myPos.x, myPos.y); - uInt32 width = std::min(myWidth, myFont.getStringWidth(text) + myTextXOfs * 2); - // Note: These include HiDPI scaling: - const Common::Rect imageRect = myDialog.instance().frameBuffer().imageRect(); - const Common::Rect dialogRect = myDialog.surface().dstRect(); - // Limit to app or screen size and adjust position - const Int32 xAbs = myPos.x + dialogRect.x() / myScale; - const uInt32 yAbs = myPos.y + dialogRect.y() / myScale; - Int32 x = std::min(xAbs, Int32(imageRect.w() / myScale - width)); - const uInt32 y = (yAbs + myHeight + hCursor > imageRect.h() / myScale) - ? yAbs - myHeight - VGAP - : yAbs + hCursor / myScale + VGAP; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ToolTip::hide() +{ + if(myTipShown) + { + myTimer = 0; + myTipWidget = myFocusWidget = nullptr; - if(x < 0) - { - x = 0; - width = imageRect.w() / myScale; - } - - mySurface->setSrcSize(width, myHeight); - mySurface->setDstSize(width * myScale, myHeight * myScale); - mySurface->setDstPos(x * myScale, y * myScale); - - mySurface->frameRect(0, 0, width, myHeight, kColor); - mySurface->fillRect(1, 1, width - 2, myHeight - 2, kWidColor); - mySurface->drawString(myFont, text, myTextXOfs, myTextYOfs, - width - myTextXOfs * 2, myHeight - myTextYOfs * 2, kTextColor); + myTipShown = false; myDialog.setDirtyChain(); } - myTimer++; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ToolTip::release() { - if(myWidget != nullptr) + if(myTipShown) { - myTimer = 0; - myWidget = nullptr; + myTimer = DELAY_TIME; + + myTipShown = false; myDialog.setDirtyChain(); } + + // After displaying a tip, slowly reset the timer to 0 + // until a new tip is requested + if(myTipWidget != myFocusWidget && myTimer) + myTimer--; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ToolTip::request() +{ + myTipWidget = myFocusWidget; + + if(myTimer == DELAY_TIME) + show(); + + myTimer++; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ToolTip::show() +{ + if(myTipWidget == nullptr) + return; + + const uInt32 V_GAP = 1; + const uInt32 H_CURSOR = 18; + string text = myTipWidget->getToolTip(myPos); + uInt32 width = std::min(myWidth, myFont.getStringWidth(text) + myTextXOfs * 2); + // Note: The rects include HiDPI scaling + const Common::Rect imageRect = myDialog.instance().frameBuffer().imageRect(); + const Common::Rect dialogRect = myDialog.surface().dstRect(); + // Limit position to app size and adjust accordingly + const Int32 xAbs = myPos.x + dialogRect.x() / myScale; + const uInt32 yAbs = myPos.y + dialogRect.y() / myScale; + Int32 x = std::min(xAbs, Int32(imageRect.w() / myScale - width)); + const uInt32 y = (yAbs + myHeight + H_CURSOR > imageRect.h() / myScale) + ? yAbs - myHeight - V_GAP + : yAbs + H_CURSOR / myScale + V_GAP; + + if(x < 0) + { + x = 0; + width = imageRect.w() / myScale; + } + + mySurface->setSrcSize(width, myHeight); + mySurface->setDstSize(width * myScale, myHeight * myScale); + mySurface->setDstPos(x * myScale, y * myScale); + + mySurface->frameRect(0, 0, width, myHeight, kColor); + mySurface->fillRect(1, 1, width - 2, myHeight - 2, kWidColor); + mySurface->drawString(myFont, text, myTextXOfs, myTextYOfs, + width - myTextXOfs * 2, myHeight - myTextYOfs * 2, kTextColor); + + myTipShown = true; + myDialog.setDirtyChain(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ToolTip::render() { - if(myWidget != nullptr) - mySurface->render(); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ToolTip::update(int x, int y) -{ - if(myWidget != nullptr && x != myPos.x || y != myPos.y) - release(); - myPos.x = x; - myPos.y = y; + if(myTipShown) + mySurface->render(), cerr << " render tooltip" << endl; } diff --git a/src/gui/ToolTip.hxx b/src/gui/ToolTip.hxx index efcf3bafe..b3bbf547a 100644 --- a/src/gui/ToolTip.hxx +++ b/src/gui/ToolTip.hxx @@ -33,50 +33,59 @@ class FBSurface; class ToolTip { -public: - // Maximum tooltip length - static constexpr uInt32 MAX_LEN = 80; + public: + // Maximum tooltip length + static constexpr uInt32 MAX_LEN = 80; - ToolTip(Dialog& dialog, const GUI::Font& font); - ~ToolTip() = default; + ToolTip(Dialog& dialog, const GUI::Font& font); + ~ToolTip() = default; - /** - Request a tooltip display - */ - void request(const Widget* widget); + /** + Request a tooltip display. + */ + void request(); + /** + Hide a displayed tooltip and reset the timer. + */ + void hide(); - /** - Hide an existing tooltip (if displayed) - */ - void release(); + /** + Hide a displayed tooltip and reset the timer slowly. + This allows faster tip display of the next tip. + */ + void release(); - /** - Update with current mouse position - */ - void update(int x, int y); + /** + Update focussed widget and current mouse position. + */ + void update(const Widget* widget, Common::Point pos); - /* - Render the tooltip - */ - void render(); + /* + Render the tooltip + */ + void render(); -private: - static constexpr uInt32 DELAY_TIME = 45; // display delay - //static constexpr int TEXT_Y_OFS = 2; + private: + void show(); - Dialog& myDialog; - const GUI::Font& myFont; + private: + static constexpr uInt32 DELAY_TIME = 45; // display delay - const Widget* myWidget{nullptr}; - uInt32 myTimer{0}; - Common::Point myPos; - uInt32 myWidth{0}; - uInt32 myHeight{0}; - uInt32 myScale{1}; - uInt32 myTextXOfs{0}; - uInt32 myTextYOfs{0}; - shared_ptr mySurface; + Dialog& myDialog; + const GUI::Font& myFont; + const Widget* myTipWidget{nullptr}; + const Widget* myFocusWidget{nullptr}; + + uInt32 myTimer{0}; + Common::Point myPos; + uInt32 myWidth{0}; + uInt32 myHeight{0}; + uInt32 myTextXOfs{0}; + uInt32 myTextYOfs{0}; + bool myTipShown{false}; + uInt32 myScale{1}; + shared_ptr mySurface; }; #endif diff --git a/src/gui/VideoAudioDialog.cxx b/src/gui/VideoAudioDialog.cxx index d34f0a330..def965aa6 100644 --- a/src/gui/VideoAudioDialog.cxx +++ b/src/gui/VideoAudioDialog.cxx @@ -129,7 +129,7 @@ void VideoAudioDialog::addDisplayTab() // TIA interpolation myTIAInterpolate = new CheckboxWidget(myTab, _font, xpos, ypos + 1, "Interpolation "); - myTIAInterpolate->setToolTip("Blur the emulated display."); + myTIAInterpolate->setToolTip("Blur emulated display."); wid.push_back(myTIAInterpolate); ypos += lineHeight + VGAP * 4; @@ -147,14 +147,14 @@ void VideoAudioDialog::addDisplayTab() // FS stretch myUseStretch = new CheckboxWidget(myTab, _font, xpos + INDENT, ypos + 1, "Stretch"); - myUseStretch->setToolTip("Stretch the emulated display to fill the whole screen."); + myUseStretch->setToolTip("Stretch emulated display to fill whole screen."); wid.push_back(myUseStretch); #ifdef ADAPTABLE_REFRESH_SUPPORT // Adapt refresh rate ypos += lineHeight + VGAP; myRefreshAdapt = new CheckboxWidget(myTab, _font, xpos + INDENT, ypos + 1, "Adapt display refresh rate"); - myRefreshAdapt->setToolTip("Select the optimal display refresh rate for each ROM."); + myRefreshAdapt->setToolTip("Select optimal display refresh rate for each ROM."); wid.push_back(myRefreshAdapt); #else myRefreshAdapt = nullptr; @@ -181,7 +181,7 @@ void VideoAudioDialog::addDisplayTab() "V-Size adjust", lwidth, kVSizeChanged, fontWidth * 7, "%", 0, true); myVSizeAdjust->setMinValue(-5); myVSizeAdjust->setMaxValue(5); myVSizeAdjust->setTickmarkIntervals(2); - myVSizeAdjust->setToolTip("Adapt vertical size to emulated TV display."); + myVSizeAdjust->setToolTip("Adjust vertical size to match emulated TV display."); wid.push_back(myVSizeAdjust); diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index a7fb55561..cfb933965 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -75,8 +75,8 @@ void Widget::tick() { if(isEnabled()) { - if(hasMouseFocus() && hasToolTip()) - dialog().tooltip().request(this); + if(wantsToolTip()) + dialog().tooltip().request(); // Recursively tick widget and all child dialogs and widgets Widget* w = _firstWidget; diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 33c6a3e20..45c676fe2 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -26,6 +26,7 @@ class Dialog; #include #include "bspf.hxx" +#include "Rect.hxx" #include "Event.hxx" #include "EventHandlerConstants.hxx" #include "FrameBufferConstants.hxx" @@ -105,8 +106,8 @@ class Widget : public GuiObject void setShadowColor(ColorId color) { _shadowcolor = color; setDirty(); } void setToolTip(const string& text); - virtual string getToolTip(int x = 0, int y = 0) const { return _toolTipText; } - virtual bool hasToolTip() const { return !_toolTipText.empty(); } + virtual string getToolTip(Common::Point pos) const { return _toolTipText; } + virtual bool changedToolTip(Common::Point oldPos, Common::Point newPos) const { return false; } virtual void loadConfig() { } @@ -120,6 +121,9 @@ class Widget : public GuiObject void releaseFocus() override { assert(_boss); _boss->releaseFocus(); } + virtual bool wantsToolTip() const { return hasMouseFocus() && hasToolTip(); } + virtual bool hasToolTip() const { return !_toolTipText.empty(); } + // By default, delegate unhandled commands to the boss void handleCommand(CommandSender* sender, int cmd, int data, int id) override { assert(_boss); _boss->handleCommand(sender, cmd, data, id); } From 35971d3353a78292a31126d61fb7d587abc83ffe Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 17 Nov 2020 13:06:11 +0100 Subject: [PATCH 49/70] added considering bit order in PF pixel tooltip display removed unused click count from ToggleWidget --- src/debugger/gui/TiaWidget.cxx | 2 +- src/debugger/gui/ToggleBitWidget.cxx | 2 +- src/debugger/gui/TogglePixelWidget.cxx | 5 +++-- src/debugger/gui/TogglePixelWidget.hxx | 4 ++-- src/debugger/gui/ToggleWidget.cxx | 25 ++++++++++++++++--------- src/debugger/gui/ToggleWidget.hxx | 7 ++++--- 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/debugger/gui/TiaWidget.cxx b/src/debugger/gui/TiaWidget.cxx index 5f6ba56ab..20aba0763 100644 --- a/src/debugger/gui/TiaWidget.cxx +++ b/src/debugger/gui/TiaWidget.cxx @@ -563,7 +563,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont, new StaticTextWidget(boss, lfont, xpos, ypos+2, 2*fontWidth, fontHeight, "PF", TextAlign::Left); xpos += 2*fontWidth + 5; - myPF[0] = new TogglePixelWidget(boss, nfont, xpos, ypos+1, 4, 1); + myPF[0] = new TogglePixelWidget(boss, nfont, xpos, ypos+1, 4, 1, 4); myPF[0]->setTarget(this); myPF[0]->setID(kPF0ID); addFocusWidget(myPF[0]); diff --git a/src/debugger/gui/ToggleBitWidget.cxx b/src/debugger/gui/ToggleBitWidget.cxx index 479f31225..39ca7dcce 100644 --- a/src/debugger/gui/ToggleBitWidget.cxx +++ b/src/debugger/gui/ToggleBitWidget.cxx @@ -26,7 +26,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ToggleBitWidget::ToggleBitWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int cols, int rows, int colchars) - : ToggleWidget(boss, font, x, y, cols, rows, 1) + : ToggleWidget(boss, font, x, y, cols, rows) { _rowHeight = font.getLineHeight(); _colWidth = colchars * font.getMaxCharWidth() + 8; diff --git a/src/debugger/gui/TogglePixelWidget.cxx b/src/debugger/gui/TogglePixelWidget.cxx index fdc1609bc..b7dd5dbdf 100644 --- a/src/debugger/gui/TogglePixelWidget.cxx +++ b/src/debugger/gui/TogglePixelWidget.cxx @@ -24,8 +24,9 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TogglePixelWidget::TogglePixelWidget(GuiObject* boss, const GUI::Font& font, - int x, int y, int cols, int rows) - : ToggleWidget(boss, font, x, y, cols, rows, 1) + int x, int y, int cols, int rows, + int shiftBits) + : ToggleWidget(boss, font, x, y, cols, rows, shiftBits) { _rowHeight = _colWidth = font.getLineHeight(); diff --git a/src/debugger/gui/TogglePixelWidget.hxx b/src/debugger/gui/TogglePixelWidget.hxx index 6177cac45..c748210f2 100644 --- a/src/debugger/gui/TogglePixelWidget.hxx +++ b/src/debugger/gui/TogglePixelWidget.hxx @@ -25,7 +25,8 @@ class TogglePixelWidget : public ToggleWidget { public: TogglePixelWidget(GuiObject* boss, const GUI::Font& font, - int x, int y, int cols, int rows); + int x, int y, int cols = 1, int rows = 1, + int shiftBits = 0); ~TogglePixelWidget() override = default; void setColor(ColorId color) { _pixelColor = color; } @@ -42,7 +43,6 @@ class TogglePixelWidget : public ToggleWidget private: ColorId _pixelColor{kNone}, _backgroundColor{kDlgColor}; - bool _swapBits{false}; bool _crossBits{false}; private: diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index 3d2fca262..60f4ee154 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -23,8 +23,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ToggleWidget::ToggleWidget(GuiObject* boss, const GUI::Font& font, - int x, int y, int cols, int rows, - int clicksToChange) + int x, int y, int cols, int rows, int shiftBits) : Widget(boss, font, x, y, 16, 16), CommandSender(boss), _rows(rows), @@ -34,7 +33,7 @@ ToggleWidget::ToggleWidget(GuiObject* boss, const GUI::Font& font, _rowHeight(0), _colWidth(0), _selectedItem(0), - _clicksToChange(clicksToChange), + _shiftBits(shiftBits), _editable(true) { _flags = Widget::FLAG_ENABLED | Widget::FLAG_CLEARBG | Widget::FLAG_RETAIN_FOCUS | @@ -70,7 +69,7 @@ void ToggleWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount) // If this was a double click and the mouse is still over the selected item, // send the double click command - if (clickCount == _clicksToChange && (_selectedItem == findItem(x, y))) + if (clickCount == 1 && (_selectedItem == findItem(x, y))) { _stateList[_selectedItem] = !_stateList[_selectedItem]; _changedList[_selectedItem] = !_changedList[_selectedItem]; @@ -225,11 +224,19 @@ string ToggleWidget::getToolTip(Common::Point pos) const const int idx = getToolTipIndex(pos); Int32 val = 0; - for(int col = 0; col < _cols; ++col) - { - val <<= 1; - val += _stateList[idx + col]; - } + if(_swapBits) + for(int col = _cols - 1; col >= 0; --col) + { + val <<= 1; + val += _stateList[idx + col]; + } + else + for(int col = 0; col < _cols; ++col) + { + val <<= 1; + val += _stateList[idx + col]; + } + val <<= _shiftBits; const string hex = Common::Base::toString(val, Common::Base::Fmt::_16); const string dec = Common::Base::toString(val, Common::Base::Fmt::_10); diff --git a/src/debugger/gui/ToggleWidget.hxx b/src/debugger/gui/ToggleWidget.hxx index 060a52e13..5f4ec13a7 100644 --- a/src/debugger/gui/ToggleWidget.hxx +++ b/src/debugger/gui/ToggleWidget.hxx @@ -33,8 +33,8 @@ class ToggleWidget : public Widget, public CommandSender public: ToggleWidget(GuiObject* boss, const GUI::Font& font, - int x, int y, int cols, int rows, - int clicksToChange = 2); + int x, int y, int cols = 1, int rows = 1, + int shiftBits = 0); ~ToggleWidget() override = default; const BoolArray& getState() { return _stateList; } @@ -60,8 +60,9 @@ class ToggleWidget : public Widget, public CommandSender int _rowHeight; // explicitly set in child classes int _colWidth; // explicitly set in child classes int _selectedItem; - int _clicksToChange; // number of clicks to register a change bool _editable; + bool _swapBits{false}; + int _shiftBits{0}; // shift bits for tooltip display BoolArray _stateList; BoolArray _changedList; From 92b77f32c474700e1583816aa4543ea2f5ab17ea Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 17 Nov 2020 13:36:12 +0100 Subject: [PATCH 50/70] enhanced GPRx bits display in debugger, now considers reflection --- src/debugger/gui/TiaWidget.cxx | 12 ++++++++---- src/debugger/gui/TogglePixelWidget.hxx | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/debugger/gui/TiaWidget.cxx b/src/debugger/gui/TiaWidget.cxx index 20aba0763..c330bf386 100644 --- a/src/debugger/gui/TiaWidget.cxx +++ b/src/debugger/gui/TiaWidget.cxx @@ -919,10 +919,14 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) case kRefP0ID: tia.refP0(myRefP0->getState() ? 1 : 0); + myGRP0->setIntState(myGRP0->getIntState(), !myRefP0->getState()); + myGRP0Old->setIntState(myGRP0Old->getIntState(), !myRefP0->getState()); break; case kRefP1ID: tia.refP1(myRefP1->getState() ? 1 : 0); + myGRP1->setIntState(myGRP1->getIntState(), !myRefP1->getState()); + myGRP1Old->setIntState(myGRP1Old->getIntState(), !myRefP1->getState()); break; case kDelP0ID: @@ -1043,8 +1047,8 @@ void TiaWidget::loadConfig() myGRP0Old->setColor(kBGColorLo); myGRP0Old->setCrossed(true); } - myGRP0->setIntState(state.gr[TiaState::P0], false); - myGRP0Old->setIntState(state.gr[TiaState::P0+2], false); + myGRP0->setIntState(state.gr[TiaState::P0], state.ref[TiaState::P0]); + myGRP0Old->setIntState(state.gr[TiaState::P0+2], state.ref[TiaState::P0]); // posP0 myPosP0->setList(0, state.pos[TiaState::P0], @@ -1079,8 +1083,8 @@ void TiaWidget::loadConfig() myGRP1Old->setColor(kBGColorLo); myGRP1Old->setCrossed(true); } - myGRP1->setIntState(state.gr[TiaState::P1], false); - myGRP1Old->setIntState(state.gr[TiaState::P1+2], false); + myGRP1->setIntState(state.gr[TiaState::P1], state.ref[TiaState::P1]); + myGRP1Old->setIntState(state.gr[TiaState::P1+2], state.ref[TiaState::P1]); // posP1 myPosP1->setList(0, state.pos[TiaState::P1], diff --git a/src/debugger/gui/TogglePixelWidget.hxx b/src/debugger/gui/TogglePixelWidget.hxx index c748210f2..fe63cd964 100644 --- a/src/debugger/gui/TogglePixelWidget.hxx +++ b/src/debugger/gui/TogglePixelWidget.hxx @@ -36,7 +36,7 @@ class TogglePixelWidget : public ToggleWidget void setState(const BoolArray& state); - void setIntState(int value, bool swap); + void setIntState(int value, bool swap = false); int getIntState(); void setCrossed(bool enable) { _crossBits = enable; } From 9bb6959dd857fc2025a97b730c0e019e7a7621af Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 17 Nov 2020 18:10:54 +0100 Subject: [PATCH 51/70] aligned tooltip font to dialog font improved debugger tooltip display added tooltips for RomListWidget bytes --- src/debugger/gui/DataGridWidget.cxx | 11 ++--- src/debugger/gui/DebuggerDialog.cxx | 2 + src/debugger/gui/RomListWidget.cxx | 63 +++++++++++++++++++++++++++++ src/debugger/gui/RomListWidget.hxx | 7 ++++ src/debugger/gui/ToggleWidget.cxx | 12 +++--- src/gui/LauncherDialog.cxx | 6 ++- src/gui/ToolTip.cxx | 34 +++++++++++----- src/gui/ToolTip.hxx | 4 +- 8 files changed, 116 insertions(+), 23 deletions(-) diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index d11375d29..9e75a955f 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -583,13 +583,14 @@ int DataGridWidget::getToolTipIndex(Common::Point pos) const string DataGridWidget::getToolTip(Common::Point pos) const { const Int32 val = _valueList[getToolTipIndex(pos)]; - const string hex = Common::Base::toString(val, Common::Base::Fmt::_16); - const string dec = Common::Base::toString(val, Common::Base::Fmt::_10); - const string bin = Common::Base::toString(val, Common::Base::Fmt::_2); ostringstream buf; - // TODO: time leading spaces and zeroes - buf << "$" << hex << " = #" << dec << " = %" << bin; + buf << _toolTipText + << "$" << Common::Base::toString(val, Common::Base::Fmt::_16) + << " = #" << val; + if(val < 0x100) + buf << " = %" << Common::Base::toString(val, Common::Base::Fmt::_2); + return buf.str(); } diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index b8c0662ee..07e530ac6 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -18,6 +18,7 @@ #include "Cart.hxx" #include "Widget.hxx" #include "Dialog.hxx" +#include "ToolTip.hxx" #include "Settings.hxx" #include "StellaKeys.hxx" #include "EventHandler.hxx" @@ -406,6 +407,7 @@ void DebuggerDialog::createFont() break; } } + tooltip().setFont(*myNFont); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 58d392ee9..e595fc6aa 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -442,6 +442,69 @@ void RomListWidget::lostFocusWidget() abortEditMode(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Common::Point RomListWidget::getToolTipIndex(Common::Point pos) const +{ + const Common::Rect& r = getEditRect(); + const int col = (pos.x - r.x() - getAbsX()) / _font.getMaxCharWidth(); + const int row = (pos.y - getAbsY()) / _lineHeight; + + if(col < 0) + return Common::Point(-1, -1); + else + return Common::Point(col, row + _currentPos); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string RomListWidget::getToolTip(Common::Point pos) const +{ + const Common::Point idx = getToolTipIndex(pos); + + if(idx.y == -1) + return EmptyString; + + const string bytes = myDisasm->list[idx.y].bytes; + + if(bytes.length() < idx.x + 1) + return EmptyString; + + Int32 val; + if(bytes.length() == 8 && bytes[2] != ' ') + { + // Binary value + val = stol(bytes, 0, 2); + } + else + { + // hex 1..3 values + if(idx.x % 3 == 2) + // Skip gaps between hex values + return EmptyString; + + // Get one hex byte + const string valStr = bytes.substr((idx.x / 3) * 3, 2); + + val = stol(valStr, 0, 16); + + } + ostringstream buf; + + buf << _toolTipText + << "$" << Common::Base::toString(val, Common::Base::Fmt::_16) + << " = #" << val; + if(val < 0x100) + buf << " = %" << Common::Base::toString(val, Common::Base::Fmt::_2); + + return buf.str(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool RomListWidget::changedToolTip(Common::Point oldPos, Common::Point newPos) const +{ + return getToolTipIndex(oldPos) != getToolTipIndex(newPos); +} + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RomListWidget::drawWidget(bool hilite) { diff --git a/src/debugger/gui/RomListWidget.hxx b/src/debugger/gui/RomListWidget.hxx index 37473d12f..3f26d217f 100644 --- a/src/debugger/gui/RomListWidget.hxx +++ b/src/debugger/gui/RomListWidget.hxx @@ -56,6 +56,9 @@ class RomListWidget : public EditableWidget void setSelected(int item); void setHighlighted(int item); + string getToolTip(Common::Point pos) const override; + bool changedToolTip(Common::Point oldPos, Common::Point newPos) const override; + protected: void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; @@ -77,11 +80,15 @@ class RomListWidget : public EditableWidget void endEditMode() override; void abortEditMode() override; void lostFocusWidget() override; + + bool hasToolTip() const override { return true; } + void scrollToSelected() { scrollToCurrent(_selectedItem); } void scrollToHighlighted() { scrollToCurrent(_highlightedItem); } private: void scrollToCurrent(int item); + Common::Point getToolTipIndex(Common::Point pos) const; private: unique_ptr myMenu; diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index 60f4ee154..e20544783 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -223,6 +223,7 @@ string ToggleWidget::getToolTip(Common::Point pos) const { const int idx = getToolTipIndex(pos); Int32 val = 0; + ostringstream buf; if(_swapBits) for(int col = _cols - 1; col >= 0; --col) @@ -238,13 +239,12 @@ string ToggleWidget::getToolTip(Common::Point pos) const } val <<= _shiftBits; - const string hex = Common::Base::toString(val, Common::Base::Fmt::_16); - const string dec = Common::Base::toString(val, Common::Base::Fmt::_10); - const string bin = Common::Base::toString(val, Common::Base::Fmt::_2); - ostringstream buf; + buf << _toolTipText + << "$" << Common::Base::toString(val, Common::Base::Fmt::_16) + << " = #" << val; + if(val < 0x100) + buf << " = %" << Common::Base::toString(val, Common::Base::Fmt::_2); - // TODO: time leading spaces and zeroes - buf << "$" << hex << " = #" << dec << " = %" << bin; return buf.str(); } diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 9c140e15c..5092299ec 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -30,6 +30,7 @@ #include "StellaSettingsDialog.hxx" #include "WhatsNewDialog.hxx" #include "MessageBox.hxx" +#include "ToolTip.hxx" #include "OSystem.hxx" #include "FrameBuffer.hxx" #include "FBSurface.hxx" @@ -56,8 +57,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent, int x, int y, int w, int h) - : Dialog(osystem, parent, osystem.frameBuffer().launcherFont(), "", - x, y, w, h) + : Dialog(osystem, parent, x, y, w, h) { myUseMinimalUI = instance().settings().getBool("minimal_ui"); @@ -80,6 +80,8 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent, const string& lblAllFiles = "Show all files"; const string& lblFound = "XXXX items found"; + tooltip().setFont(font); + lwidth = font.getStringWidth(lblRom); lwidth2 = font.getStringWidth(lblAllFiles) + CheckboxWidget::boxSize(font); int lwidth3 = font.getStringWidth(lblFilter); diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index 36c8b1b20..85f5bedf4 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -32,16 +32,24 @@ // + disable when in edit mode // - option to disable tips // - multi line tips -// - nicer formating of DataDridWidget tip -// - allow reversing ToogleWidget (TooglePixelWidget) -// - shift checkbox bits +// + nicer formating of DataDridWidget tip +// + allow reversing ToogleWidget (TooglePixelWidget) +// + shift checkbox bits // - RomListWidget (hex codes, maybe disassembly operands) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ToolTip::ToolTip(Dialog& dialog, const GUI::Font& font) - : myDialog(dialog), - myFont(font) + : myDialog(dialog) { + myScale = myDialog.instance().frameBuffer().hidpiScaleFactor(); + + setFont(font); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ToolTip::setFont(const GUI::Font& font) +{ + myFont = &font; const int fontWidth = font.getMaxCharWidth(), fontHeight = font.getFontHeight(); @@ -51,7 +59,6 @@ ToolTip::ToolTip(Dialog& dialog, const GUI::Font& font) myHeight = fontHeight + myTextYOfs * 2; mySurface = myDialog.instance().frameBuffer().allocateSurface(myWidth, myHeight); - myScale = myDialog.instance().frameBuffer().hidpiScaleFactor(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -86,7 +93,7 @@ void ToolTip::release() { if(myTipShown) { - myTimer = DELAY_TIME; + myTimer = DELAY_TIME - 1; myTipShown = false; myDialog.setDirtyChain(); @@ -118,7 +125,16 @@ void ToolTip::show() const uInt32 V_GAP = 1; const uInt32 H_CURSOR = 18; string text = myTipWidget->getToolTip(myPos); - uInt32 width = std::min(myWidth, myFont.getStringWidth(text) + myTextXOfs * 2); + + myTipShown = true; + if(text.empty()) + { + release(); + return; + } + + uInt32 width = std::min(myWidth, myFont->getStringWidth(text) + myTextXOfs * 2); + //uInt32 height = std::min(myHeight, font.getFontHeight() + myTextYOfs * 2); // Note: The rects include HiDPI scaling const Common::Rect imageRect = myDialog.instance().frameBuffer().imageRect(); const Common::Rect dialogRect = myDialog.surface().dstRect(); @@ -142,7 +158,7 @@ void ToolTip::show() mySurface->frameRect(0, 0, width, myHeight, kColor); mySurface->fillRect(1, 1, width - 2, myHeight - 2, kWidColor); - mySurface->drawString(myFont, text, myTextXOfs, myTextYOfs, + mySurface->drawString(*myFont, text, myTextXOfs, myTextYOfs, width - myTextXOfs * 2, myHeight - myTextYOfs * 2, kTextColor); myTipShown = true; diff --git a/src/gui/ToolTip.hxx b/src/gui/ToolTip.hxx index b3bbf547a..879200c06 100644 --- a/src/gui/ToolTip.hxx +++ b/src/gui/ToolTip.hxx @@ -40,6 +40,8 @@ class ToolTip ToolTip(Dialog& dialog, const GUI::Font& font); ~ToolTip() = default; + void setFont(const GUI::Font& font); + /** Request a tooltip display. */ @@ -73,7 +75,7 @@ class ToolTip static constexpr uInt32 DELAY_TIME = 45; // display delay Dialog& myDialog; - const GUI::Font& myFont; + const GUI::Font* myFont{nullptr}; const Widget* myTipWidget{nullptr}; const Widget* myFocusWidget{nullptr}; From 94ed04469761e2b7b35eeb1611b5eb36dcd2e12b Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 17 Nov 2020 19:41:23 +0100 Subject: [PATCH 52/70] added tooltips to TiaInfoWidget and CpuWidget --- src/debugger/gui/CpuWidget.cxx | 6 +++--- src/debugger/gui/RomListWidget.cxx | 2 +- src/debugger/gui/TiaInfoWidget.cxx | 11 +++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/debugger/gui/CpuWidget.cxx b/src/debugger/gui/CpuWidget.cxx index ea6fbb96f..a8719f448 100644 --- a/src/debugger/gui/CpuWidget.cxx +++ b/src/debugger/gui/CpuWidget.cxx @@ -85,18 +85,19 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n _w = lwidth + myPCGrid->getWidth() + myPCLabel->getWidth() + 20; // Create labels showing the source of data for SP/A/X/Y registers + const std::array labels = { "SP", "A", "X", "Y" }; xpos += myCpuGridBinValue->getWidth() + 20; int src_y = ypos, src_w = (max_w - xpos + x) - 10; for(int i = 0; i < 4; ++i) { myCpuDataSrc[i] = new EditTextWidget(boss, nfont, xpos, src_y, src_w, fontHeight + 1); + myCpuDataSrc[i]->setToolTip("Source label of last load into " + labels[i] + "."); myCpuDataSrc[i]->setEditable(false, true); src_y += fontHeight + 2; } // Add labels for other CPU registers xpos = x; - const std::array labels = { "SP ", "A ", "X ", "Y " }; for(int row = 0; row < 4; ++row) { new StaticTextWidget(boss, lfont, xpos, ypos + row*lineHeight + 2, @@ -139,10 +140,9 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n xpos = myCpuDataSrc[0]->getLeft(); new StaticTextWidget(boss, lfont, xpos - fontWidth * 4.5, ypos + 2, "Dest"); myCpuDataDest = new EditTextWidget(boss, nfont, xpos, ypos, src_w, fontHeight + 1); + myCpuDataDest->setToolTip("Destination label of last store."); myCpuDataDest->setEditable(false, true); - - _h = ypos + myPSRegister->getHeight() - y; } diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index e595fc6aa..72f3a0b03 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -476,7 +476,7 @@ string RomListWidget::getToolTip(Common::Point pos) const } else { - // hex 1..3 values + // 1..3 hex values if(idx.x % 3 == 2) // Skip gaps between hex values return EmptyString; diff --git a/src/debugger/gui/TiaInfoWidget.cxx b/src/debugger/gui/TiaInfoWidget.cxx index a02b2365d..2690f8b4f 100644 --- a/src/debugger/gui/TiaInfoWidget.cxx +++ b/src/debugger/gui/TiaInfoWidget.cxx @@ -60,30 +60,35 @@ TiaInfoWidget::TiaInfoWidget(GuiObject* boss, const GUI::Font& lfont, xpos = x; new StaticTextWidget(boss, lfont, xpos, ypos + 1, longstr ? "Frame Cycls" : "F. Cycls"); myFrameCycles = new EditTextWidget(boss, nfont, xpos + lwidth, ypos - 1, fwidth, lineHeight); + myFrameCycles->setToolTip("CPU cycles executed this frame."); myFrameCycles->setEditable(false, true); // Left: WSync Cycles ypos += lineHeight + VGAP; new StaticTextWidget(boss, lfont, xpos, ypos + 1, longstr ? "WSync Cycls" : "WSync C."); myWSyncCylces = new EditTextWidget(boss, nfont, xpos + lwidth, ypos - 1, fwidth, lineHeight); + myWSyncCylces->setToolTip("CPU cycles used for WSYNC this frame."); myWSyncCylces->setEditable(false, true); // Left: Timer Cycles ypos += lineHeight + VGAP; new StaticTextWidget(boss, lfont, xpos, ypos + 1, longstr ? "Timer Cycls" : "Timer C."); myTimerCylces = new EditTextWidget(boss, nfont, xpos + lwidth, ypos - 1, fwidth, lineHeight); + myTimerCylces->setToolTip("CPU cycles roughly used for INTIM reads this frame."); myTimerCylces->setEditable(false, true); // Left: Total Cycles ypos += lineHeight + VGAP; new StaticTextWidget(boss, lfont, xpos, ypos + 1, "Total"); myTotalCycles = new EditTextWidget(boss, nfont, xpos + lwidth8, ypos - 1, twidth, lineHeight); + myTotalCycles->setToolTip("Total CPU cycles executed for this session (E notation)."); myTotalCycles->setEditable(false, true); // Left: Delta Cycles ypos += lineHeight + VGAP; new StaticTextWidget(boss, lfont, xpos, ypos + 1, "Delta"); myDeltaCycles = new EditTextWidget(boss, nfont, xpos + lwidth8, ypos - 1, twidth, lineHeight); + myDeltaCycles->setToolTip("CPU cycles executed since last debug break."); myDeltaCycles->setEditable(false, true); // Right column @@ -93,6 +98,7 @@ TiaInfoWidget::TiaInfoWidget(GuiObject* boss, const GUI::Font& lfont, // Right: Frame Count new StaticTextWidget(boss, lfont, xpos, ypos + 1, longstr ? "Frame Cnt." : "Frame"); myFrameCount = new EditTextWidget(boss, nfont, xpos + lwidthR, ypos - 1, fwidth, lineHeight); + myFrameCount->setToolTip("Total number of frames executed this session."); myFrameCount->setEditable(false, true); lwidth = lfont.getStringWidth(longstr ? "Color Clock " : "Pixel Pos ") + LGAP; @@ -102,28 +108,33 @@ TiaInfoWidget::TiaInfoWidget(GuiObject* boss, const GUI::Font& lfont, ypos += lineHeight + VGAP; new StaticTextWidget(boss, lfont, xpos, ypos + 1, longstr ? "Scanline" : "Scn Ln"); myScanlineCountLast = new EditTextWidget(boss, nfont, xpos + lwidth, ypos - 1, fwidth, lineHeight); + myScanlineCountLast->setToolTip("Number of scanlines of last frame."); myScanlineCountLast->setEditable(false, true); myScanlineCount = new EditTextWidget(boss, nfont, xpos + lwidth - myScanlineCountLast->getWidth() - 2, ypos - 1, fwidth, lineHeight); + myScanlineCount->setToolTip("Current scanline of this frame."); myScanlineCount->setEditable(false, true); // Right: Scan Cycle ypos += lineHeight + VGAP; new StaticTextWidget(boss, lfont, xpos, ypos + 1, longstr ? "Scan Cycle" : "Scn Cycle"); myScanlineCycles = new EditTextWidget(boss, nfont, xpos + lwidth, ypos - 1, fwidth, lineHeight); + myScanlineCycles->setToolTip("CPU cycles in current scanline."); myScanlineCycles->setEditable(false, true); // Right: Pixel Pos ypos += lineHeight + VGAP; new StaticTextWidget(boss, lfont, xpos, ypos + 1, "Pixel Pos"); myPixelPosition = new EditTextWidget(boss, nfont, xpos + lwidth, ypos - 1, fwidth, lineHeight); + myPixelPosition->setToolTip("Pixel position in current scanline."); myPixelPosition->setEditable(false, true); // Right: Color Clock ypos += lineHeight + VGAP; new StaticTextWidget(boss, lfont, xpos, ypos + 1, longstr ? "Color Clock" : "Color Clk"); myColorClocks = new EditTextWidget(boss, nfont, xpos + lwidth, ypos - 1, fwidth, lineHeight); + myColorClocks->setToolTip("Color clocks in current scanline."); myColorClocks->setEditable(false, true); // Calculate actual dimensions From a660861008adf479525c7283ab3fb86c6af7251f Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Tue, 17 Nov 2020 18:37:10 -0330 Subject: [PATCH 53/70] Fixed minor clang warnings, and implemented clang-tidy suggestions. --- src/debugger/gui/RomListWidget.cxx | 6 +++--- src/debugger/gui/ToggleWidget.cxx | 8 +------- src/debugger/gui/ToggleWidget.hxx | 16 ++++++++-------- src/gui/ToolTip.cxx | 7 +++++-- src/gui/ToolTip.hxx | 4 ++-- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 72f3a0b03..504f7443d 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -465,14 +465,14 @@ string RomListWidget::getToolTip(Common::Point pos) const const string bytes = myDisasm->list[idx.y].bytes; - if(bytes.length() < idx.x + 1) + if(bytes.length() < size_t(idx.x + 1)) return EmptyString; Int32 val; if(bytes.length() == 8 && bytes[2] != ' ') { // Binary value - val = stol(bytes, 0, 2); + val = static_cast(stol(bytes, 0, 2)); } else { @@ -484,7 +484,7 @@ string RomListWidget::getToolTip(Common::Point pos) const // Get one hex byte const string valStr = bytes.substr((idx.x / 3) * 3, 2); - val = stol(valStr, 0, 16); + val = static_cast(stol(valStr, 0, 16)); } ostringstream buf; diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index e20544783..2a4187c6d 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -28,13 +28,7 @@ ToggleWidget::ToggleWidget(GuiObject* boss, const GUI::Font& font, CommandSender(boss), _rows(rows), _cols(cols), - _currentRow(0), - _currentCol(0), - _rowHeight(0), - _colWidth(0), - _selectedItem(0), - _shiftBits(shiftBits), - _editable(true) + _shiftBits(shiftBits) { _flags = Widget::FLAG_ENABLED | Widget::FLAG_CLEARBG | Widget::FLAG_RETAIN_FOCUS | Widget::FLAG_WANTS_RAWDATA; diff --git a/src/debugger/gui/ToggleWidget.hxx b/src/debugger/gui/ToggleWidget.hxx index 5f4ec13a7..3f74237b0 100644 --- a/src/debugger/gui/ToggleWidget.hxx +++ b/src/debugger/gui/ToggleWidget.hxx @@ -53,14 +53,14 @@ class ToggleWidget : public Widget, public CommandSender bool hasToolTip() const override { return true; } protected: - int _rows; - int _cols; - int _currentRow; - int _currentCol; - int _rowHeight; // explicitly set in child classes - int _colWidth; // explicitly set in child classes - int _selectedItem; - bool _editable; + int _rows{0}; + int _cols{0}; + int _currentRow{0}; + int _currentCol{0}; + int _rowHeight{0}; // explicitly set in child classes + int _colWidth{0}; // explicitly set in child classes + int _selectedItem{0}; + bool _editable{true}; bool _swapBits{false}; int _shiftBits{0}; // shift bits for tooltip display diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index 85f5bedf4..77b5d5e20 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -62,7 +62,7 @@ void ToolTip::setFont(const GUI::Font& font) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ToolTip::update(const Widget* widget, Common::Point pos) +void ToolTip::update(const Widget* widget, const Common::Point& pos) { if(myTipWidget != widget) { @@ -70,7 +70,10 @@ void ToolTip::update(const Widget* widget, Common::Point pos) release(); } if(myTipShown && myTipWidget->changedToolTip(myPos, pos)) - myPos = pos, show(); + { + myPos = pos; + show(); + } else myPos = pos; } diff --git a/src/gui/ToolTip.hxx b/src/gui/ToolTip.hxx index 879200c06..17ff2e7ec 100644 --- a/src/gui/ToolTip.hxx +++ b/src/gui/ToolTip.hxx @@ -59,9 +59,9 @@ class ToolTip void release(); /** - Update focussed widget and current mouse position. + Update focused widget and current mouse position. */ - void update(const Widget* widget, Common::Point pos); + void update(const Widget* widget, const Common::Point& pos); /* Render the tooltip From d7d813b901e4ecb22dcdca291a62921f0d840d48 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Tue, 17 Nov 2020 18:54:35 -0330 Subject: [PATCH 54/70] Fixed another minor clang warning. --- src/debugger/gui/RomListWidget.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 504f7443d..0d0d6c3fa 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -472,7 +472,7 @@ string RomListWidget::getToolTip(Common::Point pos) const if(bytes.length() == 8 && bytes[2] != ' ') { // Binary value - val = static_cast(stol(bytes, 0, 2)); + val = static_cast(stol(bytes, nullptr, 2)); } else { @@ -484,7 +484,7 @@ string RomListWidget::getToolTip(Common::Point pos) const // Get one hex byte const string valStr = bytes.substr((idx.x / 3) * 3, 2); - val = static_cast(stol(valStr, 0, 16)); + val = static_cast(stol(valStr, nullptr, 16)); } ostringstream buf; From 9aaca0bd4e01c17f4aba012d3120d9d0799cf719 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 18 Nov 2020 17:48:19 +0100 Subject: [PATCH 55/70] improved tooltip handling (better delays, rerender instead of redraw) added tooltip to StringListWidget for shortened texts (e.g. ROM names in launcher) added code for StaticTextWidget tooltip (without setting widget dirty) --- src/debugger/gui/RomListWidget.cxx | 2 +- src/gui/Dialog.cxx | 4 +- src/gui/EditableWidget.cxx | 8 +-- src/gui/EditableWidget.hxx | 1 + src/gui/GuiObject.hxx | 8 +-- src/gui/StringListWidget.cxx | 30 +++++++++ src/gui/StringListWidget.hxx | 9 +++ src/gui/ToolTip.cxx | 104 ++++++++++++++--------------- src/gui/ToolTip.hxx | 12 ++-- src/gui/Widget.cxx | 21 +++++- src/gui/Widget.hxx | 4 +- 11 files changed, 130 insertions(+), 73 deletions(-) diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 0d0d6c3fa..861a4112d 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -40,6 +40,7 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, _textcolorhi = kTextColor; _editMode = false; + _dyCaret = 1; _cols = w / _fontWidth; _rows = h / _lineHeight; @@ -485,7 +486,6 @@ string RomListWidget::getToolTip(Common::Point pos) const const string valStr = bytes.substr((idx.x / 3) * 3, 2); val = static_cast(stol(valStr, nullptr, 16)); - } ostringstream buf; diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index a33b4ffa1..1b58d7729 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -432,9 +432,9 @@ void Dialog::drawDialog() FBSurface& s = surface(); - cerr << endl << "d"; if(isDirty()) { + cerr << endl << "d"; //cerr << "*** draw dialog " << typeid(*this).name() << " ***" << endl; if(clearsBackground()) @@ -464,6 +464,8 @@ void Dialog::drawDialog() clearDirty(); } + else + cerr << endl; // Draw all children drawChain(); diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 39a4b519f..8ff411f83 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -107,7 +107,7 @@ void EditableWidget::receivedFocusWidget() { _caretTimer = 0; _caretEnabled = true; - dialog().tooltip().release(); + dialog().tooltip().hide(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -379,7 +379,7 @@ void EditableWidget::drawCaretSelection() x += _x; y += _y; - s.fillRect(x - 1, y + 1, w + 1, h - 3, kTextColorHi); + s.fillRect(x - 1, y + 1 + _dyCaret, w + 1, h - 3, kTextColorHi); s.drawString(_font, text, x, y + 1, w, h, kTextColorInv, TextAlign::Left, 0, false); } @@ -397,8 +397,8 @@ void EditableWidget::drawCaretSelection() x += _x; y += _y; - s.vLine(x, y + 1, y + editRect.h() - 3, color); - s.vLine(x - 1, y + 1, y + editRect.h() - 3, color); + s.vLine(x, y + 1 + _dyCaret, y + editRect.h() - 3, color); + s.vLine(x - 1, y + 1 + _dyCaret, y + editRect.h() - 3, color); clearDirty(); } } diff --git a/src/gui/EditableWidget.hxx b/src/gui/EditableWidget.hxx index 6e55cf541..497c2a4e8 100644 --- a/src/gui/EditableWidget.hxx +++ b/src/gui/EditableWidget.hxx @@ -125,6 +125,7 @@ class EditableWidget : public Widget, public CommandSender protected: int _editScrollOffset{0}; bool _editMode{true}; + int _dyCaret{0}; private: TextFilter _filter; diff --git a/src/gui/GuiObject.hxx b/src/gui/GuiObject.hxx index 490df4344..85424a670 100644 --- a/src/gui/GuiObject.hxx +++ b/src/gui/GuiObject.hxx @@ -106,20 +106,20 @@ class GuiObject : public CommandReceiver virtual void tick() = 0; - void setFlags(uInt32 flags) + void setFlags(uInt32 flags, bool updateDirty = true) { uInt32 oldFlags = _flags; _flags |= flags; - if(oldFlags != _flags) + if(updateDirty && oldFlags != _flags) setDirty(); } - void clearFlags(uInt32 flags) + void clearFlags(uInt32 flags, bool updateDirty = true) { uInt32 oldFlags = _flags; _flags &= ~flags; - if(oldFlags != _flags) + if(updateDirty && oldFlags != _flags) setDirty(); } uInt32 getFlags() const { return _flags; } diff --git a/src/gui/StringListWidget.cxx b/src/gui/StringListWidget.cxx index ad5f1e7ec..74cf23e40 100644 --- a/src/gui/StringListWidget.cxx +++ b/src/gui/StringListWidget.cxx @@ -50,6 +50,36 @@ void StringListWidget::setList(const StringList& list) ListWidget::recalc(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int StringListWidget::getToolTipIndex(Common::Point pos) const +{ + return (pos.y - getAbsY()) / _lineHeight + _currentPos; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string StringListWidget::getToolTip(Common::Point pos) const +{ + Common::Rect rect = getEditRect(); + const string value = _list[getToolTipIndex(pos)]; + + if(uInt32(_font.getStringWidth(value)) > rect.w()) + return _toolTipText + value; + else + return _toolTipText; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool StringListWidget::changedToolTip(Common::Point oldPos, Common::Point newPos) const +{ + bool ch = getToolTipIndex(oldPos) != getToolTipIndex(newPos) + && getToolTip(oldPos) != getToolTip(newPos); + + if(ch) + cerr << "changed" << endl; + + return ch; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void StringListWidget::drawWidget(bool hilite) { diff --git a/src/gui/StringListWidget.hxx b/src/gui/StringListWidget.hxx index ed5874b91..fb96a9e22 100644 --- a/src/gui/StringListWidget.hxx +++ b/src/gui/StringListWidget.hxx @@ -32,10 +32,16 @@ class StringListWidget : public ListWidget void setList(const StringList& list); bool wantsFocus() const override { return true; } + string getToolTip(Common::Point pos) const override; + bool changedToolTip(Common::Point oldPos, Common::Point newPos) const override; + protected: // display depends on _hasFocus so we have to redraw when focus changes void receivedFocusWidget() override { setDirty(); } void lostFocusWidget() override { setDirty(); } + + bool hasToolTip() const override { return true; } + void drawWidget(bool hilite) override; Common::Rect getEditRect() const override; @@ -43,6 +49,9 @@ class StringListWidget : public ListWidget bool _hilite{false}; int _textOfs{0}; + private: + int getToolTipIndex(Common::Point pos) const; + private: // Following constructors and assignment operators not supported StringListWidget() = delete; diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index 77b5d5e20..5d37478db 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -17,6 +17,7 @@ #include "OSystem.hxx" #include "Dialog.hxx" +#include "DialogContainer.hxx" #include "Font.hxx" #include "FrameBuffer.hxx" #include "FBSurface.hxx" @@ -25,17 +26,8 @@ #include "ToolTip.hxx" // TODOs: -// + keep enabled when mouse moves over same widget -// + static position and text for normal widgets -// + moving position and text over e.g. DataGridWidget -// + reenable tip faster -// + disable when in edit mode // - option to disable tips // - multi line tips -// + nicer formating of DataDridWidget tip -// + allow reversing ToogleWidget (TooglePixelWidget) -// + shift checkbox bits -// - RomListWidget (hex codes, maybe disassembly operands) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ToolTip::ToolTip(Dialog& dialog, const GUI::Font& font) @@ -61,21 +53,48 @@ void ToolTip::setFont(const GUI::Font& font) mySurface = myDialog.instance().frameBuffer().allocateSurface(myWidth, myHeight); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ToolTip::request() +{ + // Called each frame when a tooltip is wanted + if(myFocusWidget && myTimer < DELAY_TIME * RELEASE_SPEED) + { + const string tip = myFocusWidget->getToolTip(myMousePos); + + if(!tip.empty()) + { + myTipWidget = myFocusWidget; + myTimer += RELEASE_SPEED; + if(myTimer >= DELAY_TIME * RELEASE_SPEED) + show(tip); + } + } +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ToolTip::update(const Widget* widget, const Common::Point& pos) { + // Called each mouse move + myMousePos = pos; + myFocusWidget = widget; + if(myTipWidget != widget) - { - myFocusWidget = widget; - release(); - } - if(myTipShown && myTipWidget->changedToolTip(myPos, pos)) - { - myPos = pos; - show(); - } + release(false); + + if(!myTipShown) + release(true); else - myPos = pos; + { + if(myTipWidget->changedToolTip(myTipPos, myMousePos)) + { + const string tip = myTipWidget->getToolTip(myMousePos); + + if(!tip.empty()) + show(tip); + else + release(true); + } + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -85,65 +104,40 @@ void ToolTip::hide() { myTimer = 0; myTipWidget = myFocusWidget = nullptr; - myTipShown = false; - myDialog.setDirtyChain(); + myDialog.instance().frameBuffer().setPendingRender(); } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ToolTip::release() +void ToolTip::release(bool emptyTip) { if(myTipShown) { - myTimer = DELAY_TIME - 1; - myTipShown = false; - myDialog.setDirtyChain(); + myDialog.instance().frameBuffer().setPendingRender(); } // After displaying a tip, slowly reset the timer to 0 // until a new tip is requested - if(myTipWidget != myFocusWidget && myTimer) + if((emptyTip || myTipWidget != myFocusWidget) && myTimer) myTimer--; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ToolTip::request() +void ToolTip::show(const string& tip) { - myTipWidget = myFocusWidget; - - if(myTimer == DELAY_TIME) - show(); - - myTimer++; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ToolTip::show() -{ - if(myTipWidget == nullptr) - return; + myTipPos = myMousePos; const uInt32 V_GAP = 1; const uInt32 H_CURSOR = 18; - string text = myTipWidget->getToolTip(myPos); - - myTipShown = true; - if(text.empty()) - { - release(); - return; - } - - uInt32 width = std::min(myWidth, myFont->getStringWidth(text) + myTextXOfs * 2); - //uInt32 height = std::min(myHeight, font.getFontHeight() + myTextYOfs * 2); + uInt32 width = std::min(myWidth, myFont->getStringWidth(tip) + myTextXOfs * 2); // Note: The rects include HiDPI scaling const Common::Rect imageRect = myDialog.instance().frameBuffer().imageRect(); const Common::Rect dialogRect = myDialog.surface().dstRect(); // Limit position to app size and adjust accordingly - const Int32 xAbs = myPos.x + dialogRect.x() / myScale; - const uInt32 yAbs = myPos.y + dialogRect.y() / myScale; + const Int32 xAbs = myTipPos.x + dialogRect.x() / myScale; + const uInt32 yAbs = myTipPos.y + dialogRect.y() / myScale; Int32 x = std::min(xAbs, Int32(imageRect.w() / myScale - width)); const uInt32 y = (yAbs + myHeight + H_CURSOR > imageRect.h() / myScale) ? yAbs - myHeight - V_GAP @@ -161,11 +155,11 @@ void ToolTip::show() mySurface->frameRect(0, 0, width, myHeight, kColor); mySurface->fillRect(1, 1, width - 2, myHeight - 2, kWidColor); - mySurface->drawString(*myFont, text, myTextXOfs, myTextYOfs, + mySurface->drawString(*myFont, tip, myTextXOfs, myTextYOfs, width - myTextXOfs * 2, myHeight - myTextYOfs * 2, kTextColor); myTipShown = true; - myDialog.setDirtyChain(); + myDialog.instance().frameBuffer().setPendingRender(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/ToolTip.hxx b/src/gui/ToolTip.hxx index 17ff2e7ec..2c9f95037 100644 --- a/src/gui/ToolTip.hxx +++ b/src/gui/ToolTip.hxx @@ -56,7 +56,7 @@ class ToolTip Hide a displayed tooltip and reset the timer slowly. This allows faster tip display of the next tip. */ - void release(); + void release(bool emptyTip); /** Update focused widget and current mouse position. @@ -69,10 +69,13 @@ class ToolTip void render(); private: - void show(); + void show(const string& tip); private: - static constexpr uInt32 DELAY_TIME = 45; // display delay + static constexpr uInt32 DELAY_TIME = 45; // display delay [frames] + // Tips are slower released than requested, so that repeated tips are shown + // faster. This constant defines how much faster. + static constexpr uInt32 RELEASE_SPEED = 2; Dialog& myDialog; const GUI::Font* myFont{nullptr}; @@ -80,7 +83,8 @@ class ToolTip const Widget* myFocusWidget{nullptr}; uInt32 myTimer{0}; - Common::Point myPos; + Common::Point myMousePos; + Common::Point myTipPos; uInt32 myWidth{0}; uInt32 myHeight{0}; uInt32 myTextXOfs{0}; diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index cfb933965..23c72760d 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -97,8 +97,8 @@ void Widget::draw() if(isDirty()) { - //cerr << " *** draw widget " << typeid(*this).name() << " ***" << endl; - cerr << "w"; + cerr << " *** draw widget " << typeid(*this).name() << " ***" << endl; + //cerr << "w"; FBSurface& s = _boss->dialog().surface(); @@ -418,6 +418,23 @@ void StaticTextWidget::setLabel(const string& label) setDirty(); } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void StaticTextWidget::handleMouseEntered() +{ + if(isEnabled()) + // Mouse focus for tooltips must not change dirty status + setFlags(Widget::FLAG_MOUSE_FOCUS, false); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void StaticTextWidget::handleMouseLeft() +{ + if(isEnabled()) + // Mouse focus for tooltips must not change dirty status + clearFlags(Widget::FLAG_MOUSE_FOCUS, false); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void StaticTextWidget::drawWidget(bool hilite) { diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 45c676fe2..c5eb233b3 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -186,8 +186,8 @@ class StaticTextWidget : public Widget ColorId shadowColor = kNone); ~StaticTextWidget() override = default; - void handleMouseEntered() override {} - void handleMouseLeft() override {} + void handleMouseEntered() override; + void handleMouseLeft() override; void setValue(int value); void setLabel(const string& label); From c19cde6f118ef3e4456fe51c0d0e19a4dc222626 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 18 Nov 2020 20:07:25 +0100 Subject: [PATCH 56/70] added multi-line tooltip support --- src/debugger/gui/RomListWidget.cxx | 6 ++-- src/emucore/FBSurface.cxx | 52 +++++++++++++++++------------- src/emucore/FBSurface.hxx | 15 +++++++-- src/gui/EditableWidget.cxx | 8 ++--- src/gui/EditableWidget.hxx | 2 +- src/gui/ToolTip.cxx | 44 +++++++++++++++++-------- src/gui/ToolTip.hxx | 6 +++- 7 files changed, 84 insertions(+), 49 deletions(-) diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 861a4112d..5f4487786 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -40,7 +40,7 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, _textcolorhi = kTextColor; _editMode = false; - _dyCaret = 1; + _dyText = -1; // fixes the vertical position of selected text _cols = w / _fontWidth; _rows = h / _lineHeight; @@ -631,8 +631,8 @@ Common::Rect RomListWidget::getEditRect() const { const int yoffset = std::max(0, (_selectedItem - _currentPos) * _lineHeight); - return Common::Rect(2 + _w - _bytesWidth, 1 + yoffset, - _w, _lineHeight + yoffset); + return Common::Rect(2 + _w - _bytesWidth, 1 + yoffset + 1, + _w, _lineHeight + yoffset + 1); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index c489fc703..cfcf58ff3 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -296,21 +296,39 @@ void FBSurface::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FBSurface::wrapString(const string& inStr, int pos, string& leftStr, string& rightStr) const +void FBSurface::splitString(const GUI::Font& font, const string& s, int w, + string& left, string& right) const { - for(int i = pos; i > 0; --i) + uInt32 pos; + int w2 = 0; + bool split = false; + + // SLOW algorithm to find the acceptable length. But it is good enough for now. + for(pos = 0; pos < s.size(); ++pos) { - if(isWhiteSpace(inStr[i])) + int charWidth = font.getCharWidth(s[pos]); + if(w2 + charWidth > w) { - leftStr = inStr.substr(0, i); - if(inStr[i] == ' ') // skip leading space after line break - i++; - rightStr = inStr.substr(i); - return; + split = true; + break; } + w2 += charWidth; } - leftStr = inStr.substr(0, pos); - rightStr = inStr.substr(pos); + + if(split) + for(int i = pos; i > 0; --i) + { + if(isWhiteSpace(s[i])) + { + left = s.substr(0, i); + if(s[i] == ' ') // skip leading space after line break + i++; + right = s.substr(i); + return; + } + } + left = s.substr(0, pos); + right = s.substr(pos); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -340,21 +358,9 @@ int FBSurface::drawString(const GUI::Font& font, const string& s, while (font.getStringWidth(inStr) > w && h >= font.getFontHeight() * 2) { // String is too wide. - uInt32 i; string leftStr, rightStr; - int w2 = 0; - // SLOW algorithm to find the acceptable length. But it is good enough for now. - for(i = 0; i < inStr.size(); ++i) - { - int charWidth = font.getCharWidth(inStr[i]); - if(w2 + charWidth > w) - break; - - w2 += charWidth; - //str += inStr[i]; - } - wrapString(inStr, i, leftStr, rightStr); + splitString(font, inStr, w, leftStr, rightStr); drawString(font, leftStr, x, y, w, color, align, deltax, false, shadowColor); h -= font.getFontHeight(); y += font.getFontHeight(); diff --git a/src/emucore/FBSurface.hxx b/src/emucore/FBSurface.hxx index 71bddc289..de19fca28 100644 --- a/src/emucore/FBSurface.hxx +++ b/src/emucore/FBSurface.hxx @@ -247,6 +247,18 @@ class FBSurface ColorId color, TextAlign align = TextAlign::Left, int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone); + /** + Splits a given string to a given width considering whitespaces. + + @param font The font to draw the string with + @param s The string to split + @param w The width of the string area + @param left The left part of the split string + @param right The right part of the split string + */ + void splitString(const GUI::Font& font, const string& s, int w, + string& left, string& right) const; + /** The rendering attributes that can be modified for this texture. These probably can only be implemented in child FBSurfaces where @@ -383,9 +395,6 @@ class FBSurface */ bool checkBounds(const uInt32 x, const uInt32 y) const; - void wrapString(const string& inStr, int pos, - string& leftStr, string& rightStr) const; - /** Check if the given character is a whitespace. @param s Character to check diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 8ff411f83..e015dd899 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -379,8 +379,8 @@ void EditableWidget::drawCaretSelection() x += _x; y += _y; - s.fillRect(x - 1, y + 1 + _dyCaret, w + 1, h - 3, kTextColorHi); - s.drawString(_font, text, x, y + 1, w, h, + s.fillRect(x - 1, y + 1, w + 1, h - 3, kTextColorHi); + s.drawString(_font, text, x, y + 1 + _dyText, w, h, kTextColorInv, TextAlign::Left, 0, false); } @@ -397,8 +397,8 @@ void EditableWidget::drawCaretSelection() x += _x; y += _y; - s.vLine(x, y + 1 + _dyCaret, y + editRect.h() - 3, color); - s.vLine(x - 1, y + 1 + _dyCaret, y + editRect.h() - 3, color); + s.vLine(x, y + 1, y + editRect.h() - 3, color); + s.vLine(x - 1, y + 1, y + editRect.h() - 3, color); clearDirty(); } } diff --git a/src/gui/EditableWidget.hxx b/src/gui/EditableWidget.hxx index 497c2a4e8..3ffe09a65 100644 --- a/src/gui/EditableWidget.hxx +++ b/src/gui/EditableWidget.hxx @@ -125,7 +125,7 @@ class EditableWidget : public Widget, public CommandSender protected: int _editScrollOffset{0}; bool _editMode{true}; - int _dyCaret{0}; + int _dyText{0}; private: TextFilter _filter; diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index 5d37478db..5cfed635c 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -27,7 +27,6 @@ // TODOs: // - option to disable tips -// - multi line tips // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ToolTip::ToolTip(Dialog& dialog, const GUI::Font& font) @@ -47,8 +46,8 @@ void ToolTip::setFont(const GUI::Font& font) myTextXOfs = fontHeight < 24 ? 5 : 8; myTextYOfs = fontHeight < 24 ? 2 : 3; - myWidth = fontWidth * MAX_LEN + myTextXOfs * 2; - myHeight = fontHeight + myTextYOfs * 2; + myWidth = fontWidth * MAX_COLUMNS + myTextXOfs * 2; + myHeight = fontHeight * MAX_ROWS + myTextYOfs * 2; mySurface = myDialog.instance().frameBuffer().allocateSurface(myWidth, myHeight); } @@ -129,9 +128,30 @@ void ToolTip::show(const string& tip) { myTipPos = myMousePos; + uInt32 maxWidth = std::min(myWidth - myTextXOfs * 2, uInt32(myFont->getStringWidth(tip))); + + mySurface->fillRect(1, 1, maxWidth + myTextXOfs * 2 - 2, myHeight - 2, kWidColor); + int lines = std::min(MAX_ROWS, + uInt32(mySurface->drawString(*myFont, tip, myTextXOfs, myTextYOfs, + maxWidth, myHeight - myTextYOfs * 2, + kTextColor))); + // Calculate maximum width of drawn string lines + uInt32 width = 0; + string inStr = tip; + for(int i = 0; i < lines; ++i) + { + string leftStr, rightStr; + + mySurface->splitString(*myFont, inStr, maxWidth, leftStr, rightStr); + width = std::max(width, uInt32(myFont->getStringWidth(leftStr))); + inStr = rightStr; + } + width += myTextXOfs * 2; + + // Calculate and set surface size and position + const uInt32 height = std::min(myHeight, myFont->getFontHeight() * lines + myTextYOfs * 2); const uInt32 V_GAP = 1; const uInt32 H_CURSOR = 18; - uInt32 width = std::min(myWidth, myFont->getStringWidth(tip) + myTextXOfs * 2); // Note: The rects include HiDPI scaling const Common::Rect imageRect = myDialog.instance().frameBuffer().imageRect(); const Common::Rect dialogRect = myDialog.surface().dstRect(); @@ -139,24 +159,20 @@ void ToolTip::show(const string& tip) const Int32 xAbs = myTipPos.x + dialogRect.x() / myScale; const uInt32 yAbs = myTipPos.y + dialogRect.y() / myScale; Int32 x = std::min(xAbs, Int32(imageRect.w() / myScale - width)); - const uInt32 y = (yAbs + myHeight + H_CURSOR > imageRect.h() / myScale) - ? yAbs - myHeight - V_GAP + const uInt32 y = (yAbs + height + H_CURSOR > imageRect.h() / myScale) + ? yAbs - height - V_GAP : yAbs + H_CURSOR / myScale + V_GAP; if(x < 0) { x = 0; - width = imageRect.w() / myScale; + width = std::min(width, imageRect.w() / myScale); } - mySurface->setSrcSize(width, myHeight); - mySurface->setDstSize(width * myScale, myHeight * myScale); + mySurface->setSrcSize(width, height); + mySurface->setDstSize(width * myScale, height * myScale); mySurface->setDstPos(x * myScale, y * myScale); - - mySurface->frameRect(0, 0, width, myHeight, kColor); - mySurface->fillRect(1, 1, width - 2, myHeight - 2, kWidColor); - mySurface->drawString(*myFont, tip, myTextXOfs, myTextYOfs, - width - myTextXOfs * 2, myHeight - myTextYOfs * 2, kTextColor); + mySurface->frameRect(0, 0, width, height, kColor); myTipShown = true; myDialog.instance().frameBuffer().setPendingRender(); diff --git a/src/gui/ToolTip.hxx b/src/gui/ToolTip.hxx index 2c9f95037..71da6dc13 100644 --- a/src/gui/ToolTip.hxx +++ b/src/gui/ToolTip.hxx @@ -33,9 +33,13 @@ class FBSurface; class ToolTip { + private: + static constexpr uInt32 MAX_COLUMNS = 60; + static constexpr uInt32 MAX_ROWS = 5; + public: // Maximum tooltip length - static constexpr uInt32 MAX_LEN = 80; + static constexpr uInt32 MAX_LEN = MAX_COLUMNS * MAX_ROWS; ToolTip(Dialog& dialog, const GUI::Font& font); ~ToolTip() = default; From 59f157187fb3fceb62e61d1318247263bcd3de95 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 18 Nov 2020 21:02:42 +0100 Subject: [PATCH 57/70] improved string wrapping (incl. '\n') fixed potential exception in StringListWidget --- src/emucore/FBSurface.cxx | 17 +++++++++++------ src/gui/StringListWidget.cxx | 14 ++++++++++++-- src/gui/ToolTip.cxx | 3 --- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index cfcf58ff3..6421dd171 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -307,7 +307,7 @@ void FBSurface::splitString(const GUI::Font& font, const string& s, int w, for(pos = 0; pos < s.size(); ++pos) { int charWidth = font.getCharWidth(s[pos]); - if(w2 + charWidth > w) + if(w2 + charWidth > w || s[pos] == '\n') { split = true; break; @@ -321,7 +321,7 @@ void FBSurface::splitString(const GUI::Font& font, const string& s, int w, if(isWhiteSpace(s[i])) { left = s.substr(0, i); - if(s[i] == ' ') // skip leading space after line break + if(s[i] == ' ' || s[pos] == '\n') // skip leading space after line break i++; right = s.substr(i); return; @@ -334,7 +334,7 @@ void FBSurface::splitString(const GUI::Font& font, const string& s, int w, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool FBSurface::isWhiteSpace(const char s) const { - const string WHITESPACES = " ,.;:+-"; + const string WHITESPACES = " ,.;:+-*/'([\n"; for(size_t i = 0; i < WHITESPACES.length(); ++i) if(s == WHITESPACES[i]) @@ -349,13 +349,14 @@ int FBSurface::drawString(const GUI::Font& font, const string& s, ColorId color, TextAlign align, int deltax, bool useEllipsis, ColorId shadowColor) { - int lines = 1; + int lines = 0; #ifdef GUI_SUPPORT string inStr = s; // draw multiline string - while (font.getStringWidth(inStr) > w && h >= font.getFontHeight() * 2) + //while (font.getStringWidth(inStr) > w && h >= font.getFontHeight() * 2) + while(inStr.length() && h >= font.getFontHeight() * 2) { // String is too wide. string leftStr, rightStr; @@ -367,7 +368,11 @@ int FBSurface::drawString(const GUI::Font& font, const string& s, inStr = rightStr; lines++; } - drawString(font, inStr, x, y, w, color, align, deltax, useEllipsis, shadowColor); + if(inStr.length()) + { + drawString(font, inStr, x, y, w, color, align, deltax, useEllipsis, shadowColor); + lines++; + } #endif return lines; } diff --git a/src/gui/StringListWidget.cxx b/src/gui/StringListWidget.cxx index 74cf23e40..04820090c 100644 --- a/src/gui/StringListWidget.cxx +++ b/src/gui/StringListWidget.cxx @@ -53,14 +53,24 @@ void StringListWidget::setList(const StringList& list) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int StringListWidget::getToolTipIndex(Common::Point pos) const { - return (pos.y - getAbsY()) / _lineHeight + _currentPos; + int idx = (pos.y - getAbsY()) / _lineHeight + _currentPos; + + if(idx >= int(_list.size())) + return -1; + else + return idx; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string StringListWidget::getToolTip(Common::Point pos) const { Common::Rect rect = getEditRect(); - const string value = _list[getToolTipIndex(pos)]; + int idx = getToolTipIndex(pos); + + if(idx < 0) + return EmptyString; + + const string value = _list[idx]; if(uInt32(_font.getStringWidth(value)) > rect.w()) return _toolTipText + value; diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index 5cfed635c..6e6ef9fc9 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -25,9 +25,6 @@ #include "ToolTip.hxx" -// TODOs: -// - option to disable tips - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ToolTip::ToolTip(Dialog& dialog, const GUI::Font& font) : myDialog(dialog) From 355dc9597d597048b637e9483424491dd24b0e9a Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Wed, 18 Nov 2020 17:56:57 -0330 Subject: [PATCH 58/70] Use const references where appropriate. Probably not a huge performance gain, but added to match the rest of the code. --- src/debugger/gui/DataGridWidget.cxx | 7 ++++--- src/debugger/gui/DataGridWidget.hxx | 6 +++--- src/debugger/gui/RomListWidget.cxx | 9 +++++---- src/debugger/gui/RomListWidget.hxx | 6 +++--- src/debugger/gui/ToggleWidget.cxx | 10 ++++------ src/debugger/gui/ToggleWidget.hxx | 6 +++--- src/gui/StringListWidget.cxx | 7 ++++--- src/gui/StringListWidget.hxx | 6 +++--- src/gui/Widget.hxx | 5 +++-- 9 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 9e75a955f..fb078ba18 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -571,7 +571,7 @@ void DataGridWidget::handleCommand(CommandSender* sender, int cmd, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int DataGridWidget::getToolTipIndex(Common::Point pos) const +int DataGridWidget::getToolTipIndex(const Common::Point& pos) const { const int col = (pos.x - getAbsX()) / _colWidth; const int row = (pos.y - getAbsY()) / _rowHeight; @@ -580,7 +580,7 @@ int DataGridWidget::getToolTipIndex(Common::Point pos) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string DataGridWidget::getToolTip(Common::Point pos) const +string DataGridWidget::getToolTip(const Common::Point& pos) const { const Int32 val = _valueList[getToolTipIndex(pos)]; ostringstream buf; @@ -595,7 +595,8 @@ string DataGridWidget::getToolTip(Common::Point pos) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool DataGridWidget::changedToolTip(Common::Point oldPos, Common::Point newPos) const +bool DataGridWidget::changedToolTip(const Common::Point& oldPos, + const Common::Point& newPos) const { return getToolTipIndex(oldPos) != getToolTipIndex(newPos); } diff --git a/src/debugger/gui/DataGridWidget.hxx b/src/debugger/gui/DataGridWidget.hxx index 1a402659d..37434db3c 100644 --- a/src/debugger/gui/DataGridWidget.hxx +++ b/src/debugger/gui/DataGridWidget.hxx @@ -84,8 +84,8 @@ class DataGridWidget : public EditableWidget void setCrossed(bool enable) { _crossGrid = enable; } - string getToolTip(Common::Point pos) const override; - bool changedToolTip(Common::Point oldPos, Common::Point newPos) const override; + string getToolTip(const Common::Point& pos) const override; + bool changedToolTip(const Common::Point& oldPos, const Common::Point& newPos) const override; protected: void drawWidget(bool hilite) override; @@ -150,7 +150,7 @@ class DataGridWidget : public EditableWidget void enableEditMode(bool state) { _editMode = state; } - int getToolTipIndex(Common::Point pos) const; + int getToolTipIndex(const Common::Point& pos) const; private: // Following constructors and assignment operators not supported diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 5f4487786..236f99a31 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -444,7 +444,7 @@ void RomListWidget::lostFocusWidget() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Common::Point RomListWidget::getToolTipIndex(Common::Point pos) const +Common::Point RomListWidget::getToolTipIndex(const Common::Point& pos) const { const Common::Rect& r = getEditRect(); const int col = (pos.x - r.x() - getAbsX()) / _font.getMaxCharWidth(); @@ -457,9 +457,9 @@ Common::Point RomListWidget::getToolTipIndex(Common::Point pos) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string RomListWidget::getToolTip(Common::Point pos) const +string RomListWidget::getToolTip(const Common::Point& pos) const { - const Common::Point idx = getToolTipIndex(pos); + const Common::Point& idx = getToolTipIndex(pos); if(idx.y == -1) return EmptyString; @@ -499,7 +499,8 @@ string RomListWidget::getToolTip(Common::Point pos) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool RomListWidget::changedToolTip(Common::Point oldPos, Common::Point newPos) const +bool RomListWidget::changedToolTip(const Common::Point& oldPos, + const Common::Point& newPos) const { return getToolTipIndex(oldPos) != getToolTipIndex(newPos); } diff --git a/src/debugger/gui/RomListWidget.hxx b/src/debugger/gui/RomListWidget.hxx index 3f26d217f..9baa9350a 100644 --- a/src/debugger/gui/RomListWidget.hxx +++ b/src/debugger/gui/RomListWidget.hxx @@ -56,8 +56,8 @@ class RomListWidget : public EditableWidget void setSelected(int item); void setHighlighted(int item); - string getToolTip(Common::Point pos) const override; - bool changedToolTip(Common::Point oldPos, Common::Point newPos) const override; + string getToolTip(const Common::Point& pos) const override; + bool changedToolTip(const Common::Point& oldPos, const Common::Point& newPos) const override; protected: void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; @@ -88,7 +88,7 @@ class RomListWidget : public EditableWidget private: void scrollToCurrent(int item); - Common::Point getToolTipIndex(Common::Point pos) const; + Common::Point getToolTipIndex(const Common::Point& pos) const; private: unique_ptr myMenu; diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index 2a4187c6d..4fced1146 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -205,7 +205,7 @@ void ToggleWidget::handleCommand(CommandSender* sender, int cmd, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int ToggleWidget::getToolTipIndex(Common::Point pos) const +int ToggleWidget::getToolTipIndex(const Common::Point& pos) const { const int row = (pos.y - getAbsY()) / _rowHeight; @@ -213,7 +213,7 @@ int ToggleWidget::getToolTipIndex(Common::Point pos) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string ToggleWidget::getToolTip(Common::Point pos) const +string ToggleWidget::getToolTip(const Common::Point& pos) const { const int idx = getToolTipIndex(pos); Int32 val = 0; @@ -243,10 +243,8 @@ string ToggleWidget::getToolTip(Common::Point pos) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool ToggleWidget::changedToolTip(Common::Point oldPos, Common::Point newPos) const +bool ToggleWidget::changedToolTip(const Common::Point& oldPos, + const Common::Point& newPos) const { return getToolTipIndex(oldPos) != getToolTipIndex(newPos); } - - - diff --git a/src/debugger/gui/ToggleWidget.hxx b/src/debugger/gui/ToggleWidget.hxx index 3f74237b0..347359677 100644 --- a/src/debugger/gui/ToggleWidget.hxx +++ b/src/debugger/gui/ToggleWidget.hxx @@ -46,8 +46,8 @@ class ToggleWidget : public Widget, public CommandSender void setEditable(bool editable) { _editable = editable; } bool isEditable() const { return _editable; } - string getToolTip(Common::Point pos) const override; - bool changedToolTip(Common::Point oldPos, Common::Point newPos) const override; + string getToolTip(const Common::Point& pos) const override; + bool changedToolTip(const Common::Point& oldPos, const Common::Point& newPos) const override; protected: bool hasToolTip() const override { return true; } @@ -76,7 +76,7 @@ class ToggleWidget : public Widget, public CommandSender bool handleKeyDown(StellaKey key, StellaMod mod) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override; - int getToolTipIndex(Common::Point pos) const; + int getToolTipIndex(const Common::Point& pos) const; // Following constructors and assignment operators not supported ToggleWidget() = delete; diff --git a/src/gui/StringListWidget.cxx b/src/gui/StringListWidget.cxx index 04820090c..a512425b5 100644 --- a/src/gui/StringListWidget.cxx +++ b/src/gui/StringListWidget.cxx @@ -51,7 +51,7 @@ void StringListWidget::setList(const StringList& list) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int StringListWidget::getToolTipIndex(Common::Point pos) const +int StringListWidget::getToolTipIndex(const Common::Point& pos) const { int idx = (pos.y - getAbsY()) / _lineHeight + _currentPos; @@ -62,7 +62,7 @@ int StringListWidget::getToolTipIndex(Common::Point pos) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string StringListWidget::getToolTip(Common::Point pos) const +string StringListWidget::getToolTip(const Common::Point& pos) const { Common::Rect rect = getEditRect(); int idx = getToolTipIndex(pos); @@ -79,7 +79,8 @@ string StringListWidget::getToolTip(Common::Point pos) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool StringListWidget::changedToolTip(Common::Point oldPos, Common::Point newPos) const +bool StringListWidget::changedToolTip(const Common::Point& oldPos, + const Common::Point& newPos) const { bool ch = getToolTipIndex(oldPos) != getToolTipIndex(newPos) && getToolTip(oldPos) != getToolTip(newPos); diff --git a/src/gui/StringListWidget.hxx b/src/gui/StringListWidget.hxx index fb96a9e22..f0bf8544b 100644 --- a/src/gui/StringListWidget.hxx +++ b/src/gui/StringListWidget.hxx @@ -32,8 +32,8 @@ class StringListWidget : public ListWidget void setList(const StringList& list); bool wantsFocus() const override { return true; } - string getToolTip(Common::Point pos) const override; - bool changedToolTip(Common::Point oldPos, Common::Point newPos) const override; + string getToolTip(const Common::Point& pos) const override; + bool changedToolTip(const Common::Point& oldPos, const Common::Point& newPos) const override; protected: // display depends on _hasFocus so we have to redraw when focus changes @@ -50,7 +50,7 @@ class StringListWidget : public ListWidget int _textOfs{0}; private: - int getToolTipIndex(Common::Point pos) const; + int getToolTipIndex(const Common::Point& pos) const; private: // Following constructors and assignment operators not supported diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index c5eb233b3..64685813a 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -106,8 +106,9 @@ class Widget : public GuiObject void setShadowColor(ColorId color) { _shadowcolor = color; setDirty(); } void setToolTip(const string& text); - virtual string getToolTip(Common::Point pos) const { return _toolTipText; } - virtual bool changedToolTip(Common::Point oldPos, Common::Point newPos) const { return false; } + virtual string getToolTip(const Common::Point& pos) const { return _toolTipText; } + virtual bool changedToolTip(const Common::Point& oldPos, + const Common::Point& newPos) const { return false; } virtual void loadConfig() { } From d0e818a693c32f926b17a123070f3702b782dd54 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 18 Nov 2020 23:52:19 +0100 Subject: [PATCH 59/70] added a few more tooltips to VideoAudioDialog --- src/gui/VideoAudioDialog.cxx | 8 ++++++++ src/gui/VideoAudioDialog.hxx | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/VideoAudioDialog.cxx b/src/gui/VideoAudioDialog.cxx index def965aa6..ac2ad19bf 100644 --- a/src/gui/VideoAudioDialog.cxx +++ b/src/gui/VideoAudioDialog.cxx @@ -237,6 +237,7 @@ void VideoAudioDialog::addPaletteTab() myPhaseShiftNtsc->setMinValue((PaletteHandler::DEF_NTSC_SHIFT - PaletteHandler::MAX_PHASE_SHIFT) * 10); myPhaseShiftNtsc->setMaxValue((PaletteHandler::DEF_NTSC_SHIFT + PaletteHandler::MAX_PHASE_SHIFT) * 10); myPhaseShiftNtsc->setTickmarkIntervals(4); + myPhaseShiftNtsc->setToolTip("Adjust NTSC phase shift of 'Custom' palette."); wid.push_back(myPhaseShiftNtsc); ypos += lineHeight + VGAP; @@ -246,6 +247,7 @@ void VideoAudioDialog::addPaletteTab() myPhaseShiftPal->setMinValue((PaletteHandler::DEF_PAL_SHIFT - PaletteHandler::MAX_PHASE_SHIFT) * 10); myPhaseShiftPal->setMaxValue((PaletteHandler::DEF_PAL_SHIFT + PaletteHandler::MAX_PHASE_SHIFT) * 10); myPhaseShiftPal->setTickmarkIntervals(4); + myPhaseShiftPal->setToolTip("Adjust PAL phase shift of 'Custom' palette."); wid.push_back(myPhaseShiftPal); ypos += lineHeight + VGAP; @@ -258,6 +260,7 @@ void VideoAudioDialog::addPaletteTab() myTVRedScale->setMinValue(0); myTVRedScale->setMaxValue(100); myTVRedScale->setTickmarkIntervals(2); + myTVRedScale->setToolTip("Adjust red saturation of 'Custom' palette."); wid.push_back(myTVRedScale); const int xposr = myTIAPalette->getRight() - rgbsWidth; @@ -267,6 +270,7 @@ void VideoAudioDialog::addPaletteTab() myTVRedShift->setMinValue((PaletteHandler::DEF_RGB_SHIFT - PaletteHandler::MAX_RGB_SHIFT) * 10); myTVRedShift->setMaxValue((PaletteHandler::DEF_RGB_SHIFT + PaletteHandler::MAX_RGB_SHIFT) * 10); myTVRedShift->setTickmarkIntervals(2); + myTVRedShift->setToolTip("Adjust red shift of 'Custom' palette."); wid.push_back(myTVRedShift); ypos += lineHeight + VGAP; @@ -276,6 +280,7 @@ void VideoAudioDialog::addPaletteTab() myTVGreenScale->setMinValue(0); myTVGreenScale->setMaxValue(100); myTVGreenScale->setTickmarkIntervals(2); + myTVGreenScale->setToolTip("Adjust green saturation of 'Custom' palette."); wid.push_back(myTVGreenScale); myTVGreenShift = @@ -284,6 +289,7 @@ void VideoAudioDialog::addPaletteTab() myTVGreenShift->setMinValue((PaletteHandler::DEF_RGB_SHIFT - PaletteHandler::MAX_RGB_SHIFT) * 10); myTVGreenShift->setMaxValue((PaletteHandler::DEF_RGB_SHIFT + PaletteHandler::MAX_RGB_SHIFT) * 10); myTVGreenShift->setTickmarkIntervals(2); + myTVGreenShift->setToolTip("Adjust green shift of 'Custom' palette."); wid.push_back(myTVGreenShift); ypos += lineHeight + VGAP; @@ -293,6 +299,7 @@ void VideoAudioDialog::addPaletteTab() myTVBlueScale->setMinValue(0); myTVBlueScale->setMaxValue(100); myTVBlueScale->setTickmarkIntervals(2); + myTVBlueScale->setToolTip("Adjust blue saturation of 'Custom' palette."); wid.push_back(myTVBlueScale); myTVBlueShift = @@ -301,6 +308,7 @@ void VideoAudioDialog::addPaletteTab() myTVBlueShift->setMinValue((PaletteHandler::DEF_RGB_SHIFT - PaletteHandler::MAX_RGB_SHIFT) * 10); myTVBlueShift->setMaxValue((PaletteHandler::DEF_RGB_SHIFT + PaletteHandler::MAX_RGB_SHIFT) * 10); myTVBlueShift->setTickmarkIntervals(2); + myTVBlueShift->setToolTip("Adjust blue shift of 'Custom' palette."); wid.push_back(myTVBlueShift); ypos += lineHeight + VGAP; xpos -= INDENT; diff --git a/src/gui/VideoAudioDialog.hxx b/src/gui/VideoAudioDialog.hxx index 1d0e8a637..0c8c44bf7 100644 --- a/src/gui/VideoAudioDialog.hxx +++ b/src/gui/VideoAudioDialog.hxx @@ -16,7 +16,7 @@ //============================================================================ #ifndef VIDEOAUDIO_DIALOG_HXX -#define VIDEOAUDIO_DIALOG_HXX +#define D class CommandSender; class CheckboxWidget; From 9ab2a5c41745db578f4cd5fe4a89da37b93bc12a Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 18 Nov 2020 23:54:43 +0100 Subject: [PATCH 60/70] disable tooltip when displayed value changes/is edited --- src/debugger/gui/DataGridWidget.cxx | 6 +++++- src/debugger/gui/RomListWidget.cxx | 3 +++ src/debugger/gui/ToggleWidget.cxx | 4 ++++ src/gui/StringListWidget.cxx | 4 ++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index fb078ba18..4304ecb0e 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -17,6 +17,7 @@ #include "Widget.hxx" #include "Dialog.hxx" +#include "ToolTip.hxx" #include "Font.hxx" #include "OSystem.hxx" #include "Debugger.hxx" @@ -294,6 +295,7 @@ void DataGridWidget::handleMouseWheel(int x, int y, int direction) else if(direction < 0) incrementCell(); } + dialog().tooltip().hide(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -491,6 +493,7 @@ bool DataGridWidget::handleKeyDown(StellaKey key, StellaMod mod) sendCommand(DataGridWidget::kSelectionChangedCmd, _selectedItem, _id); setDirty(); + dialog().tooltip().hide(); } _currentKeyDown = key; @@ -582,7 +585,8 @@ int DataGridWidget::getToolTipIndex(const Common::Point& pos) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string DataGridWidget::getToolTip(const Common::Point& pos) const { - const Int32 val = _valueList[getToolTipIndex(pos)]; + const int idx = getToolTipIndex(pos); + const Int32 val = _valueList[idx]; ostringstream buf; buf << _toolTipText diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 236f99a31..c06675e32 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -20,6 +20,8 @@ #include "Debugger.hxx" #include "DiStella.hxx" #include "Widget.hxx" +#include "Dialog.hxx" +#include "ToolTip.hxx" #include "StellaKeys.hxx" #include "FBSurface.hxx" #include "Font.hxx" @@ -646,6 +648,7 @@ void RomListWidget::startEditMode() return; _editMode = true; + dialog().tooltip().hide(); switch(myDisasm->list[_selectedItem].type) { case Device::GFX: diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index 4fced1146..ac321f4bf 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -19,6 +19,8 @@ #include "Base.hxx" #include "StellaKeys.hxx" #include "Widget.hxx" +#include "Dialog.hxx" +#include "ToolTip.hxx" #include "ToggleWidget.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -51,6 +53,7 @@ void ToggleWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) _selectedItem = newSelectedItem; _currentRow = _selectedItem / _cols; _currentCol = _selectedItem - (_currentRow * _cols); + dialog().tooltip().hide(); setDirty(); } } @@ -182,6 +185,7 @@ bool ToggleWidget::handleKeyDown(StellaKey key, StellaMod mod) _stateList[_selectedItem] = !_stateList[_selectedItem]; _changedList[_selectedItem] = !_changedList[_selectedItem]; sendCommand(ToggleWidget::kItemDataChangedCmd, _selectedItem, _id); + dialog().tooltip().hide(); } setDirty(); diff --git a/src/gui/StringListWidget.cxx b/src/gui/StringListWidget.cxx index a512425b5..536240b8a 100644 --- a/src/gui/StringListWidget.cxx +++ b/src/gui/StringListWidget.cxx @@ -56,9 +56,9 @@ int StringListWidget::getToolTipIndex(const Common::Point& pos) const int idx = (pos.y - getAbsY()) / _lineHeight + _currentPos; if(idx >= int(_list.size())) - return -1; + return -1; else - return idx; + return idx; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From db8e6d3ea8e1f0b6b9fae226fe5d6f25505c1142 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Wed, 18 Nov 2020 22:18:07 -0330 Subject: [PATCH 61/70] Fix some clang warnings and minor typo. --- src/debugger/gui/Cart3EWidget.cxx | 2 +- src/debugger/gui/RomListWidget.cxx | 2 +- src/gui/VideoAudioDialog.hxx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/debugger/gui/Cart3EWidget.cxx b/src/debugger/gui/Cart3EWidget.cxx index 910f03368..9e0822b51 100644 --- a/src/debugger/gui/Cart3EWidget.cxx +++ b/src/debugger/gui/Cart3EWidget.cxx @@ -117,7 +117,7 @@ void Cartridge3EWidget::loadConfig() myBankWidgets[1]->setSelectedIndex(bank - myCart.romBankCount(), oldBank != bank); } - CartDebugWidget::loadConfig(); + CartDebugWidget::loadConfig(); // Intentionally calling grand-parent method } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index c06675e32..868b72cdf 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -468,7 +468,7 @@ string RomListWidget::getToolTip(const Common::Point& pos) const const string bytes = myDisasm->list[idx.y].bytes; - if(bytes.length() < size_t(idx.x + 1)) + if(static_cast(bytes.length()) < idx.x + 1) return EmptyString; Int32 val; diff --git a/src/gui/VideoAudioDialog.hxx b/src/gui/VideoAudioDialog.hxx index 0c8c44bf7..550617d2d 100644 --- a/src/gui/VideoAudioDialog.hxx +++ b/src/gui/VideoAudioDialog.hxx @@ -16,7 +16,7 @@ //============================================================================ #ifndef VIDEOAUDIO_DIALOG_HXX -#define D +#define VIDEOAUDIO_DIALOG_HXX class CommandSender; class CheckboxWidget; @@ -38,7 +38,7 @@ class VideoAudioDialog : public Dialog { public: VideoAudioDialog(OSystem& osystem, DialogContainer& parent, const GUI::Font& font, - int max_w, int max_h); + int max_w, int max_h); ~VideoAudioDialog() override = default; private: From 2bdd09fec99e0743d85549973af33ebfed1b7889 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 19 Nov 2020 12:25:07 +0100 Subject: [PATCH 62/70] added tooltip display of RAM labels in DataGridWidgets added tooltip display of labels of some ToggleBitsWidget bits merged tooltip display of 2nd and 3rd RomListWidget byte added tooltip display of signed values --- src/debugger/gui/CartRamWidget.hxx | 2 +- src/debugger/gui/DataGridWidget.cxx | 13 ++++++++++- src/debugger/gui/DataGridWidget.hxx | 2 +- src/debugger/gui/RamWidget.cxx | 6 ++--- src/debugger/gui/RamWidget.hxx | 6 +++-- src/debugger/gui/RiotRamWidget.hxx | 3 ++- src/debugger/gui/RiotWidget.cxx | 26 +++++++++++++++++++-- src/debugger/gui/RomListWidget.cxx | 23 ++++++++++++++----- src/debugger/gui/ToggleBitWidget.cxx | 34 ++++++++++++++++++++++++++-- src/debugger/gui/ToggleBitWidget.hxx | 6 +++++ src/debugger/gui/ToggleWidget.cxx | 14 +++++++++--- src/debugger/gui/ToggleWidget.hxx | 3 +-- src/debugger/gui/module.mk | 1 + src/windows/Stella.vcxproj | 6 +++++ src/windows/Stella.vcxproj.filters | 6 +++++ 15 files changed, 127 insertions(+), 24 deletions(-) diff --git a/src/debugger/gui/CartRamWidget.hxx b/src/debugger/gui/CartRamWidget.hxx index bc0f4f810..d24a5d134 100644 --- a/src/debugger/gui/CartRamWidget.hxx +++ b/src/debugger/gui/CartRamWidget.hxx @@ -67,11 +67,11 @@ class CartRamWidget : public Widget, public CommandSender int x, int y, int w, int h, CartDebugWidget& cartDebug); ~InternalRamWidget() override = default; + string getLabel(int addr) const override; private: uInt8 getValue(int addr) const override; void setValue(int addr, uInt8 value) override; - string getLabel(int addr) const override; void fillList(uInt32 start, uInt32 size, IntArray& alist, IntArray& vlist, BoolArray& changed) const override; diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 4304ecb0e..5d0dc0623 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -579,13 +579,20 @@ int DataGridWidget::getToolTipIndex(const Common::Point& pos) const const int col = (pos.x - getAbsX()) / _colWidth; const int row = (pos.y - getAbsY()) / _rowHeight; - return row * _cols + col; + if(row >= 0 && row < _rows && col >= 0 && col < _cols) + return row * _cols + col; + else + return -1; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string DataGridWidget::getToolTip(const Common::Point& pos) const { const int idx = getToolTipIndex(pos); + + if(idx < 0) + return EmptyString; + const Int32 val = _valueList[idx]; ostringstream buf; @@ -593,7 +600,11 @@ string DataGridWidget::getToolTip(const Common::Point& pos) const << "$" << Common::Base::toString(val, Common::Base::Fmt::_16) << " = #" << val; if(val < 0x100) + { + if(val >= 0x80) + buf << '/' << -(0x100 - val); buf << " = %" << Common::Base::toString(val, Common::Base::Fmt::_2); + } return buf.str(); } diff --git a/src/debugger/gui/DataGridWidget.hxx b/src/debugger/gui/DataGridWidget.hxx index 37434db3c..848993311 100644 --- a/src/debugger/gui/DataGridWidget.hxx +++ b/src/debugger/gui/DataGridWidget.hxx @@ -102,6 +102,7 @@ class DataGridWidget : public EditableWidget void lostFocusWidget() override; bool hasToolTip() const override { return true; } + int getToolTipIndex(const Common::Point& pos) const; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override; @@ -150,7 +151,6 @@ class DataGridWidget : public EditableWidget void enableEditMode(bool state) { _editMode = state; } - int getToolTipIndex(const Common::Point& pos) const; private: // Following constructors and assignment operators not supported diff --git a/src/debugger/gui/RamWidget.cxx b/src/debugger/gui/RamWidget.cxx index 77456f810..7f651910a 100644 --- a/src/debugger/gui/RamWidget.cxx +++ b/src/debugger/gui/RamWidget.cxx @@ -15,7 +15,7 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#include "DataGridWidget.hxx" +#include "DataGridRamWidget.hxx" #include "EditTextWidget.hxx" #include "GuiObject.hxx" #include "InputTextDialog.hxx" @@ -54,8 +54,8 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n // Add RAM grid (with scrollbar) int xpos = x + _font.getStringWidth("xxxx"); bool useScrollbar = ramsize / numrows > 16; - myRamGrid = new DataGridWidget(_boss, _nfont, xpos, ypos, - 16, myNumRows, 2, 8, Common::Base::Fmt::_16, useScrollbar); + myRamGrid = new DataGridRamWidget(_boss, *this, _nfont, xpos, ypos, + 16, myNumRows, 2, 8, Common::Base::Fmt::_16, useScrollbar); myRamGrid->setTarget(this); myRamGrid->setID(kRamGridID); addFocusWidget(myRamGrid); diff --git a/src/debugger/gui/RamWidget.hxx b/src/debugger/gui/RamWidget.hxx index fbc7747e6..069086fef 100644 --- a/src/debugger/gui/RamWidget.hxx +++ b/src/debugger/gui/RamWidget.hxx @@ -22,6 +22,7 @@ class GuiObject; class ButtonWidget; class DataGridWidget; class DataGridOpsWidget; +class DataGridRamWidget; class EditTextWidget; class StaticTextWidget; class InputTextDialog; @@ -41,11 +42,12 @@ class RamWidget : public Widget, public CommandSender void setOpsWidget(DataGridOpsWidget* w); void handleCommand(CommandSender* sender, int cmd, int data, int id) override; + virtual string getLabel(int addr) const = 0; + private: // To be implemented by derived classes virtual uInt8 getValue(int addr) const = 0; virtual void setValue(int addr, uInt8 value) = 0; - virtual string getLabel(int addr) const = 0; virtual void fillList(uInt32 start, uInt32 size, IntArray& alist, IntArray& vlist, @@ -97,7 +99,7 @@ class RamWidget : public Widget, public CommandSender StaticTextWidget* myRamStart{nullptr}; std::array myRamLabels{nullptr}; - DataGridWidget* myRamGrid{nullptr}; + DataGridRamWidget* myRamGrid{nullptr}; DataGridWidget* myHexValue{nullptr}; DataGridWidget* myDecValue{nullptr}; DataGridWidget* myBinValue{nullptr}; diff --git a/src/debugger/gui/RiotRamWidget.hxx b/src/debugger/gui/RiotRamWidget.hxx index 53d006bb0..3e30fc3e0 100644 --- a/src/debugger/gui/RiotRamWidget.hxx +++ b/src/debugger/gui/RiotRamWidget.hxx @@ -36,10 +36,11 @@ class RiotRamWidget : public RamWidget int x, int y, int w); ~RiotRamWidget() override = default; + string getLabel(int addr) const override; + private: uInt8 getValue(int addr) const override; void setValue(int addr, uInt8 value) override; - string getLabel(int addr) const override; void fillList(uInt32 start, uInt32 size, IntArray& alist, IntArray& vlist, BoolArray& changed) const override; diff --git a/src/debugger/gui/RiotWidget.cxx b/src/debugger/gui/RiotWidget.cxx index 73a70391f..053ff1325 100644 --- a/src/debugger/gui/RiotWidget.cxx +++ b/src/debugger/gui/RiotWidget.cxx @@ -66,11 +66,13 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont, on.push_back("1"); } + StringList labels; + #define CREATE_IO_REGS(desc, bits, bitsID, editable) \ t = new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight,\ - desc, TextAlign::Left); \ + desc); \ xpos += t->getWidth() + 5; \ - bits = new ToggleBitWidget(boss, nfont, xpos, ypos, 8, 1); \ + bits = new ToggleBitWidget(boss, nfont, xpos, ypos, 8, 1, 1, labels); \ bits->setTarget(this); \ bits->setID(bitsID); \ if(editable) addFocusWidget(bits); else bits->setEditable(false); \ @@ -78,6 +80,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont, bits->setList(off, on); // SWCHA bits in 'poke' mode + labels.clear(); CREATE_IO_REGS("SWCHA(W)", mySWCHAWriteBits, kSWCHABitsID, true) col = xpos + 20; // remember this for adding widgets to the second column @@ -87,10 +90,20 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont, // SWCHA bits in 'peek' mode xpos = 10; ypos += lineHeight + 5; + labels.clear(); + labels.push_back("P0 right"); + labels.push_back("P0 left"); + labels.push_back("P0 down"); + labels.push_back("P0 up"); + labels.push_back("P1 right"); + labels.push_back("P1 left"); + labels.push_back("P1 down"); + labels.push_back("P1 up"); CREATE_IO_REGS("SWCHA(R)", mySWCHAReadBits, kSWCHARBitsID, true) // SWCHB bits in 'poke' mode xpos = 10; ypos += 2 * lineHeight; + labels.clear(); CREATE_IO_REGS("SWCHB(W)", mySWCHBWriteBits, kSWCHBBitsID, true) // SWBCNT bits @@ -99,6 +112,15 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont, // SWCHB bits in 'peek' mode xpos = 10; ypos += lineHeight + 5; + labels.clear(); + labels.push_back("P1 difficulty"); + labels.push_back("P0 difficulty"); + labels.push_back(""); + labels.push_back(""); + labels.push_back("Color/B+W"); + labels.push_back(""); + labels.push_back("Select"); + labels.push_back("Reset"); CREATE_IO_REGS("SWCHB(R)", mySWCHBReadBits, kSWCHBRBitsID, true) // Timer registers (R/W) diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 868b72cdf..aab298fad 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -452,7 +452,8 @@ Common::Point RomListWidget::getToolTipIndex(const Common::Point& pos) const const int col = (pos.x - r.x() - getAbsX()) / _font.getMaxCharWidth(); const int row = (pos.y - getAbsY()) / _lineHeight; - if(col < 0) + if(col < 0 || col >= 8 + || row < 0 || row + _currentPos >= int(myDisasm->list.size())) return Common::Point(-1, -1); else return Common::Point(col, row + _currentPos); @@ -463,7 +464,7 @@ string RomListWidget::getToolTip(const Common::Point& pos) const { const Common::Point& idx = getToolTipIndex(pos); - if(idx.y == -1) + if(idx.y < 0) return EmptyString; const string bytes = myDisasm->list[idx.y].bytes; @@ -480,12 +481,18 @@ string RomListWidget::getToolTip(const Common::Point& pos) const else { // 1..3 hex values - if(idx.x % 3 == 2) - // Skip gaps between hex values + if(idx.x == 2) + // Skip gap after first byte return EmptyString; - // Get one hex byte - const string valStr = bytes.substr((idx.x / 3) * 3, 2); + string valStr; + + if(idx.x < 2 || bytes.length() < 8) + // 1 or 2 hex bytes, get one hex byte + valStr = bytes.substr((idx.x / 3) * 3, 2); + else + // 3 hex bytes, get two rightmost hex bytes + valStr = bytes.substr(6, 2) + bytes.substr(3, 2); val = static_cast(stol(valStr, nullptr, 16)); } @@ -495,7 +502,11 @@ string RomListWidget::getToolTip(const Common::Point& pos) const << "$" << Common::Base::toString(val, Common::Base::Fmt::_16) << " = #" << val; if(val < 0x100) + { + if(val >= 0x80) + buf << '/' << -(0x100 - val); buf << " = %" << Common::Base::toString(val, Common::Base::Fmt::_2); + } return buf.str(); } diff --git a/src/debugger/gui/ToggleBitWidget.cxx b/src/debugger/gui/ToggleBitWidget.cxx index 39ca7dcce..212ae60ed 100644 --- a/src/debugger/gui/ToggleBitWidget.cxx +++ b/src/debugger/gui/ToggleBitWidget.cxx @@ -25,8 +25,10 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ToggleBitWidget::ToggleBitWidget(GuiObject* boss, const GUI::Font& font, - int x, int y, int cols, int rows, int colchars) - : ToggleWidget(boss, font, x, y, cols, rows) + int x, int y, int cols, int rows, int colchars, + const StringList& labels) + : ToggleWidget(boss, font, x, y, cols, rows), + _labelList(labels) { _rowHeight = font.getLineHeight(); _colWidth = colchars * font.getMaxCharWidth() + 8; @@ -47,6 +49,13 @@ ToggleBitWidget::ToggleBitWidget(GuiObject* boss, const GUI::Font& font, _h = _rowHeight * rows + 1; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ToggleBitWidget::ToggleBitWidget(GuiObject* boss, const GUI::Font& font, + int x, int y, int cols, int rows, int colchars) + : ToggleBitWidget(boss, font, x, y, cols, rows, colchars, StringList()) +{ +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ToggleBitWidget::setList(const StringList& off, const StringList& on) { @@ -69,6 +78,27 @@ void ToggleBitWidget::setState(const BoolArray& state, const BoolArray& changed) setDirty(); } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string ToggleBitWidget::getToolTip(const Common::Point& pos) const +{ + Common::Point idx = getToolTipIndex(pos); + + if(idx.y < 0) + return EmptyString; + + const string tip = ToggleWidget::getToolTip(pos); + + if(idx.x < _labelList.size()) + { + const string label = _labelList[idx.x]; + + if(!label.empty()) + return tip + "\n" + label; + } + return tip; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ToggleBitWidget::drawWidget(bool hilite) { diff --git a/src/debugger/gui/ToggleBitWidget.hxx b/src/debugger/gui/ToggleBitWidget.hxx index 6d5505030..707aea1cc 100644 --- a/src/debugger/gui/ToggleBitWidget.hxx +++ b/src/debugger/gui/ToggleBitWidget.hxx @@ -26,17 +26,23 @@ class ToggleBitWidget : public ToggleWidget public: ToggleBitWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int cols, int rows, int colchars = 1); + ToggleBitWidget(GuiObject* boss, const GUI::Font& font, + int x, int y, int cols, int rows, int colchars, + const StringList& labels); ~ToggleBitWidget() override = default; void setList(const StringList& off, const StringList& on); void setState(const BoolArray& state, const BoolArray& changed); + string getToolTip(const Common::Point& pos) const override; + protected: void drawWidget(bool hilite) override; protected: StringList _offList; StringList _onList; + StringList _labelList; private: // Following constructors and assignment operators not supported diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index ac321f4bf..adb33e118 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -209,17 +209,25 @@ void ToggleWidget::handleCommand(CommandSender* sender, int cmd, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int ToggleWidget::getToolTipIndex(const Common::Point& pos) const +Common::Point ToggleWidget::getToolTipIndex(const Common::Point& pos) const { + const int col = (pos.x - getAbsX()) / _colWidth; const int row = (pos.y - getAbsY()) / _rowHeight; - return row * _cols; + if(row >= 0 && row < _rows && col >= 0 && col < _cols) + return Common::Point(col, row); + else + return Common::Point(-1, -1); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string ToggleWidget::getToolTip(const Common::Point& pos) const { - const int idx = getToolTipIndex(pos); + const int idx = getToolTipIndex(pos).y * _cols; + + if(idx < 0) + return EmptyString; + Int32 val = 0; ostringstream buf; diff --git a/src/debugger/gui/ToggleWidget.hxx b/src/debugger/gui/ToggleWidget.hxx index 347359677..ee70f6233 100644 --- a/src/debugger/gui/ToggleWidget.hxx +++ b/src/debugger/gui/ToggleWidget.hxx @@ -51,6 +51,7 @@ class ToggleWidget : public Widget, public CommandSender protected: bool hasToolTip() const override { return true; } + Common::Point getToolTipIndex(const Common::Point& pos) const; protected: int _rows{0}; @@ -76,8 +77,6 @@ class ToggleWidget : public Widget, public CommandSender bool handleKeyDown(StellaKey key, StellaMod mod) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override; - int getToolTipIndex(const Common::Point& pos) const; - // Following constructors and assignment operators not supported ToggleWidget() = delete; ToggleWidget(const ToggleWidget&) = delete; diff --git a/src/debugger/gui/module.mk b/src/debugger/gui/module.mk index cda7666e9..0a985e71b 100644 --- a/src/debugger/gui/module.mk +++ b/src/debugger/gui/module.mk @@ -55,6 +55,7 @@ MODULE_OBJS := \ src/debugger/gui/CartDebugWidget.o \ src/debugger/gui/CpuWidget.o \ src/debugger/gui/DataGridOpsWidget.o \ + src/debugger/gui/DataGridRamWidget.o \ src/debugger/gui/DataGridWidget.o \ src/debugger/gui/DebuggerDialog.o \ src/debugger/gui/DelayQueueWidget.o \ diff --git a/src/windows/Stella.vcxproj b/src/windows/Stella.vcxproj index f9b5d3499..76e311ce3 100644 --- a/src/windows/Stella.vcxproj +++ b/src/windows/Stella.vcxproj @@ -525,6 +525,9 @@ true + + true + true @@ -1550,6 +1553,9 @@ true + + true + true diff --git a/src/windows/Stella.vcxproj.filters b/src/windows/Stella.vcxproj.filters index 550419e9a..6db5675f0 100644 --- a/src/windows/Stella.vcxproj.filters +++ b/src/windows/Stella.vcxproj.filters @@ -1035,6 +1035,9 @@ Source Files\gui + + Source Files\debugger + @@ -2129,6 +2132,9 @@ Header Files\gui + + Header Files\debugger + From b77afae17840dae057ad14d70e9e58181b81e57c Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 19 Nov 2020 12:26:03 +0100 Subject: [PATCH 63/70] oops, added missing files --- src/debugger/DataGridRamWidget.cxx | 54 ++++++++++++++++++++++++++++++ src/debugger/DataGridRamWidget.hxx | 51 ++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 src/debugger/DataGridRamWidget.cxx create mode 100644 src/debugger/DataGridRamWidget.hxx diff --git a/src/debugger/DataGridRamWidget.cxx b/src/debugger/DataGridRamWidget.cxx new file mode 100644 index 000000000..9be4c4f14 --- /dev/null +++ b/src/debugger/DataGridRamWidget.cxx @@ -0,0 +1,54 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#include "RamWidget.hxx" +#include "DataGridRamWidget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +DataGridRamWidget::DataGridRamWidget(GuiObject* boss, const RamWidget& ram, + const GUI::Font& font, + int x, int y, int cols, int rows, + int colchars, int bits, + Common::Base::Fmt base, + bool useScrollbar) + : DataGridWidget(boss, font, x, y, cols, rows, colchars, + bits, base, useScrollbar), + _ram(ram) +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string DataGridRamWidget::getToolTip(const Common::Point& pos) const +{ + const int idx = getToolTipIndex(pos); + + if(idx < 0) + return EmptyString; + + const Int32 addr = _addrList[idx]; + const string label = _ram.getLabel(addr); + const string tip = DataGridWidget::getToolTip(pos); + + if(label.empty()) + return tip; + + ostringstream buf; + + buf << _ram.getLabel(addr) << '\n' << tip; + + return buf.str(); +} diff --git a/src/debugger/DataGridRamWidget.hxx b/src/debugger/DataGridRamWidget.hxx new file mode 100644 index 000000000..451c23403 --- /dev/null +++ b/src/debugger/DataGridRamWidget.hxx @@ -0,0 +1,51 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#ifndef DATA_GRID_RAM_WIDGET_HXX +#define DATA_GRID_RAM_WIDGET_HXX + +class RamWidget; + +#include "DataGridWidget.hxx" +#include "Base.hxx" + +class DataGridRamWidget : public DataGridWidget +{ + public: + DataGridRamWidget(GuiObject* boss, const RamWidget& ram, + const GUI::Font& font, + int x, int y, int cols, int rows, + int colchars, int bits, + Common::Base::Fmt format = Common::Base::Fmt::_DEFAULT, + bool useScrollbar = false); + ~DataGridRamWidget() override = default; + + string getToolTip(const Common::Point& pos) const override; + + private: + const RamWidget& _ram; + + private: + // Following constructors and assignment operators not supported + DataGridRamWidget() = delete; + DataGridRamWidget(const DataGridRamWidget&) = delete; + DataGridRamWidget(DataGridRamWidget&&) = delete; + DataGridRamWidget& operator=(const DataGridRamWidget&) = delete; + DataGridRamWidget& operator=(DataGridRamWidget&&) = delete; +}; + +#endif From 4f43334b6ce663d2a4bb3f1ce196c655ac7a1464 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Thu, 19 Nov 2020 09:36:02 -0330 Subject: [PATCH 64/70] Fix wrong location of debugger files. --- src/debugger/{ => gui}/DataGridRamWidget.cxx | 0 src/debugger/{ => gui}/DataGridRamWidget.hxx | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/debugger/{ => gui}/DataGridRamWidget.cxx (100%) rename src/debugger/{ => gui}/DataGridRamWidget.hxx (100%) diff --git a/src/debugger/DataGridRamWidget.cxx b/src/debugger/gui/DataGridRamWidget.cxx similarity index 100% rename from src/debugger/DataGridRamWidget.cxx rename to src/debugger/gui/DataGridRamWidget.cxx diff --git a/src/debugger/DataGridRamWidget.hxx b/src/debugger/gui/DataGridRamWidget.hxx similarity index 100% rename from src/debugger/DataGridRamWidget.hxx rename to src/debugger/gui/DataGridRamWidget.hxx From 2abfd14d46e3271edf2aa775e90e9b42f0d5217f Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Thu, 19 Nov 2020 09:49:38 -0330 Subject: [PATCH 65/70] Fix location of files in VS project. --- src/windows/Stella.vcxproj | 8 ++------ src/windows/Stella.vcxproj.filters | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/windows/Stella.vcxproj b/src/windows/Stella.vcxproj index 76e311ce3..d1cf96c6b 100644 --- a/src/windows/Stella.vcxproj +++ b/src/windows/Stella.vcxproj @@ -525,9 +525,6 @@ true - - true - true @@ -684,6 +681,7 @@ true + true @@ -1553,9 +1551,6 @@ true - - true - true @@ -1712,6 +1707,7 @@ true + true diff --git a/src/windows/Stella.vcxproj.filters b/src/windows/Stella.vcxproj.filters index 6db5675f0..a8cac63d6 100644 --- a/src/windows/Stella.vcxproj.filters +++ b/src/windows/Stella.vcxproj.filters @@ -1035,7 +1035,7 @@ Source Files\gui - + Source Files\debugger @@ -2132,7 +2132,7 @@ Header Files\gui - + Header Files\debugger From 7112dc553370982120ae1f376fe0975d83d5558b Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Thu, 19 Nov 2020 10:29:41 -0330 Subject: [PATCH 66/70] Add debugger files to Xcode project, and fix minor warnings. --- src/debugger/gui/ToggleBitWidget.cxx | 4 ++-- src/macos/stella.xcodeproj/project.pbxproj | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/debugger/gui/ToggleBitWidget.cxx b/src/debugger/gui/ToggleBitWidget.cxx index 212ae60ed..1ebe1c5e4 100644 --- a/src/debugger/gui/ToggleBitWidget.cxx +++ b/src/debugger/gui/ToggleBitWidget.cxx @@ -82,14 +82,14 @@ void ToggleBitWidget::setState(const BoolArray& state, const BoolArray& changed) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string ToggleBitWidget::getToolTip(const Common::Point& pos) const { - Common::Point idx = getToolTipIndex(pos); + const Common::Point& idx = getToolTipIndex(pos); if(idx.y < 0) return EmptyString; const string tip = ToggleWidget::getToolTip(pos); - if(idx.x < _labelList.size()) + if(idx.x < static_cast(_labelList.size())) { const string label = _labelList[idx.x]; diff --git a/src/macos/stella.xcodeproj/project.pbxproj b/src/macos/stella.xcodeproj/project.pbxproj index a23a0b173..09a728c1b 100644 --- a/src/macos/stella.xcodeproj/project.pbxproj +++ b/src/macos/stella.xcodeproj/project.pbxproj @@ -533,6 +533,8 @@ DCBDDE9F1D6A5F2F009DF1E9 /* Cart3EPlus.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCBDDE9D1D6A5F2F009DF1E9 /* Cart3EPlus.hxx */; }; DCC2FDF5255EB82500FA5E81 /* ToolTip.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCC2FDF3255EB82500FA5E81 /* ToolTip.hxx */; }; DCC2FDF6255EB82500FA5E81 /* ToolTip.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DCC2FDF4255EB82500FA5E81 /* ToolTip.cxx */; }; + DCC2FDF92566AD8800FA5E81 /* DataGridRamWidget.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DCC2FDF72566AD8800FA5E81 /* DataGridRamWidget.cxx */; }; + DCC2FDFA2566AD8800FA5E81 /* DataGridRamWidget.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCC2FDF82566AD8800FA5E81 /* DataGridRamWidget.hxx */; }; DCC527D110B9DA19005E1287 /* Device.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCC527C910B9DA19005E1287 /* Device.hxx */; }; DCC527D210B9DA19005E1287 /* M6502.cxx in Sources */ = {isa = PBXBuildFile; fileRef = DCC527CA10B9DA19005E1287 /* M6502.cxx */; }; DCC527D310B9DA19005E1287 /* M6502.hxx in Headers */ = {isa = PBXBuildFile; fileRef = DCC527CB10B9DA19005E1287 /* M6502.hxx */; }; @@ -1302,6 +1304,8 @@ DCBDDE9D1D6A5F2F009DF1E9 /* Cart3EPlus.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Cart3EPlus.hxx; sourceTree = ""; }; DCC2FDF3255EB82500FA5E81 /* ToolTip.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ToolTip.hxx; sourceTree = ""; }; DCC2FDF4255EB82500FA5E81 /* ToolTip.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ToolTip.cxx; sourceTree = ""; }; + DCC2FDF72566AD8800FA5E81 /* DataGridRamWidget.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataGridRamWidget.cxx; sourceTree = ""; }; + DCC2FDF82566AD8800FA5E81 /* DataGridRamWidget.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DataGridRamWidget.hxx; sourceTree = ""; }; DCC527C910B9DA19005E1287 /* Device.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Device.hxx; sourceTree = ""; }; DCC527CA10B9DA19005E1287 /* M6502.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = M6502.cxx; sourceTree = ""; }; DCC527CB10B9DA19005E1287 /* M6502.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = M6502.hxx; sourceTree = ""; }; @@ -1706,6 +1710,8 @@ 2D20F9E708C603EC00A73076 /* CpuWidget.hxx */, 2D20F9E808C603EC00A73076 /* DataGridOpsWidget.cxx */, 2D20F9E908C603EC00A73076 /* DataGridOpsWidget.hxx */, + DCC2FDF72566AD8800FA5E81 /* DataGridRamWidget.cxx */, + DCC2FDF82566AD8800FA5E81 /* DataGridRamWidget.hxx */, 2D20F9EA08C603EC00A73076 /* DataGridWidget.cxx */, 2D20F9EB08C603EC00A73076 /* DataGridWidget.hxx */, 2D20F9EC08C603EC00A73076 /* DebuggerDialog.cxx */, @@ -2578,6 +2584,7 @@ E08FCD5823A037EB0051F59B /* QisBlitter.hxx in Headers */, DCA078351F8C1B04008EFEE5 /* SDL_lib.hxx in Headers */, DCDA03B11A2009BB00711920 /* CartWD.hxx in Headers */, + DCC2FDFA2566AD8800FA5E81 /* DataGridRamWidget.hxx in Headers */, 2D91745909BA90380026E9FF /* PromptWidget.hxx in Headers */, DC3C9BC62469C8F700CF2D47 /* PaletteHandler.hxx in Headers */, 2D91745A09BA90380026E9FF /* RamWidget.hxx in Headers */, @@ -3198,6 +3205,7 @@ DC676A591729A0B000E4E73D /* CartSBWidget.cxx in Sources */, DC3C9BCC2469C93D00CF2D47 /* EmulationDialog.cxx in Sources */, DC676A5B1729A0B000E4E73D /* CartX07Widget.cxx in Sources */, + DCC2FDF92566AD8800FA5E81 /* DataGridRamWidget.cxx in Sources */, DC7A24DF173B1DBC00B20FE9 /* FileListWidget.cxx in Sources */, DC13B53F176FF2F500B8B4BB /* RomListSettings.cxx in Sources */, DC3EE8581E2C0E6D00905161 /* crc32.c in Sources */, From 319c521b77fedc204d9e90f0065714b1195d79d5 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Thu, 19 Nov 2020 11:35:02 -0330 Subject: [PATCH 67/70] Enable RTTI by default for Linux/UNIX builds; disable it for release builds only. --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 90279a56a..87a2c9847 100644 --- a/Makefile +++ b/Makefile @@ -48,11 +48,11 @@ endif CXXFLAGS+= -Wall -Wextra -Wno-unused-parameter ifdef HAVE_GCC - CXXFLAGS+= -Wno-multichar -Wunused -fno-rtti -Woverloaded-virtual -Wnon-virtual-dtor -std=c++14 -frtti + CXXFLAGS+= -Wno-multichar -Wunused -Woverloaded-virtual -Wnon-virtual-dtor -std=c++14 endif ifdef HAVE_CLANG - CXXFLAGS+= -Wno-multichar -Wunused -frtti -Woverloaded-virtual -Wnon-virtual-dtor -std=c++14 + CXXFLAGS+= -Wno-multichar -Wunused -Woverloaded-virtual -Wnon-virtual-dtor -std=c++14 endif ifdef CLANG_WARNINGS @@ -81,8 +81,8 @@ else endif ifdef RELEASE - CXXFLAGS += -flto - LDFLAGS += -flto + CXXFLAGS += -flto -fno-rtti + LDFLAGS += -flto -fno-rtti endif ####################################################################### From 3c50de30a6d32724f8a02aa858006595e4a9ec77 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 19 Nov 2020 16:40:16 +0100 Subject: [PATCH 68/70] added tooltip hiding when context menus are opened added tooltips to TiaOutputWidget and TiaZoomWidget --- src/debugger/gui/RomListWidget.cxx | 2 +- src/debugger/gui/TiaOutputWidget.cxx | 49 ++++++++++++++++++++++++++++ src/debugger/gui/TiaOutputWidget.hxx | 7 ++++ src/debugger/gui/TiaZoomWidget.cxx | 46 ++++++++++++++++++++++++++ src/debugger/gui/TiaZoomWidget.hxx | 7 ++++ src/gui/LauncherDialog.cxx | 1 + 6 files changed, 111 insertions(+), 1 deletion(-) diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index aab298fad..d732cd328 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -247,6 +247,7 @@ void RomListWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) // Set selected and add menu at current x,y mouse location _selectedItem = findItem(x, y); scrollToSelected(); + dialog().tooltip().hide(); myMenu->show(x + getAbsX(), y + getAbsY(), dialog().surface().dstRect(), _selectedItem); } @@ -518,7 +519,6 @@ bool RomListWidget::changedToolTip(const Common::Point& oldPos, return getToolTipIndex(oldPos) != getToolTipIndex(newPos); } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RomListWidget::drawWidget(bool hilite) { diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index 2062bd436..94963f870 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -22,6 +22,8 @@ #include "FBSurface.hxx" #include "Widget.hxx" #include "GuiObject.hxx" +#include "Dialog.hxx" +#include "ToolTip.hxx" #include "ContextMenu.hxx" #include "TiaZoomWidget.hxx" #include "Debugger.hxx" @@ -55,6 +57,7 @@ TiaOutputWidget::TiaOutputWidget(GuiObject* boss, const GUI::Font& font, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaOutputWidget::loadConfig() { + setEnabled(true); setDirty(); } @@ -110,6 +113,7 @@ void TiaOutputWidget::handleMouseDown(int x, int y, MouseButton b, int clickCoun myClickX = x; myClickY = y; + dialog().tooltip().hide(); // Add menu at current x,y mouse location myMenu->show(x + getAbsX(), y + getAbsY(), dialog().surface().dstRect()); } @@ -158,6 +162,51 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Common::Point TiaOutputWidget::getToolTipIndex(const Common::Point& pos) const +{ + const Int32 width = instance().console().tia().width(); + const Int32 height = instance().console().tia().height(); + const int col = (pos.x - 1 - getAbsX()) >> 1; + const int row = pos.y - 1 - getAbsY(); + + if(col < 0 || col >= width || row < 0 || row >= height) + return Common::Point(-1, -1); + else + return Common::Point(col, row); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string TiaOutputWidget::getToolTip(const Common::Point& pos) const +{ + Common::Point idx = getToolTipIndex(pos); + + if(idx.x < 0) + return EmptyString; + + uInt32 height = instance().console().tia().height(); + // limit to 274 lines (PAL default without scaling) + uInt32 yStart = height <= FrameManager::Metrics::baseHeightPAL + ? 0 : (height - FrameManager::Metrics::baseHeightPAL) >> 1; + const Int32 i = idx.x + (yStart + idx.y) * instance().console().tia().width(); + uInt8* tiaOutputBuffer = instance().console().tia().outputBuffer(); + ostringstream buf; + + buf << _toolTipText + << "X: #" << idx.x + << "\nY: #" << idx.y + << "\nC: $" << Common::Base::toString(tiaOutputBuffer[i], Common::Base::Fmt::_16); + + return buf.str(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool TiaOutputWidget::changedToolTip(const Common::Point& oldPos, + const Common::Point& newPos) const +{ + return getToolTipIndex(oldPos) != getToolTipIndex(newPos); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaOutputWidget::drawWidget(bool hilite) { diff --git a/src/debugger/gui/TiaOutputWidget.hxx b/src/debugger/gui/TiaOutputWidget.hxx index c7bfd26f6..cc465266a 100644 --- a/src/debugger/gui/TiaOutputWidget.hxx +++ b/src/debugger/gui/TiaOutputWidget.hxx @@ -47,6 +47,13 @@ class TiaOutputWidget : public Widget, public CommandSender bool handleKeyDown(StellaKey key, StellaMod mod) override; bool handleKeyUp(StellaKey key, StellaMod mod) override; */ + string getToolTip(const Common::Point& pos) const override; + bool changedToolTip(const Common::Point& oldPos, const Common::Point& newPos) const override; + + protected: + bool hasToolTip() const override { return true; } + Common::Point getToolTipIndex(const Common::Point& pos) const; + private: unique_ptr myMenu; TiaZoomWidget* myZoom{nullptr}; diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index 0895c51a8..eec9723ff 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -26,6 +26,8 @@ #include "FBSurface.hxx" #include "Widget.hxx" #include "GuiObject.hxx" +#include "Dialog.hxx" +#include "ToolTip.hxx" #include "ContextMenu.hxx" #include "FrameManager.hxx" #include "TiaZoomWidget.hxx" @@ -127,6 +129,7 @@ void TiaZoomWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) } else if(b == MouseButton::RIGHT) { + dialog().tooltip().hide(); // Add menu at current x,y mouse location myMenu->show(x + getAbsX(), y + getAbsY(), dialog().surface().dstRect()); } @@ -141,6 +144,8 @@ void TiaZoomWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaZoomWidget::handleMouseWheel(int x, int y, int direction) { + dialog().tooltip().hide(); + // zoom towards mouse position myClickX = x; myClickY = y; @@ -274,6 +279,47 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Common::Point TiaZoomWidget::getToolTipIndex(const Common::Point& pos) const +{ + const Int32 width = instance().console().tia().width() * 2; + const Int32 height = instance().console().tia().height(); + const int col = (pos.x - 1 - getAbsX()) / (myZoomLevel << 1) + (myOffX >> 1); + const int row = (pos.y - 1 - getAbsY()) / myZoomLevel + myOffY; + + if(col < 0 || col >= width || row < 0 || row >= height) + return Common::Point(-1, -1); + else + return Common::Point(col, row); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string TiaZoomWidget::getToolTip(const Common::Point& pos) const +{ + Common::Point idx = getToolTipIndex(pos); + + if(idx.x < 0) + return EmptyString; + + const Int32 i = idx.x + idx.y * instance().console().tia().width(); + uInt8* tiaOutputBuffer = instance().console().tia().outputBuffer(); + ostringstream buf; + + buf << _toolTipText + << "X: #" << idx.x + << "\nY: #" << idx.y + << "\nC: $" << Common::Base::toString(tiaOutputBuffer[i], Common::Base::Fmt::_16); + + return buf.str(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool TiaZoomWidget::changedToolTip(const Common::Point& oldPos, + const Common::Point& newPos) const +{ + return getToolTipIndex(oldPos) != getToolTipIndex(newPos); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaZoomWidget::drawWidget(bool hilite) { diff --git a/src/debugger/gui/TiaZoomWidget.hxx b/src/debugger/gui/TiaZoomWidget.hxx index 7169645bf..d46787f23 100644 --- a/src/debugger/gui/TiaZoomWidget.hxx +++ b/src/debugger/gui/TiaZoomWidget.hxx @@ -34,6 +34,13 @@ class TiaZoomWidget : public Widget, public CommandSender void loadConfig() override; void setPos(int x, int y); + string getToolTip(const Common::Point& pos) const override; + bool changedToolTip(const Common::Point& oldPos, const Common::Point& newPos) const override; + + protected: + bool hasToolTip() const override { return true; } + Common::Point getToolTipIndex(const Common::Point& pos) const; + private: void zoom(int level); void recalc(); diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 5092299ec..405be5745 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -568,6 +568,7 @@ void LauncherDialog::handleMouseDown(int x, int y, MouseButton b, int clickCount // Grab right mouse button for context menu, send left to base class if(b == MouseButton::RIGHT) { + dialog().tooltip().hide(); // Dynamically create context menu for ROM list options VariantList items; From 779375abec6c4d8a2df48dc03225b49c7c379ad8 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 19 Nov 2020 16:44:03 +0100 Subject: [PATCH 69/70] fixed potential Clang warnings --- src/debugger/gui/TiaOutputWidget.cxx | 6 +++--- src/debugger/gui/TiaZoomWidget.cxx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index 94963f870..6d2a1b9cb 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -179,14 +179,14 @@ Common::Point TiaOutputWidget::getToolTipIndex(const Common::Point& pos) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string TiaOutputWidget::getToolTip(const Common::Point& pos) const { - Common::Point idx = getToolTipIndex(pos); + const Common::Point& idx = getToolTipIndex(pos); if(idx.x < 0) return EmptyString; - uInt32 height = instance().console().tia().height(); + const uInt32 height = instance().console().tia().height(); // limit to 274 lines (PAL default without scaling) - uInt32 yStart = height <= FrameManager::Metrics::baseHeightPAL + const uInt32 yStart = height <= FrameManager::Metrics::baseHeightPAL ? 0 : (height - FrameManager::Metrics::baseHeightPAL) >> 1; const Int32 i = idx.x + (yStart + idx.y) * instance().console().tia().width(); uInt8* tiaOutputBuffer = instance().console().tia().outputBuffer(); diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index eec9723ff..3cbbad8e2 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -296,7 +296,7 @@ Common::Point TiaZoomWidget::getToolTipIndex(const Common::Point& pos) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string TiaZoomWidget::getToolTip(const Common::Point& pos) const { - Common::Point idx = getToolTipIndex(pos); + const Common::Point& idx = getToolTipIndex(pos); if(idx.x < 0) return EmptyString; From 4d19473bb4c204dbc7bab454321a2f6c9606a5ab Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Thu, 19 Nov 2020 13:39:32 -0330 Subject: [PATCH 70/70] Enable RTTI for Xcode. --- src/macos/stella.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/macos/stella.xcodeproj/project.pbxproj b/src/macos/stella.xcodeproj/project.pbxproj index 09a728c1b..d0892bdce 100644 --- a/src/macos/stella.xcodeproj/project.pbxproj +++ b/src/macos/stella.xcodeproj/project.pbxproj @@ -3405,7 +3405,7 @@ ., "$(HOME)/Library/Frameworks", ); - GCC_ENABLE_CPP_RTTI = NO; + GCC_ENABLE_CPP_RTTI = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_VERSION = ""; @@ -3480,7 +3480,7 @@ ., "$(HOME)/Library/Frameworks", ); - GCC_ENABLE_CPP_RTTI = NO; + GCC_ENABLE_CPP_RTTI = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 3; GCC_VERSION = "";