Bläddra i källkod

[tip] - 工具栏tip

liujiajie 11 månader sedan
förälder
incheckning
99bbc46c39

+ 26 - 26
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarCustomViewController.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -30,9 +30,6 @@
             <subviews>
                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="JZu-O5-GoZ">
                     <rect key="frame" x="513" y="13" width="94" height="32"/>
-                    <constraints>
-                        <constraint firstAttribute="width" constant="80" id="h2s-r9-6d8"/>
-                    </constraints>
                     <buttonCell key="cell" type="push" title="Done" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="rfx-u3-2x9">
                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                         <font key="font" metaFont="system"/>
@@ -40,15 +37,15 @@
 DQ
 </string>
                     </buttonCell>
+                    <constraints>
+                        <constraint firstAttribute="width" constant="80" id="h2s-r9-6d8"/>
+                    </constraints>
                     <connections>
                         <action selector="okButtonAction:" target="-2" id="9tf-3v-g0t"/>
                     </connections>
                 </button>
                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fOg-Is-A3R">
                     <rect key="frame" x="419" y="13" width="94" height="32"/>
-                    <constraints>
-                        <constraint firstAttribute="width" constant="80" id="1IZ-2V-dBT"/>
-                    </constraints>
                     <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="0x6-wB-v3u">
                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                         <font key="font" metaFont="system"/>
@@ -56,19 +53,22 @@ DQ
 Gw
 </string>
                     </buttonCell>
+                    <constraints>
+                        <constraint firstAttribute="width" constant="80" id="1IZ-2V-dBT"/>
+                    </constraints>
                     <connections>
                         <action selector="cancelButtonAction:" target="-2" id="Ogb-1a-mak"/>
                     </connections>
                 </button>
                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="VEO-jz-lfH">
                     <rect key="frame" x="25" y="13" width="94" height="32"/>
-                    <constraints>
-                        <constraint firstAttribute="width" constant="80" id="wbC-5f-UKJ"/>
-                    </constraints>
                     <buttonCell key="cell" type="push" title="Reset" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="bNS-W6-Syp">
                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                         <font key="font" metaFont="system"/>
                     </buttonCell>
+                    <constraints>
+                        <constraint firstAttribute="width" constant="80" id="wbC-5f-UKJ"/>
+                    </constraints>
                     <connections>
                         <action selector="resetButtonAction:" target="-2" id="NHV-fP-cgQ"/>
                     </connections>
@@ -98,7 +98,7 @@ Gw
                                         </textFieldCell>
                                         <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
                                         <prototypeCellViews>
-                                            <tableCellView identifier="KMAllowedItemsCell" id="u8k-Vq-Sh4" customClass="KMToolbarCellView" customModule="PDF_Master" customModuleProvider="target">
+                                            <tableCellView identifier="KMAllowedItemsCell" id="u8k-Vq-Sh4" customClass="KMToolbarCellView" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                                 <rect key="frame" x="1" y="1" width="166" height="36"/>
                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 <subviews>
@@ -110,7 +110,7 @@ Gw
                                                         </constraints>
                                                         <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="ol3-6y-x6T"/>
                                                     </imageView>
-                                                    <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="Dvo-uU-C7l">
+                                                    <textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="Dvo-uU-C7l">
                                                         <rect key="frame" x="31" y="11" width="110" height="15"/>
                                                         <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="odU-Fg-eBv">
                                                             <font key="font" metaFont="cellTitle"/>
@@ -199,7 +199,7 @@ Gw
                                                         </constraints>
                                                         <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="UwL-bD-Gm5"/>
                                                     </imageView>
-                                                    <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="nNa-su-WPu">
+                                                    <textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="nNa-su-WPu">
                                                         <rect key="frame" x="31" y="11" width="129" height="15"/>
                                                         <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="Lej-Ie-YTM">
                                                             <font key="font" metaFont="cellTitle"/>
@@ -240,7 +240,7 @@ Gw
                         <autoresizingMask key="autoresizingMask"/>
                     </scroller>
                 </scrollView>
-                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lpU-dG-ZRi">
+                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lpU-dG-ZRi">
                     <rect key="frame" x="30" y="507" width="65" height="19"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Custom" id="ejK-89-G5U">
                         <font key="font" metaFont="systemBold" size="16"/>
@@ -248,7 +248,7 @@ Gw
                         <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
-                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rVi-sQ-x2v">
+                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rVi-sQ-x2v">
                     <rect key="frame" x="369" y="476" width="163" height="15"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Options Currently Dispalyed" id="G51-Vy-5jr">
                         <font key="font" metaFont="cellTitle"/>
@@ -258,28 +258,28 @@ Gw
                 </textField>
                 <button translatesAutoresizingMaskIntoConstraints="NO" id="bkC-VM-YPd">
                     <rect key="frame" x="276" y="291" width="80" height="32"/>
