F49AABE61DFC48F300E0B24F /* MainTouchBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = F49AABE51DFC48F300E0B24F /* MainTouchBar.xib */; };
F49AABE81DFD33FB00E0B24F /* HistoryWindowTouchBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = F49AABE71DFD33FB00E0B24F /* HistoryWindowTouchBar.xib */; };
F49AABF21DFD53A300E0B24F /* SlotItemWindowTouchBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = F49AABF11DFD53A300E0B24F /* SlotItemWindowTouchBar.xib */; };
- F4A2AF521A074DCF0024BD9E /* HMScreenshotListWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4A2AF501A074DCF0024BD9E /* HMScreenshotListWindowController.m */; };
F4A2AF581A0930160024BD9E /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4A2AF571A0930160024BD9E /* Quartz.framework */; };
F4A2AF5B1A0F9B490024BD9E /* HMScreenshotInformation.m in Sources */ = {isa = PBXBuildFile; fileRef = F4A2AF5A1A0F9B490024BD9E /* HMScreenshotInformation.m */; };
F4A3AD82199F529700FDBF80 /* HMCombinedBattleCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4A3AD81199F529700FDBF80 /* HMCombinedBattleCommand.m */; };
F4E5FF081E1542780026868C /* HMScreenshotEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4E5FF071E1542780026868C /* HMScreenshotEditorViewController.swift */; };
F4E5FF0A1E15CE3D0026868C /* HMBridgeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4E5FF091E15CE3D0026868C /* HMBridgeViewController.swift */; };
F4E5FF0C1E1645280026868C /* HMScreenshotListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4E5FF0B1E1645280026868C /* HMScreenshotListViewController.swift */; };
+ F4E5FF101E17A83D0026868C /* HMScreenshotListWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4E5FF0F1E17A83D0026868C /* HMScreenshotListWindowController.swift */; };
F4E7802818DBD2A00011BC4C /* HMGetShipCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E7802718DBD2A00011BC4C /* HMGetShipCommand.m */; };
F4E7802B18DC3A820011BC4C /* HMLocalDataStore.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E7802A18DC3A820011BC4C /* HMLocalDataStore.m */; };
F4E7802E18DC3AF00011BC4C /* LocalData.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = F4E7802C18DC3AF00011BC4C /* LocalData.xcdatamodeld */; };
F49AABE51DFC48F300E0B24F /* MainTouchBar.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainTouchBar.xib; sourceTree = "<group>"; };
F49AABE71DFD33FB00E0B24F /* HistoryWindowTouchBar.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HistoryWindowTouchBar.xib; sourceTree = "<group>"; };
F49AABF11DFD53A300E0B24F /* SlotItemWindowTouchBar.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SlotItemWindowTouchBar.xib; sourceTree = "<group>"; };
- F4A2AF4F1A074DCF0024BD9E /* HMScreenshotListWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMScreenshotListWindowController.h; sourceTree = "<group>"; };
- F4A2AF501A074DCF0024BD9E /* HMScreenshotListWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMScreenshotListWindowController.m; sourceTree = "<group>"; };
F4A2AF571A0930160024BD9E /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; };
F4A2AF591A0F9B490024BD9E /* HMScreenshotInformation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMScreenshotInformation.h; sourceTree = "<group>"; };
F4A2AF5A1A0F9B490024BD9E /* HMScreenshotInformation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMScreenshotInformation.m; sourceTree = "<group>"; };
F4E5FF071E1542780026868C /* HMScreenshotEditorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMScreenshotEditorViewController.swift; sourceTree = "<group>"; };
F4E5FF091E15CE3D0026868C /* HMBridgeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMBridgeViewController.swift; sourceTree = "<group>"; };
F4E5FF0B1E1645280026868C /* HMScreenshotListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMScreenshotListViewController.swift; sourceTree = "<group>"; };
+ F4E5FF0F1E17A83D0026868C /* HMScreenshotListWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMScreenshotListWindowController.swift; sourceTree = "<group>"; };
F4E7802618DBD2A00011BC4C /* HMGetShipCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMGetShipCommand.h; sourceTree = "<group>"; };
F4E7802718DBD2A00011BC4C /* HMGetShipCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMGetShipCommand.m; sourceTree = "<group>"; };
F4E7802918DC3A820011BC4C /* HMLocalDataStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMLocalDataStore.h; sourceTree = "<group>"; };
F4A9E7F61D045BC100F91746 /* HMScreenshotModel.m */,
F4A2AF591A0F9B490024BD9E /* HMScreenshotInformation.h */,
F4A2AF5A1A0F9B490024BD9E /* HMScreenshotInformation.m */,
- F4A2AF4F1A074DCF0024BD9E /* HMScreenshotListWindowController.h */,
- F4A2AF501A074DCF0024BD9E /* HMScreenshotListWindowController.m */,
+ F4E5FF0F1E17A83D0026868C /* HMScreenshotListWindowController.swift */,
F41465761DB4F1A700D68C97 /* HMScreenshotListWindowController.xib */,
F4E5FF0B1E1645280026868C /* HMScreenshotListViewController.swift */,
F4649FCB1DBC51EF0097AEBF /* HMScreenshotListViewController.xib */,
F45F3BE31E06A60A0009434E /* HMUpgradableShipsWindowController.swift in Sources */,
F4E33B5818BF5F67005B8C07 /* HMMemberSlotItemCommand.m in Sources */,
F4C1190B18A74DF0005D5B25 /* HMJSONCommand.m in Sources */,
+ F4E5FF101E17A83D0026868C /* HMScreenshotListWindowController.swift in Sources */,
F48A70671DE5D62C005DFC0B /* HMOrderedSetToArrayTransformer.m in Sources */,
F44AB23E19E824D700F217AF /* HMKCSlotItemObject.m in Sources */,
F4D6BCB01AA2A97200742FEB /* HMLengTransformer.m in Sources */,
F4E5FF021E150A850026868C /* HMAncherageRepairTimerViewController.swift in Sources */,
F4B414F218B1013C00468DAF /* HMMasterSlotItemCommand.m in Sources */,
F45FBB6F1E0FDB33000E72B9 /* HMStrengthenListViewController.swift in Sources */,
- F4A2AF521A074DCF0024BD9E /* HMScreenshotListWindowController.m in Sources */,
F45FBB711E101492000E72B9 /* HMDocksViewController.swift in Sources */,
F4131EE61910318F004F7F9A /* HMMasterSlotItemEquipTypeCommand.m in Sources */,
F4F9F8721C6A306A00D0EE76 /* HMKCBattle.m in Sources */,
#import "HMUserDefaults.h"
#import "HMBroserWindowController.h"
-#import "HMScreenshotListWindowController.h"
#import "HMShipMasterDetailWindowController.h"
#import "HMAppDelegate.h"
#import "HMUserDefaults.h"
-#import "HMScreenshotListWindowController.h"
@interface HMGameViewController ()
@property NSPoint flashTopLeft;
+++ /dev/null
-//
-// HMScreenshotListWindowController.h
-// KCD
-//
-// Created by Hori,Masaki on 2014/11/03.
-// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#import <Cocoa/Cocoa.h>
-
-
-@class HMMaskSelectView;
-
-@interface HMScreenshotListWindowController : NSWindowController
-
-- (void)registerScreenshot:(NSBitmapImageRep *)image fromOnScreen:(NSRect)screenRect;
-
-- (IBAction)changeToDetail:(id)sender;
-
-@end
+++ /dev/null
-//
-// HMScreenshotListWindowController.m
-// KCD
-//
-// Created by Hori,Masaki on 2014/11/03.
-// Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#import "HMScreenshotListWindowController.h"
-
-#import "KCD-Swift.h"
-
-#import "HMScreenshotModel.h"
-
-
-typedef BOOL (^HMFindViewController)(NSViewController *viewController);
-
-
-@interface HMScreenshotListWindowController () <NSSplitViewDelegate, NSSharingServicePickerTouchBarItemDelegate>
-@property (nonatomic, weak) NSPredicate *filterPredicate;
-@property (nonatomic, weak) IBOutlet NSButton *shareButton;
-
-@property (nonatomic, weak) IBOutlet NSView *left;
-@property (nonatomic, weak) IBOutlet NSView *right;
-
-@property (nonatomic, weak) IBOutlet NSViewController *rightController;
-
-@property (nonatomic, strong) HMScreenshotListViewController *listViewController;
-@property (nonatomic, strong) HMScreenshotDetailViewController *detailViewController;
-@property (nonatomic, strong) HMScreenshotEditorViewController *editorViewController;
-
-@property (strong) NSMutableArray<NSViewController *> *viewControllers;
-@property (nonatomic, weak) HMBridgeViewController *currentRightViewController;
-
-@end
-
-@implementation HMScreenshotListWindowController
-@synthesize filterPredicate = _filterPredicate;
-
-
-+ (instancetype)new
-{
- HMScreenshotListWindowController *result = [[self alloc] initWithWindowNibName:NSStringFromClass([self class])];
- [result window];
- return result;
-}
-
-- (void)replaceView:(NSView *)placeholder withViewController:(NSViewController *)viewController
-{
- [viewController.view setFrame:[placeholder frame]];
- [viewController.view setFrameOrigin:NSZeroPoint];
- [viewController.view setAutoresizingMask:[placeholder autoresizingMask]];
- [placeholder addSubview:viewController.view];
-}
-
-- (void)windowDidLoad
-{
- _viewControllers = [NSMutableArray array];
-
- [super windowDidLoad];
-
- self.listViewController = [HMScreenshotListViewController new];
- [self.viewControllers addObject:self.listViewController];
- [self replaceView:self.left withViewController:self.listViewController];
- self.listViewController.representedObject = self.listViewController.screenshots;
-
- self.detailViewController = [HMScreenshotDetailViewController new];
- [self.viewControllers addObject:self.detailViewController];
- [self.rightController addChildViewController:self.detailViewController];
- [self replaceView:self.right withViewController:self.detailViewController];
- self.detailViewController.representedObject = self.listViewController.screenshots;
-
- self.currentRightViewController = self.detailViewController;
-
- [self.shareButton sendActionOn:NSLeftMouseDownMask];
-}
-
-- (void)setFilterPredicate:(NSPredicate *)filterPredicate
-{
- self.listViewController.screenshots.filterPredicate = filterPredicate;
- _filterPredicate = filterPredicate;
-}
-- (NSPredicate *)filterPredicate
-{
- return _filterPredicate;
-}
-
-- (NSViewController *)findFromViewControllerUsingBlock:(HMFindViewController)blocks
-{
- for(NSViewController *vc in self.viewControllers) {
- if(blocks(vc)) return vc;
- }
-
- return nil;
-}
-
-- (void)registerScreenshot:(NSBitmapImageRep *)image fromOnScreen:(NSRect)screenRect
-{
- id viewControler = [self findFromViewControllerUsingBlock:^BOOL(NSViewController *viewController) {
- return [viewController respondsToSelector:_cmd];
- }];
-
- [viewControler registerScreenshot:image fromOnScreen:screenRect];
-}
-
-- (IBAction)share:(id)sender
-{
- [self.currentRightViewController share:sender];
-}
-
-- (id <NSSharingServiceDelegate>)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker delegateForSharingService:(NSSharingService *)sharingService
-{
- return self.currentRightViewController;
-}
-- (NSArray *)itemsForSharingServicePickerTouchBarItem:(NSSharingServicePickerTouchBarItem *)pickerTouchBarItem
-{
- return [self.currentRightViewController itemsForSharingServicePickerTouchBarItem:pickerTouchBarItem];
-}
-
-- (IBAction)changeToEditor:(id)sender
-{
- if(!self.editorViewController) {
- self.editorViewController = [HMScreenshotEditorViewController new];
- [self.rightController addChildViewController:self.editorViewController];
- [self.editorViewController view];
- self.editorViewController.representedObject = self.listViewController.screenshots;
- }
-
- [self.rightController transitionFromViewController:self.detailViewController
- toViewController:self.editorViewController
- options:NSViewControllerTransitionSlideLeft
- completionHandler:nil];
-
- self.currentRightViewController = self.editorViewController;
-}
-- (IBAction)changeToDetail:(id)sender
-{
- [self.rightController transitionFromViewController:self.editorViewController
- toViewController:self.detailViewController
- options:NSViewControllerTransitionSlideRight
- completionHandler:nil];
-
- self.currentRightViewController = self.detailViewController;
-}
-
-- (NSTouchBar *)touchBar
-{
- return self.listViewController.touchBar;
-}
-#pragma mark - NSSplitViewDelegate
-
-const CGFloat leftMinWidth = 299;
-const CGFloat rightMinWidth = 400;
-
-- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex
-{
- if(dividerIndex == 0) {
- return leftMinWidth;
- }
- return proposedMinimumPosition;
-}
-- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex
-{
- if(dividerIndex == 0) {
- NSSize size = splitView.frame.size;
- CGFloat rightWidth = size.width - proposedPosition;
- if(rightWidth < rightMinWidth) {
- return size.width - rightMinWidth;
- }
- }
- return proposedPosition;
-}
-- (void)splitView:(NSSplitView *)splitView resizeSubviewsWithOldSize:(NSSize)oldSize
-{
- [splitView adjustSubviews];
-
- NSView *leftView = splitView.subviews[0];
- NSView *rightView = splitView.subviews[1];
-
- if(NSWidth(leftView.frame) < leftMinWidth) {
- NSRect leftRect = leftView.frame;
- leftRect.size.width = leftMinWidth;
- leftView.frame = leftRect;
-
- NSRect rightRect = rightView.frame;
- rightRect.size.width = NSWidth(splitView.frame) - NSWidth(leftRect) - splitView.dividerThickness;
- rightRect.origin.x = NSWidth(leftRect) + splitView.dividerThickness;
- rightView.frame = rightRect;
- }
-}
-- (BOOL)splitView:(NSSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)view
-{
- NSView *leftView = splitView.subviews[0];
- NSView *rightView = splitView.subviews[1];
-
- if(leftView == view) {
- if(NSWidth(leftView.frame) < leftMinWidth) return NO;
- }
- if(rightView == view) {
- if(NSWidth(leftView.frame) >= leftMinWidth) return NO;
- }
-
- return YES;
-}
-
-
-@end
--- /dev/null
+//
+// HMScreenshotListWindowController.swift
+// KCD
+//
+// Created by Hori,Masaki on 2016/12/31.
+// Copyright © 2016年 Hori,Masaki. All rights reserved.
+//
+
+import Cocoa
+
+class HMScreenshotListWindowController: NSWindowController {
+ override var windowNibName: String! {
+ return "HMScreenshotListWindowController"
+ }
+ override func windowDidLoad() {
+ super.windowDidLoad()
+
+ // load window
+ guard let _ = self.window else { return }
+
+ listViewController = HMScreenshotListViewController()
+ viewControllers.append(listViewController)
+ replaceView(left, viewController: listViewController)
+ listViewController.representedObject = listViewController.screenshots
+ guard let _ = listViewController else {
+ print("Can not load listViewController")
+ return
+ }
+
+ detailViewController = HMScreenshotDetailViewController()
+ viewControllers.append(detailViewController)
+ rightController.addChildViewController(detailViewController)
+ replaceView(right, viewController: detailViewController)
+ detailViewController.representedObject = listViewController.screenshots
+ guard let _ = detailViewController else {
+ print("Can not load detailViewController")
+ return
+ }
+
+ editorViewController = HMScreenshotEditorViewController()
+ rightController.addChildViewController(editorViewController)
+ // force load view.
+ guard let _ = editorViewController.view.superview else { return }
+ editorViewController.representedObject = listViewController.screenshots
+ guard let _ = editorViewController else {
+ print("Can not load editorViewContoller")
+ return
+ }
+
+ currentRightViewController = detailViewController
+
+ shareButton.sendAction(on: [.leftMouseDown])
+ }
+
+ @IBOutlet weak var shareButton: NSButton!
+ @IBOutlet var rightController: NSViewController!
+ @IBOutlet weak var left: NSView!
+ @IBOutlet weak var right: NSView!
+
+ var filterPredicate: NSPredicate? = nil {
+ didSet {
+ listViewController.screenshots.filterPredicate = filterPredicate
+ }
+ }
+
+ fileprivate var listViewController: HMScreenshotListViewController! = nil
+ private var detailViewController: HMScreenshotDetailViewController! = nil
+ private var editorViewController: HMScreenshotEditorViewController! = nil
+ private var viewControllers: [NSViewController] = []
+ fileprivate weak var currentRightViewController: HMBridgeViewController! = nil
+
+
+ func replaceView(_ view: NSView, viewController: NSViewController) {
+ viewController.view.frame = view.frame
+ viewController.view.setFrameOrigin(NSZeroPoint)
+ viewController.view.autoresizingMask = view.autoresizingMask
+ view.addSubview(viewController.view)
+ }
+
+ func registerScreenshot(_ image: NSBitmapImageRep, fromOnScreen: NSRect) {
+ listViewController.registerScreenshot(image, fromOnScreen: fromOnScreen)
+ }
+
+ @IBAction func share(_ sender: AnyObject?) {
+ currentRightViewController.share(sender)
+ }
+ @IBAction func changeToEditor(_ sender: AnyObject?) {
+ rightController.transition(from: detailViewController, to: editorViewController, options: [.slideLeft], completionHandler: nil)
+ currentRightViewController = editorViewController
+ }
+ @IBAction func changeToDetail(_ sender: AnyObject?) {
+ rightController.transition(from: editorViewController, to: detailViewController, options: [.slideRight], completionHandler: nil)
+ currentRightViewController = detailViewController
+ }
+}
+
+extension HMScreenshotListWindowController: NSSharingServicePickerDelegate {
+ func sharingServicePicker(_ sharingServicePicker: NSSharingServicePicker, delegateFor sharingService: NSSharingService) -> NSSharingServiceDelegate? {
+ return currentRightViewController
+ }
+}
+
+extension HMScreenshotListWindowController: NSSplitViewDelegate {
+ private static let leftMinWidth: CGFloat = 299
+ private static let rightMinWidth: CGFloat = 400
+
+ func splitView(_ splitView: NSSplitView, constrainMinCoordinate proposedMinimumPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat {
+ if dividerIndex == 0 { return HMScreenshotListWindowController.leftMinWidth }
+ return proposedMinimumPosition
+ }
+ func splitView(_ splitView: NSSplitView, constrainSplitPosition proposedPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat {
+ if dividerIndex == 0 {
+ let rightWidth = splitView.frame.size.width - proposedPosition
+ if rightWidth < HMScreenshotListWindowController.rightMinWidth {
+ return splitView.frame.size.width - HMScreenshotListWindowController.rightMinWidth
+ }
+ }
+ return proposedPosition
+ }
+ func splitView(_ splitView: NSSplitView, resizeSubviewsWithOldSize oldSize: NSSize) {
+ splitView.adjustSubviews()
+
+ let leftView = splitView.subviews[0]
+ let rightView = splitView.subviews[1]
+ if NSWidth(leftView.frame) < HMScreenshotListWindowController.leftMinWidth {
+ var leftRect = leftView.frame
+ leftRect.size.width = HMScreenshotListWindowController.leftMinWidth
+ leftView.frame = leftRect
+
+ var rightRect = rightView.frame
+ rightRect.size.width = NSWidth(splitView.frame) - NSWidth(leftRect) - splitView.dividerThickness
+ rightRect.origin.x = NSWidth(leftRect) + splitView.dividerThickness
+ rightView.frame = rightRect
+ }
+ }
+ func splitView(_ splitView: NSSplitView, shouldAdjustSizeOfSubview view: NSView) -> Bool {
+ let leftView = splitView.subviews[0]
+ let rightView = splitView.subviews[1]
+ if leftView == view {
+ if NSWidth(leftView.frame) < HMScreenshotListWindowController.leftMinWidth { return false }
+ }
+ if rightView == view {
+ if NSWidth(leftView.frame) >= HMScreenshotListWindowController.leftMinWidth { return false }
+ }
+ return true
+ }
+}
+
+@available(OSX 10.12.2, *)
+extension HMScreenshotListWindowController: NSSharingServicePickerTouchBarItemDelegate {
+ override func makeTouchBar() -> NSTouchBar? {
+ return listViewController.touchBar
+ }
+
+ func items(for pickerTouchBarItem: NSSharingServicePickerTouchBarItem) -> [Any] {
+ return currentRightViewController.items(for: pickerTouchBarItem)
+ }
+}
#import "HMDamageView.h"
#import "HMStrengthenListItemCellView.h"
-#import "HMScreenshotListWindowController.h"
-
#import "HMImageView.h"
#import "HMTiledImageView.h"