EchoMap 2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
Loading...
Searching...
No Matches
FilesystemCombo.hpp
Go to the documentation of this file.
1
9
10#ifndef ECHOMAP_FILESYSTEMCOMBO_HPP
11#define ECHOMAP_FILESYSTEMCOMBO_HPP
12
13#if !defined(__EMSCRIPTEN__) || defined(__DOXYGEN__)
14
15#include <imgui.h>
16
17#include <array>
18#include <filesystem>
19#include <optional>
20#include <string>
21#include <vector>
22
23namespace echomap
24{
25
26class EchoMap;
27
32{
33public:
42 explicit FilesystemCombo(EchoMap* app);
43
52 bool operator()(std::filesystem::path& selected_path);
53
54private:
55 static constexpr unsigned int max_path_length = 4096;
56
60 struct Entry
61 {
71 bool is_directory_hint);
72
78 [[nodiscard]] bool draw() const noexcept;
79
89 const Entry& lhs,
90 const Entry& rhs
91 ) noexcept
92 {
93 if (lhs.is_directory != rhs.is_directory)
94 return lhs.is_directory ? std::strong_ordering::less : std::strong_ordering::greater;
95
96 return lhs.name <=> rhs.name;
97 }
98
104 friend bool operator==(
105 const Entry&,
106 const Entry&
107 ) = default;
108
109 // NOLINTBEGIN(*-non-private-member-variables-in-classes) - Acceptable for private sub-struct.
110
114
115 // NOLINTEND(*-non-private-member-variables-in-classes)
116
117 private:
119 ImGuiSelectableFlags flags;
120 };
121
131
151
155 void invalidate_cache();
156
166
167 bool draw_combo_body(std::filesystem::path& selected_path);
168
169 [[nodiscard]] BrowseTarget get_browse_target() const;
170
171 bool draw_parent_entry(const std::filesystem::path& directory);
172
173 bool draw_child_entries(
174 std::string_view filter,
175 std::filesystem::path& selected_path
176 );
177
178 void accept_path(
179 std::filesystem::path& selected_path,
180 const std::filesystem::path& path
181 );
182
187};
188
189} // namespace echomap
190
191#endif // __EMSCRIPTEN__
192
193#endif // ECHOMAP_FILESYSTEMCOMBO_HPP
The EchoMap maintains state for the application including WebGPU and Dear ImGui context,...
Definition EchoMap.hpp:35
void invalidate_cache()
Invalidates the EntryCache.
bool operator()(std::filesystem::path &selected_path)
Draws the FilesystemCombo control.
FilesystemCombo(EchoMap *app)
Sets up a new FilesystemCombo with the given EchoMap application context.
std::optional< EntryCache > cache
Cache of entries visible in the combo box.
BrowseTarget current_target
The current target specified in the filter window.
EchoMap * app
Pointer to the owning application instance.
void update_current_state(const std::filesystem::path &path)
Copies and formats the given path into the fixed-size current directory state member variable.
static constexpr unsigned int max_path_length
Maximum number of characters in a filesystem path.
std::array< char, max_path_length > current_root
The current raw string entered by the user.
The main EchoMap outermost namespace for all non-exported symbols.
A root target selected by the user to focus on.
std::filesystem::path parent_directory
The parent directory of the target path.
std::filesystem::path target_path
The selected path.
std::string filter
Cached string of the target path filename.
EntryCache(const std::filesystem::path &directory)
Creates a new EntryCache and populates it for the given root directory.
std::filesystem::path directory
The root directory on the file-system.
std::vector< Entry > entries
The first-level children of the root.
bool is_directory
Directory sentinel flag.
friend bool operator==(const Entry &, const Entry &)=default
Determines equality between two Entry objects.
std::string name
The cached display name of the path.
friend std::strong_ordering operator<=>(const Entry &lhs, const Entry &rhs) noexcept
Determines the ordering between two Entry objects.
std::string imgui_id
Dear ImGui display name, including ID disambiguator.
std::filesystem::path path
The path represented by the Entry.
Entry(const std::filesystem::path &path, bool is_directory_hint)
Create a new Entry for a regular file or directory.
ImGuiSelectableFlags flags
Dear ImGui flags for rendering the Selectable.
bool draw() const noexcept
Draws the Entry as a Dear ImGui Selectable.