Ver código fonte

【fix】【注释】列表文案和页码排版异常

tangchao 6 meses atrás
pai
commit
74e770ba3c

+ 32 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Annotation/View/KMNoteTableViewCell.swift

@@ -34,6 +34,9 @@ class KMNoteTableViewCell: NSTableCellView {
     @IBOutlet var contentViewTopConstraint: NSLayoutConstraint!
     @IBOutlet var pageLabelTopConstraint: NSLayoutConstraint!
     
+    @IBOutlet var timeWidthConstraint: NSLayoutConstraint!
+    @IBOutlet var annotationContentWidthConstraint: NSLayoutConstraint!
+    
     var isFold = false {
         didSet {
             if (self.isFold) {
@@ -93,6 +96,8 @@ class KMNoteTableViewCell: NSTableCellView {
         self.autherLabel.textColor = KMAppearance.Layout.h0Color()
         
         self.timeLabel.textColor = KMAppearance.Layout.h1Color()
+        self.timeLabel.lineBreakMode = .byTruncatingTail
+        self.timeLabel.cell?.truncatesLastVisibleLine = true
         self.pageLabel.textColor = KMAppearance.Layout.h2Color()
         
         self.noteContentBox.borderWidth = 1.0
@@ -124,6 +129,28 @@ class KMNoteTableViewCell: NSTableCellView {
         }
     }
     
+    override func layout() {
+        super.layout()
+        
+        let showAuthor = self.model?.showAuthor ?? false
+        let authorW = showAuthor ? self.autherLabel.frame.size.width : 0
+        
+        let showTime = self.model?.showTime ?? false
+        if showTime {
+            let x: CGFloat = 16 + 10 + authorW
+            let width = NSWidth(self.topView.frame)
+            
+//            self.timeLabel.lineBreakMode = .byTruncatingTail
+//            self.timeLabel.cell?.truncatesLastVisibleLine = true
+            self.timeWidthConstraint.constant = width - x
+        }
+        
+        let foldW: CGFloat = 16
+//        let margin: CGFloat = 9
+        let contentW = NSWidth(self.contentView.frame)
+        self.annotationContentWidthConstraint.constant = contentW-foldW
+    }
+    
 }
 
 // MARK: - Private Methods
@@ -181,6 +208,8 @@ extension KMNoteTableViewCell {
         let showTime = model?.showTime ?? true
         if showTime {
             self.timeLabel.stringValue =  dateString
+            self.timeLabel.lineBreakMode = .byTruncatingTail
+            self.timeLabel.cell?.truncatesLastVisibleLine = true
             self.timeLabel.isHidden = false
         } else {
             self.timeLabel.isHidden = true
@@ -198,6 +227,7 @@ extension KMNoteTableViewCell {
         if showAuthor {
             self.autherLabel.stringValue = authorString
             self.autherLabel.isHidden = false
+            self.autherLabel.sizeToFit()
         } else {
             self.autherLabel.isHidden = true
         }
@@ -343,5 +373,7 @@ extension KMNoteTableViewCell {
         self.autherLayoutConstraint.constant = self.autherLabel.isHidden ? -(self.autherLabel.bounds.size.width) + 10.0 : 10.0
         self.typeImageViewLayoutConstraint.constant = self.typeImageView.isHidden ? -(self.typeImageView.bounds.size.width) : 0.0
         self.contentBoxLayoutConstraint.constant = self.noteContentBox.isHidden ? -(self.noteContentBox.bounds.size.height+8.0) : 8.0
+        
+        self.needsLayout = true
     }
 }

+ 9 - 4
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/LeftSideView.xib

@@ -1129,7 +1129,7 @@
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="z3N-jy-sfp">
                 <rect key="frame" x="0.0" y="0.0" width="251" height="429"/>
-                <autoresizingMask key="autoresizingMask"/>
+                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                 <subviews>
                     <outlineView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="firstColumnOnly" tableStyle="plain" typeSelect="NO" autosaveName="KMNoteOutlineView" rowHeight="92" usesAutomaticRowHeights="YES" viewBased="YES" indentationPerLevel="16" outlineTableColumn="yso-Z1-ZNZ" id="ZeT-gb-jMM" customClass="KMNoteOutlineView" customModule="PDF_Reader_Pro" customModuleProvider="target">
                         <rect key="frame" x="0.0" y="0.0" width="251" height="429"/>
@@ -1155,7 +1155,7 @@
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
                                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="udQ-rE-Njy">
-                                                <rect key="frame" x="16" y="81" width="219" height="24"/>
+                                                <rect key="frame" x="16" y="81" width="205" height="24"/>
                                                 <subviews>
                                                     <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Lbo-Vh-Jiw">
                                                         <rect key="frame" x="0.0" y="4" width="16" height="16"/>
@@ -1167,6 +1167,9 @@
                                                     </imageView>
                                                     <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="pnF-AX-GzW">
                                                         <rect key="frame" x="57" y="4" width="37" height="16"/>
+                                                        <constraints>
+                                                            <constraint firstAttribute="width" constant="33" id="RUe-fo-jZ0"/>
+                                                        </constraints>
                                                         <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="ULE-OT-mhR">
                                                             <font key="font" metaFont="system"/>
                                                             <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -1249,6 +1252,7 @@
                                                     <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="ItP-E5-6eI">
                                                         <rect key="frame" x="14" y="44" width="196" height="17"/>
                                                         <constraints>
+                                                            <constraint firstAttribute="width" constant="192" id="i3V-IY-30U"/>
                                                             <constraint firstAttribute="height" constant="17" id="nok-GN-zdZ"/>
                                                         </constraints>
                                                         <textFieldCell key="cell" selectable="YES" title="Multiline Label" id="l6T-Ur-NC1">
@@ -1262,7 +1266,6 @@
                                                     <constraint firstItem="ItP-E5-6eI" firstAttribute="top" secondItem="mv9-xH-dgE" secondAttribute="top" id="1pi-eo-zxg"/>
                                                     <constraint firstItem="8iM-cD-LbJ" firstAttribute="leading" secondItem="mv9-xH-dgE" secondAttribute="leading" id="5dx-aT-2kx"/>
                                                     <constraint firstAttribute="trailing" secondItem="urW-lZ-sYJ" secondAttribute="trailing" id="UCC-Vh-Iff"/>
-                                                    <constraint firstAttribute="trailing" secondItem="ItP-E5-6eI" secondAttribute="trailing" id="VHm-CJ-l1J"/>
                                                     <constraint firstItem="8iM-cD-LbJ" firstAttribute="top" secondItem="mv9-xH-dgE" secondAttribute="top" constant="2" id="fxh-Uo-6vV"/>
                                                     <constraint firstAttribute="bottom" secondItem="urW-lZ-sYJ" secondAttribute="bottom" constant="8" id="oWU-lA-pXE"/>
                                                     <constraint firstItem="urW-lZ-sYJ" firstAttribute="leading" secondItem="mv9-xH-dgE" secondAttribute="leading" constant="18" id="qyo-CS-jHE"/>
@@ -1280,7 +1283,7 @@
                                         </subviews>
                                         <constraints>
                                             <constraint firstItem="Pnc-2Q-X2x" firstAttribute="top" secondItem="udQ-rE-Njy" secondAttribute="bottom" constant="4" id="0VN-YH-0OW"/>
-                                            <constraint firstAttribute="trailing" secondItem="udQ-rE-Njy" secondAttribute="trailing" constant="16" id="1h3-oY-1aP"/>
+                                            <constraint firstAttribute="trailing" secondItem="udQ-rE-Njy" secondAttribute="trailing" constant="30" id="1h3-oY-1aP"/>
                                             <constraint firstItem="zkB-0O-cuV" firstAttribute="leading" secondItem="3TS-lp-G7v" secondAttribute="leading" constant="16" id="809-dl-a9T"/>
                                             <constraint firstItem="mv9-xH-dgE" firstAttribute="top" secondItem="udQ-rE-Njy" secondAttribute="bottom" constant="8" id="DIv-1w-hI5"/>
                                             <constraint firstItem="Pnc-2Q-X2x" firstAttribute="leading" secondItem="mv9-xH-dgE" secondAttribute="trailing" constant="4" id="DVe-2C-VRp"/>
@@ -1294,6 +1297,7 @@
                                         </constraints>
                                         <connections>
                                             <outlet property="annotationContentLabel" destination="ItP-E5-6eI" id="kMP-h9-dGK"/>
+                                            <outlet property="annotationContentWidthConstraint" destination="i3V-IY-30U" id="WYc-QA-5WR"/>
                                             <outlet property="autherLabel" destination="nWk-O1-Rta" id="O0E-Ss-a6t"/>
                                             <outlet property="autherLayoutConstraint" destination="Yhb-f4-1D9" id="hnM-Rf-QUk"/>
                                             <outlet property="contentBoxLayoutConstraint" destination="x1P-qf-lR6" id="afO-aB-G4l"/>
@@ -1310,6 +1314,7 @@
                                             <outlet property="pageLabelTopConstraint" destination="0VN-YH-0OW" id="tbY-J9-NAu"/>
                                             <outlet property="pageLabelWidthConstraint" destination="ns3-Zn-Vcw" id="73W-dC-pwH"/>
                                             <outlet property="timeLabel" destination="pnF-AX-GzW" id="Dkf-aL-E5s"/>
+                                            <outlet property="timeWidthConstraint" destination="RUe-fo-jZ0" id="v6s-yr-RjZ"/>
                                             <outlet property="topView" destination="udQ-rE-Njy" id="KvO-gr-9Q8"/>
                                             <outlet property="topViewLayoutConstraint" destination="P1e-sT-bb4" id="aqL-Cr-rrA"/>
                                             <outlet property="typeImageView" destination="Lbo-Vh-Jiw" id="OhF-xv-3jN"/>