-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile-browser.hpp
More file actions
37 lines (29 loc) · 928 Bytes
/
file-browser.hpp
File metadata and controls
37 lines (29 loc) · 928 Bytes
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
#pragma once
#include <filesystem>
#include <string>
#include <vector>
namespace fs = std::filesystem;
namespace Engine {
struct FileBrowserState {
std::string root_directory;
bool has_root = false;
std::string selected_path;
// sizing state (percentages tracked elsewhere if needed)
int mainWindowWidth = 1000;
int mainWindowHeight = 800;
float filebrowserWidth = 400.f;
float filebrowserHeight = 480.f;
bool mainwindowresize = false;
};
class FileBrowser {
public:
void Initialize();
void UpdateOnWindowResize(FileBrowserState &state, int w, int h);
bool SetRootDirectory(FileBrowserState &state, const std::string &path);
void Render(FileBrowserState &state);
private:
void RenderDirectoryNode(FileBrowserState &state, const fs::path &dirPath,
int depth = 0);
void OpenFile(const std::string &path);
};
} // namespace Engine