Browse Source

【综合】自定义图章界面细节优化

niehaoyu 8 months ago
parent
commit
5d4af2c22d

+ 7 - 0
PDF Office/PDF Master/Class/PDFTools/CustomStamp/CustomStampWindowController.swift

@@ -411,6 +411,13 @@ extension CustomStampWindowController: CSRightToolbarDelegate {
             return
         }
         for anno in page.annotations ?? [] {
+            if anno is CPDFFreeTextAnnotation {
+                let newAnnotation = (anno as! CPDFFreeTextAnnotation)
+                if self.pdfView.isEdit(withCurrentFreeText: newAnnotation) {
+                    self.pdfView.commitEditAnnotationFreeText(newAnnotation)
+                    self.pdfView.annotationType = .unkown
+                }
+            }
             self.pdfView.setNeedsDisplay(anno)
         }
         

+ 5 - 0
PDF Office/PDF Master/Class/PDFTools/CustomStamp/Views/CustomStampTopToolbar.swift

@@ -245,6 +245,11 @@ class CustomStampTopToolbar: NSView, NibLoadable {
     //MARK: IBAction
     @IBAction func fitPageWidthAction(_ sender: Any) {
         self.pdfView.autoScales = true
+         
+        guard let activeAnnot = self.pdfView.activeAnnotation else {
+            return
+        }
+        self.pdfView.setNeedsDisplay(self.pdfView.activeAnnotation)
     }
     
     @IBAction func increaseAction(_ sender: Any) {

+ 2 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListView.h

@@ -277,6 +277,8 @@ enum {
 
 - (void)changeAnnotationTypeWithoutAction:(CAnnotationType)annotationType;
 
+- (void)clearStampCursor;
+
 @end
 
 @protocol CPDFListViewDelegate <NSObject>

+ 10 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListView.m

@@ -400,8 +400,12 @@ NSNotificationName const CPDFListViewDisplayModeChangeNotification = @"CPDFListV
 }
 
 - (void)setPageBackgroundColorWithColor:(NSColor *)color viewMode:(KMPDFViewMode)viewMode {
-    if (self.activeAnnotation != nil) {
-        return;
+    if ([self.isCustomStampType isEqualToString: @"1"]) {
+        
+    } else {
+        if (self.activeAnnotation != nil) {
+            return;
+        }
     }
     _viewMode = viewMode;
     if (viewMode == KMPDFViewModeNormal) {
@@ -928,6 +932,10 @@ NSNotificationName const CPDFListViewDisplayModeChangeNotification = @"CPDFListV
     }
 }
 
+- (void)clearStampCursor {
+    [NSCursor clearStampCursor];
+}
+
 - (void)setAddStampObject:(CStampSignatureObject *)stampObject keepToolModel:(BOOL)isToolModel {
     if (CAnnotationTypeStamp == self.annotationType ||
         CAnnotationTypeSignSignature == self.annotationType) {

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m

@@ -2589,7 +2589,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                 if (toolbarType == CSToolbarTypeText) {
                     originalBounds = [annotation bounds];
                     NSRect newBounds = [self getValidFreetText:((CPDFFreeTextAnnotation *)annotation) rect:originalBounds];
-                    originalBounds.size.width = newBounds.size.width;
+                    originalBounds.size.width = MAX(newBounds.size.width, 30);
                     originalBounds.size.height = newBounds.size.height;
                     annotation.bounds = originalBounds;
                 } else if (toolbarType == CSToolbarTypeDateText) {

+ 1 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.swift

@@ -1130,6 +1130,7 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
                     }
                 }
             }
+            self?.pdfView?.clearStampCursor()
             self?.view.window?.endSheet(windowVC.window!)
             windowVC.clear()
             CustomStampManager.manager.isWindowShow = false