[studio] Cleanup
This commit is contained in:
parent
7cab133127
commit
aad4b8a44c
@ -2,6 +2,8 @@
|
|||||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <studio/imguiutil.hpp>
|
||||||
|
|
||||||
#include "makecopypopup.hpp"
|
#include "makecopypopup.hpp"
|
||||||
|
|
||||||
namespace studio {
|
namespace studio {
|
||||||
@ -26,7 +28,7 @@ bool MakeCopyPopup::isOpen() const noexcept {
|
|||||||
return m_open;
|
return m_open;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeCopyPopup::draw(StudioContext const &ctx) noexcept {
|
void MakeCopyPopup::draw(StudioContext &ctx) noexcept {
|
||||||
switch (m_stage) {
|
switch (m_stage) {
|
||||||
case Stage::Closed:
|
case Stage::Closed:
|
||||||
break;
|
break;
|
||||||
|
@ -7,11 +7,12 @@
|
|||||||
#include <ox/std/string.hpp>
|
#include <ox/std/string.hpp>
|
||||||
|
|
||||||
#include <studio/context.hpp>
|
#include <studio/context.hpp>
|
||||||
#include <studio/imguiutil.hpp>
|
|
||||||
|
#include <studio/widget.hpp>
|
||||||
|
|
||||||
namespace studio {
|
namespace studio {
|
||||||
|
|
||||||
class MakeCopyPopup {
|
class MakeCopyPopup: public Widget {
|
||||||
private:
|
private:
|
||||||
enum class Stage {
|
enum class Stage {
|
||||||
Closed,
|
Closed,
|
||||||
@ -36,7 +37,7 @@ class MakeCopyPopup {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool isOpen() const noexcept;
|
bool isOpen() const noexcept;
|
||||||
|
|
||||||
void draw(StudioContext const &ctx) noexcept;
|
void draw(StudioContext &ctx) noexcept override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void accept(StudioContext const &ctx) noexcept;
|
void accept(StudioContext const &ctx) noexcept;
|
||||||
|
@ -159,15 +159,9 @@ void StudioUI::draw() noexcept {
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
}
|
}
|
||||||
drawTabBar();
|
drawTabBar();
|
||||||
for (auto const&w : m_widgets) {
|
for (auto const w : m_widgets) {
|
||||||
w->draw(m_sctx);
|
w->draw(m_sctx);
|
||||||
}
|
}
|
||||||
for (auto const p : m_popups) {
|
|
||||||
p->draw(m_sctx);
|
|
||||||
}
|
|
||||||
m_closeAppConfirm.draw(m_sctx);
|
|
||||||
m_closeFileConfirm.draw(m_sctx);
|
|
||||||
m_copyFilePopup.draw(m_sctx);
|
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
handleKeyInput();
|
handleKeyInput();
|
||||||
@ -285,7 +279,6 @@ void StudioUI::drawTabs() noexcept {
|
|||||||
}
|
}
|
||||||
if (!open) {
|
if (!open) {
|
||||||
if (e->unsavedChanges()) {
|
if (e->unsavedChanges()) {
|
||||||
m_closeAppConfirm.open();
|
|
||||||
m_closeFileConfirm.open();
|
m_closeFileConfirm.open();
|
||||||
++it;
|
++it;
|
||||||
} else {
|
} else {
|
||||||
@ -403,7 +396,6 @@ void StudioUI::handleKeyInput() noexcept {
|
|||||||
} else if (ImGui::IsKeyPressed(ImGuiKey_W)) {
|
} else if (ImGui::IsKeyPressed(ImGuiKey_W)) {
|
||||||
if (m_activeEditor) {
|
if (m_activeEditor) {
|
||||||
if (m_activeEditor->unsavedChanges()) {
|
if (m_activeEditor->unsavedChanges()) {
|
||||||
m_closeAppConfirm.open();
|
|
||||||
m_closeFileConfirm.open();
|
m_closeFileConfirm.open();
|
||||||
} else {
|
} else {
|
||||||
oxLogError(closeCurrentFile());
|
oxLogError(closeCurrentFile());
|
||||||
|
@ -35,7 +35,6 @@ class StudioUI: public ox::SignalHandler {
|
|||||||
ox::UPtr<Project> m_project;
|
ox::UPtr<Project> m_project;
|
||||||
TaskRunner m_taskRunner;
|
TaskRunner m_taskRunner;
|
||||||
ox::Vector<ox::UPtr<BaseEditor>> m_editors;
|
ox::Vector<ox::UPtr<BaseEditor>> m_editors;
|
||||||
ox::Vector<ox::UPtr<Widget>> m_widgets;
|
|
||||||
ox::HashMap<ox::String, EditorMaker::Func> m_editorMakers;
|
ox::HashMap<ox::String, EditorMaker::Func> m_editorMakers;
|
||||||
ProjectExplorer m_projectExplorer;
|
ProjectExplorer m_projectExplorer;
|
||||||
ox::Vector<ox::String> m_openFiles;
|
ox::Vector<ox::String> m_openFiles;
|
||||||
@ -57,6 +56,17 @@ class StudioUI: public ox::SignalHandler {
|
|||||||
RenameFile m_renameFile;
|
RenameFile m_renameFile;
|
||||||
NewProject m_newProject;
|
NewProject m_newProject;
|
||||||
AboutPopup m_aboutPopup;
|
AboutPopup m_aboutPopup;
|
||||||
|
ox::Array<Widget*, 9> const m_widgets {
|
||||||
|
&m_closeFileConfirm,
|
||||||
|
&m_closeAppConfirm,
|
||||||
|
&m_copyFilePopup,
|
||||||
|
&m_newMenu,
|
||||||
|
&m_newProject,
|
||||||
|
&m_aboutPopup,
|
||||||
|
&m_deleteConfirmation,
|
||||||
|
&m_newDirDialog,
|
||||||
|
&m_renameFile,
|
||||||
|
};
|
||||||
ox::Array<Popup*, 6> const m_popups = {
|
ox::Array<Popup*, 6> const m_popups = {
|
||||||
&m_newMenu,
|
&m_newMenu,
|
||||||
&m_newProject,
|
&m_newProject,
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <turbine/context.hpp>
|
#include <turbine/context.hpp>
|
||||||
#include <studio/context.hpp>
|
#include <studio/context.hpp>
|
||||||
|
#include <studio/widget.hpp>
|
||||||
|
|
||||||
namespace studio::ig {
|
namespace studio::ig {
|
||||||
|
|
||||||
@ -303,7 +304,7 @@ class FilePicker {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class QuestionPopup {
|
class QuestionPopup: public Widget {
|
||||||
private:
|
private:
|
||||||
enum class Stage {
|
enum class Stage {
|
||||||
Closed,
|
Closed,
|
||||||
@ -316,7 +317,7 @@ class QuestionPopup {
|
|||||||
ox::String m_question;
|
ox::String m_question;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ox::Signal<ox::Error(ig::PopupResponse)> response;
|
ox::Signal<ox::Error(PopupResponse)> response;
|
||||||
|
|
||||||
QuestionPopup(ox::StringParam title, ox::StringParam question) noexcept;
|
QuestionPopup(ox::StringParam title, ox::StringParam question) noexcept;
|
||||||
|
|
||||||
@ -327,7 +328,7 @@ class QuestionPopup {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool isOpen() const noexcept;
|
bool isOpen() const noexcept;
|
||||||
|
|
||||||
void draw(StudioContext &ctx, ImVec2 const &sz = {}) noexcept;
|
void draw(StudioContext &ctx) noexcept;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,10 +12,12 @@
|
|||||||
|
|
||||||
#include <turbine/context.hpp>
|
#include <turbine/context.hpp>
|
||||||
|
|
||||||
|
#include "widget.hpp"
|
||||||
|
|
||||||
namespace studio {
|
namespace studio {
|
||||||
|
|
||||||
|
|
||||||
class Popup {
|
class Popup: public Widget {
|
||||||
private:
|
private:
|
||||||
ox::Vec2 m_size;
|
ox::Vec2 m_size;
|
||||||
ox::String m_title;
|
ox::String m_title;
|
||||||
@ -32,8 +34,6 @@ class Popup {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
virtual bool isOpen() const noexcept = 0;
|
virtual bool isOpen() const 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 {
|
||||||
m_size = {static_cast<float>(sz.width), static_cast<float>(sz.height)};
|
m_size = {static_cast<float>(sz.width), static_cast<float>(sz.height)};
|
||||||
|
@ -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(studio::StudioContext&) noexcept = 0;
|
virtual void draw(StudioContext&) noexcept = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ bool QuestionPopup::isOpen() const noexcept {
|
|||||||
return m_open;
|
return m_open;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuestionPopup::draw(StudioContext &ctx, ImVec2 const &sz) noexcept {
|
void QuestionPopup::draw(StudioContext &ctx) noexcept {
|
||||||
switch (m_stage) {
|
switch (m_stage) {
|
||||||
case Stage::Closed:
|
case Stage::Closed:
|
||||||
break;
|
break;
|
||||||
@ -255,7 +255,7 @@ void QuestionPopup::draw(StudioContext &ctx, ImVec2 const &sz) noexcept {
|
|||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case Stage::Open:
|
case Stage::Open:
|
||||||
centerNextWindow(ctx.tctx);
|
centerNextWindow(ctx.tctx);
|
||||||
ImGui::SetNextWindowSize(static_cast<ImVec2>(sz));
|
ImGui::SetNextWindowSize({});
|
||||||
constexpr auto modalFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
constexpr auto modalFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
||||||
if (ImGui::BeginPopupModal(m_title.c_str(), &m_open, modalFlags)) {
|
if (ImGui::BeginPopupModal(m_title.c_str(), &m_open, modalFlags)) {
|
||||||
ImGui::Text("%s", m_question.c_str());
|
ImGui::Text("%s", m_question.c_str());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user