tomato/src/file_selector.hpp

32 lines
802 B
C++
Raw Normal View History

2023-07-27 19:34:47 +02:00
#pragma once
#include <filesystem>
#include <functional>
struct FileSelector {
std::filesystem::path _current_file_path = std::filesystem::canonical(".") / ""; // add /
bool _open_popup {false};
2024-02-08 18:11:51 +01:00
std::function<bool(std::filesystem::path& path)> _is_valid = [](auto){ return true; };
2023-07-27 19:34:47 +02:00
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
2024-02-08 18:11:51 +01:00
// HACK: until we supply hints, is_valid can modify
2023-07-27 19:34:47 +02:00
void requestFile(
2024-02-08 18:11:51 +01:00
std::function<bool(std::filesystem::path& path)>&& is_valid,
2023-07-27 19:34:47 +02:00
std::function<void(const std::filesystem::path& path)>&& on_choose,
std::function<void(void)>&& on_cancel
);
// call this each frame
void render(void);
};