Elevate Engine 1
Loading...
Searching...
No Matches
Elevate::Editor::AssetBrowserPanel Class Reference

#include <AssetBrowserPanel.h>

Inheritance diagram for Elevate::Editor::AssetBrowserPanel:
Elevate::Editor::EditorWidget

Public Member Functions

 AssetBrowserPanel ()
 
void OnUpdate () override
 
void OnImGuiRender () override
 
- Public Member Functions inherited from Elevate::Editor::EditorWidget
 EditorWidget ()=default
 
virtual ~EditorWidget ()=default
 

Detailed Description

Definition at line 63 of file AssetBrowserPanel.h.

Constructor & Destructor Documentation

◆ AssetBrowserPanel()

Elevate::Editor::AssetBrowserPanel::AssetBrowserPanel ( )

Definition at line 19 of file AssetBrowserPanel.cpp.

20{
21 LoadExtensionsMeta();
22 m_folderTexture = Texture::CreateFromFile(m_FileMetadata["DIRECTORY"].iconPath);
23 EE_CORE_INFO("Editor Assets Browser Initiated.");
24}
static TexturePtr CreateFromFile(const std::string &path, TextureType usage=TextureType::Diffuse)
Definition Texture.cpp:22

Member Function Documentation

◆ OnImGuiRender()

void Elevate::Editor::AssetBrowserPanel::OnImGuiRender ( )
overridevirtual

Reimplemented from Elevate::Editor::EditorWidget.

Definition at line 35 of file AssetBrowserPanel.cpp.

36{
37 ImGui::Begin("Asset Browser");
38
39 ImGui::BeginGroup();
40 for (auto it = m_relatedPaths.rbegin(); it != m_relatedPaths.rend(); ++it)
41 {
42 ImGui::BeginDisabled(it->Path == m_CurrentPath);
43 if (ImGui::Button(it->DisplayName.c_str()))
44 {
45 m_CurrentPath = it->Path;
46 m_shouldUpdate = true;
47 }
48 ImGui::EndDisabled();
49
50 ImGui::SameLine();
51 ImGui::Text("/");
52 ImGui::SameLine();
53 }
54 ImGui::EndGroup();
55 ImGui::Separator();
56
57 ImVec2 buttonSize(72, 72);
58 float spacing = ImGui::GetStyle().ItemSpacing.x * 2;
59 float panelWidth = ImGui::GetWindowSize().x;
60 int colNb = (int) std::floor(panelWidth / (buttonSize.x + spacing));
61 colNb = std::max(1, colNb);
62
63 int index = 0;
64
65 if (m_CurrentPath != ".") {
66 ImGui::PushID(index);
67 ImGui::BeginGroup();
68 ImGui::ImageButton("back", (ImTextureID) m_folderTexture->GetNativeHandle(), buttonSize);
69
70 if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
71 m_CurrentPath = m_CurrentPath.parent_path();
72 m_shouldUpdate = true;
73 }
74
75 ImGui::TextWrapped("../");
76
77 ImGui::EndGroup();
78 ImGui::PopID();
79 ImGui::SameLine();
80 index++;
81 }
82
83 int id = 0;
84 for (FileItem item : m_FileItems)
85 {
86 ImGui::PushID(index);
87 ImGui::BeginGroup();
88
89 if (ImGui::ImageButton("file_item", (ImTextureID) m_currentTextures[item.iconPath]->GetNativeHandle(), buttonSize)) {}
90
91 if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
92 if (item.type == Directory) {
93 m_CurrentPath += "/" + item.name;
94 m_shouldUpdate = true;
95 }
96 else {
98 }
99 }
100
101 ImGui::PushTextWrapPos(ImGui::GetCursorPosX() + buttonSize.x);
102 ImGui::TextWrapped("%s", item.name.c_str());
103 ImGui::PopTextWrapPos();
104
105 ImGui::EndGroup();
106 ImGui::PopID();
107
108 if ((index + 1) % colNb != 0)
109 {
110 ImGui::SameLine();
111 }
112 index++;
113 }
114 ImGui::End();
115}
void OpenWithDefaultApp(const std::string &filePath)
Definition Files.h:14

◆ OnUpdate()

void Elevate::Editor::AssetBrowserPanel::OnUpdate ( )
overridevirtual

Reimplemented from Elevate::Editor::EditorWidget.

Definition at line 26 of file AssetBrowserPanel.cpp.

27{
28 if (m_shouldUpdate) {
29 UpdateRelatedPaths();
30 LoadFileItemsList();
31 m_shouldUpdate = false;
32 }
33}

The documentation for this class was generated from the following files: