ContentBrowserPanel
- Added ContentBrowserPanel
This commit is contained in:
parent
0c06164509
commit
cc4fc02931
4 changed files with 88 additions and 9 deletions
|
@ -12,6 +12,7 @@ namespace Light {
|
||||||
|
|
||||||
m_PropertiesPanel = CreateRef<PropertiesPanel>();
|
m_PropertiesPanel = CreateRef<PropertiesPanel>();
|
||||||
m_SceneHierarchyPanel = CreateRef<SceneHierarchyPanel>(m_Scene, m_PropertiesPanel);
|
m_SceneHierarchyPanel = CreateRef<SceneHierarchyPanel>(m_Scene, m_PropertiesPanel);
|
||||||
|
m_ContentBrowserPanel = CreateRef<ContentBrowserPanel>();
|
||||||
|
|
||||||
m_Framebuffer = Framebuffer::Create({ 1, 1, 1 }, GraphicsContext::GetSharedContext());
|
m_Framebuffer = Framebuffer::Create({ 1, 1, 1 }, GraphicsContext::GetSharedContext());
|
||||||
|
|
||||||
|
@ -84,8 +85,10 @@ namespace Light {
|
||||||
ImGui::Image(m_Framebuffer->GetColorAttachment(), regionAvail, ImVec2(0, 1), ImVec2(1, 0));
|
ImGui::Image(m_Framebuffer->GetColorAttachment(), regionAvail, ImVec2(0, 1), ImVec2(1, 0));
|
||||||
} ImGui::End();
|
} ImGui::End();
|
||||||
|
|
||||||
|
// panels
|
||||||
m_SceneHierarchyPanel->OnUserInterfaceUpdate();
|
m_SceneHierarchyPanel->OnUserInterfaceUpdate();
|
||||||
m_PropertiesPanel->OnUserInterfaceUpdate();
|
m_PropertiesPanel->OnUserInterfaceUpdate();
|
||||||
|
m_ContentBrowserPanel->OnUserInterfaceUpdate();
|
||||||
|
|
||||||
UserInterface::DockspaceEnd();
|
UserInterface::DockspaceEnd();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "Panels/SceneHierarchyPanel.h"
|
#include "Panels/SceneHierarchyPanel.h"
|
||||||
#include "Panels/PropertiesPanel.h"
|
#include "Panels/PropertiesPanel.h"
|
||||||
|
#include "Panels/ContentBrowser.h"
|
||||||
|
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
|
||||||
|
@ -22,6 +23,7 @@ namespace Light {
|
||||||
|
|
||||||
Ref<SceneHierarchyPanel> m_SceneHierarchyPanel;
|
Ref<SceneHierarchyPanel> m_SceneHierarchyPanel;
|
||||||
Ref<PropertiesPanel> m_PropertiesPanel;
|
Ref<PropertiesPanel> m_PropertiesPanel;
|
||||||
|
Ref<ContentBrowserPanel> m_ContentBrowserPanel;
|
||||||
|
|
||||||
Ref<Framebuffer> m_Framebuffer;
|
Ref<Framebuffer> m_Framebuffer;
|
||||||
|
|
||||||
|
|
51
Mirror/src/Panels/ContentBrowser.cpp
Normal file
51
Mirror/src/Panels/ContentBrowser.cpp
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#include "ContentBrowser.h"
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
|
namespace Light {
|
||||||
|
|
||||||
|
ContentBrowserPanel::ContentBrowserPanel() :
|
||||||
|
m_CurrentDirectory("assets"),
|
||||||
|
m_AssetsPath("assets")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentBrowserPanel::OnUserInterfaceUpdate()
|
||||||
|
{
|
||||||
|
ImGui::Begin("Content Browser");
|
||||||
|
|
||||||
|
if (m_CurrentDirectory != std::filesystem::path("assets"))
|
||||||
|
{
|
||||||
|
if (ImGui::Button(" <-- "))
|
||||||
|
{
|
||||||
|
m_CurrentDirectory = m_CurrentDirectory.parent_path();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& dirEntry : std::filesystem::directory_iterator(m_CurrentDirectory))
|
||||||
|
{
|
||||||
|
const auto& path = dirEntry.path();
|
||||||
|
Texture2D
|
||||||
|
auto relativePathasd; = std::filesystem::relative(path, m_AssetsPath);
|
||||||
|
std::string relativePathString = relativePath.string();
|
||||||
|
|
||||||
|
if (dirEntry.is_directory())
|
||||||
|
{
|
||||||
|
if (ImGui::Button(relativePathString.c_str()))
|
||||||
|
{
|
||||||
|
m_CurrentDirectory /= path.filename();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ImGui::Button(relativePathString.c_str()))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
23
Mirror/src/Panels/ContentBrowser.h
Normal file
23
Mirror/src/Panels/ContentBrowser.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Panel.h"
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
namespace Light {
|
||||||
|
|
||||||
|
class ContentBrowserPanel : public Panel
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
public:
|
||||||
|
ContentBrowserPanel();
|
||||||
|
|
||||||
|
void OnUserInterfaceUpdate();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::filesystem::path m_CurrentDirectory;
|
||||||
|
const std::filesystem::path m_AssetsPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue