[studio] Adjust size of NewMenu, sort items, rename Quit to Cancel

This commit is contained in:
Gary Talent 2023-12-04 21:45:59 -06:00
parent 195fd7a113
commit 54fcbb1a33

View File

@ -13,7 +13,7 @@ namespace studio {
NewMenu::NewMenu() noexcept { NewMenu::NewMenu() noexcept {
setTitle(ox::String("New Item")); setTitle(ox::String("New Item"));
setSize({225, 110}); setSize({230, 140});
} }
void NewMenu::open() noexcept { void NewMenu::open() noexcept {
@ -51,6 +51,11 @@ void NewMenu::draw(turbine::Context *ctx) noexcept {
void NewMenu::addItemMaker(ox::UniquePtr<studio::ItemMaker> im) noexcept { void NewMenu::addItemMaker(ox::UniquePtr<studio::ItemMaker> im) noexcept {
m_types.emplace_back(std::move(im)); m_types.emplace_back(std::move(im));
std::sort(
m_types.begin(), m_types.end(),
[](ox::UPtr<ItemMaker> const&im1, ox::UPtr<ItemMaker> const&im2) {
return im1->name < im2->name;
});
} }
void NewMenu::drawNewItemType(turbine::Context *ctx) noexcept { void NewMenu::drawNewItemType(turbine::Context *ctx) noexcept {
@ -76,13 +81,14 @@ void NewMenu::drawNewItemName(turbine::Context *ctx) noexcept {
} }
void NewMenu::drawFirstPageButtons() noexcept { void NewMenu::drawFirstPageButtons() noexcept {
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 80); ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 130);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetContentRegionAvail().y - 20); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetContentRegionAvail().y - 20);
if (ImGui::Button("Next")) { auto const btnSz = ImVec2(60, 20);
if (ImGui::Button("Next", btnSz)) {
m_stage = Stage::NewItemName; m_stage = Stage::NewItemName;
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Quit")) { if (ImGui::Button("Cancel", btnSz)) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
m_stage = Stage::Closed; m_stage = Stage::Closed;
} }