-                    <constraints>
-                        <constraint firstAttribute="height" constant="32" id="XIj-w9-Jtq"/>
-                        <constraint firstAttribute="width" constant="80" id="gjT-bR-jWq"/>
-                    </constraints>
                     <buttonCell key="cell" type="square" title="Add  &gt;&gt;" bezelStyle="shadowlessSquare" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="o0x-D0-sKR">
                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                         <font key="font" metaFont="system"/>
                     </buttonCell>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="32" id="XIj-w9-Jtq"/>
+                        <constraint firstAttribute="width" constant="80" id="gjT-bR-jWq"/>
+                    </constraints>
                     <connections>
                         <action selector="addButtonAction:" target="-2" id="Grg-ih-bAv"/>
                     </connections>
                 </button>
                 <button translatesAutoresizingMaskIntoConstraints="NO" id="S3L-VY-gDi">
                     <rect key="frame" x="276" y="249" width="80" height="32"/>
-                    <constraints>
-                        <constraint firstAttribute="height" constant="32" id="HNl-Lx-qyz"/>
-                        <constraint firstAttribute="width" constant="80" id="bPA-5o-8W1"/>
-                    </constraints>
                     <buttonCell key="cell" type="square" title="&lt;&lt; Remove" bezelStyle="shadowlessSquare" alignment="center" imageScaling="proportionallyUpOrDown" inset="2" id="9YJ-YG-LgS">
                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                         <font key="font" metaFont="system"/>
                     </buttonCell>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="32" id="HNl-Lx-qyz"/>
+                        <constraint firstAttribute="width" constant="80" id="bPA-5o-8W1"/>
+                    </constraints>
                     <connections>
                         <action selector="removeButtonAction:" target="-2" id="XAH-uT-0wt"/>
                     </connections>
@@ -287,7 +287,7 @@ Gw
                 <box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="Teh-6Q-kqh">
                     <rect key="frame" x="32" y="58" width="568" height="5"/>
                 </box>
-                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="f1D-Pb-iyF">
+                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="f1D-Pb-iyF">
                     <rect key="frame" x="30" y="476" width="115" height="15"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Choose Commands" id="HgT-hQ-cKy">
                         <font key="font" metaFont="cellTitle"/>
@@ -295,7 +295,7 @@ Gw
                         <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
-                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FBc-ch-2ME">
+                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FBc-ch-2ME">
                     <rect key="frame" x="393" y="67" width="180" height="30"/>
                     <constraints>
                         <constraint firstAttribute="width" constant="176" id="LR3-37-plu"/>

+ 5 - 4
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarCustomWindowController.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14113" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14113"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -13,11 +13,11 @@
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
+        <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
             <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
             <rect key="contentRect" x="196" y="240" width="574" height="570"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
             <value key="minSize" type="size" width="574" height="480"/>
             <value key="maxSize" type="size" width="574" height="1000"/>
             <view key="contentView" wantsLayer="YES" id="se5-gp-TjO">
@@ -27,6 +27,7 @@
             <connections>
                 <outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
             </connections>
+            <point key="canvasLocation" x="122" y="-138"/>
         </window>
     </objects>
 </document>

+ 49 - 28
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarItemView.swift

@@ -384,11 +384,11 @@ extension KMToolbarItemView {
             return
         }
         if (!self.isSelected) {
-            if self.selectBackgroundType == .none {
+//            if self.selectBackgroundType == .none {
                 self.layer?.backgroundColor = Self.selectedBackgroundColor.cgColor
-            } else {
-                self.imageViewBox.fillColor = Self.selectedBackgroundColor
-            }
+//            } else {
+//                self.imageViewBox.fillColor = Self.selectedBackgroundColor
+//            }
             
             if(self.image != nil && self.alternateImage != nil) {
                 self._kNormalImage = self.image
@@ -398,12 +398,17 @@ extension KMToolbarItemView {
                 }
             }
         }
