From 6dfd3fb2d0dd210d1692762d8a83536dfff9837e Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Tue, 6 Oct 2020 21:31:40 -0400 Subject: [PATCH] Added logic to draw scroll lines on NT Viewer for Qt GUI --- src/drivers/Qt/NameTableViewer.cpp | 34 ++++++++++++++++++++++++++---- src/drivers/Qt/NameTableViewer.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/drivers/Qt/NameTableViewer.cpp b/src/drivers/Qt/NameTableViewer.cpp index 240121b0..c64b5b16 100644 --- a/src/drivers/Qt/NameTableViewer.cpp +++ b/src/drivers/Qt/NameTableViewer.cpp @@ -32,6 +32,7 @@ static int chrchanged = 0; static int xpos = 0, ypos = 0; static int attview = 0; static int hidepal = 0; +static bool drawScrollLines = true; static bool redrawtables = true; // checkerboard tile for attribute view @@ -110,7 +111,7 @@ ppuNameTableViewerDialog_t::ppuNameTableViewerDialog_t(QWidget *parent) showAttrbCbox = new QCheckBox( tr("Show Attributes") ); ignorePaletteCbox = new QCheckBox( tr("Ignore Palette") ); - //showScrollLineCbox->setChecked( attview ); + showScrollLineCbox->setChecked( drawScrollLines ); showAttrbCbox->setChecked( attview ); ignorePaletteCbox->setChecked( hidepal ); @@ -118,8 +119,9 @@ ppuNameTableViewerDialog_t::ppuNameTableViewerDialog_t(QWidget *parent) grid->addWidget( showAttrbCbox , 1, 0, Qt::AlignLeft ); grid->addWidget( ignorePaletteCbox , 2, 0, Qt::AlignLeft ); - connect( showAttrbCbox , SIGNAL(stateChanged(int)), this, SLOT(showAttrbChanged(int))); - connect( ignorePaletteCbox, SIGNAL(stateChanged(int)), this, SLOT(ignorePaletteChanged(int))); + connect( showScrollLineCbox, SIGNAL(stateChanged(int)), this, SLOT(showScrollLinesChanged(int))); + connect( showAttrbCbox , SIGNAL(stateChanged(int)), this, SLOT(showAttrbChanged(int))); + connect( ignorePaletteCbox , SIGNAL(stateChanged(int)), this, SLOT(ignorePaletteChanged(int))); hbox = new QHBoxLayout(); refreshSlider = new QSlider( Qt::Horizontal ); @@ -344,6 +346,11 @@ void ppuNameTableViewerDialog_t::scanLineChanged( const QString &txt ) //printf("ScanLine: '%s' %i\n", s.c_str(), PPUViewScanline ); } //---------------------------------------------------- +void ppuNameTableViewerDialog_t::showScrollLinesChanged(int state) +{ + drawScrollLines = (state != Qt::Unchecked); +} +//---------------------------------------------------- void ppuNameTableViewerDialog_t::showAttrbChanged(int state) { attview = (state != Qt::Unchecked); @@ -473,8 +480,9 @@ void ppuNameTableView_t::mousePressEvent(QMouseEvent * event) void ppuNameTableView_t::paintEvent(QPaintEvent *event) { ppuNameTable_t *nt; - int n,i,j,ii,jj,w,h,x,y,xx,yy; + int n,i,j,ii,jj,w,h,x,y,xx,yy,ww,hh; QPainter painter(this); + QColor scanLineColor(255,255,255); viewWidth = event->rect().width(); viewHeight = event->rect().height(); @@ -514,7 +522,25 @@ void ppuNameTableView_t::paintEvent(QPaintEvent *event) } } } + if ( drawScrollLines ) + { + ww = nt->w * 256; + hh = nt->h * 240; + + painter.setPen( scanLineColor ); + + if ( (xpos >= xx) && (xpos < (xx+ww)) ) + { + painter.drawLine( xpos, yy, xpos, yy + hh ); + } + + if ( (ypos >= yy) && (ypos < (yy+hh)) ) + { + painter.drawLine( xx, ypos, xx + ww, ypos ); + } + } } + } //---------------------------------------------------- static void initNameTableViewer(void) diff --git a/src/drivers/Qt/NameTableViewer.h b/src/drivers/Qt/NameTableViewer.h index 0d27c073..f8865249 100644 --- a/src/drivers/Qt/NameTableViewer.h +++ b/src/drivers/Qt/NameTableViewer.h @@ -105,6 +105,7 @@ class ppuNameTableViewerDialog_t : public QDialog void singleScreen3Clicked(void); void showAttrbChanged(int state); void ignorePaletteChanged(int state); + void showScrollLinesChanged(int state); void refreshSliderChanged(int value); void scanLineChanged( const QString &txt ); };