21 const std::filesystem::path&
root()
const {
return root_; }
24 void navigate(
const std::filesystem::path& dir) { current_ = dir; refresh(); }
28 void set_filters(std::vector<std::string> patterns) { filters_ = std::move(patterns); refresh(); }
29 const std::vector<std::string>&
filters()
const {
return filters_; }
36 const std::filesystem::path&
selected_file()
const {
return selected_; }
39 std::function<void(
const std::filesystem::path&)>
on_select;
42 std::function<void(
const std::filesystem::path&)>
on_activate;
49 std::filesystem::path root_;
50 std::filesystem::path current_;
51 std::filesystem::path selected_;
52 std::vector<std::string> filters_;
53 bool show_hidden_ =
false;
57 bool is_directory =
false;
60 std::vector<Entry> entries_;
70 const std::filesystem::path&
root()
const {
return root_; }
73 std::function<void(
const std::filesystem::path&)>
on_select;
79 std::filesystem::path
path;
87 std::filesystem::path root_;
88 std::vector<FileTreeNode> nodes_;
100 static void share_file(
const std::filesystem::path& file,
void* parent_window =
nullptr);
138 std::unique_ptr<View> content;
140 std::vector<Document> documents_;
Definition canvas.hpp:240
Content opener for files and text.
Definition file_browser.hpp:97
static void share_text(const std::string &text, void *parent_window=nullptr)
Open text through a temporary file on supported platforms.
static void share_file(const std::filesystem::path &file, void *parent_window=nullptr)
Open a file with the platform's default opener when supported.
std::function< void(const std::filesystem::path &)> on_select
Callback when a file is selected (single click).
Definition file_browser.hpp:39
bool show_hidden() const
Definition file_browser.hpp:33
void set_root(const std::filesystem::path &root)
Set the root directory to browse from.
Definition file_browser.hpp:20
const std::filesystem::path & selected_file() const
The selected file (empty if no selection).
Definition file_browser.hpp:36
void set_filters(std::vector< std::string > patterns)
File filter patterns (e.g., {"*.wav", "*.aiff"}).
Definition file_browser.hpp:28
const std::filesystem::path & root() const
Definition file_browser.hpp:21
std::function< void(const std::filesystem::path &)> on_activate
Callback when a file is activated (double click or enter).
Definition file_browser.hpp:42
void paint(canvas::Canvas &canvas) override
void set_show_hidden(bool v)
Whether to show hidden files.
Definition file_browser.hpp:32
const std::vector< std::string > & filters() const
Definition file_browser.hpp:29
const std::filesystem::path & current_directory() const
Definition file_browser.hpp:25
void navigate(const std::filesystem::path &dir)
Set the current directory.
Definition file_browser.hpp:24
std::function< void(const std::filesystem::path &)> on_select
Callback when a file node is selected.
Definition file_browser.hpp:73
void paint(canvas::Canvas &canvas) override
const std::filesystem::path & root() const
Definition file_browser.hpp:70
void set_root(const std::filesystem::path &root)
Definition file_browser.hpp:69
void add_document(std::string title, std::unique_ptr< View > content)
Add a document tab.
std::function< void(int index)> on_active_changed
Callback when the active document changes.
Definition file_browser.hpp:131
void remove_document(int index)
Remove a document tab by index.
void set_active(int index)
Set the active document.
std::function< void(int index)> on_close
Callback when a document is closed.
Definition file_browser.hpp:128
void paint(canvas::Canvas &canvas) override
int active_index() const
Get the active document index (-1 if none).
Definition file_browser.hpp:119
int document_count() const
Number of open documents.
Definition file_browser.hpp:125
Definition affine_transform.hpp:24
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ text
Plain text (default color).
Definition code_editor_tokenizer.hpp:37
@ v
Definition input_events.hpp:41
Definition file_browser.hpp:77
bool is_directory
Definition file_browser.hpp:80
bool expanded
Definition file_browser.hpp:81
std::string name
Definition file_browser.hpp:78
std::filesystem::path path
Definition file_browser.hpp:79
int depth
Definition file_browser.hpp:82
Hierarchical tree display widget for file browsers, plugin lists, etc.