Added grid lines to the PPU pattern table viewer for the Qt GUI.

This commit is contained in:
mjbudd77 2021-01-25 20:26:09 -05:00
parent 7ce62ebee3
commit 909e3c0c20
1 changed files with 158 additions and 116 deletions

View File

@ -352,11 +352,8 @@ void ppuPatternView_t::keyPressEvent(QKeyEvent *event)
mode = !mode;
}
else if ( event->key() == Qt::Key_G )
{
if ( mode )
{
drawTileGrid = !drawTileGrid;
}
}
else if ( event->key() == Qt::Key_E )
{
@ -425,13 +422,6 @@ void ppuPatternView_t::contextMenuEvent(QContextMenuEvent *event)
act->setShortcut( QKeySequence(tr("Z")));
connect( act, SIGNAL(triggered(void)), this, SLOT(exitTileMode(void)) );
menu.addAction( act );
act = new QAction(tr("Draw Tile Grid Lines"), &menu);
act->setCheckable(true);
act->setChecked(drawTileGrid);
act->setShortcut( QKeySequence(tr("G")));
connect( act, SIGNAL(triggered(void)), this, SLOT(toggleTileGridLines(void)) );
menu.addAction( act );
}
else
{
@ -443,6 +433,13 @@ void ppuPatternView_t::contextMenuEvent(QContextMenuEvent *event)
menu.addAction( act );
}
act = new QAction(tr("Draw Tile Grid Lines"), &menu);
act->setCheckable(true);
act->setChecked(drawTileGrid);
act->setShortcut( QKeySequence(tr("G")));
connect( act, SIGNAL(triggered(void)), this, SLOT(toggleTileGridLines(void)) );
menu.addAction( act );
act = new QAction(tr("Next Palette"), &menu);
act->setShortcut( QKeySequence(tr("P")));
connect( act, SIGNAL(triggered(void)), this, SLOT(cycleNextPalette(void)) );
@ -567,9 +564,16 @@ void ppuPatternView_t::paintEvent(QPaintEvent *event)
QPainter painter(this);
viewWidth = event->rect().width();
viewHeight = event->rect().height();
QPen pen;
pen = painter.pen();
//printf("PPU PatternView %ix%i \n", viewWidth, viewHeight );
pen.setWidth( 1 );
pen.setColor( QColor( 128, 128, 128) );
painter.setPen( pen );
w = viewWidth / 128;
h = viewHeight / 128;
@ -664,6 +668,23 @@ void ppuPatternView_t::paintEvent(QPaintEvent *event)
}
}
}
if ( drawTileGrid )
{
xx = 0; y = 128*h;
for (i=0; i<16; i++) //Columns
{
painter.drawLine( xx, 0 , xx, y ); xx += (8*w);
}
yy = 0; x = 128*w;
for (j=0; j<16; j++) //Rows
{
painter.drawLine( 0, yy , x, yy ); yy += (8*h);
}
}
}
else
{
@ -688,6 +709,23 @@ void ppuPatternView_t::paintEvent(QPaintEvent *event)
}
}
}
if ( drawTileGrid )
{
xx = 0; y = 128*h;
for (i=0; i<16; i++) //Columns
{
painter.drawLine( xx, 0 , xx, y ); xx += (8*w);
}
yy = 0; x = 128*w;
for (j=0; j<16; j++) //Rows
{
painter.drawLine( 0, yy , x, yy ); yy += (8*h);
}
}
}
}
//----------------------------------------------------
@ -1622,6 +1660,10 @@ void ppuTileView_t::paintEvent(QPaintEvent *event)
if ( drawTileGrid )
{
pen.setWidth( 1 );
pen.setColor( QColor(128,128,128) );
painter.setPen( pen );
// Draw Tile Pixel grid lines
xx = 0; y = 8*h;