Added window resize presets to Qt main menu.
This commit is contained in:
parent
443752b7b8
commit
1d15fc49c3
|
@ -1155,6 +1155,22 @@ void consoleWin_t::createMainMenu(void)
|
||||||
|
|
||||||
optMenu->addSeparator();
|
optMenu->addSeparator();
|
||||||
|
|
||||||
|
// Options -> Window Resize
|
||||||
|
subMenu = optMenu->addMenu( tr("Window Resi&ze") );
|
||||||
|
|
||||||
|
for (int i=0; i<4; i++)
|
||||||
|
{
|
||||||
|
char stmp[8];
|
||||||
|
|
||||||
|
sprintf( stmp, "&%ix", i+1 );
|
||||||
|
|
||||||
|
winSizeAct[i] = new QAction(tr(stmp), this);
|
||||||
|
|
||||||
|
subMenu->addAction(winSizeAct[i]);
|
||||||
|
|
||||||
|
connect( winSizeAct[i], &QAction::triggered, [ this, i ]{ consoleWin_t::winResizeIx(i+1); } );
|
||||||
|
}
|
||||||
|
|
||||||
// Options -> Full Screen
|
// Options -> Full Screen
|
||||||
fullscreen = new QAction(tr("&Fullscreen"), this);
|
fullscreen = new QAction(tr("&Fullscreen"), this);
|
||||||
//fullscreen->setShortcut( QKeySequence(tr("Alt+Return")));
|
//fullscreen->setShortcut( QKeySequence(tr("Alt+Return")));
|
||||||
|
@ -2883,6 +2899,70 @@ void consoleWin_t::toggleAutoResume(void)
|
||||||
AutoResumePlay = autoResume->isChecked();
|
AutoResumePlay = autoResume->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void consoleWin_t::winResizeIx(int iscale)
|
||||||
|
{
|
||||||
|
QSize w, v;
|
||||||
|
double xscale = 1.0, yscale = 1.0, aspectRatio = 1.0;
|
||||||
|
int texture_width = nes_shm->video.ncol;
|
||||||
|
int texture_height = nes_shm->video.nrow;
|
||||||
|
int l=0, r=texture_width;
|
||||||
|
int t=0, b=texture_height;
|
||||||
|
int dw=0, dh=0, rw, rh;
|
||||||
|
bool forceAspect = false;
|
||||||
|
|
||||||
|
xscale = (double)iscale;
|
||||||
|
yscale = (double)iscale;
|
||||||
|
|
||||||
|
w = size();
|
||||||
|
|
||||||
|
if ( viewport_GL )
|
||||||
|
{
|
||||||
|
v = viewport_GL->size();
|
||||||
|
aspectRatio = viewport_GL->getAspectRatio();
|
||||||
|
forceAspect = viewport_GL->getForceAspectOpt();
|
||||||
|
}
|
||||||
|
else if ( viewport_SDL )
|
||||||
|
{
|
||||||
|
v = viewport_SDL->size();
|
||||||
|
aspectRatio = viewport_SDL->getAspectRatio();
|
||||||
|
forceAspect = viewport_SDL->getForceAspectOpt();
|
||||||
|
}
|
||||||
|
|
||||||
|
dw = w.width() - v.width();
|
||||||
|
dh = w.height() - v.height();
|
||||||
|
|
||||||
|
if ( forceAspect )
|
||||||
|
{
|
||||||
|
xscale = xscale / nes_shm->video.xscale;
|
||||||
|
yscale = xscale * (double)nes_shm->video.xyRatio;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xscale = xscale / nes_shm->video.xscale;
|
||||||
|
yscale = yscale / nes_shm->video.yscale;
|
||||||
|
}
|
||||||
|
rw=(int)((r-l)*xscale);
|
||||||
|
rh=(int)((b-t)*yscale);
|
||||||
|
|
||||||
|
if ( forceAspect )
|
||||||
|
{
|
||||||
|
double rr;
|
||||||
|
|
||||||
|
rr = (double)rh / (double)rw;
|
||||||
|
|
||||||
|
if ( rr > aspectRatio )
|
||||||
|
{
|
||||||
|
rw = (int)( (((double)rh) / aspectRatio) + 0.50);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rh = (int)( (((double)rw) * aspectRatio) + 0.50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resize( rw + dw, rh + dh );
|
||||||
|
}
|
||||||
|
|
||||||
void consoleWin_t::toggleFullscreen(void)
|
void consoleWin_t::toggleFullscreen(void)
|
||||||
{
|
{
|
||||||
if ( isFullScreen() )
|
if ( isFullScreen() )
|
||||||
|
|
|
@ -203,6 +203,7 @@ class consoleWin_t : public QMainWindow
|
||||||
QAction *timingConfig;
|
QAction *timingConfig;
|
||||||
QAction *movieConfig;
|
QAction *movieConfig;
|
||||||
QAction *autoResume;
|
QAction *autoResume;
|
||||||
|
QAction *winSizeAct[4];
|
||||||
QAction *fullscreen;
|
QAction *fullscreen;
|
||||||
QAction *aboutAct;
|
QAction *aboutAct;
|
||||||
QAction *aboutActQt;
|
QAction *aboutActQt;
|
||||||
|
@ -296,6 +297,7 @@ class consoleWin_t : public QMainWindow
|
||||||
void toggleFullscreen(void);
|
void toggleFullscreen(void);
|
||||||
void toggleMenuVis(void);
|
void toggleMenuVis(void);
|
||||||
void recordMovie(void);
|
void recordMovie(void);
|
||||||
|
void winResizeIx(int iScale);
|
||||||
private slots:
|
private slots:
|
||||||
void closeApp(void);
|
void closeApp(void);
|
||||||
void openROMFile(void);
|
void openROMFile(void);
|
||||||
|
|
Loading…
Reference in New Issue