Hooked up sprite viewer window menu options.
This commit is contained in:
parent
d7773c7b3d
commit
187522b4cc
|
@ -2536,9 +2536,9 @@ spriteViewerDialog_t::spriteViewerDialog_t(QWidget *parent)
|
||||||
QGridLayout *infoGrid;
|
QGridLayout *infoGrid;
|
||||||
QGroupBox *frame;
|
QGroupBox *frame;
|
||||||
QLabel *lbl;
|
QLabel *lbl;
|
||||||
//QActionGroup *group;
|
QActionGroup *group;
|
||||||
//QMenu *fileMenu, *viewMenu, *colorMenu, *optMenu, *subMenu;
|
QMenu *fileMenu, *viewMenu, *optMenu, *subMenu;
|
||||||
//QAction *act;
|
QAction *act;
|
||||||
//char stmp[64];
|
//char stmp[64];
|
||||||
int useNativeMenuBar;
|
int useNativeMenuBar;
|
||||||
|
|
||||||
|
@ -2551,6 +2551,57 @@ spriteViewerDialog_t::spriteViewerDialog_t(QWidget *parent)
|
||||||
|
|
||||||
menuBar->setNativeMenuBar( useNativeMenuBar ? true : false );
|
menuBar->setNativeMenuBar( useNativeMenuBar ? true : false );
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// Menu
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// File
|
||||||
|
fileMenu = menuBar->addMenu(tr("&File"));
|
||||||
|
|
||||||
|
// File -> Close
|
||||||
|
act = new QAction(tr("&Close"), this);
|
||||||
|
act->setShortcut(QKeySequence::Close);
|
||||||
|
act->setStatusTip(tr("Close Window"));
|
||||||
|
connect(act, SIGNAL(triggered()), this, SLOT(closeWindow(void)) );
|
||||||
|
|
||||||
|
fileMenu->addAction(act);
|
||||||
|
|
||||||
|
// View
|
||||||
|
viewMenu = menuBar->addMenu(tr("&View"));
|
||||||
|
|
||||||
|
// View -> Toggle Grid
|
||||||
|
act = new QAction(tr("Toggle &Grid"), this);
|
||||||
|
//act->setShortcut(QKeySequence::Close);
|
||||||
|
act->setStatusTip(tr("Toggle Grid"));
|
||||||
|
connect(act, SIGNAL(triggered()), this, SLOT(toggleGridVis(void)) );
|
||||||
|
|
||||||
|
viewMenu->addAction(act);
|
||||||
|
|
||||||
|
// Focus Policy
|
||||||
|
optMenu = menuBar->addMenu(tr("&Options"));
|
||||||
|
|
||||||
|
// Options -> Focus
|
||||||
|
subMenu = optMenu->addMenu(tr("&Focus Policy"));
|
||||||
|
group = new QActionGroup(this);
|
||||||
|
group->setExclusive(true);
|
||||||
|
|
||||||
|
act = new QAction(tr("&Click"), this);
|
||||||
|
act->setCheckable(true);
|
||||||
|
act->setChecked(true);
|
||||||
|
group->addAction(act);
|
||||||
|
subMenu->addAction(act);
|
||||||
|
connect(act, SIGNAL(triggered()), this, SLOT(setClickFocus(void)) );
|
||||||
|
|
||||||
|
act = new QAction(tr("&Hover"), this);
|
||||||
|
act->setCheckable(true);
|
||||||
|
act->setChecked(false);
|
||||||
|
group->addAction(act);
|
||||||
|
subMenu->addAction(act);
|
||||||
|
connect(act, SIGNAL(triggered()), this, SLOT(setHoverFocus(void)) );
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// End Menu
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
setWindowTitle( tr("Sprite Viewer") );
|
setWindowTitle( tr("Sprite Viewer") );
|
||||||
|
|
||||||
mainLayout = new QVBoxLayout();
|
mainLayout = new QVBoxLayout();
|
||||||
|
@ -2667,6 +2718,7 @@ spriteViewerDialog_t::spriteViewerDialog_t(QWidget *parent)
|
||||||
frame->setLayout( vbox );
|
frame->setLayout( vbox );
|
||||||
hbox1->addWidget( frame );
|
hbox1->addWidget( frame );
|
||||||
vbox->addWidget( preView );
|
vbox->addWidget( preView );
|
||||||
|
frame->hide(); // TODO Hide until preview code is ready
|
||||||
|
|
||||||
|
|
||||||
updateTimer = new QTimer( this );
|
updateTimer = new QTimer( this );
|
||||||
|
@ -2699,6 +2751,21 @@ void spriteViewerDialog_t::closeWindow(void)
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
void spriteViewerDialog_t::setClickFocus(void)
|
||||||
|
{
|
||||||
|
oamView->setHover2Focus(false);
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
|
void spriteViewerDialog_t::setHoverFocus(void)
|
||||||
|
{
|
||||||
|
oamView->setHover2Focus(true);
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
|
void spriteViewerDialog_t::toggleGridVis(void)
|
||||||
|
{
|
||||||
|
oamView->setGridVisibility( !oamView->getGridVisibility() );
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
void spriteViewerDialog_t::periodicUpdate(void)
|
void spriteViewerDialog_t::periodicUpdate(void)
|
||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
|
@ -2747,6 +2814,7 @@ oamPatternView_t::oamPatternView_t( QWidget *parent )
|
||||||
viewWidth = 256;
|
viewWidth = 256;
|
||||||
viewHeight = 512;
|
viewHeight = 512;
|
||||||
hover2Focus = false;
|
hover2Focus = false;
|
||||||
|
showGrid = false;
|
||||||
|
|
||||||
//selTileColor.setRgb(255,255,255);
|
//selTileColor.setRgb(255,255,255);
|
||||||
//gridColor.setRgb(128,128,128);
|
//gridColor.setRgb(128,128,128);
|
||||||
|
@ -2762,6 +2830,10 @@ oamPatternView_t::~oamPatternView_t(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
void oamPatternView_t::setHover2Focus(bool val){ hover2Focus = val; }
|
||||||
|
//----------------------------------------------------
|
||||||
|
void oamPatternView_t::setGridVisibility(bool val){ showGrid = val; }
|
||||||
|
//----------------------------------------------------
|
||||||
int oamPatternView_t::getSpriteIndex(void){ return spriteIdx; }
|
int oamPatternView_t::getSpriteIndex(void){ return spriteIdx; }
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
int oamPatternView_t::heightForWidth(int w) const
|
int oamPatternView_t::heightForWidth(int w) const
|
||||||
|
@ -2961,6 +3033,33 @@ void oamPatternView_t::paintEvent(QPaintEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( showGrid )
|
||||||
|
{
|
||||||
|
int tw, th;
|
||||||
|
pen.setWidth( 1 );
|
||||||
|
pen.setColor( QColor(128,128,128) );
|
||||||
|
painter.setPen( pen );
|
||||||
|
|
||||||
|
tw= 8*w;
|
||||||
|
th= 16*h;
|
||||||
|
|
||||||
|
xx = 0;
|
||||||
|
y = 8*th;
|
||||||
|
|
||||||
|
for (x=0; x<=8; x++)
|
||||||
|
{
|
||||||
|
painter.drawLine( xx, 0 , xx, y ); xx += tw;
|
||||||
|
}
|
||||||
|
|
||||||
|
yy = 0;
|
||||||
|
x = 8*tw;
|
||||||
|
|
||||||
|
for (y=0; y<=8; y++)
|
||||||
|
{
|
||||||
|
painter.drawLine( 0, yy , x, yy ); yy += th;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( (spriteIdx >= 0) && (spriteIdx < 64) )
|
if ( (spriteIdx >= 0) && (spriteIdx < 64) )
|
||||||
{
|
{
|
||||||
xx = (spriteIdx % 8) * (w*8);
|
xx = (spriteIdx % 8) * (w*8);
|
||||||
|
|
|
@ -326,6 +326,9 @@ class oamPatternView_t : public QWidget
|
||||||
QPoint convPixToTile( QPoint p );
|
QPoint convPixToTile( QPoint p );
|
||||||
|
|
||||||
int getSpriteIndex(void);
|
int getSpriteIndex(void);
|
||||||
|
void setHover2Focus(bool val);
|
||||||
|
void setGridVisibility(bool val);
|
||||||
|
bool getGridVisibility(void){ return showGrid; };
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
@ -339,6 +342,7 @@ class oamPatternView_t : public QWidget
|
||||||
int viewHeight;
|
int viewHeight;
|
||||||
|
|
||||||
bool hover2Focus;
|
bool hover2Focus;
|
||||||
|
bool showGrid;
|
||||||
|
|
||||||
QColor selSpriteBoxColor;
|
QColor selSpriteBoxColor;
|
||||||
QPoint selSprite;
|
QPoint selSprite;
|
||||||
|
@ -439,6 +443,9 @@ class spriteViewerDialog_t : public QDialog
|
||||||
void closeWindow(void);
|
void closeWindow(void);
|
||||||
private slots:
|
private slots:
|
||||||
void periodicUpdate(void);
|
void periodicUpdate(void);
|
||||||
|
void setClickFocus(void);
|
||||||
|
void setHoverFocus(void);
|
||||||
|
void toggleGridVis(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
int openPPUViewWindow( QWidget *parent );
|
int openPPUViewWindow( QWidget *parent );
|
||||||
|
|
Loading…
Reference in New Issue