|
@@ -7,19 +7,6 @@
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
|
-enum KMLeftSidePaneState: Int {
|
|
|
- case thumbnail = 1
|
|
|
- case outline
|
|
|
- case noteList
|
|
|
- case snapshotList
|
|
|
- case find
|
|
|
-}
|
|
|
-
|
|
|
-enum KMFindPaneState: Int {
|
|
|
- case singular = 1
|
|
|
- case grouped
|
|
|
-}
|
|
|
-
|
|
|
@objc protocol KMLeftSideViewControllerDelegate {
|
|
|
@objc optional func controlStateChange(_ obj: KMLeftSideViewController,show:Bool)
|
|
|
@objc optional func enterEditMode(_ obj: KMLeftSideViewController, _ pages: [Int])
|
|
@@ -39,10 +26,6 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
// @IBOutlet weak var contentBox: NSBox!
|
|
|
// @IBOutlet weak var leftBox: NSBox!
|
|
|
|
|
|
- lazy var thumbnailViewController : KMThumbnailViewController = {
|
|
|
- let thumbnailViewController = KMThumbnailViewController()
|
|
|
- return thumbnailViewController
|
|
|
- }()
|
|
|
lazy var outlineViewController : KMOutlineViewController = {
|
|
|
let outlineViewController = KMOutlineViewController()
|
|
|
return outlineViewController
|
|
@@ -62,10 +45,6 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
let fromViewController = KMFromViewController()
|
|
|
return fromViewController
|
|
|
}()
|
|
|
- lazy var searchViewController : KMSearchViewController = {
|
|
|
- let searchViewController = KMSearchViewController()
|
|
|
- return searchViewController
|
|
|
- }()
|
|
|
lazy var signatureViewController : KMSignatureViewController = {
|
|
|
let signatureViewController = KMSignatureViewController()
|
|
|
return signatureViewController
|
|
@@ -94,6 +73,12 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
|
|
|
open weak var delegate: KMLeftSideViewControllerDelegate?
|
|
|
|
|
|
+ deinit {
|
|
|
+ KMPrint("KMLeftSideViewController deinit.")
|
|
|
+
|
|
|
+ NotificationCenter.default.removeObserver(self)
|
|
|
+ }
|
|
|
+
|
|
|
override var nibName: NSNib.Name? {
|
|
|
return "LeftSideView"
|
|
|
}
|
|
@@ -117,6 +102,7 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
|
|
|
|
|
|
DistributedNotificationCenter.default().addObserver(self, selector: #selector(_themeChanged), name: NSApplication.interfaceThemeChangedNotification, object: nil)
|
|
|
+// self.resetThumbnails()
|
|
|
}
|
|
|
|
|
|
func showPanelView(show: Bool) {
|
|
@@ -192,13 +178,6 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
// self.fromViewController.reloadData()
|
|
|
// }
|
|
|
// break
|
|
|
-// case .Search: do {
|
|
|
-// self.searchViewController.listView = self.listView
|
|
|
-// self.searchViewController.delegate = self
|
|
|
-//// self.contentBox.contentView = self.searchViewController.view
|
|
|
-//// self.searchViewController.reloadData()
|
|
|
-// }
|
|
|
-// break
|
|
|
// case .Signature: do {
|
|
|
// self.signatureViewController.listView = self.listView
|
|
|
//// self.contentBox.contentView = self.signatureViewController.view
|
|
@@ -378,7 +357,6 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
NSArrayController *thumbnailArrayController;
|
|
|
|
|
|
NSArrayController *findArrayController;
|
|
|
- SKTableView *findTableView;
|
|
|
|
|
|
NSArrayController *groupedFindArrayController;
|
|
|
SKTableView *groupedFindTableView;
|
|
@@ -397,16 +375,17 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
// @property (nonatomic, retain) IBOutlet NSArrayController *thumbnailArrayController, *findArrayController, *groupedFindArrayController;
|
|
|
// @property (nonatomic, retain) IBOutlet SKTocOutlineView *tocOutlineView;
|
|
|
// @property (nonatomic, retain) IBOutlet *;
|
|
|
-// @property (nonatomic, retain) IBOutlet SKTableView *findTableView;
|
|
|
+// @property (nonatomic, retain) IBOutlet *;
|
|
|
// @property (nonatomic, retain) IBOutlet SKTableView *groupedFindTableView;
|
|
|
|
|
|
@IBOutlet var segmentedControl: KMSegmentedControl!
|
|
|
|
|
|
+ @IBOutlet var findTableView: KMBotaTableView!
|
|
|
@IBOutlet var thumbnailTableView: KMThumbnailTableView!
|
|
|
|
|
|
@IBOutlet weak var leftListView: NSView!
|
|
|
|
|
|
-// @property (nonatomic, retain) IBOutlet KMSearchViewController *searchViewController;
|
|
|
+ @IBOutlet var searchViewController: KMBotaSearchViewController!
|
|
|
@IBOutlet weak var toolButtonBox: NSBox!
|
|
|
@IBOutlet weak var toolButtonBoxLayoutConstraint: NSLayoutConstraint!
|
|
|
@IBOutlet weak var snapshotNormalView: NSView!
|
|
@@ -448,6 +427,14 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
@IBOutlet weak var emptySearchBox: NSBox!
|
|
|
@IBOutlet weak var emptySearchLabel: NSTextField!
|
|
|
|
|
|
+ var thumbnails: [KMThumbnail] = []
|
|
|
+ var isDisplayPageSize = false
|
|
|
+ var thumbnailCacheSize: CGFloat = 0
|
|
|
+ var findState: KMFindState = .content
|
|
|
+ var searchResults: [CPDFSelection] = []
|
|
|
+
|
|
|
+ private let MIN_SIDE_PANE_WIDTH: CGFloat = 270
|
|
|
+
|
|
|
override func loadView() {
|
|
|
super.loadView()
|
|
|
|
|
@@ -463,7 +450,7 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
self.snapshotNormalView.layer?.backgroundColor = KMAppearance.Layout.l0Color().cgColor
|
|
|
|
|
|
// tocOutlineView.backgroundColor = [KMAppearance KMColor_Layout_L0];
|
|
|
-// findTableView.backgroundColor = [KMAppearance KMColor_Layout_L0];
|
|
|
+ self.findTableView.backgroundColor = KMAppearance.KMColor_Layout_L0()
|
|
|
// groupedFindTableView.backgroundColor = [KMAppearance KMColor_Layout_L0];
|
|
|
self.thumbnailTableView.backgroundColor = KMAppearance.Layout.l0Color()
|
|
|
|
|
@@ -620,7 +607,7 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
self.noteDoneButton.toolTip = KMLocalizedString("Done", nil)
|
|
|
self.noteDoneButton.setTitleColor(KMAppearance.Layout.w0Color())
|
|
|
self.noteDoneButton.wantsLayer = true
|
|
|
- self.noteDoneButton.layer?.backgroundColor = KMAppearance.KMColor_Interactive_A0().cgColor
|
|
|
+ self.noteDoneButton.layer?.backgroundColor = KMAppearance.Interactive.a0Color().cgColor
|
|
|
self.noteDoneButton.layer?.cornerRadius = 4.0
|
|
|
// [self.noteDoneButton setAction:@selector(leftSideViewDoneButtonAction:)]
|
|
|
// [self.noteDoneButton setTarget:mainController];
|
|
@@ -637,7 +624,7 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
// }
|
|
|
// };
|
|
|
self.noteHeaderView.wantsLayer = true
|
|
|
- self.noteHeaderView.layer?.backgroundColor = KMAppearance.KMColor_Else_Text_Tag().cgColor
|
|
|
+ self.noteHeaderView.layer?.backgroundColor = KMAppearance.Else.textTagColor().cgColor
|
|
|
self.noteHeaderView.layer?.cornerRadius = 1.0
|
|
|
// let sortType = sud.integer(forKey: KMLeftSideViewNoteSortTypeKey)
|
|
|
// if (sortType) {
|
|
@@ -653,7 +640,7 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
// _noteSortType = KMNoteSortType_Time;
|
|
|
// self.sortTypeLabel.stringValue = NSLocalizedString(@"Time", nil);
|
|
|
// }
|
|
|
- self.sortTypeLabel.textColor = KMAppearance.KMColor_Layout_H1()
|
|
|
+ self.sortTypeLabel.textColor = KMAppearance.Layout.h1Color()
|
|
|
|
|
|
// _isAscendSort = [sud boolForKey:KMLeftSideViewAscendSortBoolKey];
|
|
|
// if (_isAscendSort) {
|
|
@@ -684,17 +671,17 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
// }
|
|
|
// };
|
|
|
|
|
|
-// [searchViewController loadView];
|
|
|
-// searchViewController.contentView = findTableView.enclosingScrollView;
|
|
|
-// self.searchField = searchViewController.searchField;
|
|
|
+ self.searchViewController.loadView()
|
|
|
+ self.searchViewController.contentView = self.findTableView.enclosingScrollView
|
|
|
+ self.searchField = self.searchViewController.searchField
|
|
|
|
|
|
-// [searchViewController.segmentedControl setSegmentCount:2 withWidth:25];
|
|
|
-// [searchViewController.segmentedControl setImage:[NSImage imageNamed:KMImageNameUXIconBtnSidebarListNor] forSegment:0];
|
|
|
-// [searchViewController.segmentedControl setImage:[NSImage imageNamed:KMImageNameUXIconBtnSidebarPageNor] forSegment:1];
|
|
|
-// [searchViewController.segmentedControl setToolTip:NSLocalizedString(@"Separate search results", nil) forSegment:0];
|
|
|
-// [searchViewController.segmentedControl setToolTip:NSLocalizedString(@"Group search results by page", nil) forSegment:1];
|
|
|
-// [searchViewController.segmentedControl setIsBackgroundHighlighted:YES];
|
|
|
-// [searchViewController.segmentedControl setSelectedSegment:0];
|
|
|
+ self.searchViewController.segmentedControl.setSegmentCount(2, with: 25)
|
|
|
+ self.searchViewController.segmentedControl.setImage(NSImage(named: KMImageNameUXIconBtnSidebarListNor)!, for: 0)
|
|
|
+ self.searchViewController.segmentedControl.setImage(NSImage(named: KMImageNameUXIconBtnSidebarPageNor)!, for: 1)
|
|
|
+ self.searchViewController.segmentedControl.setToolTip(KMLocalizedString("Separate search results", nil), for: 0)
|
|
|
+ self.searchViewController.segmentedControl.setToolTip(KMLocalizedString("Group search results by page", nil), for: 1)
|
|
|
+ self.searchViewController.segmentedControl.isBackgroundHighlighted = true
|
|
|
+ self.searchViewController.segmentedControl.selectedSegment = 0
|
|
|
// [mainController bind:@"findPaneState" toObject:searchViewController.segmentedControl withKeyPath:@"selectedSegment" options:nil];
|
|
|
|
|
|
self.segmentedControl.segmentCount = 5
|
|
@@ -713,6 +700,25 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
// [mainController bind:@"leftSidePaneState" toObject:segmentedControl withKeyPath:@"selectedSegment" options:nil];
|
|
|
self.segmentedControl.wantsLayer = true
|
|
|
self.segmentedControl.layer?.backgroundColor = KMAppearance.Layout.l_1Color().cgColor
|
|
|
+ self.segmentedControl.block = { [unowned self] segIndex in
|
|
|
+ self.toolButtonBox.isHidden = false
|
|
|
+ self.toolButtonBoxLayoutConstraint.constant = 40.0
|
|
|
+
|
|
|
+ if (segIndex == 0) {
|
|
|
+ self.toolButtonBox.contentView = self.thumbnailView
|
|
|
+ self.displayThumbnailViewAnimating(true)
|
|
|
+ } else if (segIndex == 1) {
|
|
|
+ self.toolButtonBox.contentView = self.outlineView
|
|
|
+ } else if (segIndex == 2) {
|
|
|
+ self.toolButtonBox.contentView = self.noteView
|
|
|
+ } else if (segIndex == 3) {
|
|
|
+ self.toolButtonBox.contentView = self.snapshotNormalView
|
|
|
+ } else if (segIndex == 4) {
|
|
|
+ self.toolButtonBox.isHidden = true
|
|
|
+ self.toolButtonBoxLayoutConstraint.constant = 0
|
|
|
+ self.displayFindViewAnimating(false)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// self.button.setHelp(KMLocalizedString("View Thumbnails", "Tool tip message"), for: KMLeftSidePaneState.thumbnail.rawValue)
|
|
|
// self.button.setHelp(KMLocalizedString("View Outline", "Tool tip message"), for: KMLeftSidePaneState.outline.rawValue)
|
|
@@ -735,11 +741,9 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
// [tocOutlineView setDelegate:mainController];
|
|
|
// [tocOutlineView setDataSource:mainController];
|
|
|
self.thumbnailTableView.delegate = self
|
|
|
-// [thumbnailTableView setDelegate:mainController];
|
|
|
-// [thumbnailTableView setDataSource:mainController];
|
|
|
self.thumbnailTableView.dataSource = self
|
|
|
self.thumbnailTableView.allowsMultipleSelection = true
|
|
|
-// [findTableView setDelegate:mainController];
|
|
|
+ self.findTableView.delegate = self
|
|
|
// // [groupedFindTableView setDelegate:mainController];
|
|
|
// [groupedFindTableView setDataSource:mainController];
|
|
|
// [[thumbnailTableView menu] setDelegate:mainController];
|
|
@@ -780,38 +784,185 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
// [self updateViewColor];
|
|
|
}
|
|
|
|
|
|
+ func displayThumbnailViewAnimating(_ animate: Bool) {
|
|
|
+ self.replaceSideView(self.thumbnailTableView.enclosingScrollView!, animate: animate)
|
|
|
+
|
|
|
+ var frame = self.thumbnailTableView.enclosingScrollView?.frame ?? .zero
|
|
|
+ frame.origin.y = 0
|
|
|
+ frame.size.height = self.thumbnailTableView.enclosingScrollView?.superview?.frame.size.height ?? 0
|
|
|
+ self.thumbnailTableView.enclosingScrollView?.frame = frame
|
|
|
+
|
|
|
+ self.resetThumbnails()
|
|
|
+
|
|
|
+// frame = rightSideController.noteOutlineView.enclosingScrollView.frame;
|
|
|
+// frame.origin.y = 0;
|
|
|
+// frame.size.height = rightSideController.noteOutlineView.enclosingScrollView.superview.frame.size.height;
|
|
|
+// rightSideController.noteOutlineView.enclosingScrollView.frame = frame;
|
|
|
+
|
|
|
+// frame = rightSideController.snapshotTableView.enclosingScrollView.frame;
|
|
|
+// frame.origin.y = 0;
|
|
|
+// frame.size.height = rightSideController.snapshotTableView.enclosingScrollView.superview.frame.size.height;
|
|
|
+// rightSideController.snapshotTableView.enclosingScrollView.frame = frame;
|
|
|
+
|
|
|
+// [self updateThumbnailSelection];
|
|
|
+ }
|
|
|
+
|
|
|
+ func displayFindViewAnimating(_ animate: Bool) {
|
|
|
+ self.replaceSideView(self.searchViewController.view, animate: animate)
|
|
|
+ if (self.findState != .content) {
|
|
|
+ self.findState = .content
|
|
|
+ } else {
|
|
|
+ self.displayFindState()
|
|
|
+ }
|
|
|
+
|
|
|
+ var frame = self.searchViewController.view.frame
|
|
|
+ frame.origin.y = 0
|
|
|
+ frame.size.height = self.searchViewController.view.superview?.frame.size.height ?? .zero
|
|
|
+ self.searchViewController.view.frame = frame
|
|
|
+
|
|
|
+// frame = rightSideController.noteOutlineView.enclosingScrollView.frame;
|
|
|
+// frame.origin.y = 0;
|
|
|
+// frame.size.height = rightSideController.noteOutlineView.enclosingScrollView.superview.frame.size.height;
|
|
|
+// rightSideController.noteOutlineView.enclosingScrollView.frame = frame;
|
|
|
+
|
|
|
+// frame = rightSideController.snapshotTableView.enclosingScrollView.frame;
|
|
|
+// frame.origin.y = 0;
|
|
|
+// frame.size.height = rightSideController.snapshotTableView.enclosingScrollView.superview.frame.size.height;
|
|
|
+// rightSideController.snapshotTableView.enclosingScrollView.frame = frame;
|
|
|
+// [self.leftSideEmptyVC.emptySnapView removeFromSuperview];
|
|
|
+
|
|
|
+// [self updataLeftSideSnapView];
|
|
|
+ }
|
|
|
+
|
|
|
+ func displayFindState() {
|
|
|
+ if (self.findState == .content) {
|
|
|
+ self.displayFind()
|
|
|
+ } else if (self.findState == .note) {
|
|
|
+// [self displayNoteFind];
|
|
|
+ } else if (self.findState == .snapshot) {
|
|
|
+// [self displaySnapshotFind];
|
|
|
+ }
|
|
|
+ }
|
|
|
/*
|
|
|
- @implementation SKLeftSideViewController
|
|
|
+
|
|
|
+ - (void) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ - (void)displayGroupedFindViewAnimating:(BOOL)animate {
|
|
|
+ [leftSideController replaceSideView:leftSideController.searchViewController.view animate:animate];
|
|
|
+ if (self.findState != SKFindStateContent) {
|
|
|
+ self.findState = SKFindStateContent;
|
|
|
+ } else {
|
|
|
+ [leftSideController displayFindState];
|
|
|
+ }
|
|
|
+
|
|
|
+ NSRect frame = leftSideController.searchViewController.view.frame;
|
|
|
+ frame.origin.y = 0;
|
|
|
+ frame.size.height = leftSideController.searchViewController.view.superview.frame.size.height;
|
|
|
+ leftSideController.searchViewController.view.frame = frame;
|
|
|
+
|
|
|
+ frame = rightSideController.noteOutlineView.enclosingScrollView.frame;
|
|
|
+ frame.origin.y = 0;
|
|
|
+ frame.size.height = rightSideController.noteOutlineView.enclosingScrollView.superview.frame.size.height;
|
|
|
+ rightSideController.noteOutlineView.enclosingScrollView.frame = frame;
|
|
|
+
|
|
|
+ frame = rightSideController.snapshotTableView.enclosingScrollView.frame;
|
|
|
+ frame.origin.y = 0;
|
|
|
+ frame.size.height = rightSideController.snapshotTableView.enclosingScrollView.superview.frame.size.height;
|
|
|
+ rightSideController.snapshotTableView.enclosingScrollView.frame = frame;
|
|
|
+
|
|
|
+ [self updataLeftSideSnapView];
|
|
|
+ }
|
|
|
|
|
|
- @synthesize tocOutlineView, thumbnailArrayController, thumbnailTableView, findArrayController, findTableView, groupedFindArrayController, groupedFindTableView;
|
|
|
-
|
|
|
- @synthesize segmentedControl, searchViewController;
|
|
|
-
|
|
|
- - (void)dealloc {
|
|
|
- [[NSNotificationCenter defaultCenter]removeObserver:self];
|
|
|
- [thumbnailTableView setDelegate:nil];
|
|
|
- [thumbnailTableView setDataSource:nil];
|
|
|
- [findTableView setDelegate:nil];
|
|
|
- // [groupedFindTableView setDelegate:nil];
|
|
|
- [groupedFindTableView setDataSource:nil];
|
|
|
- [tocOutlineView setDelegate:nil];
|
|
|
- [tocOutlineView setDataSource:nil];
|
|
|
- [_filterButtonLayer release];
|
|
|
- [_moreButtonLayer release];
|
|
|
- SKDESTROY(thumbnailArrayController);
|
|
|
- SKDESTROY(findArrayController);
|
|
|
- SKDESTROY(groupedFindArrayController);
|
|
|
- SKDESTROY(tocOutlineView);
|
|
|
- SKDESTROY(thumbnailTableView);
|
|
|
- SKDESTROY(findTableView);
|
|
|
- SKDESTROY(groupedFindTableView);
|
|
|
+ - (void)displayNoteViewAnimating:(BOOL)animate {
|
|
|
+ leftSideController.searchViewController.contentView = nil;
|
|
|
+ [leftSideController replaceSideView:rightSideController.noteOutlineView.enclosingScrollView animate:animate];
|
|
|
+ if (self.findState != SKFindStateNote) {
|
|
|
+ self.findState = SKFindStateNote;
|
|
|
+ } else {
|
|
|
+ [leftSideController displayFindState];
|
|
|
+ }
|
|
|
+
|
|
|
+ NSRect frame = rightSideController.noteOutlineView.enclosingScrollView.frame;
|
|
|
+ frame.origin.y = 0;
|
|
|
+ frame.size.height = rightSideController.noteOutlineView.enclosingScrollView.superview.frame.size.height;
|
|
|
+ rightSideController.noteOutlineView.enclosingScrollView.frame = frame;
|
|
|
|
|
|
- SKDESTROY(segmentedControl);
|
|
|
- SKDESTROY(searchViewController);
|
|
|
- [super dealloc];
|
|
|
+ frame = rightSideController.noteOutlineView.enclosingScrollView.frame;
|
|
|
+ frame.origin.y = 0;
|
|
|
+ frame.size.height = rightSideController.noteOutlineView.enclosingScrollView.superview.frame.size.height;
|
|
|
+ rightSideController.noteOutlineView.enclosingScrollView.frame = frame;
|
|
|
+
|
|
|
+ frame = rightSideController.snapshotTableView.enclosingScrollView.frame;
|
|
|
+ frame.origin.y = 0;
|
|
|
+ frame.size.height = rightSideController.snapshotTableView.enclosingScrollView.superview.frame.size.height;
|
|
|
+ rightSideController.snapshotTableView.enclosingScrollView.frame = frame;
|
|
|
+
|
|
|
+ NSView *view = rightSideController.noteOutlineView.enclosingScrollView;
|
|
|
+ CGSize emptyVcSize = self.leftSideEmptyVC.emptyAnnotationView.frame.size;
|
|
|
+ self.leftSideEmptyVC.emptyAnnotationView.frame = NSMakeRect((view.frame.size.width-emptyVcSize.width)/2.0,(view.frame.size.height-emptyVcSize.height)/2.0, emptyVcSize.width, emptyVcSize.height);
|
|
|
}
|
|
|
|
|
|
+ - (void)displaySnapshotViewAnimating:(BOOL)animate {
|
|
|
+ leftSideController.searchViewController.contentView = nil;
|
|
|
+ [leftSideController replaceSideView:rightSideController.snapshotTableView.enclosingScrollView animate:animate];
|
|
|
+ if (self.findState != SKFindStateSnapshot) {
|
|
|
+ self.findState = SKFindStateSnapshot;
|
|
|
+ } else {
|
|
|
+ [leftSideController displayFindState];
|
|
|
+ }
|
|
|
+
|
|
|
+ NSRect frame = rightSideController.snapshotTableView.enclosingScrollView.frame;
|
|
|
+ frame.origin.y = 0;
|
|
|
+ frame.size.height = rightSideController.snapshotTableView.enclosingScrollView.superview.frame.size.height;
|
|
|
+ rightSideController.snapshotTableView.enclosingScrollView.frame = frame;
|
|
|
+
|
|
|
+ frame = rightSideController.noteOutlineView.enclosingScrollView.frame;
|
|
|
+ frame.origin.y = 0;
|
|
|
+ frame.size.height = rightSideController.noteOutlineView.enclosingScrollView.superview.frame.size.height;
|
|
|
+ rightSideController.noteOutlineView.enclosingScrollView.frame = frame;
|
|
|
+
|
|
|
+ frame = leftSideController.tocOutlineView.enclosingScrollView.frame;
|
|
|
+ frame.origin.y = 0;
|
|
|
+ frame.size.height = leftSideController.tocOutlineView.enclosingScrollView.superview.frame.size.height;
|
|
|
+ leftSideController.tocOutlineView.enclosingScrollView.frame = frame;
|
|
|
+
|
|
|
+ [self updateSnapshotsIfNeeded];
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+ func displayFind() {
|
|
|
+ self.searchField = self.searchViewController.searchField
|
|
|
+
|
|
|
+ let menu = NSMenu()
|
|
|
+// menu.addItem(title: <#T##String#>, action: <#T##Selector?#>, target: <#T##AnyObject?#>)
|
|
|
+// [menu addItemWithTitle:NSLocalizedString(@"Whole Words Only", @"Menu item title") action:@selector(toggleWholeWordSearch:) target:mainController];
|
|
|
+// [menu addItemWithTitle:NSLocalizedString(@"Ignore Case", @"Menu item title") action:@selector(toggleCaseInsensitiveSearch:) target:mainController];
|
|
|
+// [[searchViewController.searchField cell] setSearchMenuTemplate:menu];
|
|
|
+ (self.searchViewController.searchField.cell as? NSSearchFieldCell)?.placeholderString = KMLocalizedString("Search PDF", "placeholder")
|
|
|
+// self.searchViewController.searchField.target =
|
|
|
+// [searchViewController.searchField setAction:@selector(search:)];
|
|
|
+// [searchViewController.searchField setTarget:mainController];
|
|
|
+
|
|
|
+// if (mainController.findPaneState == SKFindPaneStateSingular) {
|
|
|
+ self.searchViewController.contentView = self.findTableView.enclosingScrollView;
|
|
|
+// } else if (mainController.findPaneState == SKFindPaneStateGrouped) {
|
|
|
+// searchViewController.contentView = groupedFindTableView.enclosingScrollView;
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ - (void) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @implementation SKLeftSideViewController
|
|
|
+
|
|
|
+ @synthesize tocOutlineView, thumbnailArrayController, findArrayController, groupedFindArrayController, groupedFindTableView;
|
|
|
|
|
|
- (BOOL)requiresAlternateButtonForView:(NSView *)aView {
|
|
|
return NO;
|
|
@@ -835,23 +986,7 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- - (void)displayFind {
|
|
|
- self.searchField = searchViewController.searchField;
|
|
|
-
|
|
|
- NSMenu *menu = [NSMenu menu];
|
|
|
- [menu addItemWithTitle:NSLocalizedString(@"Whole Words Only", @"Menu item title") action:@selector(toggleWholeWordSearch:) target:mainController];
|
|
|
- [menu addItemWithTitle:NSLocalizedString(@"Ignore Case", @"Menu item title") action:@selector(toggleCaseInsensitiveSearch:) target:mainController];
|
|
|
- [[searchViewController.searchField cell] setSearchMenuTemplate:menu];
|
|
|
- [[searchViewController.searchField cell] setPlaceholderString:NSLocalizedString(@"Search PDF", @"placeholder")];
|
|
|
- [searchViewController.searchField setAction:@selector(search:)];
|
|
|
- [searchViewController.searchField setTarget:mainController];
|
|
|
-
|
|
|
- if (mainController.findPaneState == SKFindPaneStateSingular) {
|
|
|
- searchViewController.contentView = findTableView.enclosingScrollView;
|
|
|
- } else if (mainController.findPaneState == SKFindPaneStateGrouped) {
|
|
|
- searchViewController.contentView = groupedFindTableView.enclosingScrollView;
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
- (void)displayNoteFind {
|
|
|
mainController.rightSideController.searchField = self.noteSearchField;
|
|
@@ -962,33 +1097,59 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"KMAnnotationSortTypeKeyNotification" object:self userInfo:nil];
|
|
|
}
|
|
|
*/
|
|
|
-}
|
|
|
-
|
|
|
-extension KMLeftSideViewController: KMThumbnailViewControllerDelegate {
|
|
|
- func gotoPageEdit(thumbnailViewController: KMThumbnailViewController, pages: [Int]) {
|
|
|
- self.delegate?.enterEditMode?(self, pages)
|
|
|
- }
|
|
|
|
|
|
- func pageDidSelect(controller: KMThumbnailViewController, pages: [Int]) {
|
|
|
- self.selectPages = pages
|
|
|
- }
|
|
|
-
|
|
|
- func controller(controller: KMThumbnailViewController, itemClick item: Any?, itemKey: KMItemKey, params: Any?) {
|
|
|
- self.delegate?.controller?(controller: self, itemClick: item, itemKey: itemKey, params: params)
|
|
|
+ func resetThumbnails() {
|
|
|
+// [self willChangeValueForKey:THUMBNAILS_KEY];
|
|
|
+
|
|
|
+ self.thumbnailCacheSize = 400
|
|
|
+
|
|
|
+ self.thumbnails.removeAll()
|
|
|
+ let pageLabels = self.listView.document.pageLabels()
|
|
|
+ if (pageLabels.isEmpty == false) {
|
|
|
+ let isLocked = self.listView.document.isLocked
|
|
|
+ let firstPage = self.listView.document.page(at: 0)
|
|
|
+ // SKPDFPage
|
|
|
+ let emptyPage = CPDFPage()
|
|
|
+ let firstFrame = firstPage?.bounds(for: .cropBox) ?? .zero
|
|
|
+ let firstFrame2 = firstPage?.bounds(for: .mediaBox) ?? .zero
|
|
|
+ emptyPage.setBounds(firstFrame, for: .cropBox)
|
|
|
+ emptyPage.setBounds(firstFrame2, for: .mediaBox)
|
|
|
+ emptyPage.rotation = firstPage?.rotation ?? 0
|
|
|
+
|
|
|
+ let pageImage = firstPage!.thumbnail(of: NSMakeSize(self.thumbnailCacheSize, self.thumbnailCacheSize))
|
|
|
+// NSImage * = [emptyPage thumbnailWithSize:thumbnailCacheSize forBox:[pdfView displayBox]];
|
|
|
+ var rect: NSRect = .zero
|
|
|
+ rect.size = pageImage?.size ?? .zero
|
|
|
+ let width = 1.2 * fmin(NSWidth(rect), NSHeight(rect))
|
|
|
+ rect = NSInsetRect(rect, 0.5 * (NSWidth(rect) - width), 0.5 * (NSHeight(rect) - width));
|
|
|
+
|
|
|
+ pageImage?.lockFocus()
|
|
|
+ NSImage(named: NSImage.applicationIconName)?.draw(in: rect, from: .zero, operation: .sourceOver, fraction: 0.5)
|
|
|
+ if (isLocked) {
|
|
|
+ NSWorkspace.shared.icon(forFileType: NSFileTypeForHFSTypeCode(OSType(kLockedBadgeIcon))).draw(in: rect, from: .zero, operation: .sourceOver, fraction: 0.5)
|
|
|
+ // [[[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kLockedBadgeIcon)] drawInRect:rect fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:0.5];
|
|
|
+ }
|
|
|
+ pageImage?.unlockFocus()
|
|
|
+
|
|
|
+// __block typeof(self) blockSelf = self;
|
|
|
+ for (i, label) in pageLabels.enumerated() {
|
|
|
+ let thumbnail = KMThumbnail(image: pageImage, label: label, pageIndex: i)
|
|
|
+ // thumbnail.delegate = self
|
|
|
+ thumbnail.dirty = true
|
|
|
+ self.thumbnails.append(thumbnail)
|
|
|
+ }
|
|
|
+ }
|
|
|
+// [self didChangeValueForKey:THUMBNAILS_KEY];
|
|
|
+// [self allThumbnailsNeedUpdate];
|
|
|
+
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ self.thumbnailTableView.reloadData()
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
-extension KMLeftSideViewController : KMSearchViewControllerDelegate {
|
|
|
-// func searchAction(searchString: String,isCase:Bool) {
|
|
|
-// self.delegate?.searchAction?(searchString: searchString, isCase: isCase)
|
|
|
-// }
|
|
|
-//
|
|
|
-// func searchDoneAction(viewController: KMSearchViewController) {
|
|
|
-// self.type = KMLeftMethodMode()
|
|
|
-// self.updateViewButtonState()
|
|
|
-// self.delegate?.controlStateChange?(self,show:false)
|
|
|
-//// self.leftTableview.reloadData()
|
|
|
-// }
|
|
|
+ /*
|
|
|
+
|
|
|
+
|
|
|
+ */
|
|
|
}
|
|
|
|
|
|
//MARK: NSTableViewDelegate,NSTableViewDataSource
|
|
@@ -1216,7 +1377,6 @@ extension KMLeftSideViewController {
|
|
|
self.bookViewController.removeNotification()
|
|
|
self.annotationViewController.removeNotification()
|
|
|
self.outlineViewController.removeNotification()
|
|
|
- self.thumbnailViewController.removeNotification()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1268,7 +1428,7 @@ extension KMLeftSideViewController {
|
|
|
self.thumbnailTableView.backgroundColor = NSColor(red: 0.149, green: 0.157, blue: 0.169, alpha: 1)
|
|
|
// groupedFindTableView.backgroundColor = NSColor(red: 0.149, green: 0.157, blue: 0.169, alpha: 1)
|
|
|
// tocOutlineView.backgroundColor = NSColor(red: 0.149, green: 0.157, blue: 0.169, alpha: 1)
|
|
|
-// findTableView.backgroundColor = NSColor(red: 0.149, green: 0.157, blue: 0.169, alpha: 1)
|
|
|
+ self.findTableView.backgroundColor = NSColor(red: 0.149, green: 0.157, blue: 0.169, alpha: 1)
|
|
|
|
|
|
self.snapshotSearchField.layer?.backgroundColor = NSColor(red: 0.224, green: 0.235, blue: 0.243, alpha: 1).cgColor
|
|
|
self.outlineSearchField.layer?.backgroundColor = NSColor(red: 0.224, green: 0.235, blue: 0.243, alpha: 1).cgColor
|
|
@@ -1289,7 +1449,7 @@ extension KMLeftSideViewController {
|
|
|
self.thumbnailTableView.backgroundColor = NSColor(red: 0.988, green: 0.992, blue: 1.000, alpha: 1)
|
|
|
// groupedFindTableView.backgroundColor = NSColor(red: 0.988, green: 0.992, blue: 1.000, alpha: 1)
|
|
|
// tocOutlineView.backgroundColor = NSColor(red: 0.988, green: 0.992, blue: 1.000, alpha: 1)
|
|
|
-// findTableView.backgroundColor = NSColor(red: 0.988, green: 0.992, blue: 1.000, alpha: 1)
|
|
|
+ self.findTableView.backgroundColor = NSColor(red: 0.988, green: 0.992, blue: 1.000, alpha: 1)
|
|
|
|
|
|
self.snapshotSearchField.layer?.backgroundColor = NSColor(red: 0.922, green: 0.925, blue: 0.941, alpha: 1).cgColor
|
|
|
self.outlineSearchField.layer?.backgroundColor = NSColor(red: 0.922, green: 0.925, blue: 0.941, alpha: 1).cgColor
|
|
@@ -1305,66 +1465,73 @@ extension KMLeftSideViewController {
|
|
|
*/
|
|
|
}
|
|
|
|
|
|
-extension KMLeftSideViewController: KMThumbnailTableViewDelegate, NSTableViewDataSource {
|
|
|
+// MARK: - KMThumbnailTableViewDelegate, NSTableViewDataSource
|
|
|
+
|
|
|
+extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
func numberOfRows(in tableView: NSTableView) -> Int {
|
|
|
+ if tableView.isEqual(to: self.thumbnailTableView) {
|
|
|
+ return self.thumbnails.count
|
|
|
+ } else if tableView.isEqual(to: self.findTableView) {
|
|
|
+ return self.searchResults.count
|
|
|
+ }
|
|
|
return 0
|
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
|
|
if tableView.isEqual(to: self.thumbnailTableView) {
|
|
|
-// if ([tableView isEqual:leftSideController.thumbnailTableView]) {
|
|
|
-// let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMThumbnailTableviewCell"), owner: self)
|
|
|
-// SKThumbnail *thumbnail = thumbnails[row];
|
|
|
-// cell.pageNumLabel.stringValue = thumbnail.label;
|
|
|
-// cell.thumImage.image = thumbnail.image;
|
|
|
-// CGFloat multiplierHToW = thumbnail.image.size.height / thumbnail.image.size.width;
|
|
|
-// CGFloat multiplierWToH = thumbnail.image.size.width / thumbnail.image.size.height;
|
|
|
-// if (thumbnail.image.size.height > thumbnail.image.size.width) {
|
|
|
-// [NSLayoutConstraint deactivateConstraints:@[cell.imageAspectRatioLayout]];
|
|
|
-// cell.imageAspectRatioLayout = [NSLayoutConstraint constraintWithItem:cell.thumImage attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:cell.thumImage attribute:NSLayoutAttributeWidth multiplier:multiplierHToW constant:0];
|
|
|
-// [NSLayoutConstraint activateConstraints:@[cell.imageAspectRatioLayout]];
|
|
|
-// } else {
|
|
|
-// [NSLayoutConstraint deactivateConstraints:@[cell.imageAspectRatioLayout]];
|
|
|
-// cell.imageAspectRatioLayout = [NSLayoutConstraint constraintWithItem:cell.thumImage attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:cell.thumImage attribute:NSLayoutAttributeHeight multiplier:multiplierWToH constant:0];
|
|
|
-// [NSLayoutConstraint activateConstraints:@[cell.imageAspectRatioLayout]];
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (self.isDisplayPageSize) {
|
|
|
-// cell.sizeLabel.hidden = NO;
|
|
|
-//
|
|
|
-// //获取Page的真实尺寸
|
|
|
-// PDFPage *page = [self.pdfView.document pageAtIndex:row];
|
|
|
-// CGRect rect = [page boundsForBox:kPDFDisplayBoxCropBox];
|
|
|
-// NSString *w = [KMPageSizeTool conversionWithUnit:@"mm" value:(CGRectGetWidth(rect)/595 * 210)]?:@"";
|
|
|
-// NSString *h = [KMPageSizeTool conversionWithUnit:@"mm" value:(CGRectGetHeight(rect)/842 * 297)]?:@"";
|
|
|
-// if (page.rotation == 90 || page.rotation == 270) {
|
|
|
-// cell.sizeLabel.stringValue = [NSString stringWithFormat:@"%.f × %.f %@",[h floatValue], [w floatValue], NSLocalizedString(@"mm", nil)];
|
|
|
-// } else {
|
|
|
-// cell.sizeLabel.stringValue = [NSString stringWithFormat:@"%.f × %.f %@",[w floatValue], [h floatValue], NSLocalizedString(@"mm", nil)];
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// cell.sizeLabel.hidden = YES;
|
|
|
-// }
|
|
|
-// cell.sizeTopConstant.constant = cell.sizeLabel.hidden ? -cell.sizeLabel.frame.size.height : 0;
|
|
|
-// if([leftSideController.thumbnailTableView.selectedRowIndexes containsIndex:row]) {
|
|
|
-// cell.isSelectCell = YES;
|
|
|
-// } else {
|
|
|
-// cell.isSelectCell = NO;
|
|
|
-// }
|
|
|
-// return cell;
|
|
|
+ let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMThumbnailTableviewCell"), owner: self) as! KMThumbnailTableviewCell
|
|
|
+ let thumbnail = self.thumbnails[row]
|
|
|
+ cell.pageNumLabel.stringValue = thumbnail.label
|
|
|
+ cell.thumImage.image = thumbnail.image
|
|
|
+ if let _image = thumbnail.image {
|
|
|
+ let multiplierHToW = _image.size.height / (_image.size.width == 0 ? 1 : _image.size.width)
|
|
|
+ let multiplierWToH = _image.size.width / (_image.size.height == 0 ? 1 : _image.size.height)
|
|
|
+ if (_image.size.height > _image.size.width) {
|
|
|
+ NSLayoutConstraint.deactivate([cell.imageAspectRatioLayout])
|
|
|
+ cell.imageAspectRatioLayout = NSLayoutConstraint(item: cell.thumImage, attribute: .height, relatedBy: .equal, toItem: cell.thumImage, attribute: .width, multiplier: multiplierHToW, constant: 0)
|
|
|
+ NSLayoutConstraint.activate([cell.imageAspectRatioLayout])
|
|
|
+ } else {
|
|
|
+ NSLayoutConstraint.deactivate([cell.imageAspectRatioLayout])
|
|
|
+ cell.imageAspectRatioLayout = NSLayoutConstraint(item: cell.thumImage, attribute: .width, relatedBy: .equal, toItem: cell.thumImage, attribute: .height, multiplier: multiplierWToH, constant: 0)
|
|
|
+ NSLayoutConstraint.activate([cell.imageAspectRatioLayout])
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (self.isDisplayPageSize) {
|
|
|
+ cell.sizeLabel.isHidden = false
|
|
|
+ //获取Page的真实尺寸
|
|
|
+ let page = self.listView.document.page(at: UInt(row))
|
|
|
+ let rect = page?.bounds(for: .cropBox) ?? .zero
|
|
|
+ let w = KMPageSizeTool.conversion(withUnit: "mm", value: (CGRectGetWidth(rect)/595 * 210))
|
|
|
+ let h = KMPageSizeTool.conversion(withUnit: "mm", value: (CGRectGetHeight(rect)/842 * 297))
|
|
|
+ if let data = page?.rotation, data == 90 || data == 270 {
|
|
|
+ cell.sizeLabel.stringValue = String(format: "%.f × %.f %@", h.stringToCGFloat(), w.stringToCGFloat(), KMLocalizedString("mm", nil))
|
|
|
+ } else {
|
|
|
+ cell.sizeLabel.stringValue = String(format: "%.f × %.f %@", w.stringToCGFloat(), h.stringToCGFloat(), KMLocalizedString("mm", nil))
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ cell.sizeLabel.isHidden = true
|
|
|
+ }
|
|
|
+ cell.sizeTopConstant.constant = cell.sizeLabel.isHidden ? -cell.sizeLabel.frame.size.height : 0
|
|
|
+ if(self.thumbnailTableView.selectedRowIndexes.contains(row)) {
|
|
|
+ cell.isSelectCell = true
|
|
|
+ } else {
|
|
|
+ cell.isSelectCell = false
|
|
|
+ }
|
|
|
+ return cell
|
|
|
+ } else if (tableView.isEqual(to: self.findTableView)) {
|
|
|
+ let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMFindTableviewCell"), owner: self) as! KMFindTableviewCell
|
|
|
+ let selection = searchResults[row]
|
|
|
+ if let data = tableColumn?.identifier.rawValue, data == "results" {
|
|
|
+ cell.resultLabel.attributedStringValue = selection.attributedString()
|
|
|
+ cell.resultLabel.textColor = KMAppearance.Layout.h0Color()
|
|
|
+ } else if let data = tableColumn?.identifier.rawValue, data == "page" {
|
|
|
+ cell.resultLabel.stringValue = selection.pages().first?.label ?? ""
|
|
|
+ cell.resultLabel.textColor = KMAppearance.Layout.h2Color()
|
|
|
+ }
|
|
|
+ return cell
|
|
|
}
|
|
|
-// else if ([tableView isEqual:leftSideController.findTableView]) {
|
|
|
-// KMFindTableviewCell *cell = [tableView makeViewWithIdentifier:@"KMFindTableviewCell" owner:self];
|
|
|
-// PDFSelection *selection = searchResults[row];
|
|
|
-// if ([tableColumn.identifier isEqualToString:@"results"]) {
|
|
|
-// cell.resultLabel.attributedStringValue = [selection contextString];
|
|
|
-// cell.resultLabel.textColor = [KMAppearance KMColor_Layout_H0];
|
|
|
-// } else if ([tableColumn.identifier isEqualToString:@"page"]) {
|
|
|
-// cell.resultLabel.stringValue = selection.pages[0].label;
|
|
|
-// cell.resultLabel.textColor = [KMAppearance KMColor_Layout_H2];
|
|
|
-// }
|
|
|
-// return cell;
|
|
|
-// } else if ([tableView isEqual:rightSideController.snapshotTableView]) {
|
|
|
+// else if ([tableView isEqual:rightSideController.snapshotTableView]) {
|
|
|
//
|
|
|
// KMSnapshotTableViewCell *cell = [tableView makeViewWithIdentifier:@"KMSnapshotTableViewCell" owner:self];
|
|
|
// SKSnapshotWindowController *snapshot = snapshots[row];
|
|
@@ -1396,6 +1563,89 @@ extension KMLeftSideViewController: KMThumbnailTableViewDelegate, NSTableViewDat
|
|
|
return nil;
|
|
|
}
|
|
|
|
|
|
+ func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
|
|
|
+ if tableView.isEqual(to: self.thumbnailTableView) {
|
|
|
+// if ([tv isEqual:leftSideController.thumbnailTableView]) {
|
|
|
+ let scaling = UserDefaults.standard.float(forKey: "KMThumbnailSizeScalingKey")
|
|
|
+ let thumbnailSize = self.thumbnails[row].size
|
|
|
+
|
|
|
+ let newScaling: CGFloat = scaling.cgFloat + 0.1
|
|
|
+ let newThumbnailHeight = thumbnailSize.width * newScaling
|
|
|
+ if (newThumbnailHeight > MIN_SIDE_PANE_WIDTH) {
|
|
|
+ self.thumbnailZoomOutButton.isEnabled = false
|
|
|
+ } else {
|
|
|
+ self.thumbnailZoomOutButton.isEnabled = true
|
|
|
+ }
|
|
|
+ if ((scaling - 0.1) < 0.3) {
|
|
|
+ self.thumbnailZoomInButton.isEnabled = false
|
|
|
+ } else {
|
|
|
+ self.thumbnailZoomInButton.isEnabled = true
|
|
|
+ }
|
|
|
+ var labelHeight = 0.0
|
|
|
+ if (self.isDisplayPageSize) {
|
|
|
+ labelHeight = 56.0
|
|
|
+ } else {
|
|
|
+ labelHeight = 41.5
|
|
|
+ }
|
|
|
+ let cellHeight = thumbnailSize.height + labelHeight
|
|
|
+ var thumbSize: NSSize = .zero
|
|
|
+ if (scaling != nil && scaling > 0) {
|
|
|
+ thumbSize = NSMakeSize(thumbnailSize.width * scaling.cgFloat, cellHeight * scaling.cgFloat)
|
|
|
+ } else {
|
|
|
+ thumbSize = NSMakeSize(thumbnailSize.width, cellHeight)
|
|
|
+ }
|
|
|
+ return thumbSize.height
|
|
|
+
|
|
|
+ // NSSize cellSize = NSMakeSize([[tv tableColumnWithIdentifier:IMAGE_COLUMNID] width], fmin(thumbSize.height, roundedThumbnailSize));
|
|
|
+ // if (thumbSize.height < [tv rowHeight])
|
|
|
+ // return [tv rowHeight];
|
|
|
+ // else if (thumbSize.width / thumbSize.height < cellSize.width / cellSize.height)
|
|
|
+ // return cellSize.height;
|
|
|
+ // else
|
|
|
+ // return fmax([tv rowHeight], fmin(cellSize.width, thumbSize.width) * thumbSize.height / thumbSize.width);
|
|
|
+ }
|
|
|
+// else if ([tv isEqual:rightSideController.snapshotTableView]) {
|
|
|
+// CGFloat scaling = [[NSUserDefaults standardUserDefaults] floatForKey:@"KMSnapshotSizeScalingKey"];
|
|
|
+// // NSSize snapshotSize = [[[[rightSideController.snapshotArrayController arrangedObjects] objectAtIndex:row] thumbnail] size];
|
|
|
+// NSSize snapshotSize = CGSizeMake(120, 63);
|
|
|
+//
|
|
|
+// CGFloat newScaling = scaling + 0.1;
|
|
|
+// CGFloat newSnapshotHeight = snapshotSize.width * newScaling;
|
|
|
+// if (newSnapshotHeight > MIN_SIDE_PANE_WIDTH) {
|
|
|
+// leftSideController.snapshotNormalZoomInButton.enabled = NO;
|
|
|
+// } else {
|
|
|
+// leftSideController.snapshotNormalZoomInButton.enabled = YES;
|
|
|
+// }
|
|
|
+// if ((scaling - 0.1) < 0.3 || (newSnapshotHeight < 150.0)) {
|
|
|
+// leftSideController.snapshotNormalZoomOutButton.enabled = NO;
|
|
|
+// } else {
|
|
|
+// leftSideController.snapshotNormalZoomOutButton.enabled = YES;
|
|
|
+// }
|
|
|
+//
|
|
|
+// CGFloat cellHeight = snapshotSize.height + 24.0;
|
|
|
+// NSSize thumbSize;
|
|
|
+// if (scaling && scaling > 0) {
|
|
|
+// thumbSize = NSMakeSize(snapshotSize.width * scaling, cellHeight * scaling);
|
|
|
+// } else {
|
|
|
+// thumbSize = NSMakeSize(snapshotSize.width, cellHeight);
|
|
|
+// }
|
|
|
+// return thumbSize.height;
|
|
|
+// }
|
|
|
+ else if (tableView.isEqual(to: self.findTableView)) {
|
|
|
+ return 40.0
|
|
|
+ }
|
|
|
+ return tableView.rowHeight
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {
|
|
|
+ if (tableView.isEqual(to: self.findTableView)) {
|
|
|
+// if ([tableView isEqual:leftSideController.findTableView] || [tableView isEqual:leftSideController.groupedFindTableView]) {
|
|
|
+ let rowView = KMCustomTableRowView()
|
|
|
+ return rowView
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
|
|
|
|
|
@@ -1534,13 +1784,7 @@ extension KMLeftSideViewController: KMThumbnailTableViewDelegate, NSTableViewDat
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- - (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row {
|
|
|
- if ([tableView isEqual:leftSideController.findTableView] || [tableView isEqual:leftSideController.groupedFindTableView]) {
|
|
|
- KMCustomTableRowView *rowView = [[[KMCustomTableRowView alloc] init] autorelease];
|
|
|
- return rowView;
|
|
|
- }
|
|
|
- return nil;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
#pragma mark NSTableView delegate protocol
|
|
|
|
|
@@ -1657,77 +1901,6 @@ extension KMLeftSideViewController: KMThumbnailTableViewDelegate, NSTableViewDat
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- - (CGFloat)tableView:(NSTableView *)tv heightOfRow:(NSInteger)row {
|
|
|
- if ([tv isEqual:leftSideController.thumbnailTableView]) {
|
|
|
- CGFloat scaling = [[NSUserDefaults standardUserDefaults] floatForKey:@"KMThumbnailSizeScalingKey"];
|
|
|
- NSSize thumbnailSize = [[thumbnails objectAtIndex:row] size];
|
|
|
-
|
|
|
- CGFloat newScaling = scaling + 0.1;
|
|
|
- CGFloat newThumbnailHeight = thumbnailSize.width * newScaling;
|
|
|
- if (newThumbnailHeight > MIN_SIDE_PANE_WIDTH) {
|
|
|
- leftSideController.thumbnailZoomOutButton.enabled = NO;
|
|
|
- } else {
|
|
|
- leftSideController.thumbnailZoomOutButton.enabled = YES;
|
|
|
- }
|
|
|
- if ((scaling - 0.1) < 0.3) {
|
|
|
- leftSideController.thumbnailZoomInButton.enabled = NO;
|
|
|
- } else {
|
|
|
- leftSideController.thumbnailZoomInButton.enabled = YES;
|
|
|
- }
|
|
|
- CGFloat labelHeight = 0.0;
|
|
|
- if (self.isDisplayPageSize) {
|
|
|
- labelHeight = 56.0;
|
|
|
- } else {
|
|
|
- labelHeight = 41.5;
|
|
|
- }
|
|
|
- CGFloat cellHeight = thumbnailSize.height + labelHeight;
|
|
|
- NSSize thumbSize;
|
|
|
- if (scaling && scaling > 0) {
|
|
|
- thumbSize = NSMakeSize(thumbnailSize.width * scaling, cellHeight * scaling);
|
|
|
- } else {
|
|
|
- thumbSize = NSMakeSize(thumbnailSize.width, cellHeight);
|
|
|
- }
|
|
|
- return thumbSize.height;
|
|
|
-
|
|
|
- // NSSize cellSize = NSMakeSize([[tv tableColumnWithIdentifier:IMAGE_COLUMNID] width], fmin(thumbSize.height, roundedThumbnailSize));
|
|
|
- // if (thumbSize.height < [tv rowHeight])
|
|
|
- // return [tv rowHeight];
|
|
|
- // else if (thumbSize.width / thumbSize.height < cellSize.width / cellSize.height)
|
|
|
- // return cellSize.height;
|
|
|
- // else
|
|
|
- // return fmax([tv rowHeight], fmin(cellSize.width, thumbSize.width) * thumbSize.height / thumbSize.width);
|
|
|
- } else if ([tv isEqual:rightSideController.snapshotTableView]) {
|
|
|
- CGFloat scaling = [[NSUserDefaults standardUserDefaults] floatForKey:@"KMSnapshotSizeScalingKey"];
|
|
|
- // NSSize snapshotSize = [[[[rightSideController.snapshotArrayController arrangedObjects] objectAtIndex:row] thumbnail] size];
|
|
|
- NSSize snapshotSize = CGSizeMake(120, 63);
|
|
|
-
|
|
|
- CGFloat newScaling = scaling + 0.1;
|
|
|
- CGFloat newSnapshotHeight = snapshotSize.width * newScaling;
|
|
|
- if (newSnapshotHeight > MIN_SIDE_PANE_WIDTH) {
|
|
|
- leftSideController.snapshotNormalZoomInButton.enabled = NO;
|
|
|
- } else {
|
|
|
- leftSideController.snapshotNormalZoomInButton.enabled = YES;
|
|
|
- }
|
|
|
- if ((scaling - 0.1) < 0.3 || (newSnapshotHeight < 150.0)) {
|
|
|
- leftSideController.snapshotNormalZoomOutButton.enabled = NO;
|
|
|
- } else {
|
|
|
- leftSideController.snapshotNormalZoomOutButton.enabled = YES;
|
|
|
- }
|
|
|
-
|
|
|
- CGFloat cellHeight = snapshotSize.height + 24.0;
|
|
|
- NSSize thumbSize;
|
|
|
- if (scaling && scaling > 0) {
|
|
|
- thumbSize = NSMakeSize(snapshotSize.width * scaling, cellHeight * scaling);
|
|
|
- } else {
|
|
|
- thumbSize = NSMakeSize(snapshotSize.width, cellHeight);
|
|
|
- }
|
|
|
- return thumbSize.height;
|
|
|
- } else if ([tv isEqual:leftSideController.findTableView]) {
|
|
|
- return 40.0;
|
|
|
- }
|
|
|
- return [tv rowHeight];
|
|
|
- }
|
|
|
-
|
|
|
- (void)tableView:(NSTableView *)tv deleteRowsWithIndexes:(NSIndexSet *)rowIndexes {
|
|
|
if (![[IAPProductsManager defaultManager] isAvailableAllFunction]) {
|
|
|
[[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
|