From 6aad7b912d627e14eee579a866d780e47ca853d5 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 14 Feb 2022 12:10:08 -0400 Subject: [PATCH] Add placeholder export accessory view --- SilicaViewer.xcodeproj/project.pbxproj | 40 ++++++++++++++++++++++++-- SilicaViewer/AppDelegate.swift | 4 ++- SilicaViewer/ExportAccessoryView.swift | 16 +++++++++++ SilicaViewer/ExportAccessoryView.xib | 35 ++++++++++++++++++++++ 4 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 SilicaViewer/ExportAccessoryView.swift create mode 100644 SilicaViewer/ExportAccessoryView.xib diff --git a/SilicaViewer.xcodeproj/project.pbxproj b/SilicaViewer.xcodeproj/project.pbxproj index 16fd635..8dcee4d 100644 --- a/SilicaViewer.xcodeproj/project.pbxproj +++ b/SilicaViewer.xcodeproj/project.pbxproj @@ -28,6 +28,9 @@ 036AFC11241800350075400A /* ThumbnailProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 036AFC10241800350075400A /* ThumbnailProvider.swift */; }; 036AFC16241800350075400A /* Thumbnail.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 036AFC0B241800350075400A /* Thumbnail.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 036AFC1B241800850075400A /* ZIPFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = 036AFC1A241800850075400A /* ZIPFoundation */; }; + 0371996027BAC5D800EE1DFD /* Silica_ViewerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0371995F27BAC5D800EE1DFD /* Silica_ViewerTests.swift */; }; + 0371996727BACD8700EE1DFD /* ExportAccessoryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0371996627BACD8700EE1DFD /* ExportAccessoryView.xib */; }; + 0371996927BACDE800EE1DFD /* ExportAccessoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0371996827BACDE800EE1DFD /* ExportAccessoryView.swift */; }; 03C39DE726F90734005555AE /* lzodefs.h in Headers */ = {isa = PBXBuildFile; fileRef = 03C39DE226F90733005555AE /* lzodefs.h */; }; 03C39DE826F90734005555AE /* Makefile in Sources */ = {isa = PBXBuildFile; fileRef = 03C39DE426F90734005555AE /* Makefile */; }; 03C39DE926F90734005555AE /* testmini.c in Sources */ = {isa = PBXBuildFile; fileRef = 03C39DE526F90734005555AE /* testmini.c */; }; @@ -53,6 +56,13 @@ remoteGlobalIDString = 036AFC0A241800350075400A; remoteInfo = Thumbnail; }; + 0371996127BAC5D800EE1DFD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 030F6FE62415C5E300A43F01 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 030F6FED2415C5E300A43F01; + remoteInfo = SilicaViewer; + }; 03CB383C2419CA2D0078B3E5 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 030F6FE62415C5E300A43F01 /* Project object */; @@ -105,6 +115,11 @@ 036AFC10241800350075400A /* ThumbnailProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThumbnailProvider.swift; sourceTree = ""; }; 036AFC12241800350075400A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 036AFC13241800350075400A /* Thumbnail.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Thumbnail.entitlements; sourceTree = ""; }; + 0371995827BAC52900EE1DFD /* SilicaViewer.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = SilicaViewer.xctestplan; sourceTree = ""; }; + 0371995D27BAC5D800EE1DFD /* Silica ViewerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Silica ViewerTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 0371995F27BAC5D800EE1DFD /* Silica_ViewerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Silica_ViewerTests.swift; sourceTree = ""; }; + 0371996627BACD8700EE1DFD /* ExportAccessoryView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ExportAccessoryView.xib; sourceTree = ""; }; + 0371996827BACDE800EE1DFD /* ExportAccessoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportAccessoryView.swift; sourceTree = ""; }; 03C39DE226F90733005555AE /* lzodefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lzodefs.h; sourceTree = ""; }; 03C39DE326F90733005555AE /* COPYING */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = COPYING; sourceTree = ""; }; 03C39DE426F90734005555AE /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; @@ -143,6 +158,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 0371995A27BAC5D800EE1DFD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 03CB382C2419C9DB0078B3E5 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -156,11 +178,13 @@ 030F6FE52415C5E300A43F01 = { isa = PBXGroup; children = ( + 0371995827BAC52900EE1DFD /* SilicaViewer.xctestplan */, 0357A94826F9C71E0075D5BC /* LZO */, 035D19F726F0927200B332BE /* SilicaViewer */, 03CB383E241A5ACD0078B3E5 /* Shared */, 030F700C2415C6B500A43F01 /* Quicklook */, 036AFC0F241800350075400A /* Thumbnail */, + 0371995E27BAC5D800EE1DFD /* Silica ViewerTests */, 030F70092415C6B500A43F01 /* Frameworks */, 030F6FEF2415C5E300A43F01 /* Products */, ); @@ -173,6 +197,7 @@ 030F70082415C6B500A43F01 /* QuickLook.appex */, 036AFC0B241800350075400A /* Thumbnail.appex */, 03CB382E2419C9DB0078B3E5 /* libLZO.a */, + 0371995D27BAC5D800EE1DFD /* Silica ViewerTests.xctest */, ); name = Products; sourceTree = ""; @@ -227,6 +252,8 @@ 035D1A0126F0927200B332BE /* AppDelegate.swift */, 035D1A0226F0927200B332BE /* TimelapseViewController.swift */, 035D1A0326F0927200B332BE /* Info.plist */, + 0371996627BACD8700EE1DFD /* ExportAccessoryView.xib */, + 0371996827BACDE800EE1DFD /* ExportAccessoryView.swift */, ); path = SilicaViewer; sourceTree = ""; @@ -241,6 +268,14 @@ path = Thumbnail; sourceTree = ""; }; + 0371995E27BAC5D800EE1DFD /* Silica ViewerTests */ = { + isa = PBXGroup; + children = ( + 0371995F27BAC5D800EE1DFD /* Silica_ViewerTests.swift */, + ); + path = "Silica ViewerTests"; + sourceTree = ""; + }; 03CB383E241A5ACD0078B3E5 /* Shared */ = { isa = PBXGroup; children = ( @@ -370,8 +405,7 @@ 030F6FE62415C5E300A43F01 /* Project object */ = { isa = PBXProject; attributes = { -==== BASE ==== - LastSwiftUpdateCheck = 1130; + LastSwiftUpdateCheck = 1320; LastUpgradeCheck = 1250; ORGANIZATIONNAME = Josh; TargetAttributes = { @@ -426,6 +460,7 @@ files = ( 035D1A0626F0927200B332BE /* Assets.xcassets in Resources */, 035D1A0726F0927200B332BE /* Main.storyboard in Resources */, + 0371996727BACD8700EE1DFD /* ExportAccessoryView.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -463,6 +498,7 @@ 035D1A0426F0927200B332BE /* ViewController.swift in Sources */, 035D1A0526F0927200B332BE /* cbridge.c in Sources */, 035D1A0826F0927200B332BE /* InfoViewController.swift in Sources */, + 0371996927BACDE800EE1DFD /* ExportAccessoryView.swift in Sources */, 03CB3840241A5AED0078B3E5 /* Shared.swift in Sources */, 035D1A0926F0927200B332BE /* Document.swift in Sources */, ); diff --git a/SilicaViewer/AppDelegate.swift b/SilicaViewer/AppDelegate.swift index 3f83f15..7f035d6 100644 --- a/SilicaViewer/AppDelegate.swift +++ b/SilicaViewer/AppDelegate.swift @@ -28,7 +28,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { let savePanel = NSSavePanel() savePanel.title = "Save" - savePanel.allowedFileTypes = ["public.png"] + savePanel.allowedFileTypes = ["public.png", "public.jpeg"] + savePanel.accessoryView = ExportAccessoryView.fromNib() + savePanel.begin { (result) in if result.rawValue == NSApplication.ModalResponse.OK.rawValue { let canvas = document?.makeComposite() diff --git a/SilicaViewer/ExportAccessoryView.swift b/SilicaViewer/ExportAccessoryView.swift new file mode 100644 index 0000000..c575272 --- /dev/null +++ b/SilicaViewer/ExportAccessoryView.swift @@ -0,0 +1,16 @@ +import Foundation +import AppKit + +class ExportAccessoryView : NSView { + +} + +extension NSView { + class func fromNib() -> T? { + var topLevelObjects : NSArray? + guard Bundle.main.loadNibNamed("\(self)", owner: nil, topLevelObjects: &topLevelObjects) else { + return nil + } + return topLevelObjects!.first(where: { $0 is T }) as? T + } +} diff --git a/SilicaViewer/ExportAccessoryView.xib b/SilicaViewer/ExportAccessoryView.xib new file mode 100644 index 0000000..5225ac1 --- /dev/null +++ b/SilicaViewer/ExportAccessoryView.xib @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +