[studio] Add Back/Forward navigation
All checks were successful
Build / build (push) Successful in 1m14s
All checks were successful
Build / build (push) Successful in 1m14s
This commit is contained in:
@@ -16,11 +16,21 @@ class StudioUI;
|
||||
|
||||
struct Context {
|
||||
public:
|
||||
friend void navigateTo(Context &ctx, ox::StringParam filePath, ox::StringParam navArgs) noexcept;
|
||||
friend void navigateBack(Context &ctx) noexcept;
|
||||
friend void navigateForward(Context &ctx) noexcept;
|
||||
friend StudioUI;
|
||||
StudioUI &ui;
|
||||
Project *project = nullptr;
|
||||
turbine::Context &tctx;
|
||||
protected:
|
||||
struct NavPath {
|
||||
ox::String filePath;
|
||||
ox::String navArgs;
|
||||
};
|
||||
size_t navIdx{};
|
||||
ox::Vector<NavPath> navStack;
|
||||
std::function<void(ox::StringParam filePath, ox::StringParam navArgs)> navCallback;
|
||||
Context(StudioUI &pUi, turbine::Context &pTctx) noexcept:
|
||||
ui{pUi}, tctx{pTctx} {}
|
||||
};
|
||||
@@ -37,4 +47,8 @@ inline keel::Context const &keelCtx(Context const &ctx) noexcept {
|
||||
|
||||
void navigateTo(Context &ctx, ox::StringParam filePath, ox::StringParam navArgs = "") noexcept;
|
||||
|
||||
void navigateBack(Context &ctx) noexcept;
|
||||
|
||||
void navigateForward(Context &ctx) noexcept;
|
||||
|
||||
}
|
||||
|
@@ -46,14 +46,14 @@ ox::Result<T> getDragDropPayload() noexcept {
|
||||
static_cast<size_t>(payload->DataSize)});
|
||||
}
|
||||
|
||||
ox::Error setDragDropPayload(ox::CStringViewCR name, auto const&obj) noexcept {
|
||||
ox::Error setDragDropPayload(ox::CStringViewCR name, auto const &obj) noexcept {
|
||||
OX_REQUIRE(buff, ox::writeClaw(obj, ox::ClawFormat::Metal));
|
||||
ImGui::SetDragDropPayload(name.c_str(), buff.data(), buff.size());
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ox::Error setDragDropPayload(T const&obj) noexcept {
|
||||
ox::Error setDragDropPayload(T const &obj) noexcept {
|
||||
OX_REQUIRE(buff, ox::writeClaw(obj, ox::ClawFormat::Metal));
|
||||
ImGui::SetDragDropPayload(ox::ModelTypeName_v<T>, buff.data(), buff.size());
|
||||
return {};
|
||||
@@ -77,7 +77,7 @@ class DragDropSource {
|
||||
}
|
||||
};
|
||||
|
||||
auto dragDropSource(auto const&cb, ImGuiDragDropFlags const flags = 0) noexcept {
|
||||
auto dragDropSource(auto const &cb, ImGuiDragDropFlags const flags = 0) noexcept {
|
||||
if constexpr(ox::is_same_v<decltype(cb()), ox::Error>) {
|
||||
if (ig::DragDropSource const tgt{flags}; tgt) [[unlikely]] {
|
||||
return cb();
|
||||
@@ -108,7 +108,7 @@ class DragDropTarget {
|
||||
}
|
||||
};
|
||||
|
||||
auto dragDropTarget(auto const&cb) noexcept {
|
||||
auto dragDropTarget(auto const &cb) noexcept {
|
||||
if constexpr(ox::is_same_v<decltype(cb()), ox::Error>) {
|
||||
if (ig::DragDropTarget const tgt; tgt) [[unlikely]] {
|
||||
return cb();
|
||||
@@ -124,7 +124,7 @@ auto dragDropTarget(auto const&cb) noexcept {
|
||||
|
||||
class ChildStackItem {
|
||||
public:
|
||||
explicit ChildStackItem(ox::CStringViewCR id, ImVec2 const&sz = {}) noexcept;
|
||||
explicit ChildStackItem(ox::CStringViewCR id, ImVec2 const &sz = {}) noexcept;
|
||||
~ChildStackItem() noexcept;
|
||||
};
|
||||
|
||||
@@ -146,7 +146,7 @@ class IndentStackItem {
|
||||
|
||||
void centerNextWindow(turbine::Context &ctx) noexcept;
|
||||
|
||||
bool PushButton(ox::CStringViewCR lbl, ImVec2 const&btnSz = BtnSz) noexcept;
|
||||
bool PushButton(ox::CStringViewCR lbl, ImVec2 const &btnSz = BtnSz) noexcept;
|
||||
|
||||
template<typename Str>
|
||||
struct TextInput {
|
||||
@@ -234,7 +234,7 @@ PopupResponse PopupControlsOk(
|
||||
ox::CStringViewCR ok);
|
||||
|
||||
[[nodiscard]]
|
||||
bool BeginPopup(turbine::Context &ctx, ox::CStringViewCR popupName, bool &show, ImVec2 const&sz = {285, 0});
|
||||
bool BeginPopup(turbine::Context &ctx, ox::CStringViewCR popupName, bool &show, ImVec2 const &sz = {285, 0});
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -266,7 +266,7 @@ bool ComboBox(ox::CStringView lbl, ox::Span<const ox::String> list, size_t &sele
|
||||
*/
|
||||
bool ComboBox(
|
||||
ox::CStringViewCR lbl,
|
||||
std::function<ox::CStringView(size_t)> const&f,
|
||||
std::function<ox::CStringView(size_t)> const &f,
|
||||
size_t strCnt,
|
||||
size_t &selectedIdx) noexcept;
|
||||
|
||||
@@ -278,10 +278,10 @@ bool FileComboBox(
|
||||
|
||||
bool ListBox(
|
||||
ox::CStringViewCR name,
|
||||
std::function<ox::CStringView(size_t)> const&f,
|
||||
std::function<ox::CStringView(size_t)> const &f,
|
||||
size_t strCnt,
|
||||
size_t &selIdx,
|
||||
ImVec2 const&sz = {0, 0}) noexcept;
|
||||
ImVec2 const &sz = {0, 0}) noexcept;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -290,7 +290,7 @@ bool ListBox(
|
||||
* @param selIdx
|
||||
* @return true if new value selected, false otherwise
|
||||
*/
|
||||
bool ListBox(ox::CStringViewCR name, ox::SpanView<ox::String> const&list, size_t &selIdx) noexcept;
|
||||
bool ListBox(ox::CStringViewCR name, ox::SpanView<ox::String> const &list, size_t &selIdx) noexcept;
|
||||
|
||||
class FilePicker {
|
||||
private:
|
||||
@@ -306,7 +306,7 @@ class FilePicker {
|
||||
studio::Context &sctx,
|
||||
ox::StringParam title,
|
||||
ox::StringParam fileExt,
|
||||
ImVec2 const&size = {}) noexcept;
|
||||
ImVec2 const &size = {}) noexcept;
|
||||
|
||||
void draw() noexcept;
|
||||
|
||||
@@ -348,6 +348,8 @@ class QuestionPopup: public Popup {
|
||||
|
||||
QuestionPopup(ox::StringParam title, ox::StringParam question) noexcept;
|
||||
|
||||
void setQuestion(ox::StringParam msg) noexcept;
|
||||
|
||||
void draw(Context &ctx) noexcept override;
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user