]> Shamusworld >> Repos - virtualjaguar/commitdiff
Added preliminary full screen support.
authorShamus Hammons <jlhamm@acm.org>
Thu, 16 Aug 2012 05:01:31 +0000 (00:01 -0500)
committerShamus Hammons <jlhamm@acm.org>
Thu, 16 Aug 2012 05:01:31 +0000 (00:01 -0500)
src/gui/configdialog.cpp
src/gui/generaltab.cpp
src/gui/generaltab.h
src/gui/mainwin.cpp
src/gui/mainwin.h

index ac22898d24b244a96444d981170925af254e1165..e84cf232c93ae45d3a67a89c96b7321f623c4a48 100644 (file)
@@ -70,6 +70,7 @@ void ConfigDialog::LoadDialogFromSettings(void)
        generalTab->useBIOS->setChecked(vjs.useJaguarBIOS);
        generalTab->useGPU->setChecked(vjs.GPUEnabled);
        generalTab->useDSP->setChecked(vjs.DSPEnabled);
+       generalTab->useFullScreen->setChecked(vjs.fullscreen);
 //     generalTab->useHostAudio->setChecked(vjs.audioEnabled);
 
        if (vjs.hardwareTypeAlpine)
@@ -98,6 +99,7 @@ void ConfigDialog::UpdateVJSettings(void)
        vjs.useJaguarBIOS = generalTab->useBIOS->isChecked();
        vjs.GPUEnabled    = generalTab->useGPU->isChecked();
        vjs.DSPEnabled    = generalTab->useDSP->isChecked();
+       vjs.fullscreen    = generalTab->useFullScreen->isChecked();
 //     vjs.audioEnabled  = generalTab->useHostAudio->isChecked();
 
        if (vjs.hardwareTypeAlpine)
index 050cfff4290e2c04918479ac313af5250574fa4c..d3b3cf295b183f0355421686c0a36f56a80baa3c 100644 (file)
@@ -56,12 +56,14 @@ GeneralTab::GeneralTab(QWidget * parent/*= 0*/): QWidget(parent)
        useBIOS            = new QCheckBox(tr("Enable Jaguar BIOS"));
        useGPU             = new QCheckBox(tr("Enable GPU"));
        useDSP             = new QCheckBox(tr("Enable DSP"));
+       useFullScreen      = new QCheckBox(tr("Start Virtual Jaguar in full screen"));
 //     useHostAudio       = new QCheckBox(tr("Enable audio playback (requires DSP)"));
        useUnknownSoftware = new QCheckBox(tr("Show all files in file chooser"));
 
        layout4->addWidget(useBIOS);
        layout4->addWidget(useGPU);
        layout4->addWidget(useDSP);
+       layout4->addWidget(useFullScreen);
 //     layout4->addWidget(useHostAudio);
        layout4->addWidget(useUnknownSoftware);
 
index d1338ab4ad08e7d9e23264f8f333d4f3a71adf5f..5696dfab1c0bbd4eb4cd7e7ab9df06a7856b61d8 100644 (file)
@@ -20,7 +20,8 @@ class GeneralTab: public QWidget
                QCheckBox * useBIOS;
                QCheckBox * useGPU;
                QCheckBox * useDSP;
-               QCheckBox * useHostAudio;
+//             QCheckBox * useHostAudio;
+               QCheckBox * useFullScreen;
                QCheckBox * useUnknownSoftware;
 };
 
