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