[nostalgia,olympic] Further reduce use of applicationData
This commit is contained in:
parent
a4f0c7cdb5
commit
27f1df8f33
@ -42,7 +42,7 @@ void PaletteEditorImGui::keyStateChanged(turbine::Key key, bool down) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaletteEditorImGui::draw(turbine::Context&) noexcept {
|
void PaletteEditorImGui::draw(studio::StudioContext&) noexcept {
|
||||||
auto const paneSize = ImGui::GetContentRegionAvail();
|
auto const paneSize = ImGui::GetContentRegionAvail();
|
||||||
{
|
{
|
||||||
ImGui::BeginChild("Pages", ImVec2(250, paneSize.y), true);
|
ImGui::BeginChild("Pages", ImVec2(250, paneSize.y), true);
|
||||||
|
@ -25,7 +25,7 @@ class PaletteEditorImGui: public studio::Editor {
|
|||||||
|
|
||||||
void keyStateChanged(turbine::Key key, bool down) override;
|
void keyStateChanged(turbine::Key key, bool down) override;
|
||||||
|
|
||||||
void draw(turbine::Context&) noexcept final;
|
void draw(studio::StudioContext&) noexcept final;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ox::Error saveItem() noexcept final;
|
ox::Error saveItem() noexcept final;
|
||||||
|
@ -157,7 +157,7 @@ void TileSheetEditorImGui::keyStateChanged(turbine::Key key, bool down) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetEditorImGui::draw(turbine::Context&) noexcept {
|
void TileSheetEditorImGui::draw(studio::StudioContext&) noexcept {
|
||||||
auto const paneSize = ImGui::GetContentRegionAvail();
|
auto const paneSize = ImGui::GetContentRegionAvail();
|
||||||
auto const tileSheetParentSize = ImVec2(paneSize.x - m_palViewWidth, paneSize.y);
|
auto const tileSheetParentSize = ImVec2(paneSize.x - m_palViewWidth, paneSize.y);
|
||||||
auto const fbSize = ox::Vec2(tileSheetParentSize.x - 16, tileSheetParentSize.y - 16);
|
auto const fbSize = ox::Vec2(tileSheetParentSize.x - 16, tileSheetParentSize.y - 16);
|
||||||
@ -237,7 +237,7 @@ void TileSheetEditorImGui::draw(turbine::Context&) noexcept {
|
|||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
m_subsheetEditor.draw(m_tctx);
|
m_subsheetEditor.draw(m_tctx);
|
||||||
m_exportMenu.draw(m_tctx);
|
m_exportMenu.draw(m_sctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetEditorImGui::drawSubsheetSelector(
|
void TileSheetEditorImGui::drawSubsheetSelector(
|
||||||
@ -481,7 +481,7 @@ ox::Error TileSheetEditorImGui::markUnsavedChanges(studio::UndoCommand const*) n
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetEditorImGui::SubSheetEditor::draw(turbine::Context &ctx) noexcept {
|
void TileSheetEditorImGui::SubSheetEditor::draw(turbine::Context &sctx) noexcept {
|
||||||
constexpr auto popupName = "Edit Subsheet";
|
constexpr auto popupName = "Edit Subsheet";
|
||||||
if (!m_show) {
|
if (!m_show) {
|
||||||
return;
|
return;
|
||||||
@ -490,7 +490,7 @@ void TileSheetEditorImGui::SubSheetEditor::draw(turbine::Context &ctx) noexcept
|
|||||||
auto constexpr popupWidth = 235.f;
|
auto constexpr popupWidth = 235.f;
|
||||||
auto const popupHeight = modSize ? 130.f : 85.f;
|
auto const popupHeight = modSize ? 130.f : 85.f;
|
||||||
auto const popupSz = ImVec2(popupWidth, popupHeight);
|
auto const popupSz = ImVec2(popupWidth, popupHeight);
|
||||||
if (ig::BeginPopup(ctx, popupName, m_show, popupSz)) {
|
if (ig::BeginPopup(sctx, popupName, m_show, popupSz)) {
|
||||||
ImGui::InputText("Name", m_name.data(), m_name.cap());
|
ImGui::InputText("Name", m_name.data(), m_name.cap());
|
||||||
if (modSize) {
|
if (modSize) {
|
||||||
ImGui::InputInt("Columns", &m_cols);
|
ImGui::InputInt("Columns", &m_cols);
|
||||||
@ -507,7 +507,7 @@ void TileSheetEditorImGui::SubSheetEditor::close() noexcept {
|
|||||||
m_show = false;
|
m_show = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetEditorImGui::ExportMenu::draw(turbine::Context &ctx) noexcept {
|
void TileSheetEditorImGui::ExportMenu::draw(studio::StudioContext &sctx) noexcept {
|
||||||
constexpr auto popupName = "Export Tile Sheet";
|
constexpr auto popupName = "Export Tile Sheet";
|
||||||
if (!m_show) {
|
if (!m_show) {
|
||||||
return;
|
return;
|
||||||
@ -515,7 +515,7 @@ void TileSheetEditorImGui::ExportMenu::draw(turbine::Context &ctx) noexcept {
|
|||||||
constexpr auto popupWidth = 235.f;
|
constexpr auto popupWidth = 235.f;
|
||||||
constexpr auto popupHeight = 85.f;
|
constexpr auto popupHeight = 85.f;
|
||||||
constexpr auto popupSz = ImVec2(popupWidth, popupHeight);
|
constexpr auto popupSz = ImVec2(popupWidth, popupHeight);
|
||||||
if (ig::BeginPopup(ctx, popupName, m_show, popupSz)) {
|
if (ig::BeginPopup(sctx.tctx, popupName, m_show, popupSz)) {
|
||||||
ImGui::InputInt("Scale", &m_scale);
|
ImGui::InputInt("Scale", &m_scale);
|
||||||
m_scale = ox::clamp(m_scale, 1, 50);
|
m_scale = ox::clamp(m_scale, 1, 50);
|
||||||
if (ig::PopupControlsOkCancel(popupWidth, m_show) == ig::PopupResponse::OK) {
|
if (ig::PopupControlsOkCancel(popupWidth, m_show) == ig::PopupResponse::OK) {
|
||||||
|
@ -40,7 +40,7 @@ class TileSheetEditorImGui: public studio::Editor {
|
|||||||
m_cols = cols;
|
m_cols = cols;
|
||||||
m_rows = rows;
|
m_rows = rows;
|
||||||
}
|
}
|
||||||
void draw(turbine::Context &ctx) noexcept;
|
void draw(turbine::Context &sctx) noexcept;
|
||||||
void close() noexcept;
|
void close() noexcept;
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
inline bool isOpen() const noexcept { return m_show; }
|
inline bool isOpen() const noexcept { return m_show; }
|
||||||
@ -55,7 +55,7 @@ class TileSheetEditorImGui: public studio::Editor {
|
|||||||
m_show = true;
|
m_show = true;
|
||||||
m_scale = 5;
|
m_scale = 5;
|
||||||
}
|
}
|
||||||
void draw(turbine::Context &ctx) noexcept;
|
void draw(studio::StudioContext &sctx) noexcept;
|
||||||
void close() noexcept;
|
void close() noexcept;
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
inline bool isOpen() const noexcept { return m_show; }
|
inline bool isOpen() const noexcept { return m_show; }
|
||||||
@ -88,7 +88,7 @@ class TileSheetEditorImGui: public studio::Editor {
|
|||||||
|
|
||||||
void keyStateChanged(turbine::Key key, bool down) override;
|
void keyStateChanged(turbine::Key key, bool down) override;
|
||||||
|
|
||||||
void draw(turbine::Context&) noexcept override;
|
void draw(studio::StudioContext&) noexcept override;
|
||||||
|
|
||||||
void drawSubsheetSelector(TileSheet::SubSheet&, TileSheet::SubSheetIdx &path);
|
void drawSubsheetSelector(TileSheet::SubSheet&, TileSheet::SubSheetIdx &path);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ SceneEditorImGui::SceneEditorImGui(studio::StudioContext &ctx, ox::StringView pa
|
|||||||
setRequiresConstantRefresh(false);
|
setRequiresConstantRefresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneEditorImGui::draw(turbine::Context&) noexcept {
|
void SceneEditorImGui::draw(studio::StudioContext&) noexcept {
|
||||||
auto const paneSize = ImGui::GetContentRegionAvail();
|
auto const paneSize = ImGui::GetContentRegionAvail();
|
||||||
m_view.draw(ox::Size{static_cast<int>(paneSize.x), static_cast<int>(paneSize.y)});
|
m_view.draw(ox::Size{static_cast<int>(paneSize.x), static_cast<int>(paneSize.y)});
|
||||||
auto &fb = m_view.framebuffer();
|
auto &fb = m_view.framebuffer();
|
||||||
|
@ -23,7 +23,7 @@ class SceneEditorImGui: public studio::Editor {
|
|||||||
public:
|
public:
|
||||||
SceneEditorImGui(studio::StudioContext &ctx, ox::StringView path);
|
SceneEditorImGui(studio::StudioContext &ctx, ox::StringView path);
|
||||||
|
|
||||||
void draw(turbine::Context&) noexcept final;
|
void draw(studio::StudioContext&) noexcept final;
|
||||||
|
|
||||||
void onActivated() noexcept override;
|
void onActivated() noexcept override;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ bool AboutPopup::isOpen() const noexcept {
|
|||||||
return m_stage == Stage::Open;
|
return m_stage == Stage::Open;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutPopup::draw(turbine::Context &ctx) noexcept {
|
void AboutPopup::draw(studio::StudioContext &sctx) noexcept {
|
||||||
switch (m_stage) {
|
switch (m_stage) {
|
||||||
case Stage::Closed:
|
case Stage::Closed:
|
||||||
break;
|
break;
|
||||||
@ -41,7 +41,7 @@ void AboutPopup::draw(turbine::Context &ctx) noexcept {
|
|||||||
constexpr auto modalFlags =
|
constexpr auto modalFlags =
|
||||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
||||||
ImGui::SetNextWindowSize(ImVec2(215, 90));
|
ImGui::SetNextWindowSize(ImVec2(215, 90));
|
||||||
studio::ig::centerNextWindow(ctx);
|
studio::ig::centerNextWindow(sctx.tctx);
|
||||||
auto open = true;
|
auto open = true;
|
||||||
if (ImGui::BeginPopupModal("About", &open, modalFlags)) {
|
if (ImGui::BeginPopupModal("About", &open, modalFlags)) {
|
||||||
ImGui::Text("%s", m_text.c_str());
|
ImGui::Text("%s", m_text.c_str());
|
||||||
|
@ -35,7 +35,7 @@ class AboutPopup: public studio::Popup {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool isOpen() const noexcept override;
|
bool isOpen() const noexcept override;
|
||||||
|
|
||||||
void draw(turbine::Context &ctx) noexcept override;
|
void draw(studio::StudioContext &sctx) noexcept override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ ClawEditor::ClawEditor(ox::CRStringView path, ox::ModelObject obj) noexcept:
|
|||||||
m_obj(std::move(obj)) {
|
m_obj(std::move(obj)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClawEditor::draw(turbine::Context&) noexcept {
|
void ClawEditor::draw(studio::StudioContext&) 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)) {
|
||||||
|
@ -18,7 +18,7 @@ class ClawEditor: public studio::Editor {
|
|||||||
public:
|
public:
|
||||||
ClawEditor(ox::CRStringView path, ox::ModelObject obj) noexcept;
|
ClawEditor(ox::CRStringView path, ox::ModelObject obj) noexcept;
|
||||||
|
|
||||||
void draw(turbine::Context&) noexcept final;
|
void draw(studio::StudioContext&) noexcept final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void drawRow(ox::ModelValue const&value) noexcept;
|
static void drawRow(ox::ModelValue const&value) noexcept;
|
||||||
|
@ -33,7 +33,7 @@ bool NewMenu::isOpen() const noexcept {
|
|||||||
return m_open;
|
return m_open;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewMenu::draw(turbine::Context &ctx) noexcept {
|
void NewMenu::draw(studio::StudioContext &sctx) noexcept {
|
||||||
switch (m_stage) {
|
switch (m_stage) {
|
||||||
case Stage::Opening:
|
case Stage::Opening:
|
||||||
ImGui::OpenPopup(title().c_str());
|
ImGui::OpenPopup(title().c_str());
|
||||||
@ -41,10 +41,10 @@ void NewMenu::draw(turbine::Context &ctx) noexcept {
|
|||||||
m_open = true;
|
m_open = true;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case Stage::NewItemType:
|
case Stage::NewItemType:
|
||||||
drawNewItemType(ctx);
|
drawNewItemType(sctx);
|
||||||
break;
|
break;
|
||||||
case Stage::NewItemName:
|
case Stage::NewItemName:
|
||||||
drawNewItemName(ctx);
|
drawNewItemName(sctx);
|
||||||
break;
|
break;
|
||||||
case Stage::Closed:
|
case Stage::Closed:
|
||||||
m_open = false;
|
m_open = false;
|
||||||
@ -61,8 +61,8 @@ void NewMenu::addItemMaker(ox::UniquePtr<studio::ItemMaker> &&im) noexcept {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewMenu::drawNewItemType(turbine::Context &ctx) noexcept {
|
void NewMenu::drawNewItemType(studio::StudioContext &sctx) noexcept {
|
||||||
drawWindow(ctx, &m_open, [this] {
|
drawWindow(sctx.tctx, &m_open, [this] {
|
||||||
auto items = ox_malloca(m_types.size() * sizeof(char const*), char const*, nullptr);
|
auto items = ox_malloca(m_types.size() * sizeof(char const*), char const*, nullptr);
|
||||||
for (auto i = 0u; auto const&im : m_types) {
|
for (auto i = 0u; auto const&im : m_types) {
|
||||||
items.get()[i] = im->typeName.c_str();
|
items.get()[i] = im->typeName.c_str();
|
||||||
@ -73,13 +73,13 @@ void NewMenu::drawNewItemType(turbine::Context &ctx) noexcept {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewMenu::drawNewItemName(turbine::Context &ctx) noexcept {
|
void NewMenu::drawNewItemName(studio::StudioContext &sctx) noexcept {
|
||||||
drawWindow(ctx, &m_open, [this, &ctx] {
|
drawWindow(sctx.tctx, &m_open, [this, &sctx] {
|
||||||
auto const typeIdx = static_cast<std::size_t>(m_selectedType);
|
auto const typeIdx = static_cast<std::size_t>(m_selectedType);
|
||||||
if (typeIdx < m_types.size()) {
|
if (typeIdx < m_types.size()) {
|
||||||
ImGui::InputText("Name", m_itemName.data(), m_itemName.cap());
|
ImGui::InputText("Name", m_itemName.data(), m_itemName.cap());
|
||||||
}
|
}
|
||||||
drawLastPageButtons(ctx);
|
drawLastPageButtons(sctx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ void NewMenu::drawFirstPageButtons() noexcept {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewMenu::drawLastPageButtons(turbine::Context &ctx) noexcept {
|
void NewMenu::drawLastPageButtons(studio::StudioContext &sctx) noexcept {
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 138);
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 138);
|
||||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetContentRegionAvail().y - 20);
|
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetContentRegionAvail().y - 20);
|
||||||
if (ImGui::Button("Back")) {
|
if (ImGui::Button("Back")) {
|
||||||
@ -105,7 +105,7 @@ void NewMenu::drawLastPageButtons(turbine::Context &ctx) noexcept {
|
|||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Finish")) {
|
if (ImGui::Button("Finish")) {
|
||||||
finish(ctx);
|
finish(sctx);
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Quit")) {
|
if (ImGui::Button("Quit")) {
|
||||||
@ -114,17 +114,16 @@ void NewMenu::drawLastPageButtons(turbine::Context &ctx) noexcept {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewMenu::finish(turbine::Context &ctx) noexcept {
|
void NewMenu::finish(studio::StudioContext &sctx) noexcept {
|
||||||
if (m_itemName.len() == 0) {
|
if (m_itemName.len() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto const sctx = turbine::applicationData<studio::StudioContext>(ctx);
|
|
||||||
auto const&typeMaker = *m_types[static_cast<std::size_t>(m_selectedType)];
|
auto const&typeMaker = *m_types[static_cast<std::size_t>(m_selectedType)];
|
||||||
if (sctx->project->exists(typeMaker.itemPath(m_itemName))) {
|
if (sctx.project->exists(typeMaker.itemPath(m_itemName))) {
|
||||||
oxLogError(OxError(1, "New file error: File already exists"));
|
oxLogError(OxError(1, "New file error: File already exists"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto const [path, err] = typeMaker.write(ctx, m_itemName);
|
auto const [path, err] = typeMaker.write(sctx, m_itemName);
|
||||||
if (err) {
|
if (err) {
|
||||||
oxLogError(err);
|
oxLogError(err);
|
||||||
return;
|
return;
|
||||||
|
@ -43,7 +43,7 @@ class NewMenu: public studio::Popup {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool isOpen() const noexcept override;
|
bool isOpen() const noexcept override;
|
||||||
|
|
||||||
void draw(turbine::Context &ctx) noexcept override;
|
void draw(studio::StudioContext &sctx) noexcept override;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void addItemType(ox::String name, ox::String parentDir, ox::String fileExt, T itemTempl, ox::ClawFormat pFmt = ox::ClawFormat::Metal) noexcept;
|
void addItemType(ox::String name, ox::String parentDir, ox::String fileExt, T itemTempl, ox::ClawFormat pFmt = ox::ClawFormat::Metal) noexcept;
|
||||||
@ -54,15 +54,15 @@ class NewMenu: public studio::Popup {
|
|||||||
void addItemMaker(ox::UniquePtr<studio::ItemMaker> &&im) noexcept;
|
void addItemMaker(ox::UniquePtr<studio::ItemMaker> &&im) noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void drawNewItemType(turbine::Context &ctx) noexcept;
|
void drawNewItemType(studio::StudioContext &sctx) noexcept;
|
||||||
|
|
||||||
void drawNewItemName(turbine::Context &ctx) noexcept;
|
void drawNewItemName(studio::StudioContext &sctx) noexcept;
|
||||||
|
|
||||||
void drawFirstPageButtons() noexcept;
|
void drawFirstPageButtons() noexcept;
|
||||||
|
|
||||||
void drawLastPageButtons(turbine::Context &ctx) noexcept;
|
void drawLastPageButtons(studio::StudioContext &sctx) noexcept;
|
||||||
|
|
||||||
void finish(turbine::Context &ctx) noexcept;
|
void finish(studio::StudioContext &sctx) noexcept;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ bool NewProject::isOpen() const noexcept {
|
|||||||
return m_open;
|
return m_open;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewProject::draw(turbine::Context &ctx) noexcept {
|
void NewProject::draw(studio::StudioContext &ctx) noexcept {
|
||||||
switch (m_stage) {
|
switch (m_stage) {
|
||||||
case Stage::Opening:
|
case Stage::Opening:
|
||||||
ImGui::OpenPopup(title().c_str());
|
ImGui::OpenPopup(title().c_str());
|
||||||
@ -48,14 +48,14 @@ void NewProject::draw(turbine::Context &ctx) noexcept {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewProject::drawNewProjectName(turbine::Context &ctx) noexcept {
|
void NewProject::drawNewProjectName(studio::StudioContext &sctx) noexcept {
|
||||||
drawWindow(ctx, &m_open, [this, &ctx] {
|
drawWindow(sctx.tctx, &m_open, [this, &sctx] {
|
||||||
ImGui::InputText("Name", m_projectName.data(), m_projectName.cap());
|
ImGui::InputText("Name", m_projectName.data(), m_projectName.cap());
|
||||||
ImGui::Text("Path: %s", m_projectPath.c_str());
|
ImGui::Text("Path: %s", m_projectPath.c_str());
|
||||||
if (ImGui::Button("Browse")) {
|
if (ImGui::Button("Browse")) {
|
||||||
oxLogError(studio::chooseDirectory().moveTo(m_projectPath));
|
oxLogError(studio::chooseDirectory().moveTo(m_projectPath));
|
||||||
}
|
}
|
||||||
drawLastPageButtons(ctx);
|
drawLastPageButtons(sctx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ void NewProject::drawFirstPageButtons() noexcept {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewProject::drawLastPageButtons(turbine::Context&) noexcept {
|
void NewProject::drawLastPageButtons(studio::StudioContext&) noexcept {
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 95);
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 95);
|
||||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetContentRegionAvail().y - 20);
|
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetContentRegionAvail().y - 20);
|
||||||
if (ImGui::Button("Finish")) {
|
if (ImGui::Button("Finish")) {
|
||||||
|
@ -42,14 +42,14 @@ class NewProject: public studio::Popup {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool isOpen() const noexcept override;
|
bool isOpen() const noexcept override;
|
||||||
|
|
||||||
void draw(turbine::Context &ctx) noexcept override;
|
void draw(studio::StudioContext &ctx) noexcept override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void drawNewProjectName(turbine::Context &ctx) noexcept;
|
void drawNewProjectName(studio::StudioContext &ctx) noexcept;
|
||||||
|
|
||||||
void drawFirstPageButtons() noexcept;
|
void drawFirstPageButtons() noexcept;
|
||||||
|
|
||||||
void drawLastPageButtons(turbine::Context &ctx) noexcept;
|
void drawLastPageButtons(studio::StudioContext &ctx) noexcept;
|
||||||
|
|
||||||
void finish() noexcept;
|
void finish() noexcept;
|
||||||
|
|
||||||
|
@ -37,12 +37,12 @@ static ox::Result<ox::UniquePtr<ProjectTreeModel>> buildProjectTreeModel(
|
|||||||
ProjectExplorer::ProjectExplorer(turbine::Context &ctx) noexcept: m_ctx(ctx) {
|
ProjectExplorer::ProjectExplorer(turbine::Context &ctx) noexcept: m_ctx(ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectExplorer::draw(turbine::Context &ctx) noexcept {
|
void ProjectExplorer::draw(studio::StudioContext &ctx) noexcept {
|
||||||
auto const viewport = ImGui::GetContentRegionAvail();
|
auto const viewport = ImGui::GetContentRegionAvail();
|
||||||
ImGui::BeginChild("ProjectExplorer", ImVec2(300, viewport.y), true);
|
ImGui::BeginChild("ProjectExplorer", ImVec2(300, viewport.y), true);
|
||||||
ImGui::SetNextItemOpen(true);
|
ImGui::SetNextItemOpen(true);
|
||||||
if (m_treeModel) {
|
if (m_treeModel) {
|
||||||
m_treeModel->draw(ctx);
|
m_treeModel->draw(ctx.tctx);
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ class ProjectExplorer: public studio::Widget {
|
|||||||
public:
|
public:
|
||||||
explicit ProjectExplorer(turbine::Context &ctx) noexcept;
|
explicit ProjectExplorer(turbine::Context &ctx) noexcept;
|
||||||
|
|
||||||
void draw(turbine::Context &ctx) noexcept override;
|
void draw(studio::StudioContext &ctx) noexcept override;
|
||||||
|
|
||||||
void setModel(ox::UPtr<ProjectTreeModel> &&model) noexcept;
|
void setModel(ox::UPtr<ProjectTreeModel> &&model) noexcept;
|
||||||
|
|
||||||
|
@ -159,15 +159,15 @@ void StudioUI::draw() noexcept {
|
|||||||
ImGui::Begin("MainWindow##Studio", nullptr, windowFlags);
|
ImGui::Begin("MainWindow##Studio", nullptr, windowFlags);
|
||||||
{
|
{
|
||||||
if (m_showProjectExplorer) {
|
if (m_showProjectExplorer) {
|
||||||
m_projectExplorer.draw(m_ctx);
|
m_projectExplorer.draw(m_sctx);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
}
|
}
|
||||||
drawTabBar();
|
drawTabBar();
|
||||||
for (auto &w: m_widgets) {
|
for (auto &w: m_widgets) {
|
||||||
w->draw(m_ctx);
|
w->draw(m_sctx);
|
||||||
}
|
}
|
||||||
for (auto p: m_popups) {
|
for (auto p: m_popups) {
|
||||||
p->draw(m_ctx);
|
p->draw(m_sctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
@ -261,7 +261,7 @@ void StudioUI::drawTabs() noexcept {
|
|||||||
m_activeEditor->onActivated();
|
m_activeEditor->onActivated();
|
||||||
turbine::setConstantRefresh(m_ctx, m_activeEditor->requiresConstantRefresh());
|
turbine::setConstantRefresh(m_ctx, m_activeEditor->requiresConstantRefresh());
|
||||||
}
|
}
|
||||||
e->draw(m_ctx);
|
e->draw(m_sctx);
|
||||||
m_activeEditorOnLastDraw = e.get();
|
m_activeEditorOnLastDraw = e.get();
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,8 @@ class ItemMaker {
|
|||||||
ox::String const typeName;
|
ox::String const typeName;
|
||||||
ox::String const parentDir;
|
ox::String const parentDir;
|
||||||
ox::String const fileExt;
|
ox::String const fileExt;
|
||||||
constexpr explicit ItemMaker(ox::StringView pName, ox::StringView pParentDir, ox::CRStringView pFileExt) noexcept:
|
constexpr explicit ItemMaker(
|
||||||
|
ox::StringView pName, ox::StringView pParentDir, ox::CRStringView pFileExt) noexcept:
|
||||||
typeName(pName),
|
typeName(pName),
|
||||||
parentDir(pParentDir),
|
parentDir(pParentDir),
|
||||||
fileExt(pFileExt) {
|
fileExt(pFileExt) {
|
||||||
@ -36,7 +37,8 @@ class ItemMaker {
|
|||||||
* @param pName
|
* @param pName
|
||||||
* @return path of file or error in Result
|
* @return path of file or error in Result
|
||||||
*/
|
*/
|
||||||
virtual ox::Result<ox::String> write(turbine::Context &ctx, ox::CRStringView pName) const noexcept = 0;
|
virtual ox::Result<ox::String> write(
|
||||||
|
studio::StudioContext &ctx, ox::CRStringView pName) const noexcept = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -73,11 +75,10 @@ class ItemMakerT: public ItemMaker {
|
|||||||
m_item(std::move(pItem)),
|
m_item(std::move(pItem)),
|
||||||
m_fmt(pFmt) {
|
m_fmt(pFmt) {
|
||||||
}
|
}
|
||||||
ox::Result<ox::String> write(turbine::Context &ctx, ox::CRStringView pName) const noexcept override {
|
ox::Result<ox::String> write(studio::StudioContext &sctx, ox::CRStringView pName) const noexcept override {
|
||||||
auto const path = itemPath(pName);
|
auto const path = itemPath(pName);
|
||||||
auto const sctx = turbine::applicationData<studio::StudioContext>(ctx);
|
keel::createUuidMapping(keelCtx(sctx.tctx), path, ox::UUID::generate().unwrap());
|
||||||
keel::createUuidMapping(keelCtx(ctx), path, ox::UUID::generate().unwrap());
|
oxReturnError(sctx.project->writeObj(path, m_item, m_fmt));
|
||||||
oxReturnError(sctx->project->writeObj(path, m_item, m_fmt));
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -32,7 +32,7 @@ class Popup {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
virtual bool isOpen() const noexcept = 0;
|
virtual bool isOpen() const noexcept = 0;
|
||||||
|
|
||||||
virtual void draw(turbine::Context &ctx) noexcept = 0;
|
virtual void draw(studio::StudioContext &ctx) noexcept = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
constexpr void setSize(ox::Size sz) noexcept {
|
constexpr void setSize(ox::Size sz) noexcept {
|
||||||
|
@ -8,12 +8,14 @@
|
|||||||
|
|
||||||
#include <turbine/context.hpp>
|
#include <turbine/context.hpp>
|
||||||
|
|
||||||
|
#include "context.hpp"
|
||||||
|
|
||||||
namespace studio {
|
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(turbine::Context&) noexcept = 0;
|
virtual void draw(studio::StudioContext&) noexcept = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user