blob: 206e699b01c92d74aa070375888eac18452c6b89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*******************************************************************************************
*
* raylib-extras [ImGui] example - asset browser
*
* This is a more complex ImGui Integration
* It shows how to build windows on top of 2d and 3d views using a render texture
*
* Copyright (c) 2024 Jeffery Myers
*
********************************************************************************************/
#pragma once
#include "item_view.h"
#include "raylib.h"
#include <string>
#include <vector>
#include <list>
class AssetBrowserPanel
{
public:
AssetBrowserPanel();
void Show();
private:
std::string AssetRoot;
class AssetItemInfo : public ViewableItem
{
protected:
bool File = false;
public:
AssetItemInfo(bool file) : File(file) {}
bool IsFile() const { return File; }
};
class FileInfo : public AssetItemInfo
{
public:
FileInfo() : AssetItemInfo(true) {}
std::string FullPath;
};
class FolderInfo : public AssetItemInfo
{
public:
FolderInfo() : AssetItemInfo(false) {}
std::string FullPath;
FolderInfo* Parent = nullptr;
std::list<FolderInfo> Children;
bool ForceOpenNextFrame = false;
void PopulateChildren();
};
FolderInfo FolderRoot;
class AssetContainer : public ViewableItemContainer
{
public:
ViewableItem* Reset() override;
size_t Count() override;
ViewableItem* Next() override;
FolderInfo* Folder = nullptr;
std::vector<FileInfo> Files;
std::vector<FileInfo>::iterator FileItr;
std::list<FolderInfo>::iterator FolderItr;
};
AssetContainer CurrentFolderContents;
ListItemView ListView;
ItemView* CurrentView = nullptr;
void RebuildFolderTree();
void SetCurrentFolder(FolderInfo* folder);
bool ShowFolderTreeNode(FolderInfo& folder);
void ShowFolderTree();
void ShowFilePane();
void ShowHeader();
const char* GetFileIcon(const char* filename);
};
|