Revision: 13620
http://sourceforge.net/p/skim-app/code/13620
Author: hofman
Date: 2023-08-31 08:58:07 +0000 (Thu, 31 Aug 2023)
Log Message:
-----------
add undo manager breakpoint within interaction methods rather than generically
when adding/removing an annotation
Modified Paths:
--------------
trunk/SKPDFView.m
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2023-08-30 22:26:47 UTC (rev 13619)
+++ trunk/SKPDFView.m 2023-08-31 08:58:07 UTC (rev 13620)
@@ -225,7 +225,7 @@
- (void)editTextNoteWithEvent:(NSEvent *)theEvent;
- (BOOL)isEditingAnnotation:(PDFAnnotation *)annotation;
-- (void)beginNewUndoGroupIfNeeded;
+- (void)beginNewUndoGroupIfNeededWithCommit:(BOOL)commit;
- (void)enableNavigation;
- (void)disableNavigation;
@@ -1400,6 +1400,7 @@
[newAnnotation setBounds:bounds];
[newAnnotation registerUserName];
+ [self beginNewUndoGroupIfNeededWithCommit:YES];
[self addAnnotation:newAnnotation toPage:page];
[self setCurrentAnnotation:newAnnotation];
@@ -1472,6 +1473,7 @@
}
[newAnnotation registerUserName];
+ [self beginNewUndoGroupIfNeededWithCommit:YES];
[self addAnnotation:newAnnotation toPage:page];
[[self undoManager] setActionName:NSLocalizedString(@"Add Note",
@"Undo action name")];
@@ -2652,7 +2654,7 @@
}
if ([newAnnotations count] > 0) {
- [self commitEditing];
+ [self beginNewUndoGroupIfNeededWithCommit:YES];
for (NSArray *annotationAndPage in newAnnotations) {
newAnnotation = [annotationAndPage firstObject];
@@ -2670,7 +2672,7 @@
return YES;
} else if (newAnnotation) {
- [self commitEditing];
+ [self beginNewUndoGroupIfNeededWithCommit:YES];
if (annotationType != SKLineNote && annotationType != SKInkNote &&
[text length] > 0)
[newAnnotation setString:text];
@@ -2867,8 +2869,6 @@
}
- (void)addAnnotation:(PDFAnnotation *)annotation toPage:(PDFPage *)page {
- [self beginNewUndoGroupIfNeeded];
-
[[[self undoManager] prepareWithInvocationTarget:self]
removeAnnotation:annotation];
[annotation setShouldDisplay:pdfvFlags.hideNotes == NO || [annotation
isSkimNote] == NO];
[annotation setShouldPrint:pdfvFlags.hideNotes == NO || [annotation
isSkimNote] == NO];
@@ -2894,16 +2894,15 @@
}
- (void)removeAnnotation:(PDFAnnotation *)annotation {
- if (annotation == currentAnnotation)
- [self commitEditing];
- [self beginNewUndoGroupIfNeeded];
+ if (currentAnnotation == annotation) {
+ [self setCurrentAnnotation:nil];
+ [self beginNewUndoGroupIfNeededWithCommit:NO];
+ }
PDFAnnotation *wasAnnotation = [annotation retain];
PDFPage *page = [[wasAnnotation page] retain];
[[[self undoManager] prepareWithInvocationTarget:self]
addAnnotation:wasAnnotation toPage:page];
- if (currentAnnotation == annotation)
- [self setCurrentAnnotation:nil];
[self setNeedsDisplayForAnnotation:wasAnnotation];
[page removeAnnotation:wasAnnotation];
[self annotationsChangedOnPage:page];
@@ -3055,7 +3054,9 @@
return success;
}
-- (void)beginNewUndoGroupIfNeeded {
+- (void)beginNewUndoGroupIfNeededWithCommit:(BOOL)commit {
+ if (commit)
+ [self commitEditing];
if (pdfvFlags.wantsNewUndoGroup) {
NSUndoManager *undoManger = [self undoManager];
if ([undoManger groupingLevel] > 0) {
@@ -4361,7 +4362,7 @@
} else if (currentAnnotation == nil) {
continue;
}
- [self beginNewUndoGroupIfNeeded];
+ [self beginNewUndoGroupIfNeededWithCommit:NO];
if (resizeHandle == 0)
[self doMoveAnnotationWithEvent:lastMouseEvent offset:offset];
else if (isLine)
@@ -4458,7 +4459,7 @@
// select a new copy of the annotation
PDFAnnotation *newAnnotation = [PDFAnnotation
newSkimNoteWithProperties:[newCurrentAnnotation SkimNoteProperties]];
[newAnnotation registerUserName];
- [self commitEditing];
+ [self beginNewUndoGroupIfNeededWithCommit:YES];
[self addAnnotation:newAnnotation toPage:page];
[[self undoManager] setActionName:NSLocalizedString(@"Add Note",
@"Undo action name")];
newCurrentAnnotation = newAnnotation;
@@ -4490,7 +4491,7 @@
[paths release];
}
if (newAnnotation) {
- [self commitEditing];
+ [self beginNewUndoGroupIfNeededWithCommit:YES];
[newAnnotation setColor:[currentAnnotation color]];
[newAnnotation registerUserName];
[self removeAnnotation:newCurrentAnnotation];
@@ -4625,6 +4626,7 @@
}
if (interactionMode != SKPresentationMode) {
[annotation registerUserName];
+ [self beginNewUndoGroupIfNeededWithCommit:NO];
[self addAnnotation:annotation toPage:page];
[[self undoManager] setActionName:NSLocalizedString(@"Add Note",
@"Undo action name")];
} else {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit