Slight tweaks to ppu palette views to make more eye appealing.

This commit is contained in:
mjbudd77 2021-05-07 21:12:42 -04:00
parent a4fa6225a0
commit f4d590dd83
3 changed files with 131 additions and 118 deletions

View File

@ -1980,6 +1980,10 @@ void ppuNameTablePaletteView_t::paintEvent(QPaintEvent *event)
} }
painter.drawText( xx+i, yy+h-j, tr(c) ); painter.drawText( xx+i, yy+h-j, tr(c) );
painter.setPen( black );
painter.drawRect( xx, yy, w-1, h-1 );
painter.setPen( white );
painter.drawRect( xx+1, yy+1, w-3, h-3 );
xx += w; xx += w;
} }
} }

View File

@ -148,7 +148,7 @@ ppuViewerDialog_t::ppuViewerDialog_t(QWidget *parent)
QMenuBar *menuBar; QMenuBar *menuBar;
QVBoxLayout *mainLayout, *vbox; QVBoxLayout *mainLayout, *vbox;
QVBoxLayout *patternVbox[2]; QVBoxLayout *patternVbox[2];
QHBoxLayout *hbox; QHBoxLayout *hbox, *hbox1, *hbox2;
QGridLayout *grid; QGridLayout *grid;
QActionGroup *group; QActionGroup *group;
QMenu *fileMenu, *viewMenu, *colorMenu, *optMenu, *subMenu; QMenu *fileMenu, *viewMenu, *colorMenu, *optMenu, *subMenu;
@ -231,10 +231,30 @@ ppuViewerDialog_t::ppuViewerDialog_t(QWidget *parent)
grid->addLayout( hbox, 1, 1, Qt::AlignRight ); grid->addLayout( hbox, 1, 1, Qt::AlignRight );
vbox = new QVBoxLayout(); vbox = new QVBoxLayout();
//paletteFrame = new QGroupBox( tr("Palettes: ---- Top Row: Background ---- Bottom Row: Sprites") );
paletteFrame = new QGroupBox( tr("Palettes:") ); paletteFrame = new QGroupBox( tr("Palettes:") );
paletteView = new ppuPalatteView_t(this); //paletteView = new ppuPalatteView_t(this);
vbox->addWidget( paletteView, 1 ); hbox1 = new QHBoxLayout();
hbox2 = new QHBoxLayout();
for (int i=0; i<8; i++)
{
tilePalView[i] = new tilePaletteView_t(this);
if ( i < 4 )
{
hbox1->addWidget( tilePalView[i] );
}
else
{
hbox2->addWidget( tilePalView[i] );
}
tilePalView[i]->setIndex(i);
}
vbox->addLayout( hbox1, 1 );
vbox->addLayout( hbox2, 1 );
paletteFrame->setLayout( vbox ); paletteFrame->setLayout( vbox );
mainLayout->addWidget( paletteFrame, 1 ); mainLayout->addWidget( paletteFrame, 1 );
@ -243,7 +263,6 @@ ppuViewerDialog_t::ppuViewerDialog_t(QWidget *parent)
patternView[1]->setPattern( &pattern1 ); patternView[1]->setPattern( &pattern1 );
patternView[0]->setTileLabel( tileLabel[0] ); patternView[0]->setTileLabel( tileLabel[0] );
patternView[1]->setTileLabel( tileLabel[1] ); patternView[1]->setTileLabel( tileLabel[1] );
paletteView->setTileLabel( paletteFrame );
scanLineEdit->setRange( 0, 255 ); scanLineEdit->setRange( 0, 255 );
scanLineEdit->setValue( PPUViewScanline ); scanLineEdit->setValue( PPUViewScanline );
@ -1599,117 +1618,102 @@ void FCEUD_UpdatePPUView(int scanline, int refreshchr)
redrawWindow = true; redrawWindow = true;
} }
//---------------------------------------------------- //----------------------------------------------------
ppuPalatteView_t::ppuPalatteView_t(QWidget *parent) //-- Tile Palette View
//----------------------------------------------------
tilePaletteView_t::tilePaletteView_t(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
this->setFocusPolicy(Qt::StrongFocus); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
this->setMouseTracking(true); viewHeight = 32;
viewWidth = viewHeight*4;
setMinimumWidth( viewWidth );
setMinimumHeight( viewHeight );
setMinimumWidth( 32 * PALETTEWIDTH ); palIdx = 0;
setMinimumHeight( 32 * PALETTEHEIGHT );
viewWidth = 32 * PALETTEWIDTH;
viewHeight = 32 * PALETTEHEIGHT;
boxWidth = viewWidth / PALETTEWIDTH;
boxHeight = viewHeight / PALETTEHEIGHT;
frame = NULL;
} }
//---------------------------------------------------- //----------------------------------------------------
ppuPalatteView_t::~ppuPalatteView_t(void) tilePaletteView_t::~tilePaletteView_t(void)
{ {
} }
//---------------------------------------------------- //----------------------------------------------------
void ppuPalatteView_t::setTileLabel( QGroupBox *l ) void tilePaletteView_t::setIndex( int val )
{ {
frame = l; palIdx = val;
} }
//---------------------------------------------------- //----------------------------------------------------
QPoint ppuPalatteView_t::convPixToTile( QPoint p ) int tilePaletteView_t::heightForWidth(int w) const
{ {
QPoint t(0,0); return w/4;
t.setX( p.x() / boxWidth );
t.setY( p.y() / boxHeight );
return t;
} }
//---------------------------------------------------- //----------------------------------------------------
void ppuPalatteView_t::resizeEvent(QResizeEvent *event) QSize tilePaletteView_t::minimumSizeHint(void) const
{
return QSize(48,12);
}
//----------------------------------------------------
QSize tilePaletteView_t::maximumSizeHint(void) const
{
return QSize(256,64);
}
//----------------------------------------------------
QSize tilePaletteView_t::sizeHint(void) const
{
return QSize(128,32);
}
//----------------------------------------------------
void tilePaletteView_t::resizeEvent(QResizeEvent *event)
{ {
viewWidth = event->size().width(); viewWidth = event->size().width();
viewHeight = event->size().height(); viewHeight = event->size().height();
boxWidth = viewWidth / PALETTEWIDTH;
boxHeight = viewHeight / PALETTEHEIGHT;
} }
//---------------------------------------------------- //----------------------------------------------------
void ppuPalatteView_t::mouseMoveEvent(QMouseEvent *event) void tilePaletteView_t::paintEvent(QPaintEvent *event)
{ {
QPoint tile = convPixToTile( event->pos() ); int x,w,h,xx,yy,p,p2,i,j;
if ( (tile.x() < PALETTEWIDTH) && (tile.y() < PALETTEHEIGHT) )
{
char stmp[64];
int ix = (tile.y()<<4)|tile.x();
sprintf( stmp, "Palette: $%02X", palcache[ix]);
frame->setTitle( tr(stmp) );
}
}
//----------------------------------------------------------------------------
void ppuPalatteView_t::mousePressEvent(QMouseEvent * event)
{
//QPoint tile = convPixToTile( event->pos() );
//if ( event->button() == Qt::LeftButton )
//{
//}
//else if ( event->button() == Qt::RightButton )
//{
//}
}
//----------------------------------------------------
void ppuPalatteView_t::paintEvent(QPaintEvent *event)
{
int x,y,w,h,xx,yy,i,j,p,ii;
QPainter painter(this); QPainter painter(this);
viewWidth = event->rect().width(); QColor color( 0, 0, 0);
viewHeight = event->rect().height(); QColor white(255,255,255), black(0,0,0);
QColor color, black(0,0,0), white(255,255,255); //QPen pen;
QPen pen; //char showSelector;
char c[4]; char c[4];
pen = painter.pen(); //pen = painter.pen();
//printf("PPU PatternView %ix%i \n", viewWidth, viewHeight ); viewWidth = event->rect().width();
viewHeight = event->rect().height();
w = viewWidth / PALETTEWIDTH; w = viewWidth / 4;
h = viewHeight / PALETTEHEIGHT; h = viewHeight;
//if ( w < h )
//{
// h = w;
//}
//else
//{
// w = h;
//}
i = w / 4; i = w / 4;
j = h / 4; j = h / 4;
p2 = palIdx * 4;
yy = 0; yy = 0;
for (y=0; y < PALETTEHEIGHT; y++)
{
xx = 0; xx = 0;
for (x=0; x < 4; x++)
for (x=0; x < PALETTEWIDTH; x++)
{ {
ii = (y*PALETTEWIDTH) + x; if ( palo != NULL )
{
p = palcache[ii]; p = palcache[p2 | x];
color.setBlue( palo[p].b );
color = ppuv_palette[y][x]; color.setGreen( palo[p].g );
color.setRed( palo[p].r );
c[0] = conv2hex( (p & 0xF0) >> 4 ); c[0] = conv2hex( (p & 0xF0) >> 4 );
c[1] = conv2hex( p & 0x0F); c[1] = conv2hex( p & 0x0F);
c[2] = 0; c[2] = 0;
}
painter.fillRect( xx, yy, w, h, color ); painter.fillRect( xx, yy, w, h, color );
if ( qGray( color.red(), color.green(), color.blue() ) > 128 ) if ( qGray( color.red(), color.green(), color.blue() ) > 128 )
@ -1722,24 +1726,24 @@ void ppuPalatteView_t::paintEvent(QPaintEvent *event)
} }
painter.drawText( xx+i, yy+h-j, tr(c) ); painter.drawText( xx+i, yy+h-j, tr(c) );
painter.setPen( black );
painter.drawRect( xx, yy, w-1, h-1 );
painter.setPen( white );
painter.drawRect( xx+1, yy+1, w-3, h-3 );
xx += w; xx += w;
} }
yy += h;
}
y = PALETTEHEIGHT*h; //painter.setPen( black );
for (int i=0; i<=PALETTEWIDTH; i++) //painter.drawLine( 0, 0 , w*4, 0 );
{ //painter.drawLine( 0, h-1 , w*4, h-1 );
x = i*w; //xx = 0;
painter.drawLine( x, 0 , x, y );
}
x = PALETTEWIDTH*w; //for (int i=0; i < 5; i++)
for (int i=0; i<=PALETTEHEIGHT; i++) //{
{ // painter.drawLine( xx, 0 , xx, h );
y = i*h;
painter.drawLine( 0, y, x, y ); // xx += w;
} //}
} }
//---------------------------------------------------- //----------------------------------------------------
//---------------------------------------------------- //----------------------------------------------------
@ -3460,6 +3464,10 @@ void oamPaletteView_t::paintEvent(QPaintEvent *event)
} }
painter.drawText( xx+i, yy+h-j, tr(c) ); painter.drawText( xx+i, yy+h-j, tr(c) );
painter.setPen( black );
painter.drawRect( xx, yy, w-1, h-1 );
painter.setPen( white );
painter.drawRect( xx+1, yy+1, w-3, h-3 );
xx += w; xx += w;
} }
} }

View File

@ -102,26 +102,27 @@ class ppuPatternView_t : public QWidget
void cycleNextPalette(void); void cycleNextPalette(void);
}; };
class ppuPalatteView_t : public QWidget class tilePaletteView_t : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
ppuPalatteView_t(QWidget *parent = 0); tilePaletteView_t( QWidget *parent = 0);
~ppuPalatteView_t(void); ~tilePaletteView_t(void);
void setTileLabel( QGroupBox *l ); void setIndex( int val );
QPoint convPixToTile( QPoint p );
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
void mouseMoveEvent(QMouseEvent *event); int heightForWidth(int w) const;
void mousePressEvent(QMouseEvent * event); QSize minimumSizeHint(void) const;
QSize maximumSizeHint(void) const;
QSize sizeHint(void) const;
private:
int viewWidth; int viewWidth;
int viewHeight; int viewHeight;
int boxWidth; int palIdx;
int boxHeight;
QGroupBox *frame;
}; };
class ppuTileView_t : public QWidget class ppuTileView_t : public QWidget
@ -254,7 +255,7 @@ class ppuViewerDialog_t : public QDialog
~ppuViewerDialog_t(void); ~ppuViewerDialog_t(void);
ppuPatternView_t *patternView[2]; ppuPatternView_t *patternView[2];
ppuPalatteView_t *paletteView; tilePaletteView_t *tilePalView[8];
protected: protected:
void closeEvent(QCloseEvent *bar); void closeEvent(QCloseEvent *bar);