yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
recent_files_menu_model.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_MENU_RECENT_FILES_MENU_MODEL_H_
2#define YAZE_APP_EDITOR_MENU_RECENT_FILES_MENU_MODEL_H_
3
4#include <cstddef>
5#include <functional>
6#include <string>
7#include <vector>
8
9namespace yaze {
10namespace editor {
11
12// One row of File > Open Recent.
14 std::string path; // Full path passed to EditorManager::OpenRomOrProject.
15 std::string label; // Unique, human-readable menu label.
16 bool exists = true; // False when the file is gone; the row is disabled.
17};
18
19using RecentFileExistsFn = std::function<bool(const std::string&)>;
20
21// Builds the Open Recent rows from the MRU list (most recent first).
22// - Keeps at most `max_entries` rows and skips empty or duplicate paths.
23// - Labels are the file name; when two rows share a file name, the parent
24// directory name is appended ("oos168.sfc (Roms)"), and if that still
25// collides the full path is used, so every label is unique (ImGui IDs).
26// - `exists` defaults to std::filesystem::exists when not provided.
27std::vector<RecentFileMenuEntry> BuildRecentFileMenuEntries(
28 const std::vector<std::string>& recent_paths, size_t max_entries = 10,
29 const RecentFileExistsFn& exists = nullptr);
30
31} // namespace editor
32} // namespace yaze
33
34#endif // YAZE_APP_EDITOR_MENU_RECENT_FILES_MENU_MODEL_H_
std::vector< RecentFileMenuEntry > BuildRecentFileMenuEntries(const std::vector< std::string > &recent_paths, size_t max_entries, const RecentFileExistsFn &exists)
std::function< bool(const std::string &)> RecentFileExistsFn