Added option to Qt GUI to allow for setting of the color of the video background side panel color (side panels on either side of video image in fullscreen or large windowed modes).

This commit is contained in:
mjbudd77 2021-09-28 21:52:43 -04:00
parent 2b9b2386d3
commit 8fe52cb400
9 changed files with 63 additions and 2 deletions

View File

@ -125,6 +125,7 @@ void ColorMenuItem::pickerClosed(int ret)
g_config->save(); g_config->save();
} }
emit colorChanged( *colorPtr );
} }
//printf("Picker Closed: %i\n", ret ); //printf("Picker Closed: %i\n", ret );
} }

View File

@ -56,4 +56,7 @@ class ColorMenuItem : public QAction
public slots: public slots:
void openColorPicker(void); void openColorPicker(void);
void pickerClosed(int ret); void pickerClosed(int ret);
signals:
void colorChanged( QColor &c );
}; };

View File

@ -41,6 +41,7 @@
#include "Qt/throttle.h" #include "Qt/throttle.h"
#include "Qt/fceuWrapper.h" #include "Qt/fceuWrapper.h"
#include "Qt/ConsoleViewerGL.h" #include "Qt/ConsoleViewerGL.h"
#include "Qt/ConsoleUtilities.h"
extern unsigned int gui_draw_area_width; extern unsigned int gui_draw_area_width;
extern unsigned int gui_draw_area_height; extern unsigned int gui_draw_area_height;
@ -70,6 +71,8 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent)
textureType = GL_TEXTURE_2D; textureType = GL_TEXTURE_2D;
//textureType = GL_TEXTURE_RECTANGLE; //textureType = GL_TEXTURE_RECTANGLE;
bgColor.setRgb( 0, 0, 0 );
setMinimumWidth( 256 ); setMinimumWidth( 256 );
setMinimumHeight( 224 ); setMinimumHeight( 224 );
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
@ -100,6 +103,8 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent)
g_config->getOption("SDL.YScale", &yscale); g_config->getOption("SDL.YScale", &yscale);
g_config->getOption ("SDL.ForceAspect", &forceAspect); g_config->getOption ("SDL.ForceAspect", &forceAspect);
fceuLoadConfigColor( "SDL.VideoBgColor", &bgColor );
} }
connect( this, SIGNAL(frameSwapped(void)), this, SLOT(renderFinished(void)) ); connect( this, SIGNAL(frameSwapped(void)), this, SLOT(renderFinished(void)) );
@ -363,6 +368,11 @@ void ConsoleViewGL_t::resizeGL(int w, int h)
buildTextures(); buildTextures();
} }
void ConsoleViewGL_t::setBgColor( QColor &c )
{
bgColor = c;
}
void ConsoleViewGL_t::setLinearFilterEnable( bool ena ) void ConsoleViewGL_t::setLinearFilterEnable( bool ena )
{ {
if ( linearFilter != ena ) if ( linearFilter != ena )
@ -598,7 +608,7 @@ void ConsoleViewGL_t::paintGL(void)
glOrtho( 0.0, rw, 0.0, rh, -1.0, 1.0); glOrtho( 0.0, rw, 0.0, rh, -1.0, 1.0);
glDisable(GL_DEPTH_TEST); 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); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

View File

@ -5,6 +5,7 @@
#include <stdint.h> #include <stdint.h>
#include <QColor>
#include <QScreen> #include <QScreen>
#include <QOpenGLWidget> #include <QOpenGLWidget>
#include <QOpenGLFunctions> #include <QOpenGLFunctions>
@ -38,6 +39,7 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions
double getAspectRatio(void); double getAspectRatio(void);
void screenChanged(QScreen *scr); void screenChanged(QScreen *scr);
void setBgColor( QColor &c );
protected: protected:
void initializeGL(void); void initializeGL(void);
@ -74,6 +76,7 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions
unsigned int textureType; unsigned int textureType;
unsigned int mouseButtonMask; unsigned int mouseButtonMask;
QColor bgColor;
uint32_t *localBuf; uint32_t *localBuf;
uint32_t localBufSize; uint32_t localBufSize;

View File

@ -29,6 +29,7 @@
#include "Qt/throttle.h" #include "Qt/throttle.h"
#include "Qt/fceuWrapper.h" #include "Qt/fceuWrapper.h"
#include "Qt/ConsoleViewerSDL.h" #include "Qt/ConsoleViewerSDL.h"
#include "Qt/ConsoleUtilities.h"
extern unsigned int gui_draw_area_width; extern unsigned int gui_draw_area_width;
extern unsigned int gui_draw_area_height; extern unsigned int gui_draw_area_height;
@ -42,6 +43,8 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent)
setAutoFillBackground(true); setAutoFillBackground(true);
setPalette(pal); setPalette(pal);
bgColor.setRgb( 0, 0, 0 );
setMinimumWidth( 256 ); setMinimumWidth( 256 );
setMinimumHeight( 224 ); setMinimumHeight( 224 );
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
@ -99,6 +102,8 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent)
g_config->getOption("SDL.YScale", &yscale); g_config->getOption("SDL.YScale", &yscale);
g_config->getOption ("SDL.ForceAspect", &forceAspect); 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 ) void ConsoleViewSDL_t::setLinearFilterEnable( bool ena )
{ {
if ( ena != linearFilter ) if ( ena != linearFilter )
@ -633,7 +643,7 @@ void ConsoleViewSDL_t::render(void)
return; return;
} }
SDL_SetRenderDrawColor( sdlRenderer, 0, 0, 0, 0 ); SDL_SetRenderDrawColor( sdlRenderer, bgColor.red(), bgColor.green(), bgColor.blue(), 255 );
SDL_RenderClear(sdlRenderer); SDL_RenderClear(sdlRenderer);

