Own preview and recording workers

This commit is contained in:
2026-06-16 07:18:08 +02:00
parent 4d7a23a1fd
commit 3366b54c7f
8 changed files with 78 additions and 51 deletions

View File

@@ -108,84 +108,87 @@ public:
[[nodiscard]] pp::platform::apple::AppleDocumentPlatformServices& active_apple_document_platform_services()
{
#ifdef __IOS__
auto* const ios_view = App::I->ios_view;
static pp::platform::apple::AppleDocumentPlatformServices services(
pp::platform::PlatformFamily::ios,
[] {
[ios_view] {
pp::platform::apple::AppleDocumentPickerBridge bridge;
bridge.clipboard_text = [] {
return [App::I->ios_view clipboard_get_string];
bridge.clipboard_text = [ios_view] {
return [ios_view clipboard_get_string];
};
bridge.set_clipboard_text = [](std::string_view text) {
bridge.set_clipboard_text = [ios_view](std::string_view text) {
const std::string value(text);
return [App::I->ios_view clipboard_set_string:value];
return [ios_view clipboard_set_string:value];
};
bridge.display_file = [](std::string path) {
bridge.display_file = [ios_view](std::string path) {
dispatch_async(dispatch_get_main_queue(), ^{
[App::I->ios_view display_file:path];
[ios_view display_file:path];
});
};
bridge.share_file = [](std::string path) {
bridge.share_file = [ios_view](std::string path) {
dispatch_async(dispatch_get_main_queue(), ^{
[App::I->ios_view share_file:[NSString stringWithUTF8String:path.c_str()]];
[ios_view share_file:[NSString stringWithUTF8String:path.c_str()]];
});
};
bridge.pick_image = [](pp::platform::PickedPathCallback callback) {
bridge.pick_image = [ios_view](pp::platform::PickedPathCallback callback) {
dispatch_async(dispatch_get_main_queue(), ^{
[App::I->ios_view pick_photo:callback];
[ios_view pick_photo:callback];
});
};
bridge.pick_file = [](
bridge.pick_file = [ios_view](
std::vector<std::string> file_types,
pp::platform::PickedPathCallback callback) {
dispatch_async(dispatch_get_main_queue(), ^{
[App::I->ios_view pick_file:apple_file_types_array(file_types) then:callback];
[ios_view pick_file:apple_file_types_array(file_types) then:callback];
});
};
return bridge;
}());
return services;
#else
auto* const osx_view = App::I->osx_view;
auto* const osx_app = App::I->osx_app;
static pp::platform::apple::AppleDocumentPlatformServices services(
pp::platform::PlatformFamily::macos,
[] {
[osx_view, osx_app] {
pp::platform::apple::AppleDocumentPickerBridge bridge;
bridge.clipboard_text = [] {
return [App::I->osx_view clipboard_get_string];
bridge.clipboard_text = [osx_view] {
return [osx_view clipboard_get_string];
};
bridge.set_clipboard_text = [](std::string_view text) {
bridge.set_clipboard_text = [osx_view](std::string_view text) {
const std::string value(text);
return [App::I->osx_view clipboard_set_string:value];
return [osx_view clipboard_set_string:value];
};
bridge.share_file = [](std::string path) {
bridge.share_file = [osx_view](std::string path) {
dispatch_async(dispatch_get_main_queue(), ^{
[App::I->osx_view share_file:[NSString stringWithUTF8String:path.c_str()]];
[osx_view share_file:[NSString stringWithUTF8String:path.c_str()]];
});
};
bridge.set_cursor_visible = [](bool visible) {
[App::I->osx_view show_cursor:visible];
bridge.set_cursor_visible = [osx_view](bool visible) {
[osx_view show_cursor:visible];
};
bridge.save_ui_state = [] {
[App::I->osx_app save_ui_state];
bridge.save_ui_state = [osx_app] {
[osx_app save_ui_state];
};
bridge.pick_file = [](
bridge.pick_file = [osx_view](
std::vector<std::string> file_types,
pp::platform::PickedPathCallback callback) {
dispatch_async(dispatch_get_main_queue(), ^{
const std::string path = [App::I->osx_view pick_file:apple_file_types_array(file_types)];
const std::string path = [osx_view pick_file:apple_file_types_array(file_types)];
callback(path);
});
};
bridge.pick_save_file = [](
bridge.pick_save_file = [osx_view](
std::vector<std::string> file_types,
pp::platform::PickedPathCallback callback) {
dispatch_async(dispatch_get_main_queue(), ^{
const std::string path = [App::I->osx_view pick_file_save:apple_file_types_array(file_types)];
const std::string path = [osx_view pick_file_save:apple_file_types_array(file_types)];
callback(path);
});
};
bridge.pick_directory = [](pp::platform::PickedPathCallback callback) {
bridge.pick_directory = [osx_view](pp::platform::PickedPathCallback callback) {
dispatch_async(dispatch_get_main_queue(), ^{
const std::string path = [App::I->osx_view pick_dir];
const std::string path = [osx_view pick_dir];
callback(path);
});
};