simple custom-drawn button in registersview
This commit is contained in:
parent
29576b4bf5
commit
6d9a4520c0
|
@ -997,7 +997,8 @@ RegistersView::RegistersView(QWidget* parent) : QScrollArea(parent), mVScrollOff
|
|||
mCip = 0;
|
||||
mRegisterUpdates.clear();
|
||||
|
||||
yTopSpacing = 3; //set top spacing (in pixels)
|
||||
mButtonHeight = 5;
|
||||
yTopSpacing = 20; //set top spacing (in pixels)
|
||||
|
||||
// Context Menu
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
@ -1099,8 +1100,15 @@ void RegistersView::mousePressEvent(QMouseEvent* event)
|
|||
{
|
||||
if(!DbgIsDebugging())
|
||||
return;
|
||||
|
||||
if(event->y() < yTopSpacing - mButtonHeight)
|
||||
{
|
||||
QMessageBox::information(this, "Troll", "You are now dead...");
|
||||
}
|
||||
else
|
||||
{
|
||||
// get mouse position
|
||||
const int y = (event->y() - 3) / (double)mRowHeight;
|
||||
const int y = (event->y() - yTopSpacing) / (double)mRowHeight;
|
||||
const int x = event->x() / (double)mCharWidth;
|
||||
|
||||
REGISTER_NAME r;
|
||||
|
@ -1112,6 +1120,7 @@ void RegistersView::mousePressEvent(QMouseEvent* event)
|
|||
}
|
||||
else
|
||||
mSelected = UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
void RegistersView::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
|
@ -1120,7 +1129,7 @@ void RegistersView::mouseDoubleClickEvent(QMouseEvent* event)
|
|||
if(!DbgIsDebugging() || event->button() != Qt::LeftButton)
|
||||
return;
|
||||
// get mouse position
|
||||
const int y = (event->y() - 3) / (double)mRowHeight;
|
||||
const int y = (event->y() - yTopSpacing) / (double)mRowHeight;
|
||||
const int x = event->x() / (double)mCharWidth;
|
||||
|
||||
// do we find a corresponding register?
|
||||
|
@ -1143,6 +1152,10 @@ void RegistersView::paintEvent(QPaintEvent* event)
|
|||
QPainter wPainter(this->viewport());
|
||||
wPainter.fillRect(wPainter.viewport(), QBrush(ConfigColor("RegistersBackgroundColor")));
|
||||
|
||||
wPainter.setPen(Qt::black);
|
||||
wPainter.drawLine(0, yTopSpacing - mButtonHeight, this->viewport()->width(), yTopSpacing - mButtonHeight);
|
||||
wPainter.drawText(0, 0, this->viewport()->width(), yTopSpacing - mButtonHeight, Qt::AlignVCenter, " Press here to die...");
|
||||
|
||||
QMap<REGISTER_NAME, QString>::const_iterator it = mRegisterMapping.begin();
|
||||
// iterate all registers
|
||||
while(it != mRegisterMapping.end())
|
||||
|
|
|
@ -153,6 +153,7 @@ private:
|
|||
int mVScrollOffset;
|
||||
int mRowsNeeded;
|
||||
int yTopSpacing;
|
||||
int mButtonHeight;
|
||||
QSet<REGISTER_NAME> mUINTDISPLAY;
|
||||
QSet<REGISTER_NAME> mUSHORTDISPLAY;
|
||||
QSet<REGISTER_NAME> mDWORDDISPLAY;
|
||||
|
|
Loading…
Reference in New Issue