View File

@ -4,6 +4,7 @@
#pragma once #pragma once
#include <QWidget> #include <QWidget>
#include <QColor>
#include <QCursor> #include <QCursor>
#include <QPaintEvent> #include <QPaintEvent>
#include <QResizeEvent> #include <QResizeEvent>
@ -41,6 +42,7 @@ class ConsoleViewSDL_t : public QWidget
void setCursor(const QCursor &c); void setCursor(const QCursor &c);
void setCursor( Qt::CursorShape s ); void setCursor( Qt::CursorShape s );
void setBgColor( QColor &c );
protected: protected:
//void paintEvent(QPaintEvent *event); //void paintEvent(QPaintEvent *event);
@ -69,6 +71,7 @@ class ConsoleViewSDL_t : public QWidget
bool linearFilter; bool linearFilter;
bool forceAspect; bool forceAspect;
bool autoScaleEna; bool autoScaleEna;
QColor bgColor;
uint32_t *localBuf; uint32_t *localBuf;
uint32_t localBufSize; uint32_t localBufSize;

View File

@ -62,6 +62,7 @@
#include "Qt/main.h" #include "Qt/main.h"
#include "Qt/dface.h" #include "Qt/dface.h"
#include "Qt/input.h" #include "Qt/input.h"
#include "Qt/ColorMenu.h"
#include "Qt/ConsoleWindow.h" #include "Qt/ConsoleWindow.h"
#include "Qt/InputConf.h" #include "Qt/InputConf.h"
#include "Qt/GamePadConf.h" #include "Qt/GamePadConf.h"
@ -868,6 +869,7 @@ void consoleWin_t::createMainMenu(void)
QActionGroup *group; QActionGroup *group;
int useNativeMenuBar; int useNativeMenuBar;
int customAutofireOnFrames, customAutofireOffFrames; int customAutofireOnFrames, customAutofireOffFrames;
ColorMenuItem *bgColorItem;
//QShortcut *shortcut; //QShortcut *shortcut;
menubar = new consoleMenuBar(this); menubar = new consoleMenuBar(this);
@ -1214,6 +1216,15 @@ void consoleWin_t::createMainMenu(void)
Hotkeys[ HK_MAIN_MENU_HIDE ].setAction( act ); Hotkeys[ HK_MAIN_MENU_HIDE ].setAction( act );
connect( Hotkeys[ HK_MAIN_MENU_HIDE ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleMenuVis(void)) ); 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 // Emulation
@ -2069,6 +2080,22 @@ void consoleWin_t::closeApp(void)
qApp->quit(); 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 <std::string> &l ) int consoleWin_t::showListSelectDialog( const char *title, std::vector <std::string> &l )
{ {
if ( QThread::currentThread() == emulatorThread ) if ( QThread::currentThread() == emulatorThread )

View File

@ -22,6 +22,7 @@
#include <QThread> #include <QThread>
#include <QCursor> #include <QCursor>
#include <QMutex> #include <QMutex>
#include <QColor>
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
#include <QRecursiveMutex> #include <QRecursiveMutex>
#endif #endif
@ -250,6 +251,7 @@ class consoleWin_t : public QMainWindow
//QAction *aviMsgAct; //QAction *aviMsgAct;
QTimer *gameTimer; QTimer *gameTimer;
QColor videoBgColor;
std::string errorMsg; std::string errorMsg;
bool errorMsgValid; bool errorMsgValid;
@ -439,6 +441,7 @@ class consoleWin_t : public QMainWindow
void winScreenChanged( QScreen *scr ); void winScreenChanged( QScreen *scr );
void winActiveChanged(void); void winActiveChanged(void);
void emuFrameFinish(void); void emuFrameFinish(void);
void videoBgColorChanged( QColor &c );
}; };

View File

@ -525,6 +525,7 @@ InitConfig()
// video controls // video controls
config->addOption('f', "fullscreen", "SDL.Fullscreen", 0); config->addOption('f', "fullscreen", "SDL.Fullscreen", 0);
config->addOption("videoDriver", "SDL.VideoDriver", 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) // set x/y res to 0 for automatic fullscreen resolution detection (no change)
config->addOption('x', "xres", "SDL.XResolution", 0); config->addOption('x', "xres", "SDL.XResolution", 0);