[nostalgia] Update Studio to handle tabs and open directory dialog on Mac, Update core::init
This commit is contained in:
@@ -8,14 +8,16 @@
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include "projectexplorer.hpp"
|
||||
#include "projecttreemodel.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
|
||||
ProjectTreeModel::ProjectTreeModel(const ox::String &name,
|
||||
ox::Vector<ox::UniquePtr<ProjectTreeModel>> children) noexcept {
|
||||
ProjectTreeModel::ProjectTreeModel(ProjectExplorer *explorer, const ox::String &name,
|
||||
ProjectTreeModel *parent) noexcept {
|
||||
m_explorer = explorer;
|
||||
m_name = name;
|
||||
m_children = std::move(children);
|
||||
m_parent = parent;
|
||||
}
|
||||
|
||||
ProjectTreeModel::ProjectTreeModel(ProjectTreeModel &&other) noexcept {
|
||||
@@ -32,11 +34,23 @@ void ProjectTreeModel::draw(core::Context *ctx) noexcept {
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
} else {
|
||||
if (ImGui::TreeNodeEx(m_name.c_str(), ImGuiTreeNodeFlags_Leaf)) {
|
||||
ImGui::TreePop();
|
||||
} else if (auto path = fullPath(); ImGui::TreeNodeEx(ox::sfmt("{}##{}", m_name, path).c_str(), ImGuiTreeNodeFlags_Leaf)) {
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) {
|
||||
m_explorer->fileChosen.emit(path);
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectTreeModel::setChildren(ox::Vector<ox::UniquePtr<ProjectTreeModel>> children) noexcept {
|
||||
m_children = std::move(children);
|
||||
}
|
||||
|
||||
ox::String ProjectTreeModel::fullPath() noexcept {
|
||||
if (m_parent) {
|
||||
return m_parent->fullPath() + "/" + m_name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user