index ac017ceb4b5e87c5ea573a542e45b2bbb7e5bf1f..56c57473b51b8d8b1685a0913aee38a8088b05d4 100644 (file)
@@ -201,6 +201,10 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
        frameAdvanceAct->setShortcut(QKeySequence(tr("F7")));
        connect(frameAdvanceAct, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
 
+       fullScreenAct = new QAction(QIcon(":/res/generic.png"), tr("F&ull Screen"), this);
+       fullScreenAct->setShortcut(QKeySequence(tr("F9")));
+       connect(fullScreenAct, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
+
        // Debugger Actions
        memBrowseAct = new QAction(QIcon(":/res/generic.png"), tr("Memory Browser"), this);
        memBrowseAct->setStatusTip(tr("Shows the Jaguar memory browser window"));
@@ -252,6 +256,7 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
        toolbar->addAction(palAct);
        toolbar->addSeparator();
        toolbar->addAction(blurAct);
+       toolbar->addAction(fullScreenAct);
 
        if (vjs.hardwareTypeAlpine)
        {
@@ -338,6 +343,7 @@ void MainWin::LoadFile(QString file)
 void MainWin::SyncUI(void)
 {
        // Set toolbar buttons/menus based on settings read in (sync the UI)...
+       // (Really, this is to sync command line options passed in)
        blurAct->setChecked(vjs.glFilter);
        x1Act->setChecked(zoomLevel == 1);
        x2Act->setChecked(zoomLevel == 2);
@@ -346,6 +352,9 @@ void MainWin::SyncUI(void)
        ntscAct->setChecked(vjs.hardwareTypeNTSC);
        palAct->setChecked(!vjs.hardwareTypeNTSC);
        powerAct->setIcon(vjs.hardwareTypeNTSC ? powerRed : powerGreen);
+
+       fullScreen = vjs.fullscreen;
+       SetFullScreen(fullScreen);
 }
 
 
@@ -367,7 +376,13 @@ void MainWin::keyPressEvent(QKeyEvent * e)
                e->accept();
                return;
        }
-
+/*
+       if (e->key() == Qt::Key_F9)
+       {
+               ToggleFullScreen();
+               return;
+       }
+*/
        HandleKeys(e, true);
 }
 
@@ -788,6 +803,44 @@ void MainWin::FrameAdvance(void)
 }
 
 
+void MainWin::SetFullScreen(bool state/*= true*/)
+{
+       if (state)
+       {
+               menuBar()->hide();
+               statusBar()->hide();
+               showFullScreen();
+               QRect r = QApplication::desktop()->availableGeometry();
+               double targetWidth = 320.0, targetHeight = (vjs.hardwareTypeNTSC ? 240.0 : 256.0);
+               double aspectRatio = targetWidth / targetHeight;
+               // NOTE: Really should check here to see which dimension constrains the other.
+               //       Right now, we assume that height is the constraint.
+               int newWidth = (int)(aspectRatio * (double)r.height());
+
+               videoWidget->setFixedSize(newWidth, r.height());
+               showFullScreen();
+       }
+       else
+       {
+               menuBar()->show();
+               statusBar()->show();
+               showNormal();
+               ResizeMainWindow();
+       }
+
+       // For some reason, this doesn't work: If the emu is paused, toggling from
+       // fullscreen to windowed (& vice versa) shows a white screen.
+//     videoWidget->updateGL();
+}
+
+
+void MainWin::ToggleFullScreen(void)
+{
+       fullScreen = !fullScreen;
+       SetFullScreen(fullScreen);
+}
+
+
 void MainWin::ShowMemoryBrowserWin(void)
 {
        memBrowseWin->show();
index a5d0f764928f2844e25fc196faa656715d16f9d8..8d51e190ffa68d9b1ce9b3ee5f5c8d3cae2a9f56 100644 (file)
@@ -54,12 +54,14 @@ class MainWin: public QMainWindow
                void LoadSoftware(QString);
                void ToggleCDUsage(void);
                void FrameAdvance(void);
+               void ToggleFullScreen(void);
 
                void ShowMemoryBrowserWin(void);
                void ShowCPUBrowserWin(void);
 
        private:
                void HandleKeys(QKeyEvent *, bool);
+               void SetFullScreen(bool state = true);
                void ResizeMainWindow(void);
                void ReadSettings(void);
                void WriteSettings(void);
@@ -84,6 +86,7 @@ class MainWin: public QMainWindow
                bool pauseForFileSelector;
                bool loadAndGo;
                bool keyHeld[8];
+               bool fullScreen;
        public:
                bool plzDontKillMyComputer;
        private:
@@ -111,6 +114,7 @@ class MainWin: public QMainWindow
                QAction * configAct;
                QAction * useCDAct;
                QAction * frameAdvanceAct;
+               QAction * fullScreenAct;
 
                QAction * memBrowseAct;
                QAction * cpuBrowseAct;