| 1 |
#ifndef FILE_LIST_WIDGET_HH |
| 2 |
#define FILE_LIST_WIDGET_HH |
| 3 |
|
| 4 |
#include "ImGuiUtils.hh" |
| 5 |
|
| 6 |
#include <ctime> |
| 7 |
#include <functional> |
| 8 |
#include <string> |
| 9 |
#include <string_view> |
| 10 |
|
| 11 |
namespace openmsx { |
| 12 |
|
| 13 |
class FileListWidget { |
| 14 |
public: |
| 15 |
FileListWidget(std::string_view fileType_, std::string_view extension_, std::string_view directory_); |
| 16 |
|
| 17 |
bool menu(const char* text); |
| 18 |
|
| 19 |
bool menu(const char* text, bool enabled); |
| 20 |
void drawTable(); |
| 21 |
|
| 22 |
public: |
| 23 |
struct Entry { |
| 24 |
std::string fullName; |
| 25 |
std::time_t ftime; |
| 26 |
|
| 27 |
std::string_view getDefaultDisplayName() const; |
| 28 |
}; |
| 29 |
|
| 30 |
|
| 31 |
static void defaultDeleteAction(const Entry& entry); |
| 32 |
|
| 33 |
void defaultHoverAction(const Entry& entry) const; |
| 34 |
|
| 35 |
|
| 36 |
std::function<void()> drawAction; |
| 37 |
std::function<void(const Entry&)> singleClickAction; |
| 38 |
std::function<void(const Entry&)> hoverAction; |
| 39 |
std::function<void(const Entry&)> doubleClickAction; |
| 40 |
std::function<void(const Entry&)> deleteAction; |
| 41 |
std::function<imColor(const Entry&)> displayColor; |
| 42 |
std::function<std::string(const Entry&)> displayName; |
| 43 |
|
| 44 |
private: |
| 45 |
void draw(); |
| 46 |
void scanDirectory(); |
| 47 |
|
| 48 |
private: |
| 49 |
std::string_view fileType; |
| 50 |
std::string_view extension; |
| 51 |
std::string_view directory; |
| 52 |
ConfirmDialog confirmDelete; |
| 53 |
std::vector<Entry> entries; |
| 54 |
bool menuOpen = false; |
| 55 |
bool needSort = false; |
| 56 |
}; |
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
#endif |