Hymn to Beauty
C++ 3D Engine
FileSelector.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4#include <vector>
5#include <string>
6
7namespace GUI {
10 public:
13
15 void Show();
16
18
21 void SetFileSelectedCallback(const std::function<void(const std::string&)>& callback);
22
24
27 void SetInitialPath(const char* path);
28
30
33 void SetExtensions(const std::vector<std::string>& extensions);
34
36
39 void AddExtensions(const std::string& extension);
40
42
45 bool IsVisible() const;
46
48
51 void SetVisible(bool visible);
52
53 private:
54 void OpenParentDirectory();
55 void OpenDirectory(const std::string& name);
56 void SelectFile(const std::string& name);
57 void ScanDirectory();
58
59 bool visible = false;
60
61 // Interaction
62 std::string path;
63 std::vector<std::string> extensions;
64 bool pathChanged = true;
65
66 std::vector<std::string> directories;
67 std::vector<std::string> files;
68
69 bool hasFileSelectedCallback = false;
70 std::function<void(const std::string&)> fileSelectedCallback;
71};
72} // namespace GUI
A window where a file can be selected.
Definition: FileSelector.hpp:9
FileSelector()
Create new window.
Definition: FileSelector.cpp:10
void Show()
Show the file selector.
Definition: FileSelector.cpp:12
void SetInitialPath(const char *path)
Set the initial path.
Definition: FileSelector.cpp:52
void SetExtensions(const std::vector< std::string > &extensions)
Set extensions to select files of.
void SetFileSelectedCallback(const std::function< void(const std::string &)> &callback)
Set function to call when a file has been selected.
Definition: FileSelector.cpp:47
void SetVisible(bool visible)
Set whether the window should be visible.
Definition: FileSelector.cpp:65
void AddExtensions(const std::string &extension)
Add extension to select files of.
Definition: FileSelector.cpp:56
bool IsVisible() const
Get whether the window is visible.
Definition: FileSelector.cpp:61
Definition: AssetEditor.hpp:9