VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
vex::AssetBrowser Class Reference

Class responsible for displaying and navigating project assets within an ImGUI window. More...

#include <AssetBrowser.hpp>

Public Member Functions

 AssetBrowser (const std::string &rootPath)
 Constructs the AssetBrowser.
std::string Draw (const BrowserIcons &icons, float &thumbnailSize, bool showBottomBar=true, float height=0.0f)
 Draws the Asset Browser UI and handles interaction.
int GetJSONAssetType (const std::string path)
 Determines the type of a JSON asset (e.g., scene, material, etc.).
std::string GetExtension (const std::string path)
 Extracts the file extension from a path.
void setPadding (float padding)
 Sets the padding between asset icons in the browser.
std::string getCurrentPath () const
 Gets the currently viewed directory path.

Private Member Functions

ImTextureID GetIcon (const std::filesystem::directory_entry &entry, const BrowserIcons &icons)
 Gets the appropriate icon texture ID for a given directory entry.

Private Attributes

std::filesystem::path m_rootPath
std::filesystem::path m_currentPath
float m_padding = 16.0f
std::filesystem::path m_copiedPath
bool m_isCut = false
bool m_renaming = false
std::filesystem::path m_renamePath
char m_renameBuffer [256] = ""
char m_searchBuffer [256] = ""

Detailed Description

Class responsible for displaying and navigating project assets within an ImGUI window.

Definition at line 29 of file AssetBrowser.hpp.

Constructor & Destructor Documentation

◆ AssetBrowser()

vex::AssetBrowser::AssetBrowser ( const std::string & rootPath)

Constructs the AssetBrowser.

Parameters
conststd::string& rootPath - The root directory of the project assets.

Definition at line 13 of file AssetBrowser.cpp.

Member Function Documentation

◆ Draw()

std::string vex::AssetBrowser::Draw ( const BrowserIcons & icons,
float & thumbnailSize,
bool showBottomBar = true,
float height = 0.0f )

Draws the Asset Browser UI and handles interaction.

Parameters
constBrowserIcons& icons - The set of icons to use for drawing assets.
float&thumbnailSize - Reference to the thumbnail size from editor properties.
boolshowBottomBar - Whether to show the bottom slider bar. Set to false in file dialogs.
floatheight - The height of the asset browser. If 0, uses available space.
Returns
std::string - The path of the asset that was double-clicked/selected for action, or empty string otherwise.

Definition at line 45 of file AssetBrowser.cpp.

◆ getCurrentPath()

std::string vex::AssetBrowser::getCurrentPath ( ) const
inline

Gets the currently viewed directory path.

Returns
std::string - The current path as a string.

Definition at line 67 of file AssetBrowser.hpp.

◆ GetExtension()

std::string vex::AssetBrowser::GetExtension ( const std::string path)

Extracts the file extension from a path.

Parameters
conststd::string path - The file path.
Returns
std::string - The file extension (e.g., ".png", ".scene").

Definition at line 38 of file AssetBrowser.cpp.

◆ GetIcon()

ImTextureID vex::AssetBrowser::GetIcon ( const std::filesystem::directory_entry & entry,
const BrowserIcons & icons )
private

Gets the appropriate icon texture ID for a given directory entry.

Parameters
conststd::filesystem::directory_entry& entry - The file system entry.
constBrowserIcons& icons - The collection of available icons.
Returns
ImTextureID - The texture ID of the selected icon.

Definition at line 17 of file AssetBrowser.cpp.

◆ GetJSONAssetType()

int vex::AssetBrowser::GetJSONAssetType ( const std::string path)

Determines the type of a JSON asset (e.g., scene, material, etc.).

Parameters
conststd::string path - The file path to check.
Returns
int - An integer code representing the asset type.

Definition at line 334 of file AssetBrowser.cpp.

◆ setPadding()

void vex::AssetBrowser::setPadding ( float padding)
inline

Sets the padding between asset icons in the browser.

Parameters
floatpadding - The new padding value.

Definition at line 63 of file AssetBrowser.hpp.

Member Data Documentation

◆ m_copiedPath

std::filesystem::path vex::AssetBrowser::m_copiedPath
private

Definition at line 75 of file AssetBrowser.hpp.

◆ m_currentPath

std::filesystem::path vex::AssetBrowser::m_currentPath
private

Definition at line 71 of file AssetBrowser.hpp.

◆ m_isCut

bool vex::AssetBrowser::m_isCut = false
private

Definition at line 76 of file AssetBrowser.hpp.

◆ m_padding

float vex::AssetBrowser::m_padding = 16.0f
private

Definition at line 73 of file AssetBrowser.hpp.

◆ m_renameBuffer

char vex::AssetBrowser::m_renameBuffer[256] = ""
private

Definition at line 80 of file AssetBrowser.hpp.

◆ m_renamePath

std::filesystem::path vex::AssetBrowser::m_renamePath
private

Definition at line 79 of file AssetBrowser.hpp.

◆ m_renaming

bool vex::AssetBrowser::m_renaming = false
private

Definition at line 78 of file AssetBrowser.hpp.

◆ m_rootPath

std::filesystem::path vex::AssetBrowser::m_rootPath
private

Definition at line 70 of file AssetBrowser.hpp.

◆ m_searchBuffer

char vex::AssetBrowser::m_searchBuffer[256] = ""
private

Definition at line 82 of file AssetBrowser.hpp.


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