105 lines
1.9 KiB
C++
105 lines
1.9 KiB
C++
/*
|
|
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <ox/event/signal.hpp>
|
|
|
|
#include "undostack.hpp"
|
|
#include "widget.hpp"
|
|
|
|
#include "nostalgiastudio_export.h"
|
|
|
|
namespace nostalgia::studio {
|
|
|
|
class NOSTALGIASTUDIO_EXPORT Editor: public Widget {
|
|
|
|
private:
|
|
UndoStack m_cmdStack;
|
|
bool m_unsavedChanges = false;
|
|
bool m_exportable = false;
|
|
bool m_cutEnabled = false;
|
|
bool m_copyEnabled = false;
|
|
bool m_pasteEnabled = false;
|
|
|
|
public:
|
|
~Editor() override = default;
|
|
|
|
/**
|
|
* Returns the name of item being edited.
|
|
*/
|
|
[[nodiscard]]
|
|
virtual ox::String itemName() const = 0;
|
|
|
|
virtual ox::String itemDisplayName() const;
|
|
|
|
virtual void cut();
|
|
|
|
virtual void copy();
|
|
|
|
virtual void paste();
|
|
|
|
virtual void exportFile();
|
|
|
|
void close();
|
|
|
|
/**
|
|
* Save changes to item being edited.
|
|
*/
|
|
void save();
|
|
|
|
/**
|
|
* Sets indication of item being edited has unsaved changes. Also emits
|
|
* unsavedChangesChanged signal.
|
|
*/
|
|
void setUnsavedChanges(bool);
|
|
|
|
[[nodiscard]]
|
|
bool unsavedChanges() const noexcept;
|
|
|
|
/**
|
|
* Returns the undo stack holding changes to the item being edited.
|
|
*/
|
|
[[nodiscard]]
|
|
UndoStack *undoStack();
|
|
|
|
void setExportable(bool);
|
|
|
|
[[nodiscard]]
|
|
bool exportable() const;
|
|
|
|
void setCutEnabled(bool);
|
|
|
|
[[nodiscard]]
|
|
bool cutEnabled() const;
|
|
|
|
void setCopyEnabled(bool);
|
|
|
|
[[nodiscard]]
|
|
bool copyEnabled() const;
|
|
|
|
void setPasteEnabled(bool);
|
|
|
|
[[nodiscard]]
|
|
bool pasteEnabled() const;
|
|
|
|
protected:
|
|
/**
|
|
* Save changes to item being edited.
|
|
*/
|
|
virtual void saveItem();
|
|
|
|
// signals
|
|
public:
|
|
ox::Signal<ox::Error(bool)> unsavedChangesChanged;
|
|
ox::Signal<ox::Error(bool)> exportableChanged;
|
|
ox::Signal<ox::Error(bool)> cutEnabledChanged;
|
|
ox::Signal<ox::Error(bool)> copyEnabledChanged;
|
|
ox::Signal<ox::Error(bool)> pasteEnabledChanged;
|
|
ox::Signal<ox::Error(const ox::String&)> closed;
|
|
|
|
};
|
|
|
|
}
|