The debugger CPU area is now font-sensitive.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2799 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2013-08-19 17:45:17 +00:00
parent 29167a2e87
commit 7b79b0a971
3 changed files with 45 additions and 45 deletions

View File

@ -32,7 +32,7 @@
#include "CpuWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int max_w)
: Widget(boss, font, x, y, 16, 16),
CommandSender(boss)
{
@ -53,8 +53,8 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
// Create a read-only textbox containing the current PC label
xpos += lwidth + myPCGrid->getWidth() + 10;
myPCLabel = new EditTextWidget(boss, font, xpos, ypos-1, fontWidth*25,
lineHeight, "");
myPCLabel = new EditTextWidget(boss, font, xpos, ypos, (max_w - xpos + x) - 10,
fontHeight+1, "");
myPCLabel->setEditable(false);
// Create a 1x4 grid with labels for the other CPU registers
@ -75,15 +75,23 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
new DataGridWidget(boss, font, xpos, ypos, 1, 4, 8, 8, Common::Base::F_2);
myCpuGridBinValue->setEditable(false);
// Create a label and 1x3 grid showing the source of data for A/X/Y registers
// Calculate real dimensions (_y will be calculated at the end)
_w = lwidth + myPCGrid->getWidth() + myPCLabel->getWidth() + 20;
// Create labels showing the source of data for SP/A/X/Y registers
xpos += myCpuGridBinValue->getWidth() + 20;
myCpuDataSrcGrid =
new DataGridWidget(boss, font, xpos, ypos, 1, 4, 4, 16, Common::Base::F_16);
myCpuDataSrcGrid->setEditable(false);
new StaticTextWidget(boss, font, xpos-font.getMaxCharWidth(),
ypos+myCpuDataSrcGrid->getHeight() + 4,
font.getStringWidth("Src Addr"), fontHeight, "Src Addr",
kTextAlignLeft);
int src_y = ypos, src_w = (max_w - xpos + x) - 10;
for(int i = 0; i < 4; ++i)
{
myCpuDataSrc[i] = new EditTextWidget(boss, font, xpos, src_y, src_w,
fontHeight+1, "");
myCpuDataSrc[i]->setEditable(false);
src_y += fontHeight+2;
}
int swidth = font.getStringWidth("Source Address");
new StaticTextWidget(boss, font, xpos, src_y + 4, src_w,
fontHeight, swidth <= src_w ? "Source Address" : "Source Addr",
kTextAlignCenter);
// Add labels for other CPU registers
xpos = x;
@ -115,8 +123,6 @@ CpuWidget::CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
}
myPSRegister->setList(off, on);
// Calculate real dimensions
_w = lwidth + myPCGrid->getWidth() + myPCLabel->getWidth() + 20;
_h = ypos + myPSRegister->getHeight() - y;
}
@ -275,22 +281,16 @@ void CpuWidget::loadConfig()
myCpuGridDecValue->setList(alist, vlist, changed);
myCpuGridBinValue->setList(alist, vlist, changed);
// Update the data sources for the A/X/Y registers
alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0);
alist.push_back(0);
alist.push_back(0);
vlist.push_back(state.srcS);
vlist.push_back(state.srcA);
vlist.push_back(state.srcX);
vlist.push_back(state.srcY);
changed.push_back(state.srcS != oldstate.srcS);
changed.push_back(state.srcA != oldstate.srcA);
changed.push_back(state.srcX != oldstate.srcX);
changed.push_back(state.srcY != oldstate.srcY);
myCpuDataSrcGrid->setList(alist, vlist, changed);
// Update the data sources for the SP/A/X/Y registers
// TODO - change this to use actual labels
myCpuDataSrc[0]->setText(Common::Base::toString(state.srcS),
state.srcS != oldstate.srcS);
myCpuDataSrc[1]->setText(Common::Base::toString(state.srcA),
state.srcA != oldstate.srcA);
myCpuDataSrc[2]->setText(Common::Base::toString(state.srcX),
state.srcX != oldstate.srcX);
myCpuDataSrc[3]->setText(Common::Base::toString(state.srcY),
state.srcY != oldstate.srcY);
// Update the PS register booleans
changed.clear();

View File

@ -33,7 +33,7 @@ class ToggleBitWidget;
class CpuWidget : public Widget, public CommandSender
{
public:
CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y);
CpuWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int max_w);
virtual ~CpuWidget();
void setOpsWidget(DataGridOpsWidget* w);
@ -72,7 +72,7 @@ class CpuWidget : public Widget, public CommandSender
DataGridWidget* myCpuGrid;
DataGridWidget* myCpuGridDecValue;
DataGridWidget* myCpuGridBinValue;
DataGridWidget* myCpuDataSrcGrid;
EditTextWidget* myCpuDataSrc[4];
ToggleBitWidget* myPSRegister;
EditTextWidget* myPCLabel;
};

View File

@ -312,20 +312,6 @@ void DebuggerDialog::addRomArea()
const GUI::Rect& r = getRomBounds();
const int vBorder = 4;
int xpos, ypos;
xpos = r.left + 10; ypos = 10;
myCpu = new CpuWidget(this, *myFont, xpos, ypos);
addToFocusList(myCpu->getFocusList());
xpos = r.left + 10; ypos += myCpu->getHeight() + 10;
myRam = new RamWidget(this, *myFont, xpos, ypos);
addToFocusList(myRam->getFocusList());
xpos = r.left + 10 + myCpu->getWidth() + 5;
DataGridOpsWidget* ops = new DataGridOpsWidget(this, *myFont,
xpos, 20);
int bwidth = myFont->getStringWidth("Frame +1 "),
bheight = myFont->getLineHeight() + 2;
int buttonX = r.right - bwidth - 5, buttonY = r.top + 5;
@ -353,6 +339,20 @@ void DebuggerDialog::addRomArea()
bwidth, bheight, "<", kDDRewindCmd);
myRewindButton->clearFlags(WIDGET_ENABLED);
int xpos = buttonX - 8*myFont->getMaxCharWidth() - 20, ypos = 20;
DataGridOpsWidget* ops = new DataGridOpsWidget(this, *myFont, xpos, ypos);
int max_w = xpos - r.left - 10;
xpos = r.left + 10; ypos = 10;
myCpu = new CpuWidget(this, *myFont, xpos, ypos, max_w);
addToFocusList(myCpu->getFocusList());
xpos = r.left + 10; ypos += myCpu->getHeight() + 10;
myRam = new RamWidget(this, *myFont, xpos, ypos);
addToFocusList(myRam->getFocusList());
// Add the DataGridOpsWidget to any widgets which contain a
// DataGridWidget which we want controlled
myCpu->setOpsWidget(ops);