Added hex editor fore ground and back ground color options.

This commit is contained in:
Matthew Budd 2020-08-22 20:20:18 -04:00
parent 6a425f61d1
commit f3af7cc6c8
2 changed files with 85 additions and 10 deletions

View File

@ -10,6 +10,7 @@
#include <QScrollBar>
#include <QPainter>
#include <QMenuBar>
#include <QColorDialog>
#include "../../types.h"
#include "../../fceu.h"
@ -288,10 +289,10 @@ HexEditorDialog_t::HexEditorDialog_t(QWidget *parent)
//QVBoxLayout *mainLayout;
QGridLayout *grid;
QMenuBar *menuBar;
QMenu *fileMenu, *viewMenu, *hlgtMenu;
QMenu *fileMenu, *viewMenu, *colorMenu;
QAction *saveROM;
QAction *viewRAM, *viewPPU, *viewOAM, *viewROM;
QAction *actHlgt, *actHlgtRV;
QAction *actHlgt, *actHlgtRV, *actColorFG, *actColorBG;
QActionGroup *group;
setWindowTitle("Hex Editor");
@ -363,10 +364,10 @@ HexEditorDialog_t::HexEditorDialog_t(QWidget *parent)
viewRAM->setChecked(true); // Set default view
// Highlighting
hlgtMenu = menuBar->addMenu(tr("Highlight"));
// Color Menu
colorMenu = menuBar->addMenu(tr("Color"));
// Highlighting -> Highlight Activity
// Color -> Highlight Activity
actHlgt = new QAction(tr("Highlight Activity"), this);
//actHlgt->setShortcuts(QKeySequence::Open);
actHlgt->setStatusTip(tr("Highlight Activity"));
@ -374,17 +375,33 @@ HexEditorDialog_t::HexEditorDialog_t(QWidget *parent)
actHlgt->setChecked(true);
connect(actHlgt, SIGNAL(triggered(bool)), this, SLOT(actvHighlightCB(bool)) );
hlgtMenu->addAction(actHlgt);
colorMenu->addAction(actHlgt);
// Highlighting -> Highlight Reverse Video
// Color -> Highlight Reverse Video
actHlgtRV = new QAction(tr("Highlight Reverse Video"), this);
//actHlgtRV->setShortcuts(QKeySequence::Open);
actHlgtRV->setStatusTip(tr("Highlight Reverse Video"));
actHlgtRV->setCheckable(true);
actHlgtRV->setChecked(false);
actHlgtRV->setChecked(true);
connect(actHlgtRV, SIGNAL(triggered(bool)), this, SLOT(actvHighlightRVCB(bool)) );
hlgtMenu->addAction(actHlgtRV);
colorMenu->addAction(actHlgtRV);
// Color -> ForeGround Color
actColorFG = new QAction(tr("ForeGround Color"), this);
//actColorFG->setShortcuts(QKeySequence::Open);
actColorFG->setStatusTip(tr("ForeGround Color"));
connect(actColorFG, SIGNAL(triggered(void)), this, SLOT(pickForeGroundColor(void)) );
colorMenu->addAction(actColorFG);
// Color -> BackGround Color
actColorBG = new QAction(tr("BackGround Color"), this);
//actColorBG->setShortcuts(QKeySequence::Open);
actColorBG->setStatusTip(tr("BackGround Color"));
connect(actColorBG, SIGNAL(triggered(void)), this, SLOT(pickBackGroundColor(void)) );
colorMenu->addAction(actColorBG);
//-----------------------------------------------------------------------
// Menu End
@ -440,6 +457,36 @@ void HexEditorDialog_t::closeWindow(void)
done(0);
}
//----------------------------------------------------------------------------
void HexEditorDialog_t::pickForeGroundColor(void)
{
int ret;
QColorDialog dialog( this );
dialog.setOption( QColorDialog::DontUseNativeDialog, true );
dialog.show();
ret = dialog.exec();
if ( ret == QDialog::Accepted )
{
editor->setForeGroundColor( dialog.selectedColor() );
}
}
//----------------------------------------------------------------------------
void HexEditorDialog_t::pickBackGroundColor(void)
{
int ret;
QColorDialog dialog( this );
dialog.setOption( QColorDialog::DontUseNativeDialog, true );
dialog.show();
ret = dialog.exec();
if ( ret == QDialog::Accepted )
{
editor->setBackGroundColor( dialog.selectedColor() );
}
}
//----------------------------------------------------------------------------
void HexEditorDialog_t::vbarMoved(int value)
{
//printf("VBar Moved: %i\n", value);
@ -623,7 +670,7 @@ QHexEdit::QHexEdit(memBlock_t *blkPtr, QWidget *parent)
editAddr = -1;
editValue = 0;
editMask = 0;
reverseVideo = false;
reverseVideo = true;
actvHighlightEnable = true;
highLightColor[ 0].setRgb( 0x00, 0x00, 0x00 );
@ -704,6 +751,30 @@ void QHexEdit::setHighlightReverseVideo( int enable )
reverseVideo = enable;
}
//----------------------------------------------------------------------------
void QHexEdit::setForeGroundColor( QColor fg )
{
QPalette pal;
pal = this->palette();
//pal.setColor(QPalette::Base , Qt::black);
//pal.setColor(QPalette::Background, Qt::black);
pal.setColor(QPalette::WindowText, fg );
this->setPalette(pal);
}
//----------------------------------------------------------------------------
void QHexEdit::setBackGroundColor( QColor bg )
{
QPalette pal;
pal = this->palette();
//pal.setColor(QPalette::Base , Qt::black);
pal.setColor(QPalette::Background, bg );
//pal.setColor(QPalette::WindowText, fg );
this->setPalette(pal);
}
//----------------------------------------------------------------------------
void QHexEdit::setMode( int mode )
{
viewMode = mode;

View File

@ -55,6 +55,8 @@ class QHexEdit : public QWidget
void setScrollBars( QScrollBar *h, QScrollBar *v );
void setHighlightActivity( int enable );
void setHighlightReverseVideo( int enable );
void setForeGroundColor( QColor fg );
void setBackGroundColor( QColor bg );
static const int HIGHLIGHT_ACTIVITY_NUM_COLORS = 16;
protected:
@ -157,4 +159,6 @@ class HexEditorDialog_t : public QDialog
void setViewROM(void);
void actvHighlightCB(bool value);
void actvHighlightRVCB(bool value);
void pickForeGroundColor(void);
void pickBackGroundColor(void);
};