[nostalgia/core/studio] Add Palette page names to editor
All checks were successful
Build / build (push) Successful in 2m33s
All checks were successful
Build / build (push) Successful in 2m33s
This commit is contained in:
@ -29,7 +29,7 @@ bool AboutPopup::isOpen() const noexcept {
|
||||
return m_stage == Stage::Open;
|
||||
}
|
||||
|
||||
void AboutPopup::draw(studio::StudioContext &sctx) noexcept {
|
||||
void AboutPopup::draw(StudioContext &sctx) noexcept {
|
||||
switch (m_stage) {
|
||||
case Stage::Closed:
|
||||
break;
|
||||
@ -40,15 +40,14 @@ void AboutPopup::draw(studio::StudioContext &sctx) noexcept {
|
||||
case Stage::Open: {
|
||||
constexpr auto modalFlags =
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
||||
ImGui::SetNextWindowSize(ImVec2(215, 90));
|
||||
studio::ig::centerNextWindow(sctx.tctx);
|
||||
ig::centerNextWindow(sctx.tctx);
|
||||
auto open = true;
|
||||
if (ImGui::BeginPopupModal("About", &open, modalFlags)) {
|
||||
ImGui::Text("%s", m_text.c_str());
|
||||
ImGui::NewLine();
|
||||
ImGui::Dummy(ImVec2(148.0f, 0.0f));
|
||||
ImGui::Dummy({148.0f, 0.0f});
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Close")) {
|
||||
if (ig::PushButton("Close")) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
open = false;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ struct StudioContext {
|
||||
StudioUI &ui;
|
||||
Project *project = nullptr;
|
||||
turbine::Context &tctx;
|
||||
inline StudioContext(StudioUI &pUi, turbine::Context &pTctx) noexcept:
|
||||
StudioContext(StudioUI &pUi, turbine::Context &pTctx) noexcept:
|
||||
ui(pUi), tctx(pTctx) {}
|
||||
};
|
||||
|
||||
|
@ -45,10 +45,10 @@ class DragDropSource {
|
||||
private:
|
||||
bool const m_active{};
|
||||
public:
|
||||
inline DragDropSource() noexcept:
|
||||
DragDropSource() noexcept:
|
||||
m_active(ImGui::BeginDragDropSource()) {
|
||||
}
|
||||
inline ~DragDropSource() noexcept {
|
||||
~DragDropSource() noexcept {
|
||||
if (m_active) {
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
@ -58,7 +58,7 @@ class DragDropSource {
|
||||
}
|
||||
};
|
||||
|
||||
inline auto dragDropSource(auto const&cb) noexcept {
|
||||
auto dragDropSource(auto const&cb) noexcept {
|
||||
if constexpr(ox::is_same_v<decltype(cb()), ox::Error>) {
|
||||
if (ig::DragDropSource const tgt; tgt) [[unlikely]] {
|
||||
return cb();
|
||||
@ -75,10 +75,10 @@ class DragDropTarget {
|
||||
private:
|
||||
bool const m_active{};
|
||||
public:
|
||||
inline DragDropTarget() noexcept:
|
||||
DragDropTarget() noexcept:
|
||||
m_active(ImGui::BeginDragDropTarget()) {
|
||||
}
|
||||
inline ~DragDropTarget() noexcept {
|
||||
~DragDropTarget() noexcept {
|
||||
if (m_active) {
|
||||
ImGui::EndDragDropTarget();
|
||||
}
|
||||
@ -128,6 +128,21 @@ void centerNextWindow(turbine::Context &ctx) noexcept;
|
||||
|
||||
bool PushButton(ox::CStringView lbl, ImVec2 const&btnSz = BtnSz) noexcept;
|
||||
|
||||
template<size_t StrCap>
|
||||
bool InputText(
|
||||
ox::CStringView label,
|
||||
ox::IString<StrCap> &text,
|
||||
ImGuiInputTextFlags const flags = 0,
|
||||
ImGuiInputTextCallback const callback = nullptr,
|
||||
void *user_data = nullptr) noexcept {
|
||||
auto const out = ImGui::InputText(
|
||||
label.c_str(), text.data(), StrCap + 1, flags, callback, user_data);
|
||||
if (out) {
|
||||
std::ignore = text.unsafeResize(ox::strlen(text.c_str()));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
enum class PopupResponse {
|
||||
None,
|
||||
OK,
|
||||
@ -136,6 +151,8 @@ enum class PopupResponse {
|
||||
|
||||
PopupResponse PopupControlsOkCancel(float popupWidth, bool &popupOpen);
|
||||
|
||||
PopupResponse PopupControlsOkCancel(bool &popupOpen);
|
||||
|
||||
[[nodiscard]]
|
||||
bool BeginPopup(turbine::Context &ctx, ox::CStringView popupName, bool &show, ImVec2 const&sz = {285, 0});
|
||||
|
||||
|
@ -73,9 +73,13 @@ PopupResponse PopupControlsOkCancel(float popupWidth, bool &popupOpen) {
|
||||
return out;
|
||||
}
|
||||
|
||||
PopupResponse PopupControlsOkCancel(bool &popupOpen) {
|
||||
return PopupControlsOkCancel(ImGui::GetContentRegionAvail().x + 17, popupOpen);
|
||||
}
|
||||
|
||||
bool BeginPopup(turbine::Context &ctx, ox::CStringView popupName, bool &show, ImVec2 const&sz) {
|
||||
constexpr auto modalFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
||||
ig::centerNextWindow(ctx);
|
||||
centerNextWindow(ctx);
|
||||
ImGui::OpenPopup(popupName.c_str());
|
||||
ImGui::SetNextWindowSize(sz);
|
||||
return ImGui::BeginPopupModal(popupName.c_str(), &show, modalFlags);
|
||||
@ -122,23 +126,11 @@ bool ComboBox(
|
||||
|
||||
bool FileComboBox(
|
||||
ox::CStringView lbl,
|
||||
studio::StudioContext &sctx,
|
||||
StudioContext &sctx,
|
||||
ox::StringView fileExt,
|
||||
size_t &selectedIdx) noexcept {
|
||||
auto const&list = sctx.project->fileList(fileExt);
|
||||
bool out{};
|
||||
auto const first = selectedIdx < list.size() ? list[selectedIdx].c_str() : "";
|
||||
if (ImGui::BeginCombo(lbl.c_str(), first, 0)) {
|
||||
for (auto i = 0u; i < list.size(); ++i) {
|
||||
const auto selected = (selectedIdx == i);
|
||||
if (ImGui::Selectable(list[i].c_str(), selected) && selectedIdx != i) {
|
||||
selectedIdx = i;
|
||||
out = true;
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
return out;
|
||||
return ComboBox(lbl, list, selectedIdx);
|
||||
}
|
||||
|
||||
bool ListBox(
|
||||
@ -164,14 +156,14 @@ bool ListBox(
|
||||
}
|
||||
|
||||
bool ListBox(ox::CStringView name, ox::SpanView<ox::String> const&list, size_t &selIdx) noexcept {
|
||||
return ig::ListBox(name, [list](size_t i) -> ox::CStringView {
|
||||
return ListBox(name, [list](size_t i) -> ox::CStringView {
|
||||
return list[i];
|
||||
}, list.size(), selIdx);
|
||||
}
|
||||
|
||||
|
||||
FilePicker::FilePicker(
|
||||
studio::StudioContext &sctx,
|
||||
StudioContext &sctx,
|
||||
ox::String title,
|
||||
ox::String fileExt,
|
||||
ImVec2 const&size) noexcept:
|
||||
@ -186,12 +178,12 @@ void FilePicker::draw() noexcept {
|
||||
return;
|
||||
}
|
||||
auto constexpr popupSz = ImVec2{450.f, 0};
|
||||
ig::IDStackItem const idStackItem(m_title.c_str());
|
||||
if (ig::BeginPopup(m_sctx.tctx, m_title.c_str(), m_show, popupSz)) {
|
||||
IDStackItem const idStackItem(m_title);
|
||||
if (BeginPopup(m_sctx.tctx, m_title, m_show, popupSz)) {
|
||||
auto const&list = m_sctx.project->fileList(m_fileExt);
|
||||
size_t selIdx{};
|
||||
ig::ComboBox(m_title.c_str(), list, selIdx);
|
||||
if (ig::PopupControlsOkCancel(popupSz.x, m_show) == ig::PopupResponse::OK) {
|
||||
ComboBox(m_title, list, selIdx);
|
||||
if (PopupControlsOkCancel(popupSz.x, m_show) == ig::PopupResponse::OK) {
|
||||
filePicked.emit(list[selIdx]);
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
|
Reference in New Issue
Block a user