Squashed 'deps/nostalgia/' changes from ff666eda..161194c8
161194c8 [nostalgia/gfx/studio/tilesheeteditor] Add FilePicker to for choosing a Palette 48603ea2 [studio] Make tabs not draw while closing e2f2a173 [studio] Add FilePickerPopup e8a0ce88 Merge commit 'dff9f81e073bb994d5ce96a6eaa1bfa547f1fdf4' 82e2ea74 [studio] Fix NewMenu to track prev stage correctly when going back two stages git-subtree-dir: deps/nostalgia git-subtree-split: 161194c8b268d8fb0159f251844292660b0a7922
This commit is contained in:
@@ -21,7 +21,7 @@ void NewMenu::open() noexcept {
|
||||
m_selectedType = 0;
|
||||
m_itemName = "";
|
||||
m_typeName = "";
|
||||
m_path = "";
|
||||
m_useDefaultPath = true;
|
||||
m_explorer.setModel(buildFileTreeModel(
|
||||
m_explorer,
|
||||
[](ox::StringViewCR, ox::FileStat const&s) {
|
||||
@@ -29,9 +29,10 @@ void NewMenu::open() noexcept {
|
||||
}).or_value(ox::UPtr<FileTreeModel>{}));
|
||||
}
|
||||
|
||||
void NewMenu::openPath(ox::StringParam path) noexcept {
|
||||
void NewMenu::openPath(ox::StringViewCR path) noexcept {
|
||||
open();
|
||||
m_path = std::move(path);
|
||||
m_useDefaultPath = false;
|
||||
std::ignore = m_explorer.setSelectedPath(path);
|
||||
}
|
||||
|
||||
void NewMenu::close() noexcept {
|
||||
@@ -93,10 +94,9 @@ void NewMenu::drawNewItemType(StudioContext const&sctx) noexcept {
|
||||
drawFirstPageButtons(im.itemTemplates().size() == 1 ?
|
||||
Stage::NewItemTransitioningToPath : Stage::NewItemTemplate);
|
||||
if (m_stage == Stage::NewItemTransitioningToPath || m_stage == Stage::NewItemTemplate) {
|
||||
if (m_path.len() == 0) {
|
||||
m_path = im.defaultPath();
|
||||
if (m_useDefaultPath) {
|
||||
std::ignore = m_explorer.setSelectedPath(im.defaultPath());
|
||||
}
|
||||
std::ignore = m_explorer.setSelectedPath(m_path);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -192,11 +192,9 @@ void NewMenu::finish(StudioContext &sctx) noexcept {
|
||||
oxLogError(ox::Error{1, "New file error: no file name"});
|
||||
return;
|
||||
}
|
||||
auto const&im = *m_types[m_selectedType];
|
||||
if (auto p = m_explorer.selectedPath()) {
|
||||
m_path = std::move(*p);
|
||||
}
|
||||
auto const path = sfmt("{}/{}.{}", m_path, m_itemName, im.fileExt());
|
||||
auto const &im = *m_types[m_selectedType];
|
||||
auto const path = sfmt("{}/{}.{}",
|
||||
m_explorer.selectedPath().or_value(ox::String{}), m_itemName, im.fileExt());
|
||||
if (sctx.project->exists(path)) {
|
||||
oxLogError(ox::Error{1, "New file error: file already exists"});
|
||||
return;
|
||||
|
@@ -34,7 +34,7 @@ class NewMenu final: public Popup {
|
||||
keel::Context &m_kctx;
|
||||
ox::String m_typeName;
|
||||
ox::IString<255> m_itemName;
|
||||
ox::String m_path;
|
||||
bool m_useDefaultPath{};
|
||||
ox::Vector<ox::UPtr<ItemMaker>> m_types;
|
||||
FileExplorer m_explorer{m_kctx};
|
||||
size_t m_selectedType = 0;
|
||||
@@ -44,7 +44,7 @@ class NewMenu final: public Popup {
|
||||
public:
|
||||
NewMenu(keel::Context &kctx) noexcept;
|
||||
|
||||
void openPath(ox::StringParam path) noexcept;
|
||||
void openPath(ox::StringViewCR path) noexcept;
|
||||
|
||||
void open() noexcept override;
|
||||
|
||||
|
@@ -22,6 +22,10 @@ void ProjectExplorer::fileOpened(ox::StringViewCR path) const noexcept {
|
||||
fileChosen.emit(path);
|
||||
}
|
||||
|
||||
void ProjectExplorer::fileDeleted(ox::StringViewCR path) const noexcept {
|
||||
deleteItem.emit(path);
|
||||
}
|
||||
|
||||
void ProjectExplorer::fileContextMenu(ox::StringViewCR path) const noexcept {
|
||||
if (ImGui::BeginPopupContextItem("FileMenu", ImGuiPopupFlags_MouseButtonRight)) {
|
||||
if (ImGui::MenuItem("Delete")) {
|
||||
|
@@ -28,6 +28,8 @@ class ProjectExplorer final: public FileExplorer {
|
||||
protected:
|
||||
void fileOpened(ox::StringViewCR path) const noexcept override;
|
||||
|
||||
void fileDeleted(ox::StringViewCR path) const noexcept override;
|
||||
|
||||
void fileContextMenu(ox::StringViewCR path) const noexcept override;
|
||||
|
||||
void dirContextMenu(ox::StringViewCR path) const noexcept override;
|
||||
|
@@ -225,7 +225,9 @@ void StudioUI::drawTabs() noexcept {
|
||||
if (m_activeEditorOnLastDraw != e.get()) [[unlikely]] {
|
||||
m_activeEditor->onActivated();
|
||||
}
|
||||
e->draw(m_sctx);
|
||||
if (open) [[likely]] {
|
||||
e->draw(m_sctx);
|
||||
}
|
||||
m_activeEditorOnLastDraw = e.get();
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
|
Reference in New Issue
Block a user