Squashed 'deps/nostalgia/' changes from be518387..804d78e1
804d78e1 [nostalgia/gfx/studio] Cleanup 5351e9aa [nostalgia/core/studio/tilesheet] Add line drawing tool b5954f15 [studio] Restore context menu for root dir, but exclude Delete 5dce9dd3 [studio] Suppress context menu for root dir in ProjectExplorer 0570f762 [ox/fs] Fix PassThroughFS::stripSlash e22b658a [studio] Fix isParentOf check in Project to ensure child dir path ends with / 56b9cb6e [studio] Fix file explorer to treat empty directories as directories eaa9a241 [keel] Make reloadAsset check if file is loaded 95256a9a [studio] Make rename file give error message if the file already exists 2286238a [studio] Make rename file accept input upon pressing Enter if text input is focused 13f0bf57 [studio] Make deleting a file close tabs associated with it 8eb1ac21 [studio] Fix not to try moving a parent directory to its child e132f2fd [studio] Make file move do nothing if the file already exists 12f6b22c [nostalgia/gfx/studio/palette] Cleanup 6c858e0c [nostalgia/gfx/studio/tilesheet] UI cleanup c6b58f7c [nostalgia] Update release notes a22aafaf [nostalgia/gfx/studio/palette] Add ability to reorder Palette pages 6298ac3a [nostalgia] Update release notes cd63afac [studio] Remove Ctrl-0 tab shortcut 28591837 [nostalgia/gfx/studio/tilesheet] Add the ability to move subsheets 05516597 [nostalgia/sample_project] Update test assets git-subtree-dir: deps/nostalgia git-subtree-split: 804d78e116ca07a13f0a3bd053875657fb6dfbcd
This commit is contained in:
@@ -88,7 +88,7 @@ FileTreeModel::FileTreeModel(
|
||||
void FileTreeModel::draw(turbine::Context &tctx) const noexcept {
|
||||
constexpr auto dirFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick;
|
||||
auto const selected = m_explorer.selected(this) ? ImGuiTreeNodeFlags_Selected : 0;
|
||||
if (!m_children.empty()) {
|
||||
if (m_fileType == ox::FileType::Directory) {
|
||||
auto const nodeOpen = ImGui::TreeNodeEx(m_name.c_str(), dirFlags | selected);
|
||||
if (ImGui::IsItemActivated() || ImGui::IsItemClicked(1)) {
|
||||
m_explorer.setSelectedNode(this);
|
||||
@@ -104,7 +104,8 @@ void FileTreeModel::draw(turbine::Context &tctx) const noexcept {
|
||||
if (ig::DragDropTarget const dragDropTarget; dragDropTarget) {
|
||||
auto const [ref, err] = ig::getDragDropPayload<FileRef>("FileRef");
|
||||
if (!err) {
|
||||
auto const name = substr(ref.path, find(ref.path.rbegin(), ref.path.rend(), '/').offset() + 1);
|
||||
auto const name = substr(
|
||||
ref.path, find(ref.path.rbegin(), ref.path.rend(), '/').offset() + 1);
|
||||
if (ref.isDir) {
|
||||
m_explorer.dirMoved(ref.path, sfmt("{}/{}", m_fullPath, name));
|
||||
} else {
|
||||
|
@@ -64,13 +64,11 @@ PopupResponse PopupControlsOkCancel(
|
||||
ImGui::Separator();
|
||||
ImGui::SetCursorPosX(popupWidth - 118);
|
||||
if (ImGui::Button(ok.c_str(), btnSz)) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
popupOpen = false;
|
||||
out = PopupResponse::OK;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::IsKeyDown(ImGuiKey_Escape) || ImGui::Button(cancel.c_str(), btnSz)) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
popupOpen = false;
|
||||
out = PopupResponse::Cancel;
|
||||
}
|
||||
|
@@ -46,6 +46,13 @@ static ox::Result<ox::Vector<ox::String>> listAllRecursive(ox::FileSystem &fs, o
|
||||
return std::move(out);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
static constexpr bool isParentOf(ox::StringViewCR parent, ox::StringViewCR child) noexcept {
|
||||
if (endsWith(child, "/")) {
|
||||
return beginsWith(child, parent);
|
||||
}
|
||||
return beginsWith(sfmt("{}/", child), parent);
|
||||
}
|
||||
|
||||
Project::Project(keel::Context &ctx, ox::String path, ox::StringViewCR projectDataDir):
|
||||
m_kctx(ctx),
|
||||
@@ -99,6 +106,9 @@ ox::Error Project::moveItem(ox::StringViewCR src, ox::StringViewCR dest) noexcep
|
||||
}
|
||||
|
||||
ox::Error Project::moveDir(ox::StringViewCR src, ox::StringViewCR dest) noexcept {
|
||||
if (isParentOf(src, dest)) {
|
||||
return ox::Error{1, "cannot move parent to a child directory"};
|
||||
}
|
||||
OX_REQUIRE(files, listAllRecursive(m_fs, src));
|
||||
OX_RETURN_ERROR(m_fs.move(src, dest));
|
||||
fileMoved.emit(src, dest, ox::UUID{});
|
||||
|
Reference in New Issue
Block a user