| 15 | |
| 16 | namespace ifd { |
| 17 | class FileDialog { |
| 18 | public: |
| 19 | static inline FileDialog& Instance() |
| 20 | { |
| 21 | static FileDialog ret; |
| 22 | return ret; |
| 23 | } |
| 24 | |
| 25 | FileDialog(); |
| 26 | ~FileDialog(); |
| 27 | |
| 28 | bool Save(const std::string& key, const std::string& title, const std::string& filter, const std::string& startingDir = ""); |
| 29 | |
| 30 | bool Open(const std::string& key, const std::string& title, const std::string& filter, bool isMultiselect = false, const std::string& startingDir = ""); |
| 31 | |
| 32 | bool IsDone(const std::string& key); |
| 33 | |
| 34 | inline bool HasResult() { return m_result.size(); } |
| 35 | inline const std::filesystem::path& GetResult() { return m_result[0]; } |
| 36 | inline const std::vector<std::filesystem::path>& GetResults() { return m_result; } |
| 37 | |
| 38 | void Close(); |
| 39 | |
| 40 | void RemoveFavorite(const std::string& path); |
| 41 | void AddFavorite(const std::string& path); |
| 42 | inline const std::vector<std::string>& GetFavorites() { return m_favorites; } |
| 43 | |
| 44 | inline void SetZoom(float z) { |
| 45 | m_zoom = std::min<float>(25.0f, std::max<float>(1.0f, z)); |
| 46 | m_refreshIconPreview(); |
| 47 | } |
| 48 | inline float GetZoom() { return m_zoom; } |
| 49 | |
| 50 | std::function<void*(uint8_t*, int, int, char)> CreateTexture; // char -> fmt -> { 0 = BGRA, 1 = RGBA } |
| 51 | std::function<void(void*)> DeleteTexture; |
| 52 | |
| 53 | class FileTreeNode { |
| 54 | public: |
| 55 | #ifdef _WIN32 |
| 56 | FileTreeNode(const std::wstring& path) { |
| 57 | Path = std::filesystem::path(path); |
| 58 | Read = false; |
| 59 | } |
| 60 | #endif |
| 61 | |
| 62 | FileTreeNode(const std::string& path) { |
| 63 | Path = std::filesystem::u8path(path); |
| 64 | Read = false; |
| 65 | } |
| 66 | |
| 67 | std::filesystem::path Path; |
| 68 | bool Read; |
| 69 | std::vector<FileTreeNode*> Children; |
| 70 | }; |
| 71 | class FileData { |
| 72 | public: |
| 73 | FileData(const std::filesystem::path& path); |
| 74 |
nothing calls this directly
no outgoing calls
no test coverage detected