OSDN Git Service

Equatableを自動実装させるようにした
[kcd/KCD.git] / KCD / ScreenshotEditorViewController.swift
index f6e626b..52600c9 100644 (file)
@@ -61,6 +61,7 @@ final class ScreenshotEditorViewController: BridgeViewController {
         
         get { return tiledImageView.columnCount }
         set {
+            
             tiledImageView.columnCount = newValue
             UserDefaults.standard[.screenshotEditorColumnCount] = newValue
         }
@@ -75,7 +76,11 @@ final class ScreenshotEditorViewController: BridgeViewController {
         
         get { return realiesCurrentTrimInforIndex }
         set {
-            guard case 0..<trimInfo.count = newValue else { return }
+            
+            guard case 0..<trimInfo.count = newValue else {
+                
+                return
+            }
             
             realiesCurrentTrimInforIndex = newValue
             currentTrimInfo = trimInfo[newValue]
@@ -89,11 +94,16 @@ final class ScreenshotEditorViewController: BridgeViewController {
     private var currentTrimInfo: TrimRectInformation {
         
         didSet {
+            
             makeTrimedImage()
             trimInfo
                 .index {
                     
-                    if $0.name != currentTrimInfo.name { return false }
+                    if $0.name != currentTrimInfo.name {
+                        
+                        return false
+                    }
+                    
                     return $0.rect == currentTrimInfo.rect
                 }
                 .map { UserDefaults.standard[.scrennshotEditorType] = $0 }
@@ -124,16 +134,22 @@ final class ScreenshotEditorViewController: BridgeViewController {
     
     private func updateSelections() {
         
-        guard let selection = arrayController.selectedObjects as? [ScreenshotInformation] else { return }
+        guard let selection = arrayController.selectedObjects as? [ScreenshotInformation] else {
+            
+            return
+        }
         
-        if selection == currentSelection { return }
+        if selection == currentSelection {
+            
+            return
+        }
         
-        let removed: [ScreenshotInformation] = currentSelection.flatMap {
+        let removed: [ScreenshotInformation] = currentSelection.compactMap {
             
             selection.contains($0) ? nil : $0
         }
         
-        let appended: [ScreenshotInformation] = selection.flatMap {
+        let appended: [ScreenshotInformation] = selection.compactMap {
             
             currentSelection.contains($0) ? nil : $0
         }
@@ -171,12 +187,13 @@ final class ScreenshotEditorViewController: BridgeViewController {
         guard !originalImages.isEmpty else {
             
             tiledImageView.images = []
+            
             return
         }
         
         DispatchQueue(label: "makeTrimedImage queue").async {
             
-            let images: [NSImage] = self.originalImages.flatMap {
+            let images: [NSImage] = self.originalImages.compactMap {
                 
                 let trimedImage = NSImage(size: self.currentTrimInfo.rect.size)