MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
NSBackend.hpp
Go to the documentation of this file.
1#pragma once
2
3#ifdef MAYAFLUX_PLATFORM_MACOS
4
5#include "SystemBackend.hpp"
6
7namespace MayaFlux::Core {
8
9/**
10 * @class NSBackend
11 * @brief macOS SystemBackend via NSOpenPanel / NSSavePanel (AppKit).
12 *
13 * AppKit panel calls must run on the main thread. Each dialog operation
14 * marshals onto the main dispatch queue via Parallel::dispatch_main_sync
15 * and blocks the calling thread until the user completes or dismisses.
16 * The result is delivered via callback before returning to the caller.
17 *
18 * Implementation lives in NSBackend.mm (Objective-C++) to access AppKit.
19 */
20class MAYAFLUX_API NSBackend final : public SystemBackend {
21public:
22 NSBackend() = default;
23 ~NSBackend() override = default;
24
25 NSBackend(const NSBackend&) = delete;
26 NSBackend& operator=(const NSBackend&) = delete;
27 NSBackend(NSBackend&&) noexcept = default;
28 NSBackend& operator=(NSBackend&&) noexcept = default;
29
30 [[nodiscard]] bool initialize() override;
31 void shutdown() override;
32 [[nodiscard]] bool is_initialized() const override { return m_initialized; }
33
34 void open_file(
35 FileDialogCallback callback,
36 std::vector<SystemFileFilter> filters,
37 std::filesystem::path start_dir) override;
38
39 void save_file(
40 FileDialogCallback callback,
41 std::string suggested_name,
42 std::vector<SystemFileFilter> filters,
43 std::filesystem::path start_dir) override;
44
45private:
46 bool m_initialized { false };
47};
48
49} // namespace MayaFlux::Core
50
51#endif // MAYAFLUX_PLATFORM_MACOS
void initialize()
Definition main.cpp:11
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