Compare commits
4 Commits
04f3d6b491
...
05d08a7687
Author | SHA1 | Date | |
---|---|---|---|
05d08a7687 | |||
c6750d50fc | |||
dade484d87 | |||
b015fe88b7 |
4
deps/ox/src/ox/std/ranges.hpp
vendored
4
deps/ox/src/ox/std/ranges.hpp
vendored
@ -11,7 +11,7 @@
|
||||
namespace ox {
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool all_of(auto begin, auto end, auto pred) noexcept {
|
||||
constexpr bool all_of(auto begin, auto end, auto const&pred) noexcept {
|
||||
while (begin != end) {
|
||||
if (!pred(*begin)) {
|
||||
return false;
|
||||
@ -22,7 +22,7 @@ constexpr bool all_of(auto begin, auto end, auto pred) noexcept {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool any_of(auto begin, auto end, auto pred) noexcept {
|
||||
constexpr bool any_of(auto begin, auto end, auto const&pred) noexcept {
|
||||
while (begin != end) {
|
||||
if (pred(*begin)) {
|
||||
return true;
|
||||
|
@ -30,13 +30,13 @@ class StudioUIDrawer: public turbine::gl::Drawer {
|
||||
|
||||
static int updateHandler(turbine::Context &ctx) noexcept {
|
||||
auto sctx = turbine::applicationData<studio::StudioContext>(ctx);
|
||||
sctx->ui->update();
|
||||
sctx->ui.update();
|
||||
return 16;
|
||||
}
|
||||
|
||||
static void keyEventHandler(turbine::Context &ctx, turbine::Key key, bool down) noexcept {
|
||||
auto sctx = turbine::applicationData<studio::StudioContext>(ctx);
|
||||
sctx->ui->handleKeyEvent(key, down);
|
||||
sctx->ui.handleKeyEvent(key, down);
|
||||
}
|
||||
|
||||
static ox::Error runApp(
|
||||
@ -48,10 +48,7 @@ static ox::Error runApp(
|
||||
turbine::setUpdateHandler(*ctx, updateHandler);
|
||||
turbine::setKeyEventHandler(*ctx, keyEventHandler);
|
||||
turbine::setConstantRefresh(*ctx, false);
|
||||
studio::StudioContext studioCtx(*ctx);
|
||||
turbine::setApplicationData(*ctx, &studioCtx);
|
||||
StudioUI ui(studioCtx, projectDataDir);
|
||||
studioCtx.ui = &ui;
|
||||
StudioUI ui(*ctx, projectDataDir);
|
||||
StudioUIDrawer drawer(ui);
|
||||
turbine::gl::addDrawer(*ctx, &drawer);
|
||||
auto const err = turbine::run(*ctx);
|
||||
|
@ -10,8 +10,11 @@
|
||||
|
||||
namespace studio {
|
||||
|
||||
static ox::Result<ox::UniquePtr<ProjectTreeModel>>
|
||||
buildProjectTreeModel(ProjectExplorer &explorer, ox::StringView name, ox::CRStringView path, ProjectTreeModel *parent) noexcept {
|
||||
static ox::Result<ox::UniquePtr<ProjectTreeModel>> buildProjectTreeModel(
|
||||
ProjectExplorer &explorer,
|
||||
ox::StringView name,
|
||||
ox::StringView path,
|
||||
ProjectTreeModel *parent) noexcept {
|
||||
auto const fs = explorer.romFs();
|
||||
oxRequire(stat, fs->stat(path));
|
||||
auto out = ox::make_unique<ProjectTreeModel>(explorer, ox::String(name), parent);
|
||||
|
@ -40,13 +40,14 @@ oxModelBegin(StudioConfig)
|
||||
oxModelFieldRename(showProjectExplorer, show_project_explorer)
|
||||
oxModelEnd()
|
||||
|
||||
StudioUI::StudioUI(studio::StudioContext &ctx, ox::StringView projectDataDir) noexcept:
|
||||
m_sctx(ctx),
|
||||
m_ctx(ctx.tctx),
|
||||
StudioUI::StudioUI(turbine::Context &ctx, ox::StringView projectDataDir) noexcept:
|
||||
m_sctx(*this, ctx),
|
||||
m_ctx(ctx),
|
||||
m_projectDataDir(projectDataDir),
|
||||
m_projectExplorer(m_ctx),
|
||||
m_newProject(ox::String(projectDataDir)),
|
||||
m_aboutPopup(m_ctx) {
|
||||
turbine::setApplicationData(m_ctx, &m_sctx);
|
||||
m_projectExplorer.fileChosen.connect(this, &StudioUI::openFile);
|
||||
m_newProject.finished.connect(this, &StudioUI::createOpenProject);
|
||||
m_newMenu.finished.connect(this, &StudioUI::openFile);
|
||||
|
@ -24,7 +24,7 @@ class StudioUI: public ox::SignalHandler {
|
||||
friend class StudioUIDrawer;
|
||||
|
||||
private:
|
||||
studio::StudioContext &m_sctx;
|
||||
studio::StudioContext m_sctx;
|
||||
turbine::Context &m_ctx;
|
||||
ox::String m_projectDataDir;
|
||||
ox::UPtr<studio::Project> m_project;
|
||||
@ -48,7 +48,7 @@ class StudioUI: public ox::SignalHandler {
|
||||
bool m_showProjectExplorer = true;
|
||||
|
||||
public:
|
||||
explicit StudioUI(studio::StudioContext &ctx, ox::StringView projectDataDir) noexcept;
|
||||
explicit StudioUI(turbine::Context &ctx, ox::StringView projectDataDir) noexcept;
|
||||
|
||||
void update() noexcept;
|
||||
|
||||
|
@ -12,11 +12,14 @@
|
||||
|
||||
namespace studio {
|
||||
|
||||
class StudioUI;
|
||||
|
||||
struct StudioContext {
|
||||
class StudioUI *ui = nullptr;
|
||||
StudioUI &ui;
|
||||
Project *project = nullptr;
|
||||
turbine::Context &tctx;
|
||||
inline explicit StudioContext(turbine::Context &pTctx) noexcept: tctx(pTctx) {}
|
||||
inline StudioContext(StudioUI &pUi, turbine::Context &pTctx) noexcept:
|
||||
ui(pUi), tctx(pTctx) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,12 @@ namespace studio::ig {
|
||||
|
||||
inline constexpr auto BtnSz = ImVec2{52, 22};
|
||||
|
||||
class ChildStackItem {
|
||||
public:
|
||||
explicit ChildStackItem(ox::CStringView id, ImVec2 const&sz = {}) noexcept;
|
||||
~ChildStackItem() noexcept;
|
||||
};
|
||||
|
||||
class IDStackItem {
|
||||
public:
|
||||
explicit IDStackItem(int id) noexcept;
|
||||
@ -98,4 +104,4 @@ class FilePicker {
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,14 @@
|
||||
|
||||
namespace studio::ig {
|
||||
|
||||
ChildStackItem::ChildStackItem(ox::CStringView id, ImVec2 const&sz) noexcept {
|
||||
ImGui::BeginChild(id.c_str(), sz);
|
||||
}
|
||||
|
||||
ChildStackItem::~ChildStackItem() noexcept {
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
IDStackItem::IDStackItem(int id) noexcept {
|
||||
ImGui::PushID(id);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user