[studio] Rename StudioContext to Context
All checks were successful
Build / build (push) Successful in 1m16s

This commit is contained in:
Gary Talent 2025-05-06 22:36:49 -05:00
parent 90fc85beea
commit 0aee5fea61
42 changed files with 89 additions and 89 deletions

View File

@ -68,7 +68,7 @@ void PaletteEditorImGui::PageRenameDialog::draw(turbine::Context &tctx) noexcept
} }
PaletteEditorImGui::PaletteEditorImGui(studio::StudioContext &sctx, ox::StringParam path): PaletteEditorImGui::PaletteEditorImGui(studio::Context &sctx, ox::StringParam path):
Editor(sctx, std::move(path)), Editor(sctx, std::move(path)),
m_sctx(sctx), m_sctx(sctx),
m_tctx(sctx.tctx), m_tctx(sctx.tctx),
@ -77,7 +77,7 @@ PaletteEditorImGui::PaletteEditorImGui(studio::StudioContext &sctx, ox::StringPa
m_pageRenameDlg.inputSubmitted.connect(this, &PaletteEditorImGui::renamePage); m_pageRenameDlg.inputSubmitted.connect(this, &PaletteEditorImGui::renamePage);
} }
void PaletteEditorImGui::draw(studio::StudioContext&) noexcept { void PaletteEditorImGui::draw(studio::Context&) noexcept {
auto const paneSize = ImGui::GetContentRegionAvail(); auto const paneSize = ImGui::GetContentRegionAvail();
{ {
ImGui::BeginChild("Pages", {280, paneSize.y}, true); ImGui::BeginChild("Pages", {280, paneSize.y}, true);

View File

@ -31,16 +31,16 @@ class PaletteEditorImGui: public studio::Editor {
constexpr bool isOpen() const noexcept { return m_show; } constexpr bool isOpen() const noexcept { return m_show; }
void draw(turbine::Context &tctx) noexcept; void draw(turbine::Context &tctx) noexcept;
} m_pageRenameDlg; } m_pageRenameDlg;
studio::StudioContext &m_sctx; studio::Context &m_sctx;
turbine::Context &m_tctx; turbine::Context &m_tctx;
Palette m_pal; Palette m_pal;
size_t m_selectedColorRow = 0; size_t m_selectedColorRow = 0;
size_t m_page = 0; size_t m_page = 0;
public: public:
PaletteEditorImGui(studio::StudioContext &sctx, ox::StringParam path); PaletteEditorImGui(studio::Context &sctx, ox::StringParam path);
void draw(studio::StudioContext&) noexcept final; void draw(studio::Context&) noexcept final;
protected: protected:
ox::Error saveItem() noexcept final; ox::Error saveItem() noexcept final;

View File

@ -12,14 +12,14 @@
namespace nostalgia::gfx { namespace nostalgia::gfx {
static class: public studio::Module { static class: public studio::Module {
ox::Vector<studio::EditorMaker> editors(studio::StudioContext &ctx) const noexcept final { ox::Vector<studio::EditorMaker> editors(studio::Context &ctx) const noexcept final {
return { return {
studio::editorMaker<TileSheetEditorImGui>(ctx, {FileExt_ng, FileExt_nts}), studio::editorMaker<TileSheetEditorImGui>(ctx, {FileExt_ng, FileExt_nts}),
studio::editorMaker<PaletteEditorImGui>(ctx, FileExt_npal), studio::editorMaker<PaletteEditorImGui>(ctx, FileExt_npal),
}; };
} }
ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(studio::StudioContext&) const noexcept final { ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(studio::Context&) const noexcept final {
ox::Vector<ox::UPtr<studio::ItemMaker>> out; ox::Vector<ox::UPtr<studio::ItemMaker>> out;
out.emplace_back(ox::make<studio::ItemMakerT<TileSheet>>("Tile Sheet", "TileSheets", FileExt_nts)); out.emplace_back(ox::make<studio::ItemMakerT<TileSheet>>("Tile Sheet", "TileSheets", FileExt_nts));
out.emplace_back(ox::make<studio::ItemMakerT<Palette>>("Palette", "Palettes", FileExt_npal, Palette{ out.emplace_back(ox::make<studio::ItemMakerT<Palette>>("Palette", "Palettes", FileExt_npal, Palette{

View File

@ -87,7 +87,7 @@ static ox::Error toPngFile(
8))); 8)));
} }
TileSheetEditorImGui::TileSheetEditorImGui(studio::StudioContext &sctx, ox::StringParam path): TileSheetEditorImGui::TileSheetEditorImGui(studio::Context &sctx, ox::StringParam path):
Editor(sctx, std::move(path)), Editor(sctx, std::move(path)),
m_sctx{sctx}, m_sctx{sctx},
m_tctx{m_sctx.tctx}, m_tctx{m_sctx.tctx},
@ -188,7 +188,7 @@ void TileSheetEditorImGui::keyStateChanged(turbine::Key const key, bool const do
} }
} }
void TileSheetEditorImGui::draw(studio::StudioContext&) noexcept { void TileSheetEditorImGui::draw(studio::Context&) noexcept {
if (ig::mainWinHasFocus() && m_tool == TileSheetTool::Select) { if (ig::mainWinHasFocus() && m_tool == TileSheetTool::Select) {
if (ImGui::IsKeyDown(ImGuiKey_ModCtrl) && !m_palPathFocused) { if (ImGui::IsKeyDown(ImGuiKey_ModCtrl) && !m_palPathFocused) {
if (ImGui::IsKeyPressed(ImGuiKey_A)) { if (ImGui::IsKeyPressed(ImGuiKey_A)) {

View File

@ -45,7 +45,7 @@ class TileSheetEditorImGui: public studio::Editor {
constexpr bool isOpen() const noexcept { return m_show; } constexpr bool isOpen() const noexcept { return m_show; }
}; };
static constexpr float s_palViewWidth = 335; static constexpr float s_palViewWidth = 335;
studio::StudioContext &m_sctx; studio::Context &m_sctx;
turbine::Context &m_tctx; turbine::Context &m_tctx;
ox::Vector<ox::String> m_paletteList; ox::Vector<ox::String> m_paletteList;
SubSheetEditor m_subsheetEditor; SubSheetEditor m_subsheetEditor;
@ -60,7 +60,7 @@ class TileSheetEditorImGui: public studio::Editor {
ox::Vector<ox::UPtr<studio::UndoCommand>, 1> m_deferredCmds; ox::Vector<ox::UPtr<studio::UndoCommand>, 1> m_deferredCmds;
public: public:
TileSheetEditorImGui(studio::StudioContext &sctx, ox::StringParam path); TileSheetEditorImGui(studio::Context &sctx, ox::StringParam path);
~TileSheetEditorImGui() override = default; ~TileSheetEditorImGui() override = default;
@ -77,7 +77,7 @@ class TileSheetEditorImGui: public studio::Editor {
void keyStateChanged(turbine::Key key, bool down) override; void keyStateChanged(turbine::Key key, bool down) override;
void draw(studio::StudioContext&) noexcept override; void draw(studio::Context&) noexcept override;
void drawSubsheetSelector(TileSheet::SubSheet&, TileSheet::SubSheetIdx &path); void drawSubsheetSelector(TileSheet::SubSheet&, TileSheet::SubSheetIdx &path);

View File

@ -45,7 +45,7 @@ Palette const TileSheetEditorModel::s_defaultPalette = {
}; };
TileSheetEditorModel::TileSheetEditorModel( TileSheetEditorModel::TileSheetEditorModel(
studio::StudioContext &sctx, ox::StringParam path, studio::UndoStack &undoStack): studio::Context &sctx, ox::StringParam path, studio::UndoStack &undoStack):
m_sctx(sctx), m_sctx(sctx),
m_tctx(m_sctx.tctx), m_tctx(m_sctx.tctx),
m_path(std::move(path)), m_path(std::move(path)),

View File

@ -22,7 +22,7 @@ class TileSheetEditorModel: public ox::SignalHandler {
private: private:
static Palette const s_defaultPalette; static Palette const s_defaultPalette;
studio::StudioContext &m_sctx; studio::Context &m_sctx;
turbine::Context &m_tctx; turbine::Context &m_tctx;
ox::String m_path; ox::String m_path;
ox::String m_palPath; ox::String m_palPath;
@ -39,7 +39,7 @@ class TileSheetEditorModel: public ox::SignalHandler {
bool m_updated = false; bool m_updated = false;
public: public:
TileSheetEditorModel(studio::StudioContext &sctx, ox::StringParam path, studio::UndoStack &undoStack); TileSheetEditorModel(studio::Context &sctx, ox::StringParam path, studio::UndoStack &undoStack);
~TileSheetEditorModel() override = default; ~TileSheetEditorModel() override = default;

View File

@ -12,7 +12,7 @@
namespace nostalgia::gfx { namespace nostalgia::gfx {
TileSheetEditorView::TileSheetEditorView( TileSheetEditorView::TileSheetEditorView(
studio::StudioContext &sctx, ox::StringViewCR path, studio::UndoStack &undoStack): studio::Context &sctx, ox::StringViewCR path, studio::UndoStack &undoStack):
m_model(sctx, path, undoStack), m_model(sctx, path, undoStack),
m_pixelsDrawer(m_model) { m_pixelsDrawer(m_model) {
glBindVertexArray(0); glBindVertexArray(0);

View File

@ -56,7 +56,7 @@ class TileSheetEditorView: public ox::SignalHandler {
std::size_t m_palIdx = 0; std::size_t m_palIdx = 0;
public: public:
TileSheetEditorView(studio::StudioContext &sctx, ox::StringViewCR path, studio::UndoStack &undoStack); TileSheetEditorView(studio::Context &sctx, ox::StringViewCR path, studio::UndoStack &undoStack);
~TileSheetEditorView() override = default; ~TileSheetEditorView() override = default;

View File

@ -9,12 +9,12 @@
namespace nostalgia::sound { namespace nostalgia::sound {
static class: public studio::Module { static class: public studio::Module {
ox::Vector<studio::EditorMaker> editors(studio::StudioContext&) const noexcept final { ox::Vector<studio::EditorMaker> editors(studio::Context&) const noexcept final {
return { return {
}; };
} }
ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(studio::StudioContext&) const noexcept final { ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(studio::Context&) const noexcept final {
ox::Vector<ox::UPtr<studio::ItemMaker>> out; ox::Vector<ox::UPtr<studio::ItemMaker>> out;
return out; return out;
} }

View File

@ -29,7 +29,7 @@ bool AboutPopup::isOpen() const noexcept {
return m_stage == Stage::Open; return m_stage == Stage::Open;
} }
void AboutPopup::draw(StudioContext &sctx) noexcept { void AboutPopup::draw(Context &sctx) noexcept {
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) { if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
close(); close();
return; return;

View File

@ -35,7 +35,7 @@ class AboutPopup: public studio::Popup {
[[nodiscard]] [[nodiscard]]
bool isOpen() const noexcept override; bool isOpen() const noexcept override;
void draw(studio::StudioContext &sctx) noexcept override; void draw(studio::Context &sctx) noexcept override;
}; };

View File

@ -28,7 +28,7 @@ class StudioUIDrawer: public turbine::gl::Drawer {
}; };
static void keyEventHandler(turbine::Context &ctx, turbine::Key key, bool down) noexcept { static void keyEventHandler(turbine::Context &ctx, turbine::Key key, bool down) noexcept {
auto sctx = turbine::applicationData<studio::StudioContext>(ctx); auto sctx = turbine::applicationData<studio::Context>(ctx);
sctx->ui.handleKeyEvent(key, down); sctx->ui.handleKeyEvent(key, down);
} }

View File

@ -8,12 +8,12 @@
namespace studio { namespace studio {
ClawEditor::ClawEditor(StudioContext &sctx, ox::StringParam path): ClawEditor::ClawEditor(Context &sctx, ox::StringParam path):
Editor(sctx, std::move(path)), Editor(sctx, std::move(path)),
m_obj(sctx.project->loadObj<ox::ModelObject>(itemPath()).unwrapThrow()) { m_obj(sctx.project->loadObj<ox::ModelObject>(itemPath()).unwrapThrow()) {
} }
void ClawEditor::draw(StudioContext&) noexcept { void ClawEditor::draw(Context&) noexcept {
ImGui::BeginChild("PaletteEditor"); ImGui::BeginChild("PaletteEditor");
static constexpr auto flags = ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody; static constexpr auto flags = ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody;
if (ImGui::BeginTable("ObjTree", 3, flags)) { if (ImGui::BeginTable("ObjTree", 3, flags)) {

View File

@ -16,9 +16,9 @@ class ClawEditor: public Editor {
using ObjPath = ox::Vector<ox::StringView, 8>; using ObjPath = ox::Vector<ox::StringView, 8>;
ox::ModelObject m_obj; ox::ModelObject m_obj;
public: public:
ClawEditor(StudioContext &sctx, ox::StringParam path); ClawEditor(Context &sctx, ox::StringParam path);
void draw(StudioContext&) noexcept final; void draw(Context&) noexcept final;
private: private:
static void drawRow(ox::ModelValue const&value) noexcept; static void drawRow(ox::ModelValue const&value) noexcept;

View File

@ -31,7 +31,7 @@ bool DeleteConfirmation::isOpen() const noexcept {
return m_open; return m_open;
} }
void DeleteConfirmation::draw(StudioContext &ctx) noexcept { void DeleteConfirmation::draw(Context &ctx) noexcept {
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) { if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
close(); close();
return; return;

View File

@ -36,7 +36,7 @@ class DeleteConfirmation final: public Popup {
[[nodiscard]] [[nodiscard]]
bool isOpen() const noexcept override; bool isOpen() const noexcept override;
void draw(StudioContext &ctx) noexcept override; void draw(Context &ctx) noexcept override;
}; };

View File

@ -28,7 +28,7 @@ bool MakeCopyPopup::isOpen() const noexcept {
return m_open; return m_open;
} }
void MakeCopyPopup::draw(StudioContext &ctx) noexcept { void MakeCopyPopup::draw(Context &ctx) noexcept {
switch (m_stage) { switch (m_stage) {
case Stage::Closed: case Stage::Closed:
break; break;
@ -70,7 +70,7 @@ void MakeCopyPopup::draw(StudioContext &ctx) noexcept {
} }
} }
void MakeCopyPopup::accept(StudioContext const &ctx) noexcept { void MakeCopyPopup::accept(Context const &ctx) noexcept {
auto const p = sfmt("{}{}", m_dirPath, m_fileName); auto const p = sfmt("{}{}", m_dirPath, m_fileName);
if (!ctx.project->exists(p)) { if (!ctx.project->exists(p)) {
makeCopy.emit(m_srcPath, p); makeCopy.emit(m_srcPath, p);

View File

@ -37,10 +37,10 @@ class MakeCopyPopup: public Widget {
[[nodiscard]] [[nodiscard]]
bool isOpen() const noexcept; bool isOpen() const noexcept;
void draw(StudioContext &ctx) noexcept override; void draw(Context &ctx) noexcept override;
private: private:
void accept(StudioContext const &ctx) noexcept; void accept(Context const &ctx) noexcept;
}; };
} }

View File

@ -32,7 +32,7 @@ bool NewDir::isOpen() const noexcept {
return m_open; return m_open;
} }
void NewDir::draw(StudioContext &ctx) noexcept { void NewDir::draw(Context &ctx) noexcept {
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) { if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
close(); close();
return; return;

View File

@ -37,7 +37,7 @@ class NewDir final: public Popup {
[[nodiscard]] [[nodiscard]]
bool isOpen() const noexcept override; bool isOpen() const noexcept override;
void draw(StudioContext &ctx) noexcept override; void draw(Context &ctx) noexcept override;
[[nodiscard]] [[nodiscard]]
constexpr ox::CStringView value() const noexcept { constexpr ox::CStringView value() const noexcept {

View File

@ -44,7 +44,7 @@ bool NewMenu::isOpen() const noexcept {
return m_open; return m_open;
} }
void NewMenu::draw(StudioContext &sctx) noexcept { void NewMenu::draw(Context &sctx) noexcept {
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) { if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
close(); close();
return; return;
@ -88,7 +88,7 @@ void NewMenu::installItemTemplate(ox::UPtr<ItemTemplate> &tmplt) noexcept {
} }
} }
void NewMenu::drawNewItemType(StudioContext const&sctx) noexcept { void NewMenu::drawNewItemType(Context const&sctx) noexcept {
setSize({280, 180}); setSize({280, 180});
drawWindow(sctx.tctx, m_open, [this] { drawWindow(sctx.tctx, m_open, [this] {
ig::ListBox("Item Type", [&](size_t const i) -> ox::CStringView { ig::ListBox("Item Type", [&](size_t const i) -> ox::CStringView {
@ -105,7 +105,7 @@ void NewMenu::drawNewItemType(StudioContext const&sctx) noexcept {
}); });
} }
void NewMenu::drawNewItemTemplate(StudioContext const&sctx) noexcept { void NewMenu::drawNewItemTemplate(Context const&sctx) noexcept {
setSize({280, 180}); setSize({280, 180});
drawWindow(sctx.tctx, m_open, [this] { drawWindow(sctx.tctx, m_open, [this] {
auto const&templates = auto const&templates =
@ -117,7 +117,7 @@ void NewMenu::drawNewItemTemplate(StudioContext const&sctx) noexcept {
}); });
} }
void NewMenu::drawNewItemPath(StudioContext &sctx) noexcept { void NewMenu::drawNewItemPath(Context &sctx) noexcept {
setSize({380, 340}); setSize({380, 340});
drawWindow(sctx.tctx, m_open, [this, &sctx] { drawWindow(sctx.tctx, m_open, [this, &sctx] {
if (m_stage == Stage::NewItemTransitioningToPath) [[unlikely]] { if (m_stage == Stage::NewItemTransitioningToPath) [[unlikely]] {
@ -170,7 +170,7 @@ void NewMenu::drawFirstPageButtons(Stage const next) noexcept {
} }
} }
void NewMenu::drawLastPageButtons(StudioContext &sctx) noexcept { void NewMenu::drawLastPageButtons(Context &sctx) noexcept {
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 198); ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 198);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetContentRegionAvail().y - 20); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetContentRegionAvail().y - 20);
constexpr ImVec2 btnSz{60, 20}; constexpr ImVec2 btnSz{60, 20};
@ -191,7 +191,7 @@ void NewMenu::drawLastPageButtons(StudioContext &sctx) noexcept {
} }
} }
void NewMenu::finish(StudioContext &sctx) noexcept { void NewMenu::finish(Context &sctx) noexcept {
if (m_itemName.len() == 0) { if (m_itemName.len() == 0) {
oxLogError(ox::Error{1, "New file error: no file name"}); oxLogError(ox::Error{1, "New file error: no file name"});
return; return;

View File

@ -53,7 +53,7 @@ class NewMenu final: public Popup {
[[nodiscard]] [[nodiscard]]
bool isOpen() const noexcept override; bool isOpen() const noexcept override;
void draw(StudioContext &sctx) noexcept override; void draw(Context &sctx) noexcept override;
template<typename T> template<typename T>
void addItemType( void addItemType(
@ -75,19 +75,19 @@ class NewMenu final: public Popup {
void installItemTemplate(ox::UPtr<ItemTemplate> &tmplt) noexcept; void installItemTemplate(ox::UPtr<ItemTemplate> &tmplt) noexcept;
private: private:
void drawNewItemType(StudioContext const&sctx) noexcept; void drawNewItemType(Context const&sctx) noexcept;
void drawNewItemPath(StudioContext &sctx) noexcept; void drawNewItemPath(Context &sctx) noexcept;
void drawNewItemTemplate(StudioContext const &sctx) noexcept; void drawNewItemTemplate(Context const &sctx) noexcept;
void drawButtons(Stage next) noexcept; void drawButtons(Stage next) noexcept;
void drawFirstPageButtons(Stage next) noexcept; void drawFirstPageButtons(Stage next) noexcept;
void drawLastPageButtons(StudioContext &sctx) noexcept; void drawLastPageButtons(Context &sctx) noexcept;
void finish(StudioContext &sctx) noexcept; void finish(Context &sctx) noexcept;
}; };

View File

@ -33,7 +33,7 @@ bool NewProject::isOpen() const noexcept {
return m_open; return m_open;
} }
void NewProject::draw(StudioContext &ctx) noexcept { void NewProject::draw(Context &ctx) noexcept {
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) { if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
close(); close();
return; return;
@ -53,7 +53,7 @@ void NewProject::draw(StudioContext &ctx) noexcept {
} }
} }
void NewProject::drawNewProjectName(StudioContext &sctx) noexcept { void NewProject::drawNewProjectName(Context &sctx) noexcept {
drawWindow(sctx.tctx, m_open, [this, &sctx] { drawWindow(sctx.tctx, m_open, [this, &sctx] {
ig::InputText("Name", m_projectName); ig::InputText("Name", m_projectName);
ImGui::Text("Path: %s", m_projectPath.c_str()); ImGui::Text("Path: %s", m_projectPath.c_str());
@ -64,7 +64,7 @@ void NewProject::drawNewProjectName(StudioContext &sctx) noexcept {
}); });
} }
void NewProject::drawLastPageButtons(StudioContext&) noexcept { void NewProject::drawLastPageButtons(Context&) noexcept {
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 110); ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 110);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetContentRegionAvail().y - 22); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetContentRegionAvail().y - 22);
if (ig::PushButton("Finish")) { if (ig::PushButton("Finish")) {

View File

@ -42,12 +42,12 @@ class NewProject: public studio::Popup {
[[nodiscard]] [[nodiscard]]
bool isOpen() const noexcept override; bool isOpen() const noexcept override;
void draw(studio::StudioContext &ctx) noexcept override; void draw(studio::Context &ctx) noexcept override;
private: private:
void drawNewProjectName(studio::StudioContext &ctx) noexcept; void drawNewProjectName(studio::Context &ctx) noexcept;
void drawLastPageButtons(studio::StudioContext &ctx) noexcept; void drawLastPageButtons(studio::Context &ctx) noexcept;
void finish() noexcept; void finish() noexcept;

View File

@ -34,7 +34,7 @@ bool RenameFile::isOpen() const noexcept {
return m_open; return m_open;
} }
void RenameFile::draw(StudioContext &ctx) noexcept { void RenameFile::draw(Context &ctx) noexcept {
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) { if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
close(); close();
return; return;

View File

@ -38,7 +38,7 @@ class RenameFile: public Popup {
[[nodiscard]] [[nodiscard]]
bool isOpen() const noexcept override; bool isOpen() const noexcept override;
void draw(StudioContext &ctx) noexcept override; void draw(Context &ctx) noexcept override;
}; };

View File

@ -26,11 +26,11 @@
namespace studio { namespace studio {
static bool shutdownHandler(turbine::Context &ctx) { static bool shutdownHandler(turbine::Context &ctx) {
auto sctx = turbine::applicationData<StudioContext>(ctx); auto sctx = turbine::applicationData<Context>(ctx);
return sctx->ui.handleShutdown(); return sctx->ui.handleShutdown();
} }
void navigateTo(StudioContext &ctx, ox::StringParam filePath, ox::StringParam navArgs) noexcept { void navigateTo(Context &ctx, ox::StringParam filePath, ox::StringParam navArgs) noexcept {
ctx.ui.navigateTo(std::move(filePath), std::move(navArgs)); ctx.ui.navigateTo(std::move(filePath), std::move(navArgs));
} }

View File

@ -29,7 +29,7 @@ class StudioUI: public ox::SignalHandler {
friend class StudioUIDrawer; friend class StudioUIDrawer;
private: private:
StudioContext m_sctx; Context m_sctx;
turbine::Context &m_tctx; turbine::Context &m_tctx;
ox::String m_projectDataDir; ox::String m_projectDataDir;
ox::UPtr<Project> m_project; ox::UPtr<Project> m_project;

View File

@ -14,19 +14,19 @@ namespace studio {
class StudioUI; class StudioUI;
struct StudioContext { struct Context {
StudioUI &ui; StudioUI &ui;
Project *project = nullptr; Project *project = nullptr;
turbine::Context &tctx; turbine::Context &tctx;
StudioContext(StudioUI &pUi, turbine::Context &pTctx) noexcept: Context(StudioUI &pUi, turbine::Context &pTctx) noexcept:
ui(pUi), tctx(pTctx) {} ui(pUi), tctx(pTctx) {}
}; };
[[nodiscard]] [[nodiscard]]
inline keel::Context &keelCtx(StudioContext &ctx) noexcept { inline keel::Context &keelCtx(Context &ctx) noexcept {
return keelCtx(ctx.tctx); return keelCtx(ctx.tctx);
} }
void navigateTo(StudioContext &ctx, ox::StringParam filePath, ox::StringParam navArgs) noexcept; void navigateTo(Context &ctx, ox::StringParam filePath, ox::StringParam navArgs) noexcept;
} }

View File

@ -121,7 +121,7 @@ class Editor: public studio::BaseEditor {
ox::String m_itemName; ox::String m_itemName;
public: public:
Editor(StudioContext &ctx, ox::StringParam itemPath) noexcept; Editor(Context &ctx, ox::StringParam itemPath) noexcept;
[[nodiscard]] [[nodiscard]]
ox::CStringView itemPath() const noexcept final; ox::CStringView itemPath() const noexcept final;

View File

@ -31,7 +31,7 @@ class FilePickerPopup {
[[nodiscard]] [[nodiscard]]
bool isOpen() const noexcept; bool isOpen() const noexcept;
ox::Optional<ox::String> draw(StudioContext &ctx) noexcept; ox::Optional<ox::String> draw(Context &ctx) noexcept;
}; };

View File

@ -32,7 +32,7 @@ class FileExplorer: public ox::SignalHandler {
m_kctx{kctx}, m_kctx{kctx},
m_fileDraggable{fileDraggable} {} m_fileDraggable{fileDraggable} {}
void draw(StudioContext &ctx, ImVec2 const &sz) const noexcept; void draw(Context &ctx, ImVec2 const &sz) const noexcept;
void setModel(ox::UPtr<FileTreeModel> &&model, bool selectRoot = false) noexcept; void setModel(ox::UPtr<FileTreeModel> &&model, bool selectRoot = false) noexcept;

View File

@ -272,7 +272,7 @@ bool ComboBox(
bool FileComboBox( bool FileComboBox(
ox::CStringViewCR lbl, ox::CStringViewCR lbl,
StudioContext &sctx, Context &sctx,
ox::StringViewCR fileExt, ox::StringViewCR fileExt,
size_t &selectedIdx) noexcept; size_t &selectedIdx) noexcept;
@ -295,7 +295,7 @@ bool ListBox(ox::CStringViewCR name, ox::SpanView<ox::String> const&list, size_t
class FilePicker { class FilePicker {
private: private:
bool m_show{}; bool m_show{};
StudioContext &m_sctx; Context &m_sctx;
ox::String const m_title; ox::String const m_title;
ox::String const m_fileExt; ox::String const m_fileExt;
ImVec2 const m_size; ImVec2 const m_size;
@ -303,7 +303,7 @@ class FilePicker {
ox::Signal<ox::Error(ox::StringView)> filePicked; ox::Signal<ox::Error(ox::StringView)> filePicked;
FilePicker( FilePicker(
studio::StudioContext &sctx, studio::Context &sctx,
ox::StringParam title, ox::StringParam title,
ox::StringParam fileExt, ox::StringParam fileExt,
ImVec2 const&size = {}) noexcept; ImVec2 const&size = {}) noexcept;
@ -348,7 +348,7 @@ class QuestionPopup: public Popup {
QuestionPopup(ox::StringParam title, ox::StringParam question) noexcept; QuestionPopup(ox::StringParam title, ox::StringParam question) noexcept;
void draw(StudioContext &ctx) noexcept override; void draw(Context &ctx) noexcept override;
}; };
@ -363,7 +363,7 @@ class MessagePopup: public Popup {
void show(ox::StringParam msg) noexcept; void show(ox::StringParam msg) noexcept;
void draw(StudioContext &ctx) noexcept override; void draw(Context &ctx) noexcept override;
}; };

View File

@ -162,7 +162,7 @@ class ItemMaker {
* @return path of file or error in Result * @return path of file or error in Result
*/ */
ox::Error write( ox::Error write(
StudioContext &ctx, Context &ctx,
ox::StringViewCR pPath, ox::StringViewCR pPath,
size_t pTemplateIdx) const noexcept { size_t pTemplateIdx) const noexcept {
return writeItem(ctx, pPath, pTemplateIdx); return writeItem(ctx, pPath, pTemplateIdx);
@ -177,7 +177,7 @@ class ItemMaker {
* @return path of file or error in Result * @return path of file or error in Result
*/ */
ox::Error write( ox::Error write(
StudioContext &ctx, Context &ctx,
ox::StringViewCR pPath, ox::StringViewCR pPath,
ox::StringViewCR pName, ox::StringViewCR pName,
size_t pTemplateIdx) const noexcept { size_t pTemplateIdx) const noexcept {
@ -187,7 +187,7 @@ class ItemMaker {
protected: protected:
virtual ox::Error writeItem( virtual ox::Error writeItem(
StudioContext &ctx, Context &ctx,
ox::StringViewCR pPath, ox::StringViewCR pPath,
size_t pTemplateIdx) const noexcept = 0; size_t pTemplateIdx) const noexcept = 0;
@ -249,7 +249,7 @@ class ItemMakerT final: public ItemMaker {
} }
ox::Error writeItem( ox::Error writeItem(
StudioContext &ctx, Context &ctx,
ox::StringViewCR pPath, ox::StringViewCR pPath,
size_t const pTemplateIdx) const noexcept override { size_t const pTemplateIdx) const noexcept override {
createUuidMapping(keelCtx(ctx.tctx), pPath, ox::UUID::generate().unwrap()); createUuidMapping(keelCtx(ctx.tctx), pPath, ox::UUID::generate().unwrap());

View File

@ -27,17 +27,17 @@ class Module {
public: public:
virtual ~Module() noexcept = default; virtual ~Module() noexcept = default;
virtual ox::Vector<EditorMaker> editors(studio::StudioContext &ctx) const; virtual ox::Vector<EditorMaker> editors(studio::Context &ctx) const;
virtual ox::Vector<ox::UPtr<ItemMaker>> itemMakers(studio::StudioContext&) const; virtual ox::Vector<ox::UPtr<ItemMaker>> itemMakers(studio::Context&) const;
virtual ox::Vector<ox::UPtr<ItemTemplate>> itemTemplates(studio::StudioContext&) const; virtual ox::Vector<ox::UPtr<ItemTemplate>> itemTemplates(studio::Context&) const;
}; };
template<typename Editor> template<typename Editor>
[[nodiscard]] [[nodiscard]]
EditorMaker editorMaker(StudioContext &ctx, ox::StringParam ext) noexcept { EditorMaker editorMaker(Context &ctx, ox::StringParam ext) noexcept {
return { return {
{std::move(ext)}, {std::move(ext)},
[&ctx](ox::StringViewCR path) -> ox::Result<BaseEditor*> { [&ctx](ox::StringViewCR path) -> ox::Result<BaseEditor*> {
@ -48,7 +48,7 @@ EditorMaker editorMaker(StudioContext &ctx, ox::StringParam ext) noexcept {
template<typename Editor> template<typename Editor>
[[nodiscard]] [[nodiscard]]
EditorMaker editorMaker(StudioContext &ctx, std::initializer_list<ox::StringView> exts) noexcept { EditorMaker editorMaker(Context &ctx, std::initializer_list<ox::StringView> exts) noexcept {
return { return {
[&exts] { [&exts] {
ox::Vector<ox::String> fileTypes; ox::Vector<ox::String> fileTypes;

View File

@ -15,7 +15,7 @@ namespace studio {
class Widget: public ox::SignalHandler { class Widget: public ox::SignalHandler {
public: public:
~Widget() noexcept override = default; ~Widget() noexcept override = default;
virtual void draw(StudioContext&) noexcept = 0; virtual void draw(Context&) noexcept = 0;
}; };
} }

View File

@ -109,7 +109,7 @@ UndoStack *BaseEditor::undoStack() noexcept {
void BaseEditor::navigateTo(ox::StringViewCR) noexcept {} void BaseEditor::navigateTo(ox::StringViewCR) noexcept {}
Editor::Editor(StudioContext &ctx, ox::StringParam itemPath) noexcept: Editor::Editor(Context &ctx, ox::StringParam itemPath) noexcept:
m_itemPath(std::move(itemPath)), m_itemPath(std::move(itemPath)),
m_itemName(m_itemPath.substr(std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset() + 1)) { m_itemName(m_itemPath.substr(std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset() + 1)) {
m_undoStack.changeTriggered.connect(this, &Editor::markUnsavedChanges); m_undoStack.changeTriggered.connect(this, &Editor::markUnsavedChanges);

View File

@ -52,7 +52,7 @@ bool FilePickerPopup::isOpen() const noexcept {
return m_open; return m_open;
} }
ox::Optional<ox::String> FilePickerPopup::draw(StudioContext &ctx) noexcept { ox::Optional<ox::String> FilePickerPopup::draw(Context &ctx) noexcept {
ox::Optional<ox::String> out; ox::Optional<ox::String> out;
if (!m_open) { if (!m_open) {
return out; return out;

View File

@ -11,7 +11,7 @@
namespace studio { namespace studio {
void FileExplorer::draw(StudioContext &ctx, ImVec2 const &sz) const noexcept { void FileExplorer::draw(Context &ctx, ImVec2 const &sz) const noexcept {
ImGui::BeginChild("ProjectExplorer", sz, true); ImGui::BeginChild("ProjectExplorer", sz, true);
ImGui::SetNextItemOpen(true); ImGui::SetNextItemOpen(true);
if (m_treeModel) { if (m_treeModel) {

View File

@ -169,7 +169,7 @@ bool ComboBox(
bool FileComboBox( bool FileComboBox(
ox::CStringViewCR lbl, ox::CStringViewCR lbl,
StudioContext &sctx, Context &sctx,
ox::StringViewCR fileExt, ox::StringViewCR fileExt,
size_t &selectedIdx) noexcept { size_t &selectedIdx) noexcept {
auto const&list = sctx.project->fileList(fileExt); auto const&list = sctx.project->fileList(fileExt);
@ -213,7 +213,7 @@ bool ListBox(ox::CStringViewCR name, ox::SpanView<ox::CStringView> const&list, s
FilePicker::FilePicker( FilePicker::FilePicker(
StudioContext &sctx, Context &sctx,
ox::StringParam title, ox::StringParam title,
ox::StringParam fileExt, ox::StringParam fileExt,
ImVec2 const&size) noexcept: ImVec2 const&size) noexcept:
@ -267,7 +267,7 @@ QuestionPopup::QuestionPopup(ox::StringParam title, ox::StringParam question) no
m_question{std::move(question)} { m_question{std::move(question)} {
} }
void QuestionPopup::draw(StudioContext &ctx) noexcept { void QuestionPopup::draw(Context &ctx) noexcept {
switch (m_stage) { switch (m_stage) {
case Stage::Closed: case Stage::Closed:
break; break;
@ -312,7 +312,7 @@ void MessagePopup::show(ox::StringParam msg) noexcept {
open(); open();
} }
void MessagePopup::draw(StudioContext &ctx) noexcept { void MessagePopup::draw(Context &ctx) noexcept {
switch (m_stage) { switch (m_stage) {
case Stage::Closed: case Stage::Closed:
break; break;

View File

@ -6,15 +6,15 @@
namespace studio { namespace studio {
ox::Vector<EditorMaker> Module::editors(StudioContext&) const { ox::Vector<EditorMaker> Module::editors(Context&) const {
return {}; return {};
} }
ox::Vector<ox::UPtr<ItemMaker>> Module::itemMakers(StudioContext&) const { ox::Vector<ox::UPtr<ItemMaker>> Module::itemMakers(Context&) const {
return {}; return {};
} }
ox::Vector<ox::UPtr<ItemTemplate>> Module::itemTemplates(StudioContext&) const { ox::Vector<ox::UPtr<ItemTemplate>> Module::itemTemplates(Context&) const {
return {}; return {};
} }