add file selector with sorting
This commit is contained in:
30
src/file_selector.hpp
Normal file
30
src/file_selector.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
|
||||
struct FileSelector {
|
||||
std::filesystem::path _current_file_path = std::filesystem::canonical(".") / ""; // add /
|
||||
|
||||
bool _open_popup {false};
|
||||
|
||||
std::function<bool(const std::filesystem::path& path)> _is_valid = [](auto){ return true; };
|
||||
std::function<void(const std::filesystem::path& path)> _on_choose = [](auto){};
|
||||
std::function<void(void)> _on_cancel = [](){};
|
||||
|
||||
void reset(void);
|
||||
|
||||
public:
|
||||
FileSelector(void);
|
||||
|
||||
// TODO: supply hints
|
||||
void requestFile(
|
||||
std::function<bool(const std::filesystem::path& path)>&& is_valid,
|
||||
std::function<void(const std::filesystem::path& path)>&& on_choose,
|
||||
std::function<void(void)>&& on_cancel
|
||||
);
|
||||
|
||||
// call this each frame
|
||||
void render(void);
|
||||
};
|
||||
|
Reference in New Issue
Block a user