[nostalgia/core/studio] Cleanup pixel data QML exposure
This commit is contained in:
parent
edae4563ff
commit
1499f42361
@ -11,7 +11,7 @@ import QtQuick 2.0
|
||||
Rectangle {
|
||||
id: pixel;
|
||||
property int pixelNumber: index
|
||||
color: sheetData.pixel(pixelNumber)
|
||||
color: sheetData.palette[sheetData.pixels[pixelNumber]]
|
||||
width: parent.width / 8
|
||||
height: parent.height / 8
|
||||
border.color: '#717d7e'
|
||||
|
@ -52,11 +52,11 @@ class UpdatePixelsCommand: public QUndoCommand {
|
||||
uint64_t m_cmdIdx = 0;
|
||||
int m_newColorId = 0;
|
||||
const QStringList &m_palette;
|
||||
QVector<uint8_t> &m_pixels;
|
||||
QVector<int> &m_pixels;
|
||||
QSet<PixelUpdate> m_pixelUpdates;
|
||||
|
||||
public:
|
||||
UpdatePixelsCommand(QVector<uint8_t> &pixels, const QStringList &palette, QQuickItem *pixelItem, int newColorId, uint64_t cmdIdx): m_palette(palette), m_pixels(pixels) {
|
||||
UpdatePixelsCommand(QVector<int> &pixels, const QStringList &palette, QQuickItem *pixelItem, int newColorId, uint64_t cmdIdx): m_palette(palette), m_pixels(pixels) {
|
||||
m_newColorId = newColorId;
|
||||
m_cmdIdx = cmdIdx;
|
||||
PixelUpdate pu;
|
||||
@ -96,10 +96,6 @@ class UpdatePixelsCommand: public QUndoCommand {
|
||||
};
|
||||
|
||||
|
||||
QString SheetData::pixel(int index) {
|
||||
return m_palette[m_pixels[index]];
|
||||
}
|
||||
|
||||
void SheetData::updatePixel(QVariant pixelItem) {
|
||||
auto p = qobject_cast<QQuickItem*>(pixelItem.value<QObject*>());
|
||||
if (p && p != m_prevPixelUpdated) {
|
||||
@ -126,6 +122,10 @@ void SheetData::setRows(int rows) {
|
||||
emit rowsChanged();
|
||||
}
|
||||
|
||||
const QVector<int> &SheetData::pixels() {
|
||||
return m_pixels;
|
||||
}
|
||||
|
||||
QStringList SheetData::palette() {
|
||||
return m_palette;
|
||||
}
|
||||
@ -180,6 +180,8 @@ void SheetData::updatePixels(const NostalgiaGraphic *ng, const NostalgiaPalette
|
||||
m_pixels.push_back(p);
|
||||
}
|
||||
}
|
||||
emit pixelsChanged();
|
||||
emit paletteChanged();
|
||||
}
|
||||
|
||||
void SheetData::beginCmd() {
|
||||
|
@ -26,20 +26,20 @@ class SheetData: public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
|
||||
Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged)
|
||||
Q_PROPERTY(QVector<int> pixels READ pixels NOTIFY pixelsChanged)
|
||||
Q_PROPERTY(QStringList palette READ palette NOTIFY paletteChanged)
|
||||
|
||||
private:
|
||||
QQuickItem *m_prevPixelUpdated = nullptr;
|
||||
uint64_t m_cmdIdx = 0;
|
||||
QUndoStack m_cmdStack;
|
||||
QStringList m_palette;
|
||||
QVector<uint8_t> m_pixels;
|
||||
QVector<int> m_pixels;
|
||||
int m_columns = 2;
|
||||
int m_rows = 2;
|
||||
int m_selectedColor = 0;
|
||||
|
||||
public:
|
||||
Q_INVOKABLE QString pixel(int index);
|
||||
|
||||
Q_INVOKABLE void updatePixel(QVariant pixel);
|
||||
|
||||
Q_INVOKABLE void beginCmd();
|
||||
@ -54,6 +54,8 @@ class SheetData: public QObject {
|
||||
|
||||
void setRows(int rows);
|
||||
|
||||
const QVector<int> &pixels();
|
||||
|
||||
QStringList palette();
|
||||
|
||||
void updatePixels(const studio::Context *ctx, QString ngPath, QString palPath = "");
|
||||
@ -70,6 +72,10 @@ class SheetData: public QObject {
|
||||
|
||||
void rowsChanged();
|
||||
|
||||
void pixelsChanged();
|
||||
|
||||
void paletteChanged();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user