[studio] Cleanup
This commit is contained in:
parent
c45efa6019
commit
712299faf3
@ -8,12 +8,12 @@
|
||||
|
||||
namespace studio {
|
||||
|
||||
ClawEditor::ClawEditor(ox::CRStringView path, ox::ModelObject obj) noexcept:
|
||||
Editor(path),
|
||||
m_obj(std::move(obj)) {
|
||||
ClawEditor::ClawEditor(StudioContext &sctx, ox::StringParam path):
|
||||
Editor(std::move(path)),
|
||||
m_obj(sctx.project->loadObj<ox::ModelObject>(itemPath()).unwrapThrow()) {
|
||||
}
|
||||
|
||||
void ClawEditor::draw(studio::StudioContext&) noexcept {
|
||||
void ClawEditor::draw(StudioContext&) noexcept {
|
||||
ImGui::BeginChild("PaletteEditor");
|
||||
static constexpr auto flags = ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody;
|
||||
if (ImGui::BeginTable("ObjTree", 3, flags)) {
|
||||
|
@ -11,14 +11,14 @@
|
||||
|
||||
namespace studio {
|
||||
|
||||
class ClawEditor: public studio::Editor {
|
||||
class ClawEditor: public Editor {
|
||||
private:
|
||||
using ObjPath = ox::Vector<ox::StringView, 8>;
|
||||
ox::ModelObject m_obj;
|
||||
public:
|
||||
ClawEditor(ox::CRStringView path, ox::ModelObject obj) noexcept;
|
||||
ClawEditor(StudioContext &sctx, ox::StringParam path);
|
||||
|
||||
void draw(studio::StudioContext&) noexcept final;
|
||||
void draw(StudioContext&) noexcept final;
|
||||
|
||||
private:
|
||||
static void drawRow(ox::ModelValue const&value) noexcept;
|
||||
|
@ -366,15 +366,10 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
|
||||
}
|
||||
oxRequire(ext, studio::fileExt(path));
|
||||
// create Editor
|
||||
studio::BaseEditor *editor = nullptr;
|
||||
if (!m_editorMakers.contains(ext)) {
|
||||
auto [obj, err] = m_project->loadObj<ox::ModelObject>(path);
|
||||
if (err) {
|
||||
return OxError(1, "There is no editor for this file extension");
|
||||
}
|
||||
editor = ox::make<ClawEditor>(path, std::move(obj));
|
||||
} else {
|
||||
auto const err = m_editorMakers[ext](path).moveTo(editor);
|
||||
BaseEditor *editor = nullptr;
|
||||
auto const err = m_editorMakers.contains(ext) ?
|
||||
m_editorMakers[ext](path).moveTo(editor) :
|
||||
ox::makeCatch<ClawEditor>(m_sctx, path).moveTo(editor);
|
||||
if (err) {
|
||||
if constexpr(!ox::defines::Debug) {
|
||||
oxErrf("Could not open Editor: {}\n", toStr(err));
|
||||
@ -383,7 +378,6 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
|
||||
}
|
||||
return err;
|
||||
}
|
||||
}
|
||||
editor->closed.connect(this, &StudioUI::closeFile);
|
||||
m_editors.emplace_back(editor);
|
||||
m_openFiles.emplace_back(path);
|
||||
|
Loading…
Reference in New Issue
Block a user