[studio] Add popup to warn about UUID duplication

This commit is contained in:
2025-05-06 22:22:26 -05:00
parent d4329981e7
commit ff1e8f260b
4 changed files with 152 additions and 34 deletions

View File

@@ -169,7 +169,9 @@ TextInput<ox::IString<MaxChars>> InputText(
out.changed = ImGui::InputText(
label.c_str(), out.text.data(), MaxChars + 1, flags, callback, user_data);
if (out.changed) {
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
std::ignore = out.text.unsafeResize(ox::strlen(out.text.c_str()));
OX_ALLOW_UNSAFE_BUFFERS_END
}
return out;
}
@@ -186,7 +188,9 @@ TextInput<ox::IString<MaxChars>> InputTextWithHint(
out.changed = ImGui::InputTextWithHint(
label.c_str(), hint.c_str(), out.text.data(), MaxChars + 1, flags, callback, user_data);
if (out.changed) {
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
std::ignore = out.text.unsafeResize(ox::strlen(out.text.c_str()));
OX_ALLOW_UNSAFE_BUFFERS_END
}
return out;
}
@@ -201,7 +205,9 @@ bool InputText(
auto const out = ImGui::InputText(
label.c_str(), text.data(), StrCap + 1, flags, callback, user_data);
if (out) {
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
std::ignore = text.unsafeResize(ox::strlen(text.c_str()));
OX_ALLOW_UNSAFE_BUFFERS_END
}
return out;
}
@@ -223,6 +229,10 @@ PopupResponse PopupControlsOkCancel(
ox::CStringViewCR ok = "OK",
ox::CStringViewCR cancel = "Cancel");
PopupResponse PopupControlsOk(
bool &popupOpen,
ox::CStringViewCR ok);
[[nodiscard]]
bool BeginPopup(turbine::Context &ctx, ox::CStringViewCR popupName, bool &show, ImVec2 const&sz = {285, 0});
@@ -250,7 +260,7 @@ bool ComboBox(ox::CStringView lbl, ox::Span<const ox::String> list, size_t &sele
/**
*
* @param lbl
* @param callback
* @param f callback function
* @param selectedIdx
* @return true if new value selected, false otherwise
*/
@@ -285,7 +295,7 @@ bool ListBox(ox::CStringViewCR name, ox::SpanView<ox::String> const&list, size_t
class FilePicker {
private:
bool m_show{};
studio::StudioContext &m_sctx;
StudioContext &m_sctx;
ox::String const m_title;
ox::String const m_fileExt;
ImVec2 const m_size;
@@ -304,8 +314,8 @@ class FilePicker {
};
class QuestionPopup: public Widget {
private:
class Popup: public Widget {
protected:
enum class Stage {
Closed,
Opening,
@@ -314,12 +324,11 @@ class QuestionPopup: public Widget {
Stage m_stage = Stage::Closed;
bool m_open{};
ox::String m_title;
ox::String m_question;
public:
ox::Signal<ox::Error(PopupResponse)> response;
QuestionPopup(ox::StringParam title, ox::StringParam question) noexcept;
explicit Popup(ox::StringParam title) noexcept;
void open() noexcept;
@@ -328,7 +337,33 @@ class QuestionPopup: public Widget {
[[nodiscard]]
bool isOpen() const noexcept;
void draw(StudioContext &ctx) noexcept;
};
class QuestionPopup: public Popup {
private:
ox::String m_question;
public:
ox::Signal<ox::Error(PopupResponse)> response;
QuestionPopup(ox::StringParam title, ox::StringParam question) noexcept;
void draw(StudioContext &ctx) noexcept override;
};
class MessagePopup: public Popup {
private:
ox::String m_msg;
public:
ox::Signal<ox::Error(PopupResponse)> response;
MessagePopup(ox::StringParam title, ox::StringParam msg) noexcept;
void show(ox::StringParam msg) noexcept;
void draw(StudioContext &ctx) noexcept override;
};