-        if (self.needExpandAction) {
-            // KMImageNameUXIconBtnTriDownSel
-            self.needExpandButton.image = NSImage(named: "KMImageNameUXIconBtnTriDownNor")
+//        if (self.needExpandAction) {
+//            // KMImageNameUXIconBtnTriDownSel
+//            self.needExpandButton.image = NSImage(named: "KMImageNameUXIconBtnTriDownNor")
+//            self._showPop(self)
+//        }else if (self.isShowCustomToolTip) {
+//            self.perform(#selector(_showHUDHint), with: nil, afterDelay: 0.1)
+//        }
+        if self.toolTip?.count ?? 0 > 0 {
+//            self.needExpandButton.image = NSImage(named: "KMImageNameUXIconBtnTriDownNor")
             self._showPop(self)
-        }else if (self.isShowCustomToolTip) {
-            self.perform(#selector(_showHUDHint), with: nil, afterDelay: 0.1)
+//            self.perform(#selector(_showPop), with: self, afterDelay: 0.1)
         }
     }
     
@@ -411,11 +416,11 @@ extension KMToolbarItemView {
         super.mouseExited(with: event)
         
         if (!self.isSelected && !self.needExpandAction) {
-            if self.selectBackgroundType == .none {
+//            if self.selectBackgroundType == .none {
                 self.layer?.backgroundColor = self.normalBackgroundColor.cgColor
-            } else {
-                self.imageViewBox.fillColor = self.normalBackgroundColor
-            }
+//            } else {
+//                self.imageViewBox.fillColor = self.normalBackgroundColor
+//            }
            
             if(self.image != nil && self.alternateImage != nil) {
                 self.imageViewBtn.image = self._kNormalImage ?? self.image!
@@ -423,11 +428,11 @@ extension KMToolbarItemView {
         }
 
         if(self.needExpandAction && !self.isSelected) {
-            if self.selectBackgroundType == .none {
+//            if self.selectBackgroundType == .none {
                 self.layer?.backgroundColor = self.normalBackgroundColor.cgColor
-            } else {
-                self.imageViewBox.fillColor = self.normalBackgroundColor
-            }
+//            } else {
+//                self.imageViewBox.fillColor = self.normalBackgroundColor
+//            }
             
             if(self.image != nil && self.alternateImage != nil) {
                 self.imageViewBtn.image = self._kNormalImage ?? self.image!
@@ -447,7 +452,8 @@ extension KMToolbarItemView {
             self.nameBtn.setTitleColor(color: Self.fetchTextNormalColor())
         }
         
-        if (self.isShowCustomToolTip && !self.needExpandAction) {
+//        if (self.isShowCustomToolTip && !self.needExpandAction) {
+        if self.toolTip?.count ?? 0 > 0 {
             NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(_showHUDHint), object: nil)
             self._closePop()
         }
@@ -470,6 +476,7 @@ extension KMToolbarItemView {
                 self.imageViewBox.fillColor = Self.selectedBackgroundColor
             } else {
                 self.imageViewBox.fillColor = self.normalBackgroundColor
+                self.layer?.backgroundColor = self.normalBackgroundColor.cgColor
             }
         }
     }
@@ -490,19 +497,19 @@ extension KMToolbarItemView {
         self.addTrackingArea(trackingArea)
     }
     
-    private func _showPop(_ sender: NSView) {
+    @objc private func _showPop(_ sender: NSView) {
         if (self._popOver != nil) {
             return
         }
-        let menuViewController = KMCustomButtonPopMenuViewController()
-        menuViewController.delegate = self
-        menuViewController.dataSources = self
-        self.popOver = NSPopover()
-        self.popOver?.delegate = self
-        self.popOver?.contentViewController = menuViewController
-        self.popOver?.animates = false
-        self.popOver?.behavior = .semitransient
-        self.popOver?.contentSize = menuViewController.view.frame.size
+//        let menuViewController = KMCustomButtonPopMenuViewController()
+//        menuViewController.delegate = self
+//        menuViewController.dataSources = self
+//        self.popOver = NSPopover()
+//        self.popOver?.delegate = self
+//        self.popOver?.contentViewController = menuViewController
+//        self.popOver?.animates = false
+//        self.popOver?.behavior = .semitransient
+//        self.popOver?.contentSize = menuViewController.view.frame.size
         
         var sourcesRect = sender.bounds
         sourcesRect = sender.convert(sourcesRect, to: nil)
@@ -511,6 +518,20 @@ extension KMToolbarItemView {
         self.window?.popover = self.popOver
         self.window?.sourcesRect = sourcesRect
         
+//        self.popOver?.show(relativeTo: CGRectInset(self.bounds, 0, 5), of: self, preferredEdge: .minY)
+        
+        let popViewController = KMToolbarItemPopViewController()
+        self.popOver = NSPopover()
+        self.popOver?.contentViewController = popViewController
+        self.popOver?.animates = false
+        self.popOver?.behavior = .semitransient
+        self.popOver?.contentSize = popViewController.view.frame.size
+        
+        popViewController.updateWithHelpTip(helpTip: self.toolTip ?? "")
+
+        self.window?.popover = self.popOver
+        self.window?.sourcesRect = sourcesRect
+        
         self.popOver?.show(relativeTo: CGRectInset(self.bounds, 0, 5), of: self, preferredEdge: .minY)
     }
     

+ 1 - 0
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarViewController.swift

@@ -1514,6 +1514,7 @@ extension KMToolbarViewController {
         } else if identifier == KMToolbarAnnotationSettingItemIdentifier {
             item?.image = NSImage(named: "KMImageNameUXIconBtnSetNor")
             item?.target = self
+            item?.toolTip = String(format: "%@\n%@", NSLocalizedString("Customize Toolbar", comment: ""),NSLocalizedString("Drag-and-drop tools to change their order", comment: ""))
             item?.titleName = NSLocalizedString("Setting", comment: "")
             item?.boxImagePosition = .imageOnly
             item?.btnAction = #selector(_itemAction)