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;