MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Chooser.cpp
Go to the documentation of this file.
1#include "Chooser.hpp"
2
5
7
9 ChooserCallback callback,
10 std::vector<ChooserFilter> filters,
11 std::filesystem::path start_dir)
12{
13 auto* backend = get_backend();
14 if (!backend) {
16 "Chooser::open_file: Portal::System not initialized");
17 callback(std::unexpected(Core::SystemDialogError::BackendError));
18 return;
19 }
20 backend->open_file(std::move(callback), std::move(filters), std::move(start_dir));
21}
22
24 ChooserCallback callback,
25 std::string suggested_name,
26 std::vector<ChooserFilter> filters,
27 std::filesystem::path start_dir)
28{
29 auto* backend = get_backend();
30 if (!backend) {
32 "Chooser::save_file: Portal::System not initialized");
33 callback(std::unexpected(Core::SystemDialogError::BackendError));
34 return;
35 }
36 backend->save_file(std::move(callback), std::move(suggested_name), std::move(filters), std::move(start_dir));
37}
38
39} // namespace MayaFlux::Portal::System::Dialog
#define MF_ERROR(comp, ctx,...)
@ BackendError
Platform backend failed to open or communicate.
@ API
API calls from external code.
@ Portal
High-level user-facing API layer.
Core::FileDialogCallback ChooserCallback
Callback type for the primitive callback overload.
Definition Chooser.hpp:17
void open_file(ChooserCallback callback, std::vector< ChooserFilter > filters, std::filesystem::path start_dir)
Present a native open-file dialog, delivering the result via callback.
Definition Chooser.cpp:8
void save_file(ChooserCallback callback, std::string suggested_name, std::vector< ChooserFilter > filters, std::filesystem::path start_dir)
Present a native save-file dialog, delivering the result via callback.
Definition Chooser.cpp:23
Core::SystemBackend * get_backend()
Access the active platform backend.
Definition System.cpp:22