diff --git a/src/drivers/Qt/ColorMenu.cpp b/src/drivers/Qt/ColorMenu.cpp index 1f0705ba..c91ebe5d 100644 --- a/src/drivers/Qt/ColorMenu.cpp +++ b/src/drivers/Qt/ColorMenu.cpp @@ -125,6 +125,7 @@ void ColorMenuItem::pickerClosed(int ret) g_config->save(); } + emit colorChanged( *colorPtr ); } //printf("Picker Closed: %i\n", ret ); } diff --git a/src/drivers/Qt/ColorMenu.h b/src/drivers/Qt/ColorMenu.h index 93b3522c..d26251c3 100644 --- a/src/drivers/Qt/ColorMenu.h +++ b/src/drivers/Qt/ColorMenu.h @@ -56,4 +56,7 @@ class ColorMenuItem : public QAction public slots: void openColorPicker(void); void pickerClosed(int ret); + + signals: + void colorChanged( QColor &c ); }; diff --git a/src/drivers/Qt/ConsoleViewerGL.cpp b/src/drivers/Qt/ConsoleViewerGL.cpp index 6ad42253..4347e322 100644 --- a/src/drivers/Qt/ConsoleViewerGL.cpp +++ b/src/drivers/Qt/ConsoleViewerGL.cpp @@ -41,6 +41,7 @@ #include "Qt/throttle.h" #include "Qt/fceuWrapper.h" #include "Qt/ConsoleViewerGL.h" +#include "Qt/ConsoleUtilities.h" extern unsigned int gui_draw_area_width; extern unsigned int gui_draw_area_height; @@ -70,6 +71,8 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent) textureType = GL_TEXTURE_2D; //textureType = GL_TEXTURE_RECTANGLE; + bgColor.setRgb( 0, 0, 0 ); + setMinimumWidth( 256 ); setMinimumHeight( 224 ); setFocusPolicy(Qt::StrongFocus); @@ -100,6 +103,8 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent) g_config->getOption("SDL.YScale", &yscale); g_config->getOption ("SDL.ForceAspect", &forceAspect); + + fceuLoadConfigColor( "SDL.VideoBgColor", &bgColor ); } connect( this, SIGNAL(frameSwapped(void)), this, SLOT(renderFinished(void)) ); @@ -363,6 +368,11 @@ void ConsoleViewGL_t::resizeGL(int w, int h) buildTextures(); } +void ConsoleViewGL_t::setBgColor( QColor &c ) +{ + bgColor = c; +} + void ConsoleViewGL_t::setLinearFilterEnable( bool ena ) { if ( linearFilter != ena ) @@ -598,7 +608,7 @@ void ConsoleViewGL_t::paintGL(void) glOrtho( 0.0, rw, 0.0, rh, -1.0, 1.0); glDisable(GL_DEPTH_TEST); - glClearColor( 0.0, 0.0f, 0.0f, 0.0f); // Background color to black. + glClearColor( bgColor.redF(), bgColor.greenF(), bgColor.blueF(), 1.0f); // Background color to config value. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); diff --git a/src/drivers/Qt/ConsoleViewerGL.h b/src/drivers/Qt/ConsoleViewerGL.h index 27764d7a..b8919af4 100644 --- a/src/drivers/Qt/ConsoleViewerGL.h +++ b/src/drivers/Qt/ConsoleViewerGL.h @@ -5,6 +5,7 @@ #include +#include #include #include #include @@ -38,6 +39,7 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions double getAspectRatio(void); void screenChanged(QScreen *scr); + void setBgColor( QColor &c ); protected: void initializeGL(void); @@ -74,6 +76,7 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions unsigned int textureType; unsigned int mouseButtonMask; + QColor bgColor; uint32_t *localBuf; uint32_t localBufSize; diff --git a/src/drivers/Qt/ConsoleViewerSDL.cpp b/src/drivers/Qt/ConsoleViewerSDL.cpp index 59d47126..236aec32 100644 --- a/src/drivers/Qt/ConsoleViewerSDL.cpp +++ b/src/drivers/Qt/ConsoleViewerSDL.cpp @@ -29,6 +29,7 @@ #include "Qt/throttle.h" #include "Qt/fceuWrapper.h" #include "Qt/ConsoleViewerSDL.h" +#include "Qt/ConsoleUtilities.h" extern unsigned int gui_draw_area_width; extern unsigned int gui_draw_area_height; @@ -42,6 +43,8 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent) setAutoFillBackground(true); setPalette(pal); + bgColor.setRgb( 0, 0, 0 ); + setMinimumWidth( 256 ); setMinimumHeight( 224 ); setFocusPolicy(Qt::StrongFocus); @@ -99,6 +102,8 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent) g_config->getOption("SDL.YScale", &yscale); g_config->getOption ("SDL.ForceAspect", &forceAspect); + + fceuLoadConfigColor( "SDL.VideoBgColor", &bgColor ); } } @@ -121,6 +126,11 @@ ConsoleViewSDL_t::~ConsoleViewSDL_t(void) } } +void ConsoleViewSDL_t::setBgColor( QColor &c ) +{ + bgColor = c; +} + void ConsoleViewSDL_t::setLinearFilterEnable( bool ena ) { if ( ena != linearFilter ) @@ -633,7 +643,7 @@ void ConsoleViewSDL_t::render(void) return; } - SDL_SetRenderDrawColor( sdlRenderer, 0, 0, 0, 0 ); + SDL_SetRenderDrawColor( sdlRenderer, bgColor.red(), bgColor.green(), bgColor.blue(), 255 ); SDL_RenderClear(sdlRenderer); diff --git a/src/drivers/Qt/ConsoleViewerSDL.h b/src/drivers/Qt/ConsoleViewerSDL.h index dbe8eceb..905e9a7c 100644 --- a/src/drivers/Qt/ConsoleViewerSDL.h +++ b/src/drivers/Qt/ConsoleViewerSDL.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include #include @@ -41,6 +42,7 @@ class ConsoleViewSDL_t : public QWidget void setCursor(const QCursor &c); void setCursor( Qt::CursorShape s ); + void setBgColor( QColor &c ); protected: //void paintEvent(QPaintEvent *event); @@ -69,6 +71,7 @@ class ConsoleViewSDL_t : public QWidget bool linearFilter; bool forceAspect; bool autoScaleEna; + QColor bgColor; uint32_t *localBuf; uint32_t localBufSize; diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index 55fa9fb6..3545168e 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -62,6 +62,7 @@ #include "Qt/main.h" #include "Qt/dface.h" #include "Qt/input.h" +#include "Qt/ColorMenu.h" #include "Qt/ConsoleWindow.h" #include "Qt/InputConf.h" #include "Qt/GamePadConf.h" @@ -868,6 +869,7 @@ void consoleWin_t::createMainMenu(void) QActionGroup *group; int useNativeMenuBar; int customAutofireOnFrames, customAutofireOffFrames; + ColorMenuItem *bgColorItem; //QShortcut *shortcut; menubar = new consoleMenuBar(this); @@ -1214,6 +1216,15 @@ void consoleWin_t::createMainMenu(void) Hotkeys[ HK_MAIN_MENU_HIDE ].setAction( act ); connect( Hotkeys[ HK_MAIN_MENU_HIDE ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleMenuVis(void)) ); + // Options -> Video BG Color + fceuLoadConfigColor( "SDL.VideoBgColor", &videoBgColor ); + + bgColorItem = new ColorMenuItem( tr("BG Side Panel Color"), "SDL.VideoBgColor", this ); + bgColorItem->connectColor( &videoBgColor ); + + optMenu->addAction(bgColorItem); + + connect( bgColorItem, SIGNAL(colorChanged(QColor&)), this, SLOT(videoBgColorChanged(QColor&)) ); //----------------------------------------------------------------------- // Emulation @@ -2069,6 +2080,22 @@ void consoleWin_t::closeApp(void) qApp->quit(); } //--------------------------------------------------------------------------- +void consoleWin_t::videoBgColorChanged( QColor &c ) +{ + //printf("Color Changed\n"); + + if ( viewport_GL ) + { + viewport_GL->setBgColor(c); + viewport_GL->update(); + } + else if ( viewport_SDL ) + { + viewport_SDL->setBgColor(c); + viewport_SDL->render(); + } +} +//--------------------------------------------------------------------------- int consoleWin_t::showListSelectDialog( const char *title, std::vector &l ) { if ( QThread::currentThread() == emulatorThread ) diff --git a/src/drivers/Qt/ConsoleWindow.h b/src/drivers/Qt/ConsoleWindow.h index be2e61da..225cdf81 100644 --- a/src/drivers/Qt/ConsoleWindow.h +++ b/src/drivers/Qt/ConsoleWindow.h @@ -22,6 +22,7 @@ #include #include #include +#include #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) #include #endif @@ -250,6 +251,7 @@ class consoleWin_t : public QMainWindow //QAction *aviMsgAct; QTimer *gameTimer; + QColor videoBgColor; std::string errorMsg; bool errorMsgValid; @@ -439,6 +441,7 @@ class consoleWin_t : public QMainWindow void winScreenChanged( QScreen *scr ); void winActiveChanged(void); void emuFrameFinish(void); + void videoBgColorChanged( QColor &c ); }; diff --git a/src/drivers/Qt/config.cpp b/src/drivers/Qt/config.cpp index 80bdac5b..403247bd 100644 --- a/src/drivers/Qt/config.cpp +++ b/src/drivers/Qt/config.cpp @@ -525,6 +525,7 @@ InitConfig() // video controls config->addOption('f', "fullscreen", "SDL.Fullscreen", 0); config->addOption("videoDriver", "SDL.VideoDriver", 0); + config->addOption("SDL.VideoBgColor", "#000000"); // set x/y res to 0 for automatic fullscreen resolution detection (no change) config->addOption('x', "xres", "SDL.XResolution", 0);