implement sharing in iOS, add OpenGL renderer in OSX window
This commit is contained in:
@@ -92,21 +92,6 @@ std::mutex task_mutex;
|
||||
{
|
||||
NSURL *url = [NSURL fileURLWithPath:file_path];
|
||||
NSArray *objectsToShare = @[url];
|
||||
//
|
||||
// UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
|
||||
//
|
||||
// // Exclude all activities except AirDrop.
|
||||
// NSArray *excludedActivities = @[UIActivityTypePostToTwitter, UIActivityTypePostToFacebook,
|
||||
// UIActivityTypePostToWeibo,
|
||||
// UIActivityTypeMessage, UIActivityTypeMail,
|
||||
// UIActivityTypePrint, UIActivityTypeCopyToPasteboard,
|
||||
// UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll,
|
||||
// UIActivityTypeAddToReadingList, UIActivityTypePostToFlickr,
|
||||
// UIActivityTypePostToVimeo, UIActivityTypePostToTencentWeibo];
|
||||
// controller.excludedActivityTypes = excludedActivities;
|
||||
//
|
||||
// // Present the controller
|
||||
// [self presentViewController:controller animated:YES completion:nil];
|
||||
[airdrop_service performWithItems:objectsToShare];
|
||||
}
|
||||
- (NSWindow *)sharingService:(NSSharingService *)sharingService sourceWindowForShareItems:(NSArray *)items sharingContentScope:(NSSharingContentScope *)sharingContentScope
|
||||
@@ -170,6 +155,7 @@ std::mutex task_mutex;
|
||||
|
||||
CGLLockContext([[self openGLContext] CGLContextObj]);
|
||||
App::I.init();
|
||||
[self.window setTitle:[NSString stringWithFormat:@"%s - %s", g_window_title, glGetString(GL_RENDERER)]];
|
||||
CGLUnlockContext([[self openGLContext] CGLContextObj]);
|
||||
gl_ready = true;
|
||||
|
||||
|
||||
@@ -28,4 +28,5 @@
|
||||
- (void)registerForKeyboardNotifications;
|
||||
- (void)unregisterForKeyboardNotifications;
|
||||
- (void)crash;
|
||||
- (void)share_file:(NSString*)file_path;
|
||||
@end
|
||||
|
||||
@@ -70,6 +70,21 @@ std::recursive_mutex lock_mutex;
|
||||
[self.context presentRenderbuffer:GL_RENDERBUFFER];
|
||||
}
|
||||
|
||||
- (void)share_file:(NSString *)file_path
|
||||
{
|
||||
NSURL *url = [NSURL fileURLWithPath:file_path];
|
||||
NSArray *objectsToShare = @[url];
|
||||
|
||||
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
|
||||
|
||||
controller.excludedActivityTypes = @[];
|
||||
controller.popoverPresentationController.sourceView = self.view;
|
||||
controller.popoverPresentationController.sourceRect = CGRectMake(self.view.bounds.size.width/2, self.view.bounds.size.height/4, 0, 0);
|
||||
|
||||
// Present the controller
|
||||
[self presentViewController:controller animated:YES completion:nil];
|
||||
}
|
||||
|
||||
-(void)display_file:(std::string)filename
|
||||
{
|
||||
NSString* filePath = [NSString stringWithUTF8String:filename.c_str()];
|
||||
|
||||
@@ -873,7 +873,7 @@ Here's a list of what's available in this release.
|
||||
<icon icon="picture_go" width="20"/>
|
||||
<text text="Export JPG" grow="1" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
||||
</button-custom>
|
||||
<button-custom id="file-share" os="osx" text="Menu" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||
<button-custom id="file-share" os="osx,ios" text="Menu" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||
<icon icon="picture_go" width="20"/>
|
||||
<text text="Share" grow="1" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
||||
</button-custom>
|
||||
|
||||
@@ -164,8 +164,14 @@ void App::display_file(std::string path)
|
||||
void App::share_file(std::string path)
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
message_box("Sharing failed", "Please save the document before sharing it.");
|
||||
return;
|
||||
}
|
||||
#ifdef __IOS__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view share_file:[NSString stringWithUTF8String:path.c_str()]];
|
||||
});
|
||||
#elif __OSX__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[osx_view share_file:[NSString stringWithUTF8String:path.c_str()]];
|
||||
|
||||
Reference in New Issue
Block a user