Browse Source

【综合】首页快捷工具,页面编辑设配暗黑

tangchao 1 year ago
parent
commit
66c5fd3d17

+ 23 - 1
PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/KMPDFEditWindowController.swift

@@ -7,7 +7,7 @@
 
 import Cocoa
 
-class KMPDFEditWindowController: NSWindowController {
+class KMPDFEditWindowController: KMBaseWindowController {
     private var _viewController: KMPDFEditViewController?
     private var _modalSession: NSApplication.ModalSession?
     
@@ -40,6 +40,8 @@ class KMPDFEditWindowController: NSWindowController {
                 self.window?.contentView?.addSubview(vc.view)
             }
         }
+        
+        self.interfaceThemeDidChanged(self.window?.appearance?.name ?? .aqua)
     }
     
     @IBAction func startModal(_ sender: AnyObject?) {
@@ -61,6 +63,26 @@ class KMPDFEditWindowController: NSWindowController {
             self.window?.orderOut(self)
         }
     }
+    
+    override func interfaceThemeDidChanged(_ appearance: NSAppearance.Name) {
+        super.interfaceThemeDidChanged(appearance)
+        
+        self._viewController?.toolBar.toolBar.wantsLayer = true
+        if appearance == .darkAqua {
+            self._viewController?.toolBar.toolBar.layer?.backgroundColor = KMAppearance.Layout.l0Color().cgColor
+        } else {
+            self._viewController?.toolBar.toolBar.layer?.backgroundColor = .clear
+        }
+        
+        for item in self._viewController?.toolBar.toolBar.items ?? [] {
+            item.wantsLayer = true
+            if appearance == .darkAqua {
+                item.layer?.backgroundColor = KMAppearance.Layout.l_2Color().cgColor
+            } else {
+                item.layer?.backgroundColor = .clear
+            }
+        }
+    }
 }
 
 extension KMPDFEditWindowController: NSWindowDelegate {

+ 12 - 5
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarItemView.swift

@@ -181,7 +181,7 @@ extension KMToolbarItemView {
             if self._popOver == nil || self._popOver!.isEqual(to: newValue) == false {
                 self._popOver = newValue
                 if (newValue != nil) {
-                    self.layer?.backgroundColor = self.selectedBackgroundColor.cgColor
+                    self.layer?.backgroundColor = Self.selectedBackgroundColor.cgColor
                 } else {
                     self._updateSelectBackground()
                 }
@@ -304,9 +304,9 @@ extension KMToolbarItemView {
         }
         if (!self.isSelected) {
             if self.selectBackgroundType == .none {
-                self.layer?.backgroundColor = self.selectedBackgroundColor.cgColor
+                self.layer?.backgroundColor = Self.selectedBackgroundColor.cgColor
             } else {
-                self.imageViewBox.fillColor = self.selectedBackgroundColor
+                self.imageViewBox.fillColor = Self.selectedBackgroundColor
             }
             
             if(self.image != nil && self.alternateImage != nil) {
@@ -375,18 +375,25 @@ extension KMToolbarItemView {
     private func _updateSelectBackground() {
         if self.selectBackgroundType == .none {
             if self.isSelected {
-                self.layer?.backgroundColor = self.selectedBackgroundColor.cgColor
+                self.layer?.backgroundColor = Self.selectedBackgroundColor.cgColor
             } else {
                 self.layer?.backgroundColor = self.normalBackgroundColor.cgColor
             }
         } else if self.selectBackgroundType == .imageBox {
             if self.isSelected {
-                self.imageViewBox.fillColor = self.selectedBackgroundColor
+                self.imageViewBox.fillColor = Self.selectedBackgroundColor
             } else {
                 self.imageViewBox.fillColor = self.normalBackgroundColor
             }
         }
     }
+    
+//    override func updateLayer() {
+//        super.updateLayer()
+//
+//        self.wantsLayer = true
+//        self.layer?.backgroundColor = KMAppearance.Layout.l_2Color().cgColor
+//    }
 }
 
 // MARK: - Private Methods

+ 5 - 1
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarView.swift

@@ -462,7 +462,11 @@ private let KMToolbarItemSpace = 8.0
     override func updateLayer() {
         super.updateLayer()
         
-        self.layer?.backgroundColor = .clear
+        if KMAppearance.isDarkMode() {
+            self.layer?.backgroundColor = KMAppearance.Layout.l0Color().cgColor
+        } else {
+            self.layer?.backgroundColor = .clear
+        }
     }
     
     // MARK: - View Methods

+ 3 - 0
PDF Office/PDF Master/Class/README.md

@@ -10,6 +10,9 @@
 - 拆分 【首页快捷工具】
 * SplitWindowController
 
+- 页面编辑 【首页快捷工具】
+* KMPDFEditWindowController
+
 ## xxx
 
 [sign in](https://www.baidu.com) the [dashboard](https://www.baidu.com). to [sign up](https://www.baidu.com)