|
@@ -36,6 +36,10 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
let noteColumnId = NSUserInterfaceItemIdentifier(rawValue: "note")
|
|
|
let authorColumnId = NSUserInterfaceItemIdentifier(rawValue: "author")
|
|
|
|
|
|
+ struct Key {}
|
|
|
+
|
|
|
+ let scalingIncrement: Float = 0.1
|
|
|
+
|
|
|
deinit {
|
|
|
KMPrint("KMLeftSideViewController deinit.")
|
|
|
|
|
@@ -787,40 +791,40 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
|
|
|
let tag = sender.tag
|
|
|
if (tag == 0 || tag == 1) {
|
|
|
- var scaling = sud.float(forKey: "KMThumbnailSizeScalingKey")
|
|
|
+ var scaling = KMDataManager.ud_float(forKey: Self.Key.thumbSizeScaling)
|
|
|
if (scaling <= 0) {
|
|
|
scaling = 1
|
|
|
}
|
|
|
- if (tag == 0) { // thumbnail Zoom In
|
|
|
- scaling += 0.1
|
|
|
+ if (tag == 0) { // Zoom In
|
|
|
+ scaling += self.scalingIncrement
|
|
|
if scaling >= 2.2 {
|
|
|
return
|
|
|
}
|
|
|
- } else if (tag == 1) { // thumbnail Zoom Out
|
|
|
- scaling -= 0.1
|
|
|
+ } else if (tag == 1) { // Zoom Out
|
|
|
+ scaling -= self.scalingIncrement
|
|
|
if scaling <= 0.4 {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
- sud.setValue(scaling, forKey: "KMThumbnailSizeScalingKey")
|
|
|
+ KMDataManager.ud_set(scaling, forKey: Self.Key.thumbSizeScaling)
|
|
|
|
|
|
let selectRow = self.thumbnailTableView.selectedRow
|
|
|
self.thumbnailTableView.reloadData()
|
|
|
|
|
|
self.thumbnailTableView.selectRowIndexes(IndexSet(integer: selectRow), byExtendingSelection: false)
|
|
|
} else if (tag == 2 || tag == 3) {
|
|
|
- var scaling = sud.float(forKey: "KMSnapshotSizeScalingKey")
|
|
|
+ var scaling = KMDataManager.ud_float(forKey: Self.Key.snapshotSizeScaling)
|
|
|
if (scaling <= 0) {
|
|
|
scaling = 1
|
|
|
}
|
|
|
|
|
|
- if (tag == 2) { // snapshot Zoom In
|
|
|
- scaling += 0.1
|
|
|
- } else if (tag == 3) { // snapshot Zoom Out
|
|
|
- scaling -= 0.1
|
|
|
+ if (tag == 2) { // Zoom In
|
|
|
+ scaling += self.scalingIncrement
|
|
|
+ } else if (tag == 3) { // Zoom Out
|
|
|
+ scaling -= self.scalingIncrement
|
|
|
}
|
|
|
|
|
|
- sud.setValue(scaling, forKey: "KMSnapshotSizeScalingKey")
|
|
|
+ KMDataManager.ud_set(scaling, forKey: Self.Key.snapshotSizeScaling)
|
|
|
|
|
|
let selectRow = self.snapshotTableView.selectedRow
|
|
|
self.snapshotTableView.reloadData()
|
|
@@ -1285,7 +1289,7 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
|
|
|
func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
|
|
|
if tableView.isEqual(to: self.thumbnailTableView) {
|
|
|
- let scaling = KMDataManager.ud_float(forKey: "KMThumbnailSizeScalingKey")
|
|
|
+ let scaling = KMDataManager.ud_float(forKey: Self.Key.thumbSizeScaling)
|
|
|
// let thumbnailSize = self.thumbnails[row].size
|
|
|
let thumbnailSize = NSMakeSize(self.thumbnailCacheSize, self.thumbnailCacheSize)
|
|
|
|
|
@@ -1307,24 +1311,16 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
|
|
|
} else {
|
|
|
labelHeight = 41.5
|
|
|
}
|
|
|
- let cellHeight = thumbnailSize.height + labelHeight
|
|
|
+ let cellHeight = thumbnailSize.height + labelHeight
|
|
|
var thumbSize: NSSize = .zero
|
|
|
- if (scaling != nil && scaling > 0) {
|
|
|
+ if (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 tableView.isEqual(to: self.snapshotTableView) {
|
|
|
- let scaling = UserDefaults.standard.float(forKey: "KMSnapshotSizeScalingKey")
|
|
|
+ let scaling = KMDataManager.ud_float(forKey: Self.Key.snapshotSizeScaling)
|
|
|
let snapshotSize = (self.snapshots.safe_element(for: row) as? KMSnapshotModel)?.windowC?.thumbnail?.size ?? CGSizeMake(120, 63)
|
|
|
var newScaling = scaling + 0.1
|
|
|
let newSnapshotHeight = snapshotSize.width * newScaling.cgFloat;
|