diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index e363a0b82..abfc63ac1 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -118,7 +118,8 @@ FBInitStatus Debugger::initializeVideo() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool Debugger::start(const string& message, int address, bool read) +bool Debugger::start(const string& message, int address, bool read, + const string& toolTip) { if(myOSystem.eventHandler().enterDebugMode()) { @@ -129,6 +130,7 @@ bool Debugger::start(const string& message, int address, bool read) if(address > -1) buf << cartDebug().getLabel(address, read, 4); myDialog->message().setText(buf.str()); + myDialog->message().setToolTip(toolTip); return true; } return false; diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx index e7096cd4d..6a53238bb 100644 --- a/src/debugger/Debugger.hxx +++ b/src/debugger/Debugger.hxx @@ -97,7 +97,8 @@ class Debugger : public DialogContainer @param message Message to display when entering debugger @param address An address associated with the message */ - bool start(const string& message = "", int address = -1, bool read = true); + bool start(const string& message = "", int address = -1, bool read = true, + const string& toolTip = ""); bool startWithFatalError(const string& message = ""); /** diff --git a/src/debugger/gui/CpuWidget.cxx b/src/debugger/gui/CpuWidget.cxx index a8719f448..1069e8001 100644 --- a/src/debugger/gui/CpuWidget.cxx +++ b/src/debugger/gui/CpuWidget.cxx @@ -91,7 +91,7 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n 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]->setToolTip("Source label of last read for " + labels[i] + "."); myCpuDataSrc[i]->setEditable(false, true); src_y += fontHeight + 2; } @@ -140,7 +140,7 @@ 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->setToolTip("Destination label of last write."); myCpuDataDest->setEditable(false, true); _h = ypos + myPSRegister->getHeight() - y; diff --git a/src/debugger/gui/DataGridOpsWidget.cxx b/src/debugger/gui/DataGridOpsWidget.cxx index 102d7a94d..2a62ec60c 100644 --- a/src/debugger/gui/DataGridOpsWidget.cxx +++ b/src/debugger/gui/DataGridOpsWidget.cxx @@ -33,31 +33,38 @@ DataGridOpsWidget::DataGridOpsWidget(GuiObject* boss, const GUI::Font& font, xpos = x; ypos = y; _zeroButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, "0", kDGZeroCmd); - + _zeroButton->setToolTip("Zero currently selected value"); + ypos += bheight + space; _invButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, "Inv", kDGInvertCmd); + _invButton->setToolTip("Invert currently selected value"); ypos += bheight + space; _incButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, "++", kDGIncCmd); + _incButton->setToolTip("Increase currently selected value."); ypos += bheight + space; _shiftLeftButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, "<<", kDGShiftLCmd); + _shiftLeftButton->setToolTip("Shift currently selected value left"); // Move to next column, skip a row xpos = x + bwidth + space; ypos = y + bheight + space; _negButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, "Neg", kDGNegateCmd); + _negButton->setToolTip("Negate currently selected value"); ypos += bheight + space; _decButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, "--", kDGDecCmd); + _decButton->setToolTip("Decrease currently selected value"); ypos += bheight + space; _shiftRightButton = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, ">>", kDGShiftRCmd); + _shiftRightButton->setToolTip("Shift currently selected value right"); // Calculate real dimensions _w = 2 * (bwidth+space); diff --git a/src/debugger/gui/DataGridWidget.cxx b/src/debugger/gui/DataGridWidget.cxx index 81840147a..20489912c 100644 --- a/src/debugger/gui/DataGridWidget.cxx +++ b/src/debugger/gui/DataGridWidget.cxx @@ -713,6 +713,7 @@ void DataGridWidget::startEditMode() { if (isEditable() && !_editMode && _selectedItem >= 0) { + dialog().tooltip().hide(); enableEditMode(true); setText("", true); // Erase current entry when starting editing } diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index 07e530ac6..b8a28f579 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -94,6 +94,7 @@ void DebuggerDialog::loadConfig() myRomTab->loadConfig(); myMessageBox->setText(""); + myMessageBox->setToolTip(""); } void DebuggerDialog::saveConfig() diff --git a/src/debugger/gui/RamWidget.cxx b/src/debugger/gui/RamWidget.cxx index 7f651910a..4e097d9be 100644 --- a/src/debugger/gui/RamWidget.cxx +++ b/src/debugger/gui/RamWidget.cxx @@ -78,18 +78,21 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n by += bheight + VGAP * 6; mySearchButton = new ButtonWidget(boss, lfont, bx, by, bwidth, bheight, "Search" + ELLIPSIS, kSearchCmd); + mySearchButton->setToolTip("Search and highlight found values."); wid.push_back(mySearchButton); mySearchButton->setTarget(this); by += bheight + VGAP; myCompareButton = new ButtonWidget(boss, lfont, bx, by, bwidth, bheight, "Compare" + ELLIPSIS, kCmpCmd); + myCompareButton->setToolTip("Compare highlighted values."); wid.push_back(myCompareButton); myCompareButton->setTarget(this); by += bheight + VGAP; myRestartButton = new ButtonWidget(boss, lfont, bx, by, bwidth, bheight, "Reset", kRestartCmd); + myRestartButton->setToolTip("Reset search/compare mode."); wid.push_back(myRestartButton); myRestartButton->setTarget(this); @@ -366,6 +369,9 @@ void RamWidget::showInputBox(int cmd) myInputBox->show(x, y, dialog().surface().dstRect()); myInputBox->setText(""); myInputBox->setMessage(""); + myInputBox->setToolTip(cmd == kSValEntered + ? "Enter search value (leave blank for all)." + : "Enter relative or absolute value\nto compare with searched values."); myInputBox->setFocus(0); myInputBox->setEmitSignal(cmd); myInputBox->setTitle(cmd == kSValEntered ? "Search" : "Compare"); diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index 424efd0d1..d101fa674 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -23,7 +23,6 @@ #include "Widget.hxx" #include "GuiObject.hxx" #include "Dialog.hxx" -#include "ToolTip.hxx" #include "ContextMenu.hxx" #include "TiaZoomWidget.hxx" #include "Debugger.hxx" @@ -104,7 +103,7 @@ void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaOutputWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) -{ +{ if(b == MouseButton::LEFT) myZoom->setPos(x, y); // Grab right mouse button for command context menu @@ -113,7 +112,6 @@ void TiaOutputWidget::handleMouseDown(int x, int y, MouseButton b, int clickCoun myClickX = x; myClickY = y - 1; - dialog().tooltip().hide(); // Add menu at current x,y mouse location myMenu->show(x + getAbsX(), y + getAbsY(), dialog().surface().dstRect()); } diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index 3622c11ac..af8e468dd 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -129,7 +129,6 @@ 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()); } diff --git a/src/emucore/DispatchResult.cxx b/src/emucore/DispatchResult.cxx index 20a208a56..9ba5326ca 100644 --- a/src/emucore/DispatchResult.cxx +++ b/src/emucore/DispatchResult.cxx @@ -31,11 +31,13 @@ void DispatchResult::setOk(uInt64 cycles) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DispatchResult::setDebugger(uInt64 cycles, const string& message, int address, bool wasReadTrap) +void DispatchResult::setDebugger(uInt64 cycles, const string& message, + const string& tooltip, int address, bool wasReadTrap) { myStatus = Status::debugger; myCycles = cycles; myMessage = message; + myToolTip = tooltip; myAddress = address; myWasReadTrap = wasReadTrap; } diff --git a/src/emucore/DispatchResult.hxx b/src/emucore/DispatchResult.hxx index 6d76cf5ce..38e80a9c5 100644 --- a/src/emucore/DispatchResult.hxx +++ b/src/emucore/DispatchResult.hxx @@ -37,12 +37,14 @@ class DispatchResult bool wasReadTrap() const { assertStatus(Status::debugger); return myWasReadTrap; } + const string& getToolTip() const { assertStatus(Status::debugger, Status::fatal); return myToolTip; } + bool isSuccess() const; void setOk(uInt64 cycles); - void setDebugger(uInt64 cycles, const string& message = "", int address = -1, - bool wasReadTrap = true); + void setDebugger(uInt64 cycles, const string& message = "", + const string& tooltip = "", int address = -1, bool wasReadTrap = true); void setFatal(uInt64 cycles); @@ -73,6 +75,8 @@ class DispatchResult int myAddress{0}; bool myWasReadTrap{false}; + + string myToolTip; }; #endif // DISPATCH_RESULT_HXX diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index 86b050dfb..295697af2 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -243,7 +243,9 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) myJustHitReadTrapFlag = myJustHitWriteTrapFlag = false; myLastBreakCycle = mySystem->cycles(); - result.setDebugger(currentCycles, myHitTrapInfo.message, myHitTrapInfo.address, read); + result.setDebugger(currentCycles, myHitTrapInfo.message, + read ? "Read trap" : "Write trap", + myHitTrapInfo.address, read); return; } @@ -264,7 +266,7 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) ostringstream msg; msg << "BP: $" << Common::Base::HEX4 << PC << ", bank #" << std::dec << int(bank); - result.setDebugger(currentCycles, msg.str()); + result.setDebugger(currentCycles, msg.str(), "Breakpoint"); } return; } @@ -278,7 +280,7 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) msg << "CBP[" << Common::Base::HEX2 << cond << "]: " << myCondBreakNames[cond]; myLastBreakCycle = mySystem->cycles(); - result.setDebugger(currentCycles, msg.str()); + result.setDebugger(currentCycles, msg.str(), "Conditional breakpoint"); return; } } @@ -327,7 +329,7 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) { ostringstream msg; msg << "RWP[@ $" << Common::Base::HEX4 << rwpAddr << "]: "; - result.setDebugger(currentCycles, msg.str(), oldPC); + result.setDebugger(currentCycles, msg.str(), "Read from write port", oldPC); return; } } @@ -339,7 +341,7 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) { ostringstream msg; msg << "WRP[@ $" << Common::Base::HEX4 << wrpAddr << "]: "; - result.setDebugger(currentCycles, msg.str(), oldPC); + result.setDebugger(currentCycles, msg.str(), "Write to read port", oldPC); return; } } @@ -348,7 +350,7 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result) myExecutionStatus |= FatalErrorBit; result.setMessage(e.what()); } catch (const EmulationWarning& e) { - result.setDebugger(currentCycles, e.what(), PC); + result.setDebugger(currentCycles, e.what(), "Emulation exception", PC); return; } diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index e659c1e5c..b8f8842e6 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -775,7 +775,8 @@ double OSystem::dispatchEmulation(EmulationWorker& emulationWorker) myDebugger->start( dispatchResult.getMessage(), dispatchResult.getAddress(), - dispatchResult.wasReadTrap() + dispatchResult.wasReadTrap(), + dispatchResult.getToolTip() ); #endif diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 1b58d7729..392f2b625 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -512,6 +512,8 @@ void Dialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated) { Event::Type e = Event::NoType; + tooltip().hide(); + // FIXME - I don't think this will compile! #if defined(RETRON77) // special keys used for R77 diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index fcdac91a9..0a6730773 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -17,6 +17,7 @@ #include "OSystem.hxx" #include "Dialog.hxx" +#include "ToolTip.hxx" #include "Stack.hxx" #include "EventHandler.hxx" #include "FrameBuffer.hxx" @@ -159,6 +160,10 @@ int DialogContainer::addDialog(Dialog* d) "Unable to show dialog box; FIX THE CODE", MessagePosition::BottomCenter, true); else { + // Close all open tooltips + if(!myDialogStack.empty()) + myDialogStack.top()->tooltip().hide(); + d->setDirty(); myDialogStack.push(d); } diff --git a/src/gui/InputTextDialog.cxx b/src/gui/InputTextDialog.cxx index 54b656a67..4c34de23e 100644 --- a/src/gui/InputTextDialog.cxx +++ b/src/gui/InputTextDialog.cxx @@ -81,9 +81,10 @@ void InputTextDialog::initialize(const GUI::Font& lfont, const GUI::Font& nfont, for(i = 0; i < labels.size(); ++i) { xpos = HBORDER; - new StaticTextWidget(this, lfont, xpos, ypos + 2, - lwidth, fontHeight, - labels[i], TextAlign::Left); + StaticTextWidget* s = new StaticTextWidget(this, lfont, xpos, ypos + 2, + lwidth, fontHeight, + labels[i]); + myLabel.push_back(s); xpos += lwidth + fontWidth; EditTextWidget* w = new EditTextWidget(this, nfont, xpos, ypos, @@ -177,6 +178,13 @@ void InputTextDialog::setTextFilter(const EditableWidget::TextFilter& f, int idx myInput[idx]->setTextFilter(f); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void InputTextDialog::setToolTip(const string& str, int idx) +{ + if(uInt32(idx) < myLabel.size()) + myLabel[idx]->setToolTip(str); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void InputTextDialog::setFocus(int idx) { diff --git a/src/gui/InputTextDialog.hxx b/src/gui/InputTextDialog.hxx index a06ca4446..059c7ada7 100644 --- a/src/gui/InputTextDialog.hxx +++ b/src/gui/InputTextDialog.hxx @@ -46,6 +46,7 @@ class InputTextDialog : public Dialog, public CommandSender void setText(const string& str, int idx = 0); void setTextFilter(const EditableWidget::TextFilter& f, int idx = 0); + void setToolTip(const string& str, int idx = 0); void setEmitSignal(int cmd) { myCmd = cmd; } void setMessage(const string& title); @@ -61,6 +62,7 @@ class InputTextDialog : public Dialog, public CommandSender void setPosition() override; private: + vector myLabel; vector myInput; StaticTextWidget* myMessage{nullptr}; diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 405be5745..5092299ec 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -568,7 +568,6 @@ 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; diff --git a/src/gui/PopUpWidget.cxx b/src/gui/PopUpWidget.cxx index 82f4e2596..eb35ed9c3 100644 --- a/src/gui/PopUpWidget.cxx +++ b/src/gui/PopUpWidget.cxx @@ -21,7 +21,6 @@ #include "Font.hxx" #include "ContextMenu.hxx" #include "Dialog.hxx" -#include "ToolTip.hxx" #include "DialogContainer.hxx" #include "PopUpWidget.hxx" @@ -124,7 +123,6 @@ 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());