146 lines
3.7 KiB
C++
146 lines
3.7 KiB
C++
/*
|
|
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <ox/event/signal.hpp>
|
|
#include <ox/std/memory.hpp>
|
|
#include <ox/std/string.hpp>
|
|
|
|
#include <studio/editor.hpp>
|
|
#include <studio/imguiutil.hpp>
|
|
#include <studio/module.hpp>
|
|
#include <studio/project.hpp>
|
|
#include <studio/task.hpp>
|
|
|
|
#include "aboutpopup.hpp"
|
|
#include "deleteconfirmation.hpp"
|
|
#include "makecopypopup.hpp"
|
|
#include "newdir.hpp"
|
|
#include "newmenu.hpp"
|
|
#include "newproject.hpp"
|
|
#include "projectexplorer.hpp"
|
|
#include "renamefile.hpp"
|
|
|
|
namespace studio {
|
|
|
|
class StudioUI: public ox::SignalHandler {
|
|
friend class StudioUIDrawer;
|
|
|
|
private:
|
|
StudioContext m_sctx;
|
|
turbine::Context &m_tctx;
|
|
ox::String m_projectDataDir;
|
|
ox::UPtr<Project> m_project;
|
|
TaskRunner m_taskRunner;
|
|
ox::Vector<ox::UPtr<BaseEditor>> m_editors;
|
|
ox::Vector<ox::UPtr<Widget>> m_widgets;
|
|
ox::HashMap<ox::String, EditorMaker::Func> m_editorMakers;
|
|
ProjectExplorer m_projectExplorer;
|
|
ox::Vector<ox::String> m_openFiles;
|
|
BaseEditor *m_activeEditorOnLastDraw = nullptr;
|
|
BaseEditor *m_activeEditor = nullptr;
|
|
BaseEditor *m_activeEditorUpdatePending = nullptr;
|
|
bool m_closeActiveTab{};
|
|
ox::Vector<ox::Pair<ox::String>> m_queuedMoves;
|
|
ox::Vector<ox::Pair<ox::String>> m_queuedDirMoves;
|
|
NewMenu m_newMenu{keelCtx(m_tctx)};
|
|
DeleteConfirmation m_deleteConfirmation;
|
|
NewDir m_newDirDialog;
|
|
ig::QuestionPopup m_closeFileConfirm{"Close File?", "This file has unsaved changes. Close?"};
|
|
MakeCopyPopup m_copyFilePopup;
|
|
RenameFile m_renameFile;
|
|
NewProject m_newProject;
|
|
AboutPopup m_aboutPopup;
|
|
ox::Array<Popup*, 6> const m_popups = {
|
|
&m_newMenu,
|
|
&m_newProject,
|
|
&m_aboutPopup,
|
|
&m_deleteConfirmation,
|
|
&m_newDirDialog,
|
|
&m_renameFile,
|
|
};
|
|
bool m_showProjectExplorer = true;
|
|
struct NavAction {
|
|
ox::String path;
|
|
ox::String args;
|
|
};
|
|
ox::Optional<NavAction> m_navAction;
|
|
|
|
public:
|
|
explicit StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexcept;
|
|
|
|
void handleKeyEvent(turbine::Key, bool down) noexcept;
|
|
|
|
void navigateTo(ox::StringParam path, ox::StringParam navArgs) noexcept;
|
|
|
|
[[nodiscard]]
|
|
constexpr Project *project() noexcept {
|
|
return m_project.get();
|
|
}
|
|
|
|
protected:
|
|
void draw() noexcept;
|
|
|
|
private:
|
|
void drawMenu() noexcept;
|
|
|
|
void drawTabBar() noexcept;
|
|
|
|
void drawTabs() noexcept;
|
|
|
|
void loadEditorMaker(EditorMaker const&editorMaker) noexcept;
|
|
|
|
void loadModule(Module const&mod) noexcept;
|
|
|
|
void loadModules() noexcept;
|
|
|
|
void toggleProjectExplorer() noexcept;
|
|
|
|
void redo() noexcept;
|
|
|
|
void undo() noexcept;
|
|
|
|
void save() noexcept;
|
|
|
|
void handleKeyInput() noexcept;
|
|
|
|
ox::Error addDir(ox::StringViewCR path) noexcept;
|
|
|
|
ox::Error addFile(ox::StringViewCR path) noexcept;
|
|
|
|
ox::Error deleteFile(ox::StringViewCR path) noexcept;
|
|
|
|
ox::Error renameFile(ox::StringViewCR path) noexcept;
|
|
|
|
ox::Error handleMoveFile(ox::StringViewCR oldPath, ox::StringViewCR newPath, ox::UUID const&id) noexcept;
|
|
|
|
ox::Error handleDeleteFile(ox::StringViewCR path) noexcept;
|
|
|
|
ox::Error createOpenProject(ox::StringViewCR path) noexcept;
|
|
|
|
ox::Error openProjectPath(ox::StringParam path) noexcept;
|
|
|
|
ox::Error openFile(ox::StringViewCR path) noexcept;
|
|
|
|
ox::Error openFileActiveTab(ox::StringViewCR path, bool makeActiveTab) noexcept;
|
|
|
|
ox::Error makeCopyDlg(ox::StringViewCR path) noexcept;
|
|
|
|
ox::Error handleCloseFileResponse(ig::PopupResponse response) noexcept;
|
|
|
|
ox::Error closeCurrentFile() noexcept;
|
|
|
|
ox::Error closeFile(ox::StringViewCR path) noexcept;
|
|
|
|
ox::Error queueDirMove(ox::StringParam src, ox::StringParam dst) noexcept;
|
|
|
|
ox::Error queueFileMove(ox::StringParam src, ox::StringParam dst) noexcept;
|
|
|
|
void procFileMoves() noexcept;
|
|
|
|
};
|
|
|
|
}
|