Voltray Engine Docs
Loading...
Searching...
No Matches
AssetBrowser.h
Go to the documentation of this file.
1#pragma once
2
3#include "../Core/AssetItem.h"
4#include "../Core/AssetManager.h"
5#include "ContextMenu.h"
6#include "NavigationBar.h"
7#include "../Utils/IconRenderer.h"
8#include "../DragDrop/AssetDragDrop.h"
9#include <string>
10#include <memory>
11#include <vector>
12#include <imgui.h>
13
14namespace Editor
15{
16 namespace Assets
17 {
18
30 {
31 public:
40 AssetBrowser(AssetManager &assetManager,
41 IconRenderer &iconRenderer,
42 ContextMenu &contextMenu,
43 NavigationBar &navigationBar,
44 AssetDragDrop &dragDrop);
45
50 void Draw(const ImVec2 &windowSize);
51
56 void SetCurrentPath(const std::string &path);
57
62 const std::string &GetCurrentPath() const { return m_currentPath; }
66 void SetViewMode(AssetViewMode mode) { m_viewMode = mode; }
67
72 AssetViewMode GetViewMode() const { return m_viewMode; }
73
78 void SetIconSize(float size);
79
84 float GetIconSize() const { return m_iconSize; }
85
90 void SetSearchFilter(const std::string &filter);
91
96 const std::string &GetSearchFilter() const { return m_searchFilter; }
97
102
103 private: // Core components
104 AssetManager &m_assetManager;
105 IconRenderer &m_iconRenderer;
106 ContextMenu &m_contextMenu;
107 NavigationBar &m_navigationBar;
108 AssetDragDrop &m_dragDrop; // Browser state
109 std::string m_currentPath;
111 float m_iconSize = 64.0f;
112 std::string m_searchFilter;
113
114 // Cached data
115 std::vector<AssetItem> m_currentItems;
116 bool m_needsRefresh = true;
117
118 // UI methods
119 void RenderToolbar(float windowWidth);
120 void RenderAssetGrid();
121 void RenderAssetList();
122 void RenderAssetDetails();
123 void RenderAssetItem(const AssetItem &item, bool isGrid = true);
124
125 // Navigation methods
126 void NavigateToDirectory(const std::string &path);
127 void OnDirectoryDoubleClick(const std::string &path);
128
129 // Helper methods
130 ImVec2 CalculateGridItemSize() const;
131 float CalculateColumnsForGrid(float availableWidth) const;
132 bool PassesSearchFilter(const AssetItem &item) const;
133 void HandleItemSelection(const AssetItem &item);
134 void HandleItemDoubleClick(const AssetItem &item);
135 };
136 }
137}
Handles right-click context menus for assets.
Navigation bar component for asset browser.
A panel component responsible for managing and displaying asset resources.
Core asset browser component for displaying and managing assets.
Definition AssetBrowser.h:30
void RefreshCurrentDirectory()
Refresh the current directory contents.
Definition AssetBrowser.cpp:105
void SetCurrentPath(const std::string &path)
Set the current directory path.
Definition AssetBrowser.cpp:86
void Draw(const ImVec2 &windowSize)
Draw the asset browser interface.
Definition AssetBrowser.cpp:22
void SetIconSize(float size)
Set the icon size.
Definition AssetBrowser.cpp:95
const std::string & GetCurrentPath() const
Get the current directory path.
Definition AssetBrowser.h:62
void SetViewMode(AssetViewMode mode)
Set the view mode.
Definition AssetBrowser.h:66
float GetIconSize() const
Get the current icon size.
Definition AssetBrowser.h:84
void SetSearchFilter(const std::string &filter)
Set the search filter.
Definition AssetBrowser.cpp:100
const std::string & GetSearchFilter() const
Get the current search filter.
Definition AssetBrowser.h:96
AssetViewMode GetViewMode() const
Get the current view mode.
Definition AssetBrowser.h:72
Manages drag and drop operations for assets.
Definition AssetDragDrop.h:36
Handles asset data management, file operations, and state.
Definition AssetManager.h:20
Manages context menus for the asset browser.
Definition ContextMenu.h:45
Renders visual icons using Dear ImGui drawing primitives.
Definition IconRenderer.h:19
Provides breadcrumb navigation and path controls for asset browser.
Definition NavigationBar.h:21
AssetViewMode
Different ways to display assets in the browser.
Definition AssetItem.h:19
Definition AssetsPanel.cpp:7
Represents a single asset item in the file browser.
Definition AssetItem.h:30