diff --git a/src/PaletteDialog.cpp b/src/PaletteDialog.cpp deleted file mode 100644 index 014c6b15..00000000 --- a/src/PaletteDialog.cpp +++ /dev/null @@ -1,172 +0,0 @@ -#include -#include -#include -#include -#include "PaletteDialog.h" -#include "PalettePatch.h" -#include "Convert.h" -#include "ranges.h" - - -PaletteDialog::PaletteDialog(QWidget* parent) - : QDialog(parent), ui(std::make_unique()) -{ - ui->setupUi(this); - connect(ui->horizontalSlider_R, &QSlider::valueChanged, this, &PaletteDialog::on_horizontalSlider_R_valueChanged); - connect(ui->horizontalSlider_G, &QSlider::valueChanged, this, &PaletteDialog::on_horizontalSlider_G_valueChanged); - connect(ui->horizontalSlider_B, &QSlider::valueChanged, this, &PaletteDialog::on_horizontalSlider_B_valueChanged); - connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &PaletteDialog::on_buttonBox_clicked); - connect(ui->cb_autosync, &QCheckBox::stateChanged, this, &PaletteDialog::on_cb_autosync_stateChanged); - - const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); - ui->plainTextEdit->setFont(fixedFont); - - setWindowTitle("Palette editor"); - ranges::fill(myPal, 0); - ranges::fill(myOriginalPal, 0); - // add colors to colorframe - - signalMapper = new QSignalMapper(this); - auto* gridLayout = new QGridLayout; - gridLayout->setSpacing(0); - for (int i = 0; i < 16; ++i) { - auto* button = new PalettePatch(nullptr, i); - connect(button, &PalettePatch::clicked, signalMapper, qOverload<>(&QSignalMapper::map)); - signalMapper->setMapping(button, i); - gridLayout->addWidget(button, i / 8, i % 8); - connect(this, &PaletteDialog::paletteChanged, - button, &PalettePatch::updatePaletteChanged); - connect(signalMapper, &QSignalMapper::mappedInt, - button, &PalettePatch::setHighlightTest); - } - - connect(signalMapper, &QSignalMapper::mappedInt, - this, &PaletteDialog::colorSelected); - - ui->colorsframe->setLayout(gridLayout); - connect(this, &PaletteDialog::paletteChanged, - this, &PaletteDialog::updateText); -} - -void PaletteDialog::updateText() -{ - ui->plainTextEdit->clear(); - for (int i = 0; i < 4; ++i) { - QString txt(" db "); - for (int j = 0; j < 4; ++j) { - txt.append(QString("%1,%2 ") - .arg(hexValue(myPal[2 * (j + 4 * i) + 0], 2)) - .arg(hexValue(myPal[2 * (j + 4 * i) + 1], 2))); - if (j < 3) txt.append(','); - } - ui->plainTextEdit->appendPlainText(txt); - } -} - -void PaletteDialog::restoreOpeningsPalette() -{ - memcpy(myPal, myOriginalPal, sizeof(myPal)); - emit paletteChanged(myPal); // Resets the PalettePatches - colorSelected(currentColor); // Resets the sliders - if (autoSync) { - syncToSource(); - } -} - -void PaletteDialog::colorSelected(int colorNumber) -{ - currentColor = colorNumber; - int r = (myPal[2 * currentColor + 0] & 0x70) >> 4; - int b = (myPal[2 * currentColor + 0] & 0x07); - int g = (myPal[2 * currentColor + 1] & 0x07); - ui->horizontalSlider_R->setValue(r); - ui->horizontalSlider_G->setValue(g); - ui->horizontalSlider_B->setValue(b); - ui->label_colornr->setText(QString("Color %1").arg(colorNumber)); -} - -void PaletteDialog::setPalette(uint8_t* pal) -{ - sourcePal = pal; - memcpy(myOriginalPal, pal, sizeof(myOriginalPal)); - memcpy(myPal, pal, sizeof(myPal)); - emit paletteChanged(myPal); -} - -//void PaletteDialog::decodepalette() -//{ -// for (int i = 0; i < 16; ++i) { -// int r = (myPal[2 * i + 0] & 0xf0) >> 4; -// int b = (myPal[2 * i + 0] & 0x0f); -// int g = (myPal[2 * i + 1] & 0x0f); -// -// auto scale = [](int x) { return (x >> 1) | (x << 2) | (x << 5); }; -// msxPalette[i] = qRgb(scale(r), scale(g), scale(b)); -// -// QGridLayout* l = dynamic_cast(ui->colorsframe->layout()); -// dynamic_cast(l->itemAtPosition(i % 8, i / 8)->widget())->setText(QString("%1(%2%3%4)").arg(i).arg(r).arg(g).arg(b)); -// } -//} - -void PaletteDialog::combineRGB() -{ - int r = ui->horizontalSlider_R->value(); - int g = ui->horizontalSlider_G->value(); - int b = ui->horizontalSlider_B->value(); - myPal[2 * currentColor + 0] = 16 * r + b; - myPal[2 * currentColor + 1] = g; - emit paletteChanged(myPal); - if (autoSync) { - syncToSource(); - } -} - -void PaletteDialog::syncToSource() -{ - memcpy(sourcePal, myPal, sizeof(myPal)); - emit paletteSynced(); -} - -void PaletteDialog::setAutoSync(bool value) -{ - if (autoSync == value) return; - autoSync = value; - ui->cb_autosync->setChecked(value); -} - -void PaletteDialog::on_horizontalSlider_R_valueChanged(int value) -{ - ui->label_R->setText(QString("R=%1").arg(value)); - combineRGB(); -} - -void PaletteDialog::on_horizontalSlider_G_valueChanged(int value) -{ - ui->label_G->setText(QString("G=%1").arg(value)); - combineRGB(); -} - -void PaletteDialog::on_horizontalSlider_B_valueChanged(int value) -{ - ui->label_B->setText(QString("B=%1").arg(value)); - combineRGB(); -} - -void PaletteDialog::on_buttonBox_clicked(QAbstractButton* button) -{ - if (button== ui->buttonBox->button(QDialogButtonBox::Apply) || - button== ui->buttonBox->button(QDialogButtonBox::Ok)) { - syncToSource(); - } else if (button== ui->buttonBox->button(QDialogButtonBox::Reset) || - button== ui->buttonBox->button(QDialogButtonBox::Cancel)) { - restoreOpeningsPalette(); - } -} - -void PaletteDialog::on_cb_autosync_stateChanged(int arg1) -{ - autoSync = arg1 != Qt::Unchecked; - if (autoSync) { - syncToSource(); - } -} diff --git a/src/PaletteDialog.h b/src/PaletteDialog.h deleted file mode 100644 index 1a2bc33c..00000000 --- a/src/PaletteDialog.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef PALETTEDIALOG_H -#define PALETTEDIALOG_H - -#include "ui_PaletteDialog.h" -#include -#include -#include -#include -#include - -namespace Ui { - class PaletteDialog; -} - -class PaletteDialog : public QDialog -{ - Q_OBJECT -public: - explicit PaletteDialog(QWidget* parent = nullptr); - - void setPalette(uint8_t* pal); - void syncToSource(); - void setAutoSync(bool value); - -signals: - void paletteChanged(const uint8_t* pal); - void paletteSynced(); - -private: - void colorSelected(int colorNumber); - void on_horizontalSlider_R_valueChanged(int value); - void on_horizontalSlider_G_valueChanged(int value); - void on_horizontalSlider_B_valueChanged(int value); - void restoreOpeningsPalette(); - - void on_buttonBox_clicked(QAbstractButton* button); - - void on_cb_autosync_stateChanged(int arg1); - - void updateText(); - - void combineRGB(); - //void decodepalette(); - -private: - std::unique_ptr ui; - QSignalMapper* signalMapper; - - uint8_t* sourcePal = nullptr; - uint8_t myPal[32]; - uint8_t myOriginalPal[32]; - - int currentColor = 0; - QRgb msxPalette[16]; - - bool autoSync = false; -}; - -#endif // PALETTEDIALOG_H diff --git a/src/PaletteDialog.ui b/src/PaletteDialog.ui deleted file mode 100644 index 538acd53..00000000 --- a/src/PaletteDialog.ui +++ /dev/null @@ -1,185 +0,0 @@ - - - PaletteDialog - - - - 0 - 0 - 513 - 271 - - - - Dialog - - - - - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - - - - - - - B=0 - - - - - - - G=0 - - - - - - - 7 - - - 1 - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - - - - - R=0 - - - - - - - 7 - - - 1 - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - - - - - 7 - - - 1 - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - - - - - Color 0 - - - - - - - - - - - - 0 - 0 - - - - - 16777215 - 100 - - - - - - - - - - Autosync - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset - - - - - - - - - - - buttonBox - accepted() - PaletteDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - PaletteDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/PalettePatch.cpp b/src/PalettePatch.cpp index d537a592..03e4d29e 100644 --- a/src/PalettePatch.cpp +++ b/src/PalettePatch.cpp @@ -18,20 +18,6 @@ void PalettePatch::setMSXPalette(MSXPalette* pal) paletteChanged(); } -//old method for PaletteDialog -void PalettePatch::updatePaletteChanged(const uint8_t* pal) -{ - int r = (pal[2 * msxPalNr + 0] & 0x70) >> 4; - int b = (pal[2 * msxPalNr + 0] & 0x07); - int g = (pal[2 * msxPalNr + 1] & 0x07); - auto scale = [](int x) { return (x >> 1) | (x << 2) | (x << 5); }; - myColor = qRgb(scale(r), scale(g), scale(b)); - //setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); - update(); - //printf("PalettePatch::updatePaletteChanged %i\n", msxPalNr); -} - -//new method for PaletteView void PalettePatch::paletteChanged() { myColor = myPal->color(msxPalNr); diff --git a/src/PalettePatch.h b/src/PalettePatch.h index 73373399..07e4c491 100644 --- a/src/PalettePatch.h +++ b/src/PalettePatch.h @@ -14,7 +14,6 @@ class PalettePatch : public QPushButton public slots: void setMSXPalette(MSXPalette* pal); - void updatePaletteChanged(const uint8_t* pal); void setHighlightTest(int colorNr); void paletteChanged(); diff --git a/src/SpriteViewer.cpp b/src/SpriteViewer.cpp index a96d9135..ed3393d2 100644 --- a/src/SpriteViewer.cpp +++ b/src/SpriteViewer.cpp @@ -1,31 +1,9 @@ #include "SpriteViewer.h" #include "VDPDataStore.h" #include "VramSpriteView.h" -//#include "PaletteDialog.h" #include "Convert.h" #include "MSXPalette.h" -// static to feed to PaletteDialog and be used when VDP colors aren't selected -uint8_t SpriteViewer::defaultPalette[32] = { -// RB G - 0x00, 0, - 0x00, 0, - 0x11, 6, - 0x33, 7, - 0x17, 1, - 0x27, 3, - 0x51, 1, - 0x27, 6, - 0x71, 1, - 0x73, 3, - 0x61, 6, - 0x64, 6, - 0x11, 4, - 0x65, 2, - 0x55, 5, - 0x77, 7, -}; - SpriteViewer::SpriteViewer(QWidget* parent) : QDialog(parent) , ui(std::make_unique()) diff --git a/src/TileViewer.cpp b/src/TileViewer.cpp index b2df24a2..126ac883 100644 --- a/src/TileViewer.cpp +++ b/src/TileViewer.cpp @@ -2,13 +2,9 @@ #include "ui_TileViewer.h" #include "VramTiledView.h" #include "VDPDataStore.h" -#include "PaletteDialog.h" #include "Convert.h" #include - - - TileViewer::TileViewer(QWidget* parent) : QDialog(parent), image4label(32, 32, QImage::Format_RGB32) { diff --git a/src/node.mk b/src/node.mk index 0650e56c..b71ae2b4 100644 --- a/src/node.mk +++ b/src/node.mk @@ -10,7 +10,7 @@ MOC_SRC_HDR:= \ DebugSession MainMemoryViewer BitMapViewer VramBitMappedView \ VDPDataStore VDPStatusRegViewer VDPRegViewer InteractiveLabel \ InteractiveButton VDPCommandRegViewer GotoDialog SymbolTable \ - TileViewer VramTiledView PaletteDialog VramSpriteView SpriteViewer \ + TileViewer VramTiledView VramSpriteView SpriteViewer \ BreakpointViewer SignalDispatcher \ blendsplitter/BlendSplitter blendsplitter/Expander \ blendsplitter/Overlay blendsplitter/SplitterDecorator \ @@ -33,7 +33,7 @@ SRC_ONLY:= \ UI:= \ ConnectDialog SymbolManager PreferencesDialog BreakpointDialog \ BitMapViewer VDPStatusRegisters VDPRegistersExplained VDPCommandRegisters \ - GotoDialog TileViewer PaletteDialog SpriteViewer BreakpointViewer \ + GotoDialog TileViewer SpriteViewer BreakpointViewer \ QuickGuide PaletteView include build/node-end.mk