Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions FilterShop/FilterShop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
TargetAttributes = {
C8959EA31F6F377C006AC83B = {
CreatedOnToolsVersion = 8.3.3;
DevelopmentTeam = L2UHX34QKF;
ProvisioningStyle = Automatic;
};
};
Expand All @@ -131,6 +130,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -231,6 +231,7 @@
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand Down Expand Up @@ -273,6 +274,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -281,13 +283,13 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = L2UHX34QKF;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = FilterShop/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = com.xueyu.FilterShop;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -296,13 +298,13 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = L2UHX34QKF;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = FilterShop/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = com.xueyu.FilterShop;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>FilterShop.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
6 changes: 3 additions & 3 deletions FilterShop/FilterShop/FilterParameterVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ extension FilterParameterVC : NSTableViewDelegate, NSTableViewDataSource {

func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {

guard let view = tableView.make(withIdentifier: "cell", owner: self) as? NSTableCellView,
guard let view = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "cell"), owner: self) as? NSTableCellView,
let key = filter?.inputKeys[row],
let paraDict = filter?.attributes[key] as? [String: Any]
else { return nil }

let colId = tableColumn?.identifier ?? ""
let colId = tableColumn?.identifier ?? NSUserInterfaceItemIdentifier(rawValue: "")
var viewText = ""

switch colId {
switch colId.rawValue {
case "name":
viewText = key
case "description":
Expand Down
11 changes: 6 additions & 5 deletions FilterShop/FilterShop/MediaDisplayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Cocoa
import AppKit

/// MediaDisplayView will be used to show the image
/// It accepts drag and drop image
Expand Down Expand Up @@ -47,7 +48,7 @@ class MediaDisplayView: NSView {
}

/// Options of the drag and drop eare, only receive images
let options = [NSPasteboardURLReadingContentsConformToTypesKey: NSImage.imageTypes()]
let options = [NSPasteboard.ReadingOptionKey.urlReadingContentsConformToTypes: NSImage.imageTypes]

/// Set up ImageView and layer for filter
override func draw(_ dirtyRect: NSRect) {
Expand All @@ -61,12 +62,12 @@ class MediaDisplayView: NSView {


NSColor.gray.setFill()
NSRectFill(dirtyRect)
dirtyRect.fill()
}

/// Register drag and drop, also unregister for imageView, since imageView support drag and drop naturally
override func awakeFromNib() {
register(forDraggedTypes: [NSURLPboardType])
registerForDraggedTypes([NSPasteboard.PasteboardType(kUTTypeURL as String)])
imageView.unregisterDraggedTypes()
}

Expand All @@ -76,7 +77,7 @@ class MediaDisplayView: NSView {
func shouldAllowDrag(_ draggingInfo: NSDraggingInfo) -> Bool {

var canAccept = false
let pasteBoard = draggingInfo.draggingPasteboard()
let pasteBoard = draggingInfo.draggingPasteboard

if pasteBoard.canReadObject(forClasses: [ NSURL.self ], options: options) {
canAccept = true
Expand Down Expand Up @@ -107,7 +108,7 @@ class MediaDisplayView: NSView {
override func performDragOperation(_ sender: NSDraggingInfo) -> Bool {
isReceivingDrag = false

let pasteBoard = sender.draggingPasteboard()
let pasteBoard = sender.draggingPasteboard

if let urls = pasteBoard.readObjects(forClasses: [NSURL.self], options: options) as? [URL],
let fileUrl = urls.first {
Expand Down
22 changes: 11 additions & 11 deletions FilterShop/FilterShop/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ class ViewController: NSViewController {
*/
@IBAction func deleteFilterTouched(_ sender: NSButton) {
let idx = chosenFiltersTableView.row(for: sender)

guard idx != -1 else { return }
chosenFiltersTableView.beginUpdates()
chosenFilters.remove(at: idx)
chosenFilters.remove(at: idx == -1 ? 0 : idx)
chosenFiltersTableView.removeRows(at: IndexSet(integer: idx), withAnimation: .effectFade)
chosenFiltersTableView.endUpdates()

Expand Down Expand Up @@ -115,7 +115,7 @@ class ViewController: NSViewController {

guard let window = self.view.window else { return }
openPanel.beginSheetModal(for: window) { (result) in
if result == NSModalResponseOK {
if result == .OK {
if let url = openPanel.url {
self.mediaView.imageUrl = url
}
Expand All @@ -131,7 +131,7 @@ class ViewController: NSViewController {
// Help Menu Item
@IBAction func helpMenuItemTouched(_ sender: NSMenuItem) {
let url = URL(string: "https://github.com/KrisYu/FilterShop")!
NSWorkspace.shared().open(url)
NSWorkspace.shared.open(url)
}


Expand All @@ -140,19 +140,19 @@ class ViewController: NSViewController {
*/
@IBAction func saveAs(_ sender: AnyObject){
let savePanel = NSSavePanel()
saveOptions = IKSaveOptions(imageProperties: [:], imageUTType: kUTTypePNG as String!)
saveOptions = IKSaveOptions(imageProperties: [:], imageUTType: kUTTypePNG as String)
saveOptions.addAccessoryView(to: savePanel)

guard let window = self.view.window, let _ = mediaView.ciimage else { return }
savePanel.beginSheetModal(for: window) { (result) in
if result == NSFileHandlingPanelOKButton {
self.savePanelDidEnd(sheet: savePanel, returnCode: result)
if result == .OK {
self.savePanelDidEnd(sheet: savePanel, returnCode: result.rawValue)
}
}
}

func savePanelDidEnd (sheet: NSSavePanel, returnCode: NSInteger) {
if returnCode == NSModalResponseOK {
if returnCode == NSApplication.ModalResponse.OK.rawValue {
guard let newUTType = saveOptions.imageUTType as CFString?,
let url = sheet.url as CFURL?,
let cgimage = mediaView.export(filters: chosenFilters),
Expand Down Expand Up @@ -189,15 +189,15 @@ extension ViewController: NSTableViewDelegate, NSTableViewDataSource {

// cell display Category and Filter in a different way
if filterName.hasPrefix("CICategory") {
guard let cell = tableView.make(withIdentifier: "CategoryCell", owner: self) as? NSTableCellView else {
guard let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "CategoryCell"), owner: self) as? NSTableCellView else {
return nil
}

let text = CIFilter.localizedName(forCategory: filterName)
cell.textField?.stringValue = text
return cell
} else {
guard let cell = tableView.make(withIdentifier: "FilterCell", owner: self) as? NSTableCellView,
guard let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "FilterCell"), owner: self) as? NSTableCellView,
let text = CIFilter.localizedName(forFilterName: filterName) else {
return nil
}
Expand All @@ -208,7 +208,7 @@ extension ViewController: NSTableViewDelegate, NSTableViewDataSource {

let filterName = chosenFilters[row].name

guard let cell = tableView.make(withIdentifier: "chosenFilterCell", owner: self) as? NSTableCellView else { return nil }
guard let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "chosenFilterCell"), owner: self) as? NSTableCellView else { return nil }

// display the filter name in readable way
cell.textField?.stringValue = CIFilter.localizedName(forFilterName: filterName) ?? "Unknown Filter"
Expand Down