porymap/include/ui/paletteeditor.h

85 lines
2.1 KiB
C
Raw Permalink Normal View History

2018-10-03 01:01:41 +01:00
#ifndef PALETTEEDITOR_H
#define PALETTEEDITOR_H
#include <QMainWindow>
2022-07-05 05:47:58 +01:00
#include <QValidator>
2018-10-03 01:01:41 +01:00
#include <QSlider>
#include <QFrame>
#include <QLabel>
2018-10-03 01:01:41 +01:00
#include "project.h"
#include "history.h"
2018-10-03 01:01:41 +01:00
namespace Ui {
class PaletteEditor;
}
class PaletteHistoryItem {
public:
QList<QRgb> colors;
PaletteHistoryItem(QList<QRgb> colors) {
this->colors = colors;
}
};
2018-10-03 01:01:41 +01:00
class PaletteEditor : public QMainWindow {
Q_OBJECT
public:
explicit PaletteEditor(Project*, Tileset*, Tileset*, int paletteId, QWidget *parent = nullptr);
2018-10-03 01:01:41 +01:00
~PaletteEditor();
void setPaletteId(int);
2019-01-06 15:43:18 +00:00
void setTilesets(Tileset*, Tileset*);
2018-10-03 01:01:41 +01:00
private:
Ui::PaletteEditor *ui;
Project *project = nullptr;
2022-07-05 05:47:58 +01:00
2018-10-03 01:01:41 +01:00
QList<QList<QSlider*>> sliders;
QList<QList<QSpinBox *>> spinners;
2018-10-03 01:01:41 +01:00
QList<QFrame*> frames;
QList<QToolButton *> pickButtons;
QList<QLineEdit *> hexEdits;
2022-07-05 05:47:58 +01:00
2018-10-03 01:01:41 +01:00
Tileset *primaryTileset;
Tileset *secondaryTileset;
2022-07-05 05:47:58 +01:00
QList<History<PaletteHistoryItem*>> palettesHistory;
2022-07-05 05:47:58 +01:00
2022-07-03 16:50:00 +01:00
void refreshColorUis();
2022-07-05 05:47:58 +01:00
void updateColorUi(int index, QRgb color);
void commitEditHistory(int paletteid);
void restoreWindowState();
2022-07-05 05:47:58 +01:00
void setSignalsEnabled(bool enabled);
void setColorsFromHistory(PaletteHistoryItem*, int);
void closeEvent(QCloseEvent*);
void pickColor(int i);
2018-10-03 01:01:41 +01:00
2022-07-03 16:50:00 +01:00
void setRgb(int index, QRgb rgb);
void setRgbFromSliders(int colorIndex);
void setRgbFromHexEdit(int colorIndex);
void setRgbFromSpinners(int colorIndex);
void setBitDepth(int bits);
int bitDepth = 24;
2022-07-05 05:47:58 +01:00
class HexCodeValidator : public QValidator {
virtual QValidator::State validate(QString &input, int &) const override {
input = input.toUpper();
return QValidator::Acceptable;
}
};
HexCodeValidator *hexValidator = nullptr;
2018-10-03 01:01:41 +01:00
signals:
void closed();
void changedPaletteColor();
void changedPalette(int);
private slots:
void on_spinBox_PaletteId_valueChanged(int arg1);
void on_actionUndo_triggered();
void on_actionRedo_triggered();
void on_actionImport_Palette_triggered();
2018-10-03 01:01:41 +01:00
};
#endif // PALETTEEDITOR_H