|
@@ -10,8 +10,17 @@ import KMComponentLibrary
|
|
|
|
|
|
@objc protocol KMNDisplayViewControllerDelegate: AnyObject {
|
|
|
|
|
|
+ //
|
|
|
+ @objc optional func displayViewControllerDidDisplayModeChanged(_ controller: KMNDisplayViewController)
|
|
|
+
|
|
|
+ //阅读模式
|
|
|
@objc optional func displayViewControllerDidReadModeUpdated(_ controller: KMNDisplayViewController)
|
|
|
+
|
|
|
+ //PPT
|
|
|
+ @objc optional func displayViewControllerDidGotoSlideShow(_ controller: KMNDisplayViewController)
|
|
|
|
|
|
+ //SplitView
|
|
|
+ @objc optional func displayViewControllerDidSplitModeChanged(_ controller: KMNDisplayViewController)
|
|
|
}
|
|
|
|
|
|
class KMNDisplayViewController: NSViewController {
|
|
@@ -35,7 +44,8 @@ class KMNDisplayViewController: NSViewController {
|
|
|
@IBOutlet var noSplitSelector: ComponentCSelector!
|
|
|
@IBOutlet var verticalSelector: ComponentCSelector!
|
|
|
@IBOutlet var horizontalSelector: ComponentCSelector!
|
|
|
-
|
|
|
+ @IBOutlet var splitViewBGHeightConst: NSLayoutConstraint!
|
|
|
+
|
|
|
@IBOutlet var themesBGView: NSView!
|
|
|
@IBOutlet var themesLabel: NSTextField!
|
|
|
@IBOutlet var themesContendView: NSView!
|
|
@@ -50,6 +60,8 @@ class KMNDisplayViewController: NSViewController {
|
|
|
// Do view setup here.
|
|
|
|
|
|
setupPropertys()
|
|
|
+
|
|
|
+ reloadData()
|
|
|
}
|
|
|
|
|
|
func setupPropertys() {
|
|
@@ -115,74 +127,150 @@ class KMNDisplayViewController: NSViewController {
|
|
|
let book = self.pdfView?.displaysAsBook ?? false
|
|
|
|
|
|
singlePageSelector.properties.state = .normal
|
|
|
- singlePageSelector.properties.state = .normal
|
|
|
+ twoPageSelector.properties.state = .normal
|
|
|
bookSelector.properties.state = .normal
|
|
|
+ readModeSelector.properties.state = .normal
|
|
|
+ fullScreenSelector.properties.state = .normal
|
|
|
+ slideShowSelector.properties.state = .normal
|
|
|
|
|
|
+ bookSelector.properties.state = .normal
|
|
|
if mode == .singlePage {
|
|
|
singlePageSelector.properties.state = .pressed
|
|
|
-
|
|
|
continueScrollCheckBox.properties.checkboxType = .normal
|
|
|
|
|
|
-
|
|
|
} else if mode == .singlePageContinuous {
|
|
|
singlePageSelector.properties.state = .pressed
|
|
|
continueScrollCheckBox.properties.checkboxType = .selected
|
|
|
|
|
|
} else if mode == .twoUp {
|
|
|
+ bookSelector.properties.state = book ? .pressed : .normal
|
|
|
+ twoPageSelector.properties.state = book ? .normal : .pressed
|
|
|
|
|
|
- bookSelector.properties.state = .pressed
|
|
|
continueScrollCheckBox.properties.checkboxType = .normal
|
|
|
|
|
|
} else if mode == .twoUpContinuous {
|
|
|
- bookSelector.properties.state = .pressed
|
|
|
- continueScrollCheckBox.properties.checkboxType = .selected
|
|
|
+ bookSelector.properties.state = book ? .pressed : .normal
|
|
|
+ twoPageSelector.properties.state = book ? .normal : .pressed
|
|
|
|
|
|
+ continueScrollCheckBox.properties.checkboxType = .selected
|
|
|
}
|
|
|
|
|
|
let pageBreaks = self.pdfView?.displaysPageBreaks ?? false
|
|
|
- self.pageBreaksCheckBox.properties.checkboxType = pageBreaks ? .selected : .normal
|
|
|
+ pageBreaksCheckBox.properties.checkboxType = pageBreaks ? .selected : .normal
|
|
|
+
|
|
|
+ singlePageSelector.reloadData()
|
|
|
+ twoPageSelector.reloadData()
|
|
|
+ bookSelector.reloadData()
|
|
|
+ readModeSelector.reloadData()
|
|
|
+ fullScreenSelector.reloadData()
|
|
|
+ slideShowSelector.reloadData()
|
|
|
+
|
|
|
+ continueScrollCheckBox.reloadData()
|
|
|
+ pageBreaksCheckBox.reloadData()
|
|
|
+
|
|
|
+ //SplitView
|
|
|
+ noSplitSelector.properties.state = .normal
|
|
|
+ verticalSelector.properties.state = .normal
|
|
|
+ horizontalSelector.properties.state = .normal
|
|
|
+
|
|
|
+ if pdfView?.viewSplitMode == .disable {
|
|
|
+ noSplitSelector.properties.state = .pressed
|
|
|
+ } else if pdfView?.viewSplitMode == .horizontal {
|
|
|
+ horizontalSelector.properties.state = .pressed
|
|
|
+ } else if pdfView?.viewSplitMode == .vertical {
|
|
|
+ verticalSelector.properties.state = .pressed
|
|
|
+ }
|
|
|
+
|
|
|
+ noSplitSelector.reloadData()
|
|
|
+ horizontalSelector.reloadData()
|
|
|
+ verticalSelector.reloadData()
|
|
|
+
|
|
|
+ if pdfView?.viewSplitMode == .disable {
|
|
|
+ splitViewBGHeightConst.constant = 90
|
|
|
+ } else {
|
|
|
+ if let filePath = viewManager?.splitPDFFilePath {
|
|
|
+ splitViewBGHeightConst.constant = 246
|
|
|
+
|
|
|
+ } else {
|
|
|
+ splitViewBGHeightConst.constant = 202
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //Themes
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
//MARK: - Action
|
|
|
@objc func selectorClicked(_ sender: ComponentCSelector) {
|
|
|
if sender == singlePageSelector {
|
|
|
+ singlePageSelector.properties.state = .pressed
|
|
|
+ twoPageSelector.properties.state = .normal
|
|
|
+ bookSelector.properties.state = .normal
|
|
|
|
|
|
updatePDFViewDisplayInfo()
|
|
|
+
|
|
|
} else if sender == twoPageSelector {
|
|
|
+ singlePageSelector.properties.state = .normal
|
|
|
+ twoPageSelector.properties.state = .pressed
|
|
|
+ bookSelector.properties.state = .normal
|
|
|
|
|
|
updatePDFViewDisplayInfo()
|
|
|
+
|
|
|
} else if sender == bookSelector {
|
|
|
+ singlePageSelector.properties.state = .normal
|
|
|
+ twoPageSelector.properties.state = .normal
|
|
|
+ bookSelector.properties.state = .pressed
|
|
|
|
|
|
updatePDFViewDisplayInfo()
|
|
|
+
|
|
|
} else if sender == readModeSelector {
|
|
|
if let manager = viewManager {
|
|
|
manager.isPDFReadMode = !manager.isPDFReadMode
|
|
|
}
|
|
|
+ readModeSelector.properties.state = .normal
|
|
|
+
|
|
|
delegate?.displayViewControllerDidReadModeUpdated?(self)
|
|
|
|
|
|
} else if sender == fullScreenSelector {
|
|
|
+ fullScreenSelector.properties.state = .normal
|
|
|
+
|
|
|
+ view.window?.toggleFullScreen(nil)
|
|
|
|
|
|
} else if sender == slideShowSelector {
|
|
|
+ slideShowSelector.properties.state = .normal
|
|
|
|
|
|
} else if sender == noSplitSelector {
|
|
|
+ noSplitSelector.properties.state = .pressed
|
|
|
+ verticalSelector.properties.state = .normal
|
|
|
+ horizontalSelector.properties.state = .normal
|
|
|
|
|
|
} else if sender == verticalSelector {
|
|
|
+ noSplitSelector.properties.state = .normal
|
|
|
+ verticalSelector.properties.state = .pressed
|
|
|
+ horizontalSelector.properties.state = .normal
|
|
|
|
|
|
} else if sender == horizontalSelector {
|
|
|
+ noSplitSelector.properties.state = .normal
|
|
|
+ verticalSelector.properties.state = .normal
|
|
|
+ horizontalSelector.properties.state = .pressed
|
|
|
|
|
|
}
|
|
|
|
|
|
+ reloadData()
|
|
|
}
|
|
|
|
|
|
@objc func checkBoxClicked(_ sender: ComponentCheckBox) {
|
|
|
if sender == continueScrollCheckBox {
|
|
|
- updatePDFViewDisplayInfo()
|
|
|
|
|
|
} else if sender == pageBreaksCheckBox {
|
|
|
pdfView?.displaysPageBreaks = pageBreaksCheckBox.properties.checkboxType == .selected ? true : false
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+ updatePDFViewDisplayInfo()
|
|
|
+ reloadData()
|
|
|
}
|
|
|
|
|
|
func updatePDFViewDisplayInfo() {
|
|
@@ -209,7 +297,18 @@ class KMNDisplayViewController: NSViewController {
|
|
|
} else {
|
|
|
pdfView?.displayDirection = .horizontal
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+ delegate?.displayViewControllerDidDisplayModeChanged?(self)
|
|
|
+ }
|
|
|
+
|
|
|
+ func updatePDFSplitViewInfo() {
|
|
|
+ if noSplitSelector.properties.state == .pressed {
|
|
|
+ pdfView?.viewSplitMode = .disable
|
|
|
+ } else if verticalSelector.properties.state == .pressed {
|
|
|
+ pdfView?.viewSplitMode = .vertical
|
|
|
+ } else if horizontalSelector.properties.state == .pressed {
|
|
|
+ pdfView?.viewSplitMode = .horizontal
|
|
|
}
|
|
|
}
|
|
|
|