[olympic,nostalgia] Move item name/path studio::Editor

This commit is contained in:
2023-12-12 23:06:14 -06:00
parent d056323679
commit 1b93b2038f
8 changed files with 37 additions and 70 deletions

View File

@ -9,19 +9,10 @@
namespace studio {
ClawEditor::ClawEditor(ox::CRStringView path, ox::ModelObject obj) noexcept:
m_itemName(path),
m_itemDisplayName(pathToItemName(path)),
Editor(path),
m_obj(std::move(obj)) {
}
ox::CStringView ClawEditor::itemName() const noexcept {
return m_itemName;
}
ox::CStringView ClawEditor::itemDisplayName() const noexcept {
return m_itemDisplayName;
}
void ClawEditor::draw(turbine::Context&) noexcept {
//const auto paneSize = ImGui::GetContentRegionAvail();
ImGui::BeginChild("PaletteEditor");

View File

@ -14,19 +14,10 @@ namespace studio {
class ClawEditor: public studio::Editor {
private:
using ObjPath = ox::Vector<ox::StringView, 8>;
ox::String m_itemName;
ox::String m_itemDisplayName;
ox::ModelObject m_obj;
public:
ClawEditor(ox::CRStringView path, ox::ModelObject obj) noexcept;
/**
* Returns the name of item being edited.
*/
ox::CStringView itemName() const noexcept final;
ox::CStringView itemDisplayName() const noexcept final;
void draw(turbine::Context&) noexcept final;
private:

View File

@ -120,13 +120,19 @@ class BaseEditor: public Widget {
class Editor: public studio::BaseEditor {
private:
studio::UndoStack m_undoStack;
ox::String m_itemPath;
ox::String m_itemName;
public:
Editor() noexcept;
Editor(ox::StringView itemPath) noexcept;
UndoStack *undoStack() noexcept final {
return &m_undoStack;
}
[[nodiscard]]
ox::CStringView itemName() const noexcept final;
[[nodiscard]]
ox::CStringView itemDisplayName() const noexcept final;
UndoStack *undoStack() noexcept final;
private:
ox::Error markUnsavedChanges(const UndoCommand*) noexcept;

View File

@ -112,13 +112,29 @@ void BaseEditor::setRequiresConstantRefresh(bool value) noexcept {
}
Editor::Editor() noexcept {
Editor::Editor(ox::StringView itemPath) noexcept:
m_itemPath(itemPath),
m_itemName(m_itemPath.substr(std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset() + 1)) {
m_undoStack.changeTriggered.connect(this, &Editor::markUnsavedChanges);
}
ox::Error Editor::markUnsavedChanges(const UndoCommand*) noexcept {
[[nodiscard]]
ox::CStringView Editor::itemName() const noexcept {
return m_itemPath;
}
[[nodiscard]]
ox::CStringView Editor::itemDisplayName() const noexcept {
return m_itemName;
}
UndoStack *Editor::undoStack() noexcept {
return &m_undoStack;
}
ox::Error Editor::markUnsavedChanges(UndoCommand const*) noexcept {
setUnsavedChanges(true);
return OxError(0);
return {};
}
}