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
This commit is contained in:
thrust26 2020-11-19 12:25:07 +01:00
parent 6196c1f546
commit d3125f23d7
15 changed files with 127 additions and 24 deletions

View File

@ -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;

View File

@ -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();
}

View File

@ -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

View File

@ -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);

View File

@ -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<StaticTextWidget*, 16> myRamLabels{nullptr};
DataGridWidget* myRamGrid{nullptr};
DataGridRamWidget* myRamGrid{nullptr};
DataGridWidget* myHexValue{nullptr};
DataGridWidget* myDecValue{nullptr};
DataGridWidget* myBinValue{nullptr};

View File

@ -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;

View File

@ -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)

View File

@ -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<Int32>(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();
}

View File

@ -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)
{

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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 \

View File

@ -525,6 +525,9 @@
<ClCompile Include="..\debugger\BreakpointMap.cxx">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug-NoDebugger|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\debugger\DataGridRamWidget.cxx">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug-NoDebugger|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\debugger\Debugger.cxx">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug-NoDebugger|x64'">true</ExcludedFromBuild>
</ClCompile>
@ -1550,6 +1553,9 @@
<ClInclude Include="..\debugger\BreakpointMap.hxx">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug-NoDebugger|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\debugger\DataGridRamWidget.hxx">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug-NoDebugger|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\debugger\gui\AmigaMouseWidget.hxx">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug-NoDebugger|x64'">true</ExcludedFromBuild>
</ClInclude>

View File

@ -1035,6 +1035,9 @@
<ClCompile Include="..\gui\ToolTip.cxx">
<Filter>Source Files\gui</Filter>
</ClCompile>
<ClCompile Include="..\debugger\DataGridRamWidget.cxx">
<Filter>Source Files\debugger</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\bspf.hxx">
@ -2129,6 +2132,9 @@
<ClInclude Include="..\gui\ToolTip.hxx">
<Filter>Header Files\gui</Filter>
</ClInclude>
<ClInclude Include="..\debugger\DataGridRamWidget.hxx">
<Filter>Header Files\debugger</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="stella.ico">