[nostalgia/core/studio] Make TileSheetEditor a studio::Editor
This commit is contained in:
parent
641c6ae637
commit
dd3e5913ed
@ -149,6 +149,10 @@ void SheetData::setSelectedColor(int index) {
|
|||||||
m_selectedColor = index;
|
m_selectedColor = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUndoStack *SheetData::undoStack() {
|
||||||
|
return &m_cmdStack;
|
||||||
|
}
|
||||||
|
|
||||||
void SheetData::updatePixels(const NostalgiaGraphic *ng, const NostalgiaPalette *npal) {
|
void SheetData::updatePixels(const NostalgiaGraphic *ng, const NostalgiaPalette *npal) {
|
||||||
if (!npal) {
|
if (!npal) {
|
||||||
npal = &ng->pal;
|
npal = &ng->pal;
|
||||||
@ -187,8 +191,9 @@ void SheetData::endCmd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TileSheetEditor::TileSheetEditor(QString path, const studio::Context *ctx, QWidget *parent): QWidget(parent) {
|
TileSheetEditor::TileSheetEditor(QString path, const studio::Context *ctx, QWidget *parent): studio::Editor(parent) {
|
||||||
m_ctx = ctx;
|
m_ctx = ctx;
|
||||||
|
m_itemName = path.mid(path.lastIndexOf('/'));
|
||||||
auto lyt = new QVBoxLayout(this);
|
auto lyt = new QVBoxLayout(this);
|
||||||
m_splitter = new QSplitter(this);
|
m_splitter = new QSplitter(this);
|
||||||
auto canvas = new QQuickWidget(m_splitter);
|
auto canvas = new QQuickWidget(m_splitter);
|
||||||
@ -208,6 +213,17 @@ TileSheetEditor::~TileSheetEditor() {
|
|||||||
saveState();
|
saveState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString TileSheetEditor::itemName() {
|
||||||
|
return m_itemName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileSheetEditor::save() {
|
||||||
|
}
|
||||||
|
|
||||||
|
QUndoStack *TileSheetEditor::undoStack() {
|
||||||
|
return m_sheetData.undoStack();
|
||||||
|
}
|
||||||
|
|
||||||
QWidget *TileSheetEditor::setupColorPicker(QWidget *parent) {
|
QWidget *TileSheetEditor::setupColorPicker(QWidget *parent) {
|
||||||
auto colorPicker = new QWidget(parent);
|
auto colorPicker = new QWidget(parent);
|
||||||
auto lyt = new QVBoxLayout(colorPicker);
|
auto lyt = new QVBoxLayout(colorPicker);
|
||||||
|
@ -60,6 +60,8 @@ class SheetData: public QObject {
|
|||||||
|
|
||||||
void setSelectedColor(int index);
|
void setSelectedColor(int index);
|
||||||
|
|
||||||
|
QUndoStack *undoStack();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updatePixels(const NostalgiaGraphic *ng, const NostalgiaPalette *npal);
|
void updatePixels(const NostalgiaGraphic *ng, const NostalgiaPalette *npal);
|
||||||
|
|
||||||
@ -71,10 +73,11 @@ class SheetData: public QObject {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TileSheetEditor: public QWidget {
|
class TileSheetEditor: public studio::Editor {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString m_itemName;
|
||||||
const studio::Context *m_ctx = nullptr;
|
const studio::Context *m_ctx = nullptr;
|
||||||
SheetData m_sheetData;
|
SheetData m_sheetData;
|
||||||
QSplitter *m_splitter = nullptr;
|
QSplitter *m_splitter = nullptr;
|
||||||
@ -88,6 +91,12 @@ class TileSheetEditor: public QWidget {
|
|||||||
|
|
||||||
virtual ~TileSheetEditor();
|
virtual ~TileSheetEditor();
|
||||||
|
|
||||||
|
QString itemName() override;
|
||||||
|
|
||||||
|
void save() override;
|
||||||
|
|
||||||
|
QUndoStack *undoStack() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *setupColorPicker(QWidget *widget);
|
QWidget *setupColorPicker(QWidget *widget);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user