From: <ho...@us...> - 2024-09-17 15:47:35
|
Revision: 14456 http://sourceforge.net/p/skim-app/code/14456 Author: hofman Date: 2024-09-17 15:47:33 +0000 (Tue, 17 Sep 2024) Log Message: ----------- Use a customview to display the pdf page in presentation. Simplifies the PDFView subclass and avoids flickering when pages changeor transitions. Synchronize currentPage in pdfview with the presentation view. Modified Paths: -------------- trunk/SKMainDocument.m trunk/SKMainTouchBarController.m trunk/SKMainWindowController.h trunk/SKMainWindowController.m trunk/SKMainWindowController_Actions.m trunk/SKMainWindowController_FullScreen.m trunk/SKMainWindowController_UI.m trunk/SKNavigationWindow.h trunk/SKNavigationWindow.m trunk/SKPDFView.h trunk/SKPDFView.m trunk/SKPresentationOptionsSheetController.m trunk/SKTransitionController.h trunk/SKTransitionController.m trunk/Skim.xcodeproj/project.pbxproj Added Paths: ----------- trunk/SKPresentationView.h trunk/SKPresentationView.m Modified: trunk/SKMainDocument.m =================================================================== --- trunk/SKMainDocument.m 2024-09-12 21:33:13 UTC (rev 14455) +++ trunk/SKMainDocument.m 2024-09-17 15:47:33 UTC (rev 14456) @@ -1693,11 +1693,11 @@ } - (PDFPage *)currentPage { - return [[self pdfView] currentPage]; + return [mainWindowController currentPage]; } - (void)setCurrentPage:(PDFPage *)page { - [[self pdfView] goToCurrentPage:page]; + [mainWindowController setCurrentPage:page]; } - (NSData *)currentQDPoint { @@ -1981,14 +1981,17 @@ if ([location isKindOfClass:[PDFPage class]]) { id pointData = [args objectForKey:@"At"]; - if ([pointData isKindOfClass:[NSData class]]) { + if ([mainWindowController interactionMode] == SKPresentationMode) { + [mainWindowController setCurrentPage:(PDFPage *)location]; + } else if ([pointData isKindOfClass:[NSData class]]) { NSPoint point = [(NSData *)pointData pointValueAsQDPoint]; [[self pdfView] goToDestination:[[PDFDestination alloc] initWithPage:(PDFPage *)location atPoint:point]]; } else { [[self pdfView] goToCurrentPage:(PDFPage *)location]; } + } else if ([mainWindowController interactionMode] == SKPresentationMode) { } else if ([location isKindOfClass:[PDFAnnotation class]]) { - [[self pdfView] scrollAnnotationToVisible:(PDFAnnotation *)location]; + [[self pdfView] scrollAnnotationToVisible:(PDFAnnotation *)location]; } else if ([location isKindOfClass:[PDFOutline class]]) { PDFDestination *dest = [(PDFOutline *)location destination]; if (dest) { Modified: trunk/SKMainTouchBarController.m =================================================================== --- trunk/SKMainTouchBarController.m 2024-09-12 21:33:13 UTC (rev 14455) +++ trunk/SKMainTouchBarController.m 2024-09-17 15:47:33 UTC (rev 14456) @@ -291,33 +291,30 @@ - (void)goToPreviousNextPage:(id)sender { NSInteger tag = [sender selectedSegment]; if (tag == 0) - [mainController.pdfView goToPreviousPage:sender]; + [mainController doGoToPreviousPage:sender]; else if (tag == 1) - [mainController.pdfView goToNextPage:sender]; + [mainController doGoToNextPage:sender]; } - (void)goToPreviousNextFirstLastPage:(id)sender { NSInteger tag = [sender selectedSegment]; if (tag == 0) - [mainController.pdfView goToFirstPage:sender]; + [mainController doGoToFirstPage:sender]; else if (tag == 1) - [mainController.pdfView goToNextPage:sender]; + [mainController doGoToPreviousPage:sender]; else if (tag == 2) - [mainController.pdfView goToPreviousPage:sender]; + [mainController doGoToNextPage:sender]; else if (tag == 3) - [mainController.pdfView goToLastPage:sender]; + [mainController doGoToLastPage:sender]; } - (void)zoomInActualOut:(id)sender { NSInteger tag = [sender selectedSegment]; if ([mainController interactionMode] == SKPresentationMode) { - if (tag == 0) { - if ([mainController.pdfView autoScales]) - [mainController.pdfView setScaleFactor:1.0]; - } else if (tag == 1) { - [mainController.pdfView setScaleFactor:1.0]; + if (tag == 0 || tag == 1) { + [mainController doZoomToActualSize:sender]; } else if (tag == 2) { - [mainController.pdfView setAutoScales:YES]; + [mainController doAutoScale:sender]; } } else { if (tag == 0) { @@ -368,9 +365,10 @@ } - (void)handleScaleChangedNotification:(NSNotification *)notification { - [zoomInActualOutButton setEnabled:[mainController.pdfView canZoomOut] forSegment:0]; + BOOL isPresentation = [mainController interactionMode] == SKPresentationMode; + [zoomInActualOutButton setEnabled:isPresentation == NO && [mainController.pdfView canZoomOut] forSegment:0]; [zoomInActualOutButton setEnabled:YES forSegment:1]; - [zoomInActualOutButton setEnabled:[mainController.pdfView canZoomIn] forSegment:2]; + [zoomInActualOutButton setEnabled:isPresentation || [mainController.pdfView canZoomIn] forSegment:2]; } - (void)handleToolModeChangedNotification:(NSNotification *)notification { @@ -429,6 +427,7 @@ [toolModeButton setEnabled:enabled]; [annotationModeButton setEnabled:enabled]; [noteButton setEnabled:enabled]; + [self handleScaleChangedNotification:nil]; } - (void)overviewChanged { Modified: trunk/SKMainWindowController.h =================================================================== --- trunk/SKMainWindowController.h 2024-09-12 21:33:13 UTC (rev 14455) +++ trunk/SKMainWindowController.h 2024-09-17 15:47:33 UTC (rev 14456) @@ -69,8 +69,8 @@ }; @class PDFAnnotation, PDFSelection, SKGroupedSearchResult; -@class SKPDFView, SKSecondaryPDFView, SKStatusBar, SKFindController, SKSplitView, SKFieldEditor, SKOverviewView, SKSideWindow; -@class SKLeftSideViewController, SKRightSideViewController, SKMainToolbarController, SKMainTouchBarController, SKProgressController, SKPresentationOptionsSheetController, SKNoteTypeSheetController, SKSnapshotWindowController; +@class SKPDFView, SKSecondaryPDFView, SKPresentationView, SKStatusBar, SKFindController, SKSplitView, SKFieldEditor, SKOverviewView, SKSideWindow; +@class SKLeftSideViewController, SKRightSideViewController, SKMainToolbarController, SKMainTouchBarController, SKProgressController, SKPresentationOptionsSheetController, SKNoteTypeSheetController, SKSnapshotWindowController, SKTransitionController; @interface SKMainWindowController : NSWindowController <SKSnapshotWindowControllerDelegate, SKThumbnailDelegate, SKFindControllerDelegate, SKPDFViewDelegate, SKPDFDocumentDelegate, NSTouchBarDelegate> { SKSplitView *splitView; @@ -83,6 +83,8 @@ SKSecondaryPDFView *secondaryPdfView; + SKPresentationView *presentationView; + SKLeftSideViewController *leftSideController; SKRightSideViewController *rightSideController; @@ -224,6 +226,8 @@ @property (nonatomic, nullable, readonly) NSString *searchString; +- (SKTransitionController *)transitionControllerCreating:(BOOL)create; + - (void)showSnapshotAtPageNumber:(NSInteger)pageNum forRect:(NSRect)rect scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits; - (void)showSnapshotsWithSetups:(NSArray *)setups; - (void)showNote:(PDFAnnotation *)annotation; @@ -271,6 +275,8 @@ @property (nonatomic, nullable, copy) NSString *pageLabel; +@property (nonatomic, nullable, strong) PDFPage *currentPage; + @property (nonatomic, readonly) SKInteractionMode interactionMode; @property (nonatomic) SKLeftSidePaneState leftSidePaneState; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2024-09-12 21:33:13 UTC (rev 14455) +++ trunk/SKMainWindowController.m 2024-09-17 15:47:33 UTC (rev 14456) @@ -107,6 +107,7 @@ #import "NSObject_SKExtensions.h" #import "SKChainedUndoManager.h" #import "SKThumbnailStamp.h" +#import "SKPresentationView.h" #define MULTIPLICATION_SIGN_CHARACTER (unichar)0x00d7 @@ -158,6 +159,7 @@ #define LOCKED_KEY @"locked" #define CROPBOXES_KEY @"cropBpxes" +#define TRANSITION_KEY @"transition" #define PAGETRANSITIONS_KEY @"pageTransitions" #define WINDOW_KEY @"window" @@ -174,6 +176,8 @@ static char SKMainWindowContentLayoutObservationContext; +static char SKMainWindowTransitionsObservationContext; + #define SKLeftSidePaneWidthKey @"SKLeftSidePaneWidth" #define SKRightSidePaneWidthKey @"SKRightSidePaneWidth" @@ -212,7 +216,7 @@ @implementation SKMainWindowController @synthesize mainWindow, splitView, topConstraint, centerContentView, pdfSplitView, pdfContentView, findBarTopConstraint, statusBar, pdfView, secondaryPdfView, leftSideController, rightSideController, leftSideContentView, rightSideContentView, presentationNotesDocument, presentationNotesOffset, notes, thumbnails, snapshots, searchResults, groupedSearchResults, tags, rating, pageLabel, interactionMode, placeholderPdfDocument; -@dynamic pdfDocument, presentationOptions, presentationUndoManager, selectedNotes, hasNotes, widgetProperties, leftSidePaneState, rightSidePaneState, findPaneState, displaysFindPane, leftSidePaneIsOpen, rightSidePaneIsOpen, recentInfoNeedsUpdate, searchString, hasOverview, notesMenu; +@dynamic pdfDocument, presentationOptions, presentationUndoManager, selectedNotes, hasNotes, widgetProperties, currentPage, leftSidePaneState, rightSidePaneState, findPaneState, displaysFindPane, leftSidePaneIsOpen, rightSidePaneIsOpen, recentInfoNeedsUpdate, searchString, hasOverview, notesMenu; + (BOOL)automaticallyNotifiesObserversOfPageLabel { return NO; } @@ -1208,6 +1212,20 @@ return YES; } +- (PDFPage *)currentPage { + if ([self interactionMode] == SKPresentationMode) + return [presentationView page]; + else + return [[self pdfView] currentPage]; +} + +- (void)setCurrentPage:(PDFPage *)page { + if ([self interactionMode] == SKPresentationMode) + return [presentationView setPage:page]; + else + [[self pdfView] goToCurrentPage:page]; +} + - (SKLeftSidePaneState)leftSidePaneState { return mwcFlags.leftSidePaneState; } @@ -1399,8 +1417,21 @@ groupedSearchResults = [newGroupedSearchResults mutableCopy]; } +- (SKTransitionController *)transitionControllerCreating:(BOOL)create { + SKTransitionController *transitionController = [presentationView transitionController]; + if (transitionController == nil && create) { + transitionController = [[SKTransitionController alloc] init]; + [transitionController addObserver:self forKeyPath:TRANSITION_KEY options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:&SKMainWindowTransitionsObservationContext]; + [transitionController addObserver:self forKeyPath:PAGETRANSITIONS_KEY options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:&SKMainWindowTransitionsObservationContext]; + if (presentationView == nil) + presentationView = [[SKPresentationView alloc] init]; + [presentationView setTransitionController:transitionController]; + } + return transitionController; +} + - (NSDictionary *)presentationOptions { - SKTransitionController *transitions = [pdfView transitionController]; + SKTransitionController *transitions = [self transitionControllerCreating:NO]; SKTransitionInfo *transition = [transitions transition]; NSArray *pageTransitions = [transitions pageTransitions]; NSMutableDictionary *options = nil; @@ -1412,7 +1443,7 @@ } - (void)setPresentationOptions:(NSDictionary *)dictionary { - SKTransitionController *transitions = [pdfView transitionController]; + SKTransitionController *transitions = [self transitionControllerCreating:YES]; [transitions setTransition:[[SKTransitionInfo alloc] initWithProperties:dictionary]]; [transitions setPageTransitions:[dictionary objectForKey:PAGETRANSITIONS_KEY]]; } @@ -1545,7 +1576,7 @@ } BOOL isPresentation = [self interactionMode] == SKPresentationMode; - NSView *oldView = isPresentation ? pdfView : splitView; + NSView *oldView = isPresentation ? presentationView : splitView; NSView *contentView = [oldView superview]; BOOL hasStatus = isPresentation == NO && [statusBar isVisible]; NSArray *constraints = @[ @@ -1609,7 +1640,8 @@ animate = NO; BOOL isMainWindow = [overviewContentView window] == mainWindow; - NSView *newView = isMainWindow ? splitView : pdfView; + NSView *newView = isMainWindow ? splitView : presentationView; + NSView *newKeyView = isMainWindow ? pdfView : presentationView; NSView *contentView = [overviewContentView superview]; BOOL hasStatus = isMainWindow && [statusBar isVisible]; NSArray *constraints = @[ @@ -1625,8 +1657,7 @@ } completionHandler:^{ [touchBarController overviewChanged]; - if ([pdfView window] == [self window]) - [[self window] makeFirstResponder:pdfView]; + [[newKeyView window] makeFirstResponder:newKeyView]; if (handler) handler(); }]; @@ -1634,8 +1665,7 @@ [contentView replaceSubview:overviewContentView with:newView]; [NSLayoutConstraint activateConstraints:constraints]; [touchBarController overviewChanged]; - if ([pdfView window] == [self window]) - [[self window] makeFirstResponder:pdfView]; + [[newKeyView window] makeFirstResponder:newKeyView]; if (handler) handler(); } @@ -2160,8 +2190,11 @@ if (presentationNotes == nil) presentationNotes = [[NSMutableArray alloc] init]; [presentationNotes addObject:annotation]; - if (page) + if (page) { [self updateThumbnailAtPageIndex:[page pageIndex]]; + if ([presentationView page] == page) + [presentationView setNeedsDisplay:YES]; + } } else { [[undoManager prepareWithInvocationTarget:[notification object]] removeAnnotation:annotation]; @@ -2183,6 +2216,8 @@ [self snapshotNeedsUpdate:wc placeholder:NO]; } [secondaryPdfView setNeedsDisplayForAddedAnnotation:annotation onPage:page]; + if ([self interactionMode] == SKPresentationMode && [presentationView page] == page) + [presentationView setNeedsDisplay:YES]; } } } @@ -2197,8 +2232,11 @@ [[[self presentationUndoManager] prepareWithInvocationTarget:[notification object]] addAnnotation:annotation toPage:page]; [presentationNotes removeObject:annotation]; - if (page) + if (page) { [self updateThumbnailAtPageIndex:[page pageIndex]]; + if ([presentationView page] == page) + [presentationView setNeedsDisplay:YES]; + } } else { [[undoManager prepareWithInvocationTarget:[notification object]] addAnnotation:annotation toPage:page]; @@ -2223,6 +2261,8 @@ [self snapshotNeedsUpdate:wc placeholder:NO]; } [secondaryPdfView setNeedsDisplayForRemovedAnnotation:annotation onPage:page]; + if ([self interactionMode] == SKPresentationMode && [presentationView page] == page) + [presentationView setNeedsDisplay:YES]; } } } @@ -2246,6 +2286,8 @@ } [secondaryPdfView setNeedsDisplayForRemovedAnnotation:annotation onPage:oldPage]; [secondaryPdfView setNeedsDisplayForAddedAnnotation:annotation onPage:newPage]; + if ([self interactionMode] == SKPresentationMode && ([presentationView page] == oldPage || [presentationView page] == newPage)) + [presentationView setNeedsDisplay:YES]; } [rightSideController.noteArrayController rearrangeObjects]; @@ -2489,6 +2531,12 @@ @try { [overviewView removeObserver:self forKeyPath:@"selectionIndexPaths" context:&SKMainWindowThumbnailSelectionObservationContext]; } @catch (id e) {} } + if ([presentationView transitionController]) { + @try { [[presentationView transitionController] removeObserver:self forKeyPath:TRANSITION_KEY context:&SKMainWindowTransitionsObservationContext]; } + @catch (id e) {} + @try { [[presentationView transitionController] removeObserver:self forKeyPath:PAGETRANSITIONS_KEY context:&SKMainWindowTransitionsObservationContext]; } + @catch (id e) {} + } } #pragma mark Undo @@ -2601,13 +2649,29 @@ } } + } else if (context == &SKMainWindowTransitionsObservationContext) { + + id oldValue = [change objectForKey:NSKeyValueChangeOldKey]; + if (oldValue == [NSNull null]) + oldValue = nil; + + if ([keyPath isEqualToString:TRANSITION_KEY]) + [[[self document] undoManager] registerUndoWithTarget:object selector:@selector(setTransition:) object:oldValue]; + else if ([keyPath isEqualToString:PAGETRANSITIONS_KEY]) + [[[self document] undoManager] registerUndoWithTarget:object selector:@selector(setPageTransitions:) object:oldValue]; + } else if (context == &SKMainWindowThumbnailSelectionObservationContext) { NSIndexSet *indexes = [overviewView selectionIndexes]; if ([indexes count] == 1 && mwcFlags.updatingThumbnailSelection == 0) { NSUInteger pageIndex = [indexes firstIndex]; - if ([[pdfView currentPage] pageIndex] != pageIndex) - [pdfView goToCurrentPage:[[pdfView document] pageAtIndex:pageIndex]]; + if ([self interactionMode] == SKPresentationMode) { + if ([[presentationView page] pageIndex] != pageIndex) + [presentationView setPage:[[pdfView document] pageAtIndex:pageIndex]]; + } else { + if ([[pdfView currentPage] pageIndex] != pageIndex) + [pdfView goToCurrentPage:[[pdfView document] pageAtIndex:pageIndex]]; + } } else if ([indexes count] == 0) { mwcFlags.updatingThumbnailSelection = 1; [overviewView setSelectionIndexes:[NSIndexSet indexSetWithIndex:[[pdfView currentPage] pageIndex]]]; @@ -2705,6 +2769,9 @@ [self updateRightStatus]; } } + + if ([self interactionMode] == SKPresentationMode && [presentationView page] == page) + [presentationView setNeedsDisplay:YES]; } if (mwcFlags.autoResizeNoteRows) { Modified: trunk/SKMainWindowController_Actions.m =================================================================== --- trunk/SKMainWindowController_Actions.m 2024-09-12 21:33:13 UTC (rev 14455) +++ trunk/SKMainWindowController_Actions.m 2024-09-17 15:47:33 UTC (rev 14456) @@ -80,6 +80,7 @@ #import "PDFSelection_SKExtensions.h" #import "SKOutlineView.h" #import "SKOverviewView.h" +#import "SKPresentationView.h" #import "NSUserDefaults_SKExtensions.h" #define STATUSBAR_HEIGHT 22.0 @@ -329,20 +330,32 @@ } - (IBAction)doGoToNextPage:(id)sender { - [pdfView goToNextPage:sender]; + if ([self interactionMode] == SKPresentationMode) + [presentationView goToNextPage:sender]; + else + [pdfView goToNextPage:sender]; } - (IBAction)doGoToPreviousPage:(id)sender { - [pdfView goToPreviousPage:sender]; + if ([self interactionMode] == SKPresentationMode) + [presentationView goToPreviousPage:sender]; + else + [pdfView goToPreviousPage:sender]; } - (IBAction)doGoToFirstPage:(id)sender { - [pdfView goToFirstPage:sender]; + if ([self interactionMode] == SKPresentationMode) + [presentationView goToFirstPage:sender]; + else + [pdfView goToFirstPage:sender]; } - (IBAction)doGoToLastPage:(id)sender { - [pdfView goToLastPage:sender]; + if ([self interactionMode] == SKPresentationMode) + [presentationView goToLastPage:sender]; + else + [pdfView goToLastPage:sender]; } - (IBAction)doGoToPage:(id)sender { @@ -364,10 +377,14 @@ - (IBAction)doGoBack:(id)sender { [pdfView goBack:sender]; + if ([self interactionMode] == SKPresentationMode) + [presentationView setPage:[pdfView currentPage]]; } - (IBAction)doGoForward:(id)sender { [pdfView goForward:sender]; + if ([self interactionMode] == SKPresentationMode) + [presentationView setPage:[pdfView currentPage]]; } - (IBAction)goToMarkedPage:(id)sender { @@ -375,6 +392,7 @@ NSUInteger currentPageIndex = [[pdfView currentPage] pageIndex]; if (markedPage.pageIndex == NSNotFound || [pdfDoc isLocked] || [pdfDoc pageCount] == 0) { NSBeep(); + return; } else if (beforeMarkedPage.pageIndex != NSNotFound) { beforeMarkedPage.pageIndex = MIN(beforeMarkedPage.pageIndex, [pdfDoc pageCount] - 1); [pdfView goToCurrentDestination:beforeMarkedPage]; @@ -383,6 +401,8 @@ markedPage.pageIndex = MIN(markedPage.pageIndex, [pdfDoc pageCount] - 1); [pdfView goToCurrentDestination:markedPage]; } + if ([self interactionMode] == SKPresentationMode) + [presentationView setPage:[pdfView currentPage]]; } - (IBAction)markPage:(id)sender { @@ -409,7 +429,10 @@ } - (IBAction)doZoomToActualSize:(id)sender { - [pdfView setScaleFactor:1.0]; + if ([self interactionMode] == SKPresentationMode) + [presentationView setAutoScales:NO]; + else + [pdfView setScaleFactor:1.0]; } - (IBAction)doZoomToSelection:(id)sender { @@ -468,12 +491,15 @@ } - (IBAction)doAutoScale:(id)sender { - [pdfView setAutoScales:YES]; + if ([self interactionMode] == SKPresentationMode) + [presentationView setAutoScales:YES]; + else + [pdfView setAutoScales:YES]; } - (IBAction)toggleAutoScale:(id)sender { if ([self interactionMode] == SKPresentationMode) - [pdfView toggleAutoActualSize:sender]; + [presentationView toggleAutoActualSize:sender]; else [pdfView setAutoScales:[pdfView autoScales] == NO]; } @@ -1226,6 +1252,8 @@ [self toggleLeftSidePane:sender]; else if ([self hasOverview]) [self hideOverviewAnimating:YES]; + else if ([presentationView hasBlackout]) + [presentationView toggleBlackout:sender]; else [self exitPresentation]; } else if ([self hasOverview]) { Modified: trunk/SKMainWindowController_FullScreen.m =================================================================== --- trunk/SKMainWindowController_FullScreen.m 2024-09-12 21:33:13 UTC (rev 14455) +++ trunk/SKMainWindowController_FullScreen.m 2024-09-17 15:47:33 UTC (rev 14456) @@ -65,6 +65,7 @@ #import "NSColor_SKExtensions.h" #import "SKStatusBar.h" #import "SKAnimatedBorderlessWindow.h" +#import "SKPresentationView.h" #import "NSWindow_SKExtensions.h" #define MAINWINDOWFRAME_KEY @"windowFrame" @@ -190,61 +191,6 @@ return alternateScreens; } -- (void)enterPresentationMode { - NSScrollView *scrollView = [pdfView scrollView]; - [savedNormalSetup setObject:[NSNumber numberWithBool:[scrollView hasHorizontalScroller]] forKey:HASHORIZONTALSCROLLER_KEY]; - [savedNormalSetup setObject:[NSNumber numberWithBool:[scrollView hasVerticalScroller]] forKey:HASVERTICALSCROLLER_KEY]; - [savedNormalSetup setObject:[NSNumber numberWithBool:[scrollView autohidesScrollers]] forKey:AUTOHIDESSCROLLERS_KEY]; - [savedNormalSetup setObject:[NSNumber numberWithBool:[scrollView drawsBackground]] forKey:DRAWSBACKGROUND_KEY]; - // Set up presentation mode - [pdfView setNeedsRewind:YES]; - [pdfView setBackgroundColor:[NSColor clearColor]]; - [pdfView setAutoScales:YES]; - [pdfView setDisplayMode:kPDFDisplaySinglePage]; - [pdfView setDisplayBox:kPDFDisplayBoxCropBox]; - [pdfView setDisplaysPageBreaks:NO]; - [scrollView setAutohidesScrollers:YES]; - [scrollView setHasHorizontalScroller:NO]; - [scrollView setHasVerticalScroller:NO]; - [scrollView setDrawsBackground:NO]; - if (mwcFlags.fullSizeContent) { - [scrollView setAutomaticallyAdjustsContentInsets:YES]; - [scrollView setContentInsets:NSEdgeInsetsZero]; - } - - [pdfView setCurrentSelection:nil]; - if ([pdfView hasReadingBar]) - [pdfView toggleReadingBar]; - - if ([[NSUserDefaults standardUserDefaults] boolForKey:SKResizablePresentationKey]) { - [[self window] setStyleMask:[[self window] styleMask] | NSWindowStyleMaskResizable]; - [[self window] setHasShadow:YES]; - } - - // prevent sleep - if (activity == nil) - activity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityUserInitiated | NSActivityIdleDisplaySleepDisabled | NSActivityIdleSystemSleepDisabled reason:@"Presentation"]; -} - -- (void)exitPresentationMode { - if (activity) { - [[NSProcessInfo processInfo] endActivity:activity]; - activity = nil; - } - - [self removePresentationNotesNavigation]; - - NSScrollView *scrollView = [pdfView scrollView]; - [scrollView setHasHorizontalScroller:[[savedNormalSetup objectForKey:HASHORIZONTALSCROLLER_KEY] boolValue]]; - [scrollView setHasVerticalScroller:[[savedNormalSetup objectForKey:HASVERTICALSCROLLER_KEY] boolValue]]; - [scrollView setAutohidesScrollers:[[savedNormalSetup objectForKey:AUTOHIDESSCROLLERS_KEY] boolValue]]; - [scrollView setDrawsBackground:[[savedNormalSetup objectForKey:DRAWSBACKGROUND_KEY] boolValue]]; - if (mwcFlags.fullSizeContent && [[findController view] window]) { - [scrollView setAutomaticallyAdjustsContentInsets:NO]; - [scrollView setContentInsets:NSEdgeInsetsMake([findController height] + titleBarHeight, 0.0, 0.0, 0.0)]; - } -} - - (void)showNotesForPresentationWindow:(NSWindow *)window { PDFDocument *pdfDoc = [[self presentationNotesDocument] pdfDocument]; NSInteger offset = [self presentationNotesOffset]; @@ -284,7 +230,8 @@ [mainWindow makeKeyAndOrderFront:nil]; } [mainWindow display]; - [mainWindow makeFirstResponder:[self hasOverview] ? overviewView : pdfView]; + if ([pdfView window] == mainWindow) + [mainWindow makeFirstResponder:pdfView]; [mainWindow recalculateKeyViewLoop]; [mainWindow setDelegate:self]; [mainWindow makeKeyWindow]; @@ -327,36 +274,27 @@ [window setAlphaValue:0.0]; } -- (void)displayStaticContentInPresentationWindow:(NSWindow *)window { - NSRect rect = [[window contentView] bounds]; - NSBitmapImageRep *imageRep = nil; - - if ([pdfView window] == window) { - imageRep = [pdfView bitmapImageRepCachingDisplay]; - } else { - PDFPage *page = [pdfView currentPage]; - NSRect pageRect = [page boundsForBox:kPDFDisplayBoxCropBox]; - if (([page rotation] % 180) != 0) - pageRect = NSMakeRect(0.0, 0.0, NSHeight(pageRect), NSWidth(pageRect)); - CGFloat scale = fmin(NSHeight(rect) / NSHeight(pageRect), NSWidth(rect) / NSWidth(pageRect)); - pageRect = NSInsetRect(rect, 0.5 * (NSWidth(rect) - scale * NSWidth(pageRect)), 0.5 * (NSHeight(rect) - scale * NSHeight(pageRect))); - imageRep = [[window contentView] bitmapImageRepForCachingDisplayInRect:rect]; - CGContextRef context = [[NSGraphicsContext graphicsContextWithBitmapImageRep:imageRep] CGContext]; - CGContextSetFillColorWithColor(context, CGColorGetConstantColor(kCGColorWhite)); - CGContextFillRect(context, SKPixelAlignedRect(NSRectToCGRect(pageRect), context)); - CGContextSaveGState(context); - CGContextTranslateCTM(context, NSMinX(pageRect), NSMinY(pageRect)); - CGContextScaleCTM(context, scale, scale); - [page drawWithBox:kPDFDisplayBoxCropBox toContext:context]; - CGContextRestoreGState(context); +#pragma mark SKPresentationView delegate + +- (void)handlePresentationViewPageChanged:(NSNotification *)notification { + PDFPage *page = [presentationView page]; + if (page) { + if (page != [pdfView currentPage]) { + // make sure we can synchronize the page between the presentationView and the pdfView + if ([pdfView displayMode] != kPDFDisplaySinglePage) + [pdfView setExtendedDisplayMode:kPDFDisplaySinglePage]; + [pdfView goToCurrentPage:page]; + } + if ([self presentationNotesDocument]) { + PDFDocument *pdfDoc = [[self presentationNotesDocument] pdfDocument]; + NSInteger offset = [self presentationNotesOffset]; + NSUInteger pageIndex = (NSUInteger)MAX(0, MIN((NSInteger)[pdfDoc pageCount], (NSInteger)pageIndex + offset)); + if ([self presentationNotesDocument] == [self document]) + [[presentationPreview pdfView] goToCurrentPage:[pdfDoc pageAtIndex:pageIndex]]; + else + [[self presentationNotesDocument] setCurrentPage:[pdfDoc pageAtIndex:pageIndex]]; + } } - - NSImage *image = [[NSImage alloc] initWithSize:rect.size]; - [image addRepresentation:imageRep]; - - if ([pdfView window] == window) - [pdfView removeFromSuperview]; - [[window addImageViewWithImage:image] setContentFilters:SKColorEffectFilters()]; } #pragma mark API @@ -412,7 +350,15 @@ NSWindow *presentationWindow = [[SKFullScreenWindow alloc] initWithContentRect:[screen ?: [mainWindow screen] frame]]; [presentationWindow setAlphaValue:0.0]; - [self displayStaticContentInPresentationWindow:presentationWindow]; + + if (presentationView == nil) + presentationView = [[SKPresentationView alloc] initWithFrame:[[presentationWindow contentView] bounds]]; + [[presentationWindow contentView] addSubviewWithConstraints:presentationView]; + [presentationWindow makeFirstResponder:presentationView]; + [presentationView setAutoScales:YES]; + [presentationView setPage:[pdfView currentPage]]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePresentationViewPageChanged:) name:SKPresentationViewPageChangedNotification object:presentationView]; + [presentationWindow orderFront:nil]; if ([self presentationNotesDocument]) @@ -429,7 +375,7 @@ [[[presentationPreview window] animator] setAlphaValue:1.0]; } completionHandler:^{ - PDFPage *page = [[self pdfView] currentPage]; + //PDFPage *page = [[self pdfView] currentPage]; if ([[[self window] tabbedWindows] count] > 1) { NSUInteger tabIndex = [[[self window] tabbedWindows] indexOfObject:[self window]]; @@ -454,21 +400,19 @@ if ([self hasOverview]) [self hideOverviewAnimating:NO]; - [self enterPresentationMode]; + if ([[NSUserDefaults standardUserDefaults] boolForKey:SKResizablePresentationKey]) { + [[self window] setStyleMask:[[self window] styleMask] | NSWindowStyleMaskResizable]; + [[self window] setHasShadow:YES]; + } - [[[[presentationWindow contentView] subviews] firstObject] removeFromSuperview]; - [[presentationWindow contentView] addSubviewWithConstraints:pdfView]; - [pdfView layoutDocumentView]; - [pdfView requiresDisplay]; - [presentationWindow makeFirstResponder:pdfView]; - [presentationWindow recalculateKeyViewLoop]; + // prevent sleep + if (activity == nil) + activity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityUserInitiated | NSActivityIdleDisplaySleepDisabled | NSActivityIdleSystemSleepDisabled reason:@"Presentation"]; + [presentationWindow setDelegate:self]; - if ([[pdfView currentPage] isEqual:page] == NO) - [pdfView goToPage:page]; + [presentationView didOpen]; - [pdfView setPresentationMode:YES]; - [touchBarController interactionModeChanged]; mwcFlags.isSwitchingFullScreen = 0; @@ -479,9 +423,6 @@ if ([self canExitPresentation] == NO) return; - NSColor *backgroundColor = [PDFView defaultBackgroundColor]; - PDFPage *page = [[self pdfView] currentPage]; - mwcFlags.isSwitchingFullScreen = 1; if ([self leftSidePaneIsOpen]) @@ -495,13 +436,11 @@ presentationNotes = nil; presentationUndoManager = nil; - // do this first, otherwise the navigation window may be covered by fadeWindow and then reveiled again, which looks odd - [pdfView setPresentationMode:NO]; + [presentationView willClose]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:SKPresentationViewPageChangedNotification object:presentationView]; NSWindow *presentationWindow = [self window]; - [self displayStaticContentInPresentationWindow:presentationWindow]; - while ([[presentationWindow childWindows] count] > 0) { NSWindow *childWindow = [[presentationWindow childWindows] lastObject]; [presentationWindow removeChildWindow:childWindow]; @@ -513,21 +452,20 @@ interactionMode = SKNormalMode; - // this should be done before exitPresentationMode to get a smooth transition - [pdfContentView addSubview:pdfView positioned:NSWindowBelow relativeTo:nil]; - [NSLayoutConstraint activateConstraints:@[ - [[pdfView leadingAnchor] constraintEqualToAnchor:[pdfContentView leadingAnchor]], - [[pdfContentView trailingAnchor] constraintEqualToAnchor:[pdfView trailingAnchor]], - [[pdfView topAnchor] constraintEqualToAnchor:[pdfContentView topAnchor]], - [[pdfContentView bottomAnchor] constraintEqualToAnchor:[pdfView bottomAnchor]]]]; - [pdfView setBackgroundColor:backgroundColor]; - [secondaryPdfView setBackgroundColor:backgroundColor]; - if ([self hasOverview]) - [overviewContentView removeFromSuperview]; + if (activity) { + [[NSProcessInfo processInfo] endActivity:activity]; + activity = nil; + } - [self exitPresentationMode]; - [self applyPDFSettings:savedNormalSetup rewind:YES]; + [self removePresentationNotesNavigation]; + PDFDisplayMode mode = [[savedNormalSetup objectForKey:@"displayMode"] integerValue]; + if (mode == kPDFDisplaySinglePageContinuous && [[savedNormalSetup objectForKey:@"displayDirection"] boolValue]) + mode = kPDFDisplayHorizontalContinuous; + //make sure we reset the display mode + if (mode != [pdfView extendedDisplayMode]) + [pdfView setExtendedDisplayModeAndRewind:mode]; + [pdfView layoutDocumentView]; [pdfView requiresDisplay]; @@ -537,9 +475,6 @@ } mwcFlags.thumbnailsUpdatedDuringPresentaton = 0; - if ([[[self pdfView] currentPage] isEqual:page] == NO) - [[self pdfView] goToCurrentPage:page]; - mwcFlags.isSwitchingFullScreen = 0; [self forceSubwindowsOnTop:NO]; @@ -574,7 +509,11 @@ [[[presentationPreview window] animator] setAlphaValue:0.0]; } completionHandler:^{ + if ([overviewContentView window] == presentationWindow) + [overviewContentView removeFromSuperview]; [presentationWindow orderOut:nil]; + [presentationView setPage:nil]; + [presentationView setAutoScales:NO]; if (presentationPreview) { [[presentationPreview window] setAnimationBehavior:NSWindowAnimationBehaviorNone]; [presentationPreview close]; Modified: trunk/SKMainWindowController_UI.m =================================================================== --- trunk/SKMainWindowController_UI.m 2024-09-12 21:33:13 UTC (rev 14455) +++ trunk/SKMainWindowController_UI.m 2024-09-17 15:47:33 UTC (rev 14456) @@ -90,6 +90,7 @@ #import "NSObject_SKExtensions.h" #import "NSPasteboard_SKExtensions.h" #import "SKApplicationController.h" +#import "SKPresentationView.h" #define NOTES_KEY @"notes" #define SNAPSHOTS_KEY @"snapshots" @@ -483,11 +484,16 @@ if ([[aNotification object] isEqual:leftSideController.thumbnailTableView]) { if (mwcFlags.updatingThumbnailSelection == 0) { NSInteger row = [leftSideController.thumbnailTableView selectedRow]; - if (row != -1) - [pdfView goToCurrentPage:[[pdfView document] pageAtIndex:row]]; - - if ([self interactionMode] == SKPresentationMode && [[NSUserDefaults standardUserDefaults] boolForKey:SKAutoHidePresentationContentsKey]) - [self hideSideWindow]; + if ([self interactionMode] == SKPresentationMode) { + if (row != -1) + [presentationView setPage:[[pdfView document] pageAtIndex:row]]; + + if ([[NSUserDefaults standardUserDefaults] boolForKey:SKAutoHidePresentationContentsKey]) + [self hideSideWindow]; + } else { + if (row != -1) + [pdfView goToCurrentPage:[[pdfView document] pageAtIndex:row]]; + } } } else if ([[aNotification object] isEqual:rightSideController.snapshotTableView]) { NSInteger row = [[aNotification object] selectedRow]; @@ -1564,18 +1570,6 @@ [self showSnapshotAtPageNumber:pageNum forRect:rect scaleFactor:scaleFactor autoFits:autoFits]; } -- (void)PDFViewExitPresentation:(PDFView *)sender { - [self exitPresentation]; -} - -- (void)PDFViewTogglePages:(PDFView *)sender { - [self toggleOverview:sender]; -} - -- (void)PDFViewToggleContents:(PDFView *)sender { - [self toggleLeftSidePane:sender]; -} - - (void)PDFView:(PDFView *)sender rotatePageAtIndex:(NSUInteger)idx by:(NSInteger)rotation { [self rotatePageAtIndex:idx by:rotation]; } @@ -1801,7 +1795,7 @@ } else if (action == @selector(doZoomOut:)) { return [self interactionMode] != SKPresentationMode && [self hasOverview] == NO && [pdfView canZoomOut]; } else if (action == @selector(doZoomToActualSize:)) { - return [[self pdfDocument] isLocked] == NO && ([pdfView autoScales] || fabs([pdfView scaleFactor] - 1.0) > 0.0); + return [[self pdfDocument] isLocked] == NO && ([self interactionMode] == SKPresentationMode ? [presentationView autoScales] : ([pdfView autoScales] || fabs([pdfView scaleFactor] - 1.0) > 0.0)); } else if (action == @selector(doZoomToPhysicalSize:)) { return [self interactionMode] != SKPresentationMode && [self hasOverview] == NO && [[self pdfDocument] isLocked] == NO && ([pdfView autoScales] || fabs([pdfView physicalScaleFactor] - 1.0 ) > 0.001); } else if (action == @selector(doZoomToSelection:)) { @@ -1818,9 +1812,9 @@ } return [self interactionMode] != SKPresentationMode && [self hasOverview] == NO && [[self pdfDocument] isLocked] == NO; } else if (action == @selector(doAutoScale:)) { - return [[self pdfDocument] isLocked] == NO && [pdfView autoScales] == NO && [self hasOverview] == NO; + return [[self pdfDocument] isLocked] == NO && ([self interactionMode] == SKPresentationMode ? [presentationView autoScales] == NO : [pdfView autoScales] == NO) && [self hasOverview] == NO; } else if (action == @selector(toggleAutoScale:)) { - [menuItem setState:[pdfView autoScales] ? NSControlStateValueOn : NSControlStateValueOff]; + [menuItem setState:([self interactionMode] == SKPresentationMode ? [presentationView autoScales] : [pdfView autoScales]) ? NSControlStateValueOn : NSControlStateValueOff]; return [[self pdfDocument] isLocked] == NO && [self hasOverview] == NO; } else if (action == @selector(rotateRight:) || action == @selector(rotateLeft:) || action == @selector(rotateAllRight:) || action == @selector(rotateAllLeft:)) { return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO; @@ -1996,16 +1990,6 @@ [self updateLeftStatus]; if ([[NSUserDefaults standardUserDefaults] boolForKey:SKDisplayPageBoundsKey]) [self updateRightStatus]; - - if ([self interactionMode] == SKPresentationMode && [self presentationNotesDocument]) { - PDFDocument *pdfDoc = [[self presentationNotesDocument] pdfDocument]; - NSInteger offset = [self presentationNotesOffset]; - pageIndex = (NSUInteger)MAX(0, MIN((NSInteger)[pdfDoc pageCount], (NSInteger)pageIndex + offset)); - if ([self presentationNotesDocument] == [self document]) - [[presentationPreview pdfView] goToCurrentPage:[pdfDoc pageAtIndex:pageIndex]]; - else - [[self presentationNotesDocument] setCurrentPage:[pdfDoc pageAtIndex:pageIndex]]; - } mwcFlags.recentInfoNeedsUpdate = 1; } Modified: trunk/SKNavigationWindow.h =================================================================== --- trunk/SKNavigationWindow.h 2024-09-12 21:33:13 UTC (rev 14455) +++ trunk/SKNavigationWindow.h 2024-09-17 15:47:33 UTC (rev 14456) @@ -41,10 +41,10 @@ NS_ASSUME_NONNULL_BEGIN -@class SKPDFView, SKNavigationToolTipView, SKNavigationButton; +@class SKPresentationView, SKNavigationToolTipView, SKNavigationButton; @interface SKHUDWindow : SKAnimatedBorderlessWindow -- (instancetype)initWithPDFView:(SKPDFView *)pdfView; +- (instancetype)initWithView:(SKPresentationView *)pdfView; - (void)showForWindow:(NSWindow *)window; - (void)handleParentWindowDidResizeNotification:(NSNotification *)notification; @end @@ -57,7 +57,7 @@ SKNavigationButton *cursorButton; SKNavigationButton *closeButton; } -- (void)handleScaleChangedNotification:(NSNotification *)notification; +- (void)handleAutoScalesChangedNotification:(NSNotification *)notification; - (void)handlePageChangedNotification:(NSNotification *)notification; @end Modified: trunk/SKNavigationWindow.m =================================================================== --- trunk/SKNavigationWindow.m 2024-09-12 21:33:13 UTC (rev 14455) +++ trunk/SKNavigationWindow.m 2024-09-17 15:47:33 UTC (rev 14456) @@ -37,9 +37,8 @@ */ #import "SKNavigationWindow.h" -#import <Quartz/Quartz.h> #import "NSBezierPath_SKExtensions.h" -#import "SKPDFView.h" +#import "SKPresentationView.h" #import "NSParagraphStyle_SKExtensions.h" #import "NSGeometry_SKExtensions.h" #import "PDFView_SKExtensions.h" @@ -74,8 +73,8 @@ @implementation SKHUDWindow -- (instancetype)initWithPDFView:(SKPDFView *)pdfView { - NSScreen *screen = [[pdfView window] screen] ?: [NSScreen mainScreen]; +- (instancetype)initWithView:(SKPresentationView *)presentationView { + NSScreen *screen = [[presentationView window] screen] ?: [NSScreen mainScreen]; CGFloat width = 5 * BUTTON_WIDTH + 3 * SEP_WIDTH + 2 * BUTTON_MARGIN; NSRect contentRect = NSMakeRect(NSMidX([screen frame]) - 0.5 * width, NSMinY([screen frame]) + WINDOW_OFFSET, width, BUTTON_HEIGHT + 2 * BUTTON_MARGIN); self = [super initWithContentRect:contentRect]; @@ -83,7 +82,7 @@ [self setIgnoresMouseEvents:NO]; [self setDisplaysWhenScreenProfileChanges:YES]; - [self setLevel:[[pdfView window] level]]; + [self setLevel:[[presentationView window] level]]; [self setMovableByWindowBackground:YES]; contentRect.origin = NSZeroPoint; @@ -147,26 +146,26 @@ @implementation SKNavigationWindow -- (instancetype)initWithPDFView:(SKPDFView *)pdfView { - self = [super initWithPDFView:pdfView]; +- (instancetype)initWithView:(SKPresentationView *)presentationView { + self = [super initWithView:presentationView]; if (self) { NSRect rect = NSMakeRect(BUTTON_MARGIN, BUTTON_MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT); previousButton = [[SKNavigationButton alloc] initWithFrame:rect]; - [previousButton setTarget:pdfView]; + [previousButton setTarget:presentationView]; [previousButton setAction:@selector(goToPreviousPage:)]; [previousButton setToolTip:NSLocalizedString(@"Previous", @"Tool tip message")]; [previousButton setPath:previousButtonPath(rect.size)]; - [previousButton setEnabled:[pdfView canGoToPreviousPage]]; + [previousButton setEnabled:[presentationView canGoToPreviousPage]]; [[self contentView] addSubview:previousButton]; rect.origin.x = NSMaxX(rect); nextButton = [[SKNavigationButton alloc] initWithFrame:rect]; - [nextButton setTarget:pdfView]; + [nextButton setTarget:presentationView]; [nextButton setAction:@selector(goToNextPage:)]; [nextButton setToolTip:NSLocalizedString(@"Next", @"Tool tip message")]; [nextButton setPath:nextButtonPath(rect.size)]; - [nextButton setEnabled:[pdfView canGoToNextPage]]; + [nextButton setEnabled:[presentationView canGoToNextPage]]; [[self contentView] addSubview:nextButton]; rect.origin.x = NSMaxX(rect); @@ -176,19 +175,19 @@ rect.origin.x = NSMaxX(rect); rect.size.width = BUTTON_WIDTH; zoomButton = [[SKNavigationButton alloc] initWithFrame:rect]; - [zoomButton setTarget:pdfView]; + [zoomButton setTarget:presentationView]; [zoomButton setAction:@selector(toggleAutoActualSize:)]; [zoomButton setToolTip:NSLocalizedString(@"Fit to Screen", @"Tool tip message")]; [zoomButton setAlternateToolTip:NSLocalizedString(@"Actual Size", @"Tool tip message")]; [zoomButton setPath:zoomButtonPath(rect.size)]; [zoomButton setAlternatePath:alternateZoomButtonPath(rect.size)]; - [zoomButton setState:[pdfView autoScales]]; + [zoomButton setState:[presentationView autoScales]]; [zoomButton setButtonType:NSPushOnPushOffButton]; [[self contentView] addSubview:zoomButton]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleScaleChangedNotification:) - name:PDFViewScaleChangedNotification object:pdfView]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAutoScalesChangedNotification:) + name:SKPresentationViewAutoScalesChangedNotification object:presentationView]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePageChangedNotification:) - name:PDFViewPageChangedNotification object:pdfView]; + name:SKPresentationViewPageChangedNotification object:presentationView]; rect.origin.x = NSMaxX(rect); rect.size.width = SEP_WIDTH; @@ -197,7 +196,7 @@ rect.origin.x = NSMaxX(rect); rect.size.width = BUTTON_WIDTH; cursorButton = [[SKNavigationButton alloc] initWithFrame:rect]; - [cursorButton setTarget:pdfView]; + [cursorButton setTarget:presentationView]; [cursorButton setAction:@selector(showCursorStyleWindow:)]; [cursorButton setToolTip:NSLocalizedString(@"Pointer", @"Tool tip message")]; [cursorButton setPath:cursorButtonPath(rect.size)]; @@ -210,13 +209,13 @@ rect.origin.x = NSMaxX(rect); rect.size.width = BUTTON_WIDTH; closeButton = [[SKNavigationButton alloc] initWithFrame:rect]; - [closeButton setTarget:pdfView]; + [closeButton setTarget:presentationView]; [closeButton setAction:@selector(exitPresentation:)]; [closeButton setToolTip:NSLocalizedString(@"Close", @"Tool tip message")]; [closeButton setPath:closeButtonPath(rect.size)]; [[self contentView] addSubview:closeButton]; - NSScreen *screen = [[pdfView window] screen] ?: [NSScreen mainScreen]; + NSScreen *screen = [[presentationView window] screen] ?: [NSScreen mainScreen]; NSRect frame; frame.size.width = 5 * BUTTON_WIDTH + 3 * SEP_WIDTH + 2 * BUTTON_MARGIN; frame.size.height = BUTTON_HEIGHT + 2.0 * BUTTON_MARGIN; @@ -233,7 +232,7 @@ [super orderOut:sender]; } -- (void)handleScaleChangedNotification:(NSNotification *)notification { +- (void)handleAutoScalesChangedNotification:(NSNotification *)notification { [zoomButton setState:[[notification object] autoScales] ? NSControlStateValueOn : NSControlStateValueOff]; } @@ -251,8 +250,8 @@ @implementation SKCursorStyleWindow -- (instancetype)initWithPDFView:(SKPDFView *)pdfView { - self = [super initWithPDFView:pdfView]; +- (instancetype)initWithView:(SKPresentationView *)presentationView { + self = [super initWithView:presentationView]; if (self) { NSRect rect; @@ -270,8 +269,8 @@ rect = [styleButton frame]; rect.origin.x = rect.origin.y = BUTTON_MARGIN; [styleButton setFrame:rect]; - [styleButton selectSegmentWithTag:[pdfView cursorStyle]]; - [styleButton setTarget:pdfView]; + [styleButton selectSegmentWithTag:[presentationView cursorStyle]]; + [styleButton setTarget:presentationView]; [styleButton setAction:@selector(changeCursorStyle:)]; if (@available(macOS 10.14, *)) [[styleButton cell] setBackgroundStyle:NSBackgroundStyleEmphasized]; @@ -292,8 +291,8 @@ [removeShadowButton setSegmentCount:1]; [removeShadowButton setTrackingMode:NSSegmentSwitchTrackingSelectAny]; [removeShadowButton setLabel:NSLocalizedString(@"Remove shadow", @"Button title") forSegment:0]; - [removeShadowButton setSelected:[pdfView removeCursorShadow] forSegment:0]; - [removeShadowButton setTarget:pdfView]; + [removeShadowButton setSelected:[presentationView removeCursorShadow] forSegment:0]; + [removeShadowButton setTarget:presentationView]; [removeShadowButton setAction:@selector(toggleRemoveCursorShadow:)]; if (@available(macOS 10.14, *)) [[removeShadowButton cell] setBackgroundStyle:NSBackgroundStyleEmphasized]; @@ -313,8 +312,8 @@ [drawButton setTrackingMode:NSSegmentSwitchTrackingSelectAny]; [drawButton setWidth:30.0 forSegment:0]; [drawButton setImage:[NSImage imageNamed:SKImageNameInkToolAdorn] forSegment:0]; - [drawButton setSelected:[pdfView drawInPresentation] forSegment:0]; - [drawButton setTarget:pdfView]; + [drawButton setSelected:[presentationView drawInPresentation] forSegment:0]; + [drawButton setTarget:presentationView]; [drawButton setAction:@selector(toggleDrawInPresentation:)]; if (@available(macOS 10.14, *)) [[drawButton cell] setBackgroundStyle:NSBackgroundStyleEmphasized]; @@ -338,7 +337,7 @@ [closeButton setTrackingMode:NSSegmentSwitchTrackingMomentary]; [closeButton setWidth:24.0 forSegment:0]; [closeButton setImage:[NSImage imageNamed:NSImageNameStopProgressTemplate] forSegment:0]; - [closeButton setTarget:pdfView]; + [closeButton setTarget:presentationView]; [closeButton setAction:@selector(closeCursorStyleWindow:)]; if (@available(macOS 10.14, *)) [[closeButton cell] setBackgroundStyle:NSBackgroundStyleEmphasized]; @@ -346,7 +345,7 @@ [closeButton sizeToFit]; [[self contentView] addSubview:closeButton]; - NSScreen *screen = [[pdfView window] screen] ?: [NSScreen mainScreen]; + NSScreen *screen = [[presentationView window] screen] ?: [NSScreen mainScreen]; NSRect frame; frame.size.width = NSWidth([styleButton frame]) + NSWidth([removeShadowButton frame]) + NSWidth([drawButton frame]) + NSWidth([closeButton frame]) + 2.0 * BUTTON_MARGIN + 2.0 * SMALL_SEP_WIDTH; frame.size.height = NSHeight(rect) + 2.0 * BUTTON_MARGIN; Modified: trunk/SKPDFView.h =================================================================== --- trunk/SKPDFView.h 2024-09-12 21:33:13 UTC (rev 14455) +++ trunk/SKPDFView.h 2024-09-17 15:47:33 UTC (rev 14456) @@ -123,9 +123,6 @@ - (void)PDFViewDidEndEditing:(PDFView *)sender; - (void)PDFView:(PDFView *)sender editAnnotation:(PDFAnnotation *)annotation; - (void)PDFView:(PDFView *)sender showSnapshotAtPageNumber:(NSInteger)pageNum forRect:(NSRect)rect scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits; -- (void)PDFViewExitPresentation:(PDFView *)sender; -- (void)PDFViewTogglePages:(PDFView *)sender; -- (void)PDFViewToggleContents:(PDFView *)sender; - (void)PDFViewPerformHideFind:(PDFView *)sender; - (BOOL)PDFViewIsFindVisible:(PDFView *)sender; - (void)PDFView:(PDFView *)sender rotatePageAtIndex:(NSUInteger)idx by:(NSInteger)rotation; @@ -132,7 +129,7 @@ - (nullable NSUndoManager *)undoManagerForPDFView:(PDFView *)sender; @end -@class SKReadingBar, SKTransitionController, SKTypeSelectHelper, SKNavigationWindow, SKCursorStyleWindow, SKTextNoteEditor, SKSyncDot, SKLoupeController, SKLayerController; +@class SKReadingBar, SKTypeSelectHelper, SKNavigationWindow, SKCursorStyleWindow, SKTextNoteEditor, SKSyncDot, SKLoupeController, SKLayerController; @interface SKPDFView : SKBasePDFView { SKToolMode toolMode; @@ -152,8 +149,6 @@ CGFloat pacerWaitTime; NSInteger pacerCounter; - SKTransitionController *transitionController; - SKTypeSelectHelper *typeSelectHelper; PDFAnnotation *currentAnnotation; @@ -180,20 +175,11 @@ NSInteger spellingTag; - NSInteger laserPointerColor; - _Atomic(BOOL) inKeyWindow; - struct _pdfvFlags { - unsigned int presentationMode:1; - unsigned int hideNotes:1; - unsigned int wantsNewUndoGroup:1; - unsigned int cursorHidden:1; - unsigned int useArrowCursorInPresentation:1; - unsigned int removeLaserPointerShadow:1; - unsigned int drawInPresentation:1; - unsigned int zooming:1; - } pdfvFlags; + BOOL hideNotes; + BOOL wantsNewUndoGroup; + BOOL zooming; } @property (nonatomic) PDFDisplayMode extendedDisplayMode; @@ -201,7 +187,6 @@ @property (nonatomic) SKToolMode toolMode; @property (nonatomic) SKNoteType annotationMode; @property (nonatomic) SKTemporaryToolMode temporaryToolMode; -@property (nonatomic, getter=isPresentationMode) BOOL presentationMode; @property (nonatomic, nullable, strong) PDFAnnotation *currentAnnotation; @property (nonatomic, readonly, getter=isEditing) BOOL editing; @property (nonatomic, readonly, getter=isZooming) BOOL zooming; @@ -214,7 +199,6 @@ @property (nullable, readonly) SKReadingBar *readingBar; @property (nonatomic) CGFloat pacerSpeed; @property (nonatomic, readonly) BOOL hasPacer; -@property (nonatomic, nullable, readonly) SKTransitionController *transitionController; @property (nonatomic, nullable, strong) SKTypeSelectHelper *typeSelectHelper; @property (nonatomic) BOOL needsRewind; @@ -241,19 +225,6 @@ - (void)setDisplayBoxAndRewind:(PDFDisplayBox)box; - (void)setDisplaysAsBookAndRewind:(BOOL)asBook; -- (void)zoomLog:(nullable id)sender; -- (void)toggleAutoActualSize:(nullable id)sender; -- (void)exitPresentation:(nullable id)sender; - -- (void)showCursorStyleWindow:(nullable id)sender; -- (void)closeCursorStyleWindow:(nullable id)sender; -- (NSInteger)cursorStyle; -- (void)changeCursorStyle:(nullable id)sender; -- (BOOL)removeCursorShadow; -- (void)toggleRemoveCursorShadow:(nullable id)sender; -- (BOOL)drawInPresentation; -- (void)toggleDrawInPresentation:(nullable id)sender; - - (void)addAnnotationForContext:(nullable id)sender; - (void)addAnnotationWithType:(SKNoteType)annotationType; - (void)removeCurrentAnnotation:(nullable id)sender; Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2024-09-12 21:33:13 UTC (rev 14455) +++ trunk/SKPDFView.m 2024-09-17 15:47:33 UTC (rev 14456) @@ -37,7 +37,6 @@ */ #import "SKPDFView.h" -#import "SKNavigationWindow.h" #import "SKImageToolTipWindow.h" #import <SkimNotes/SkimNotes.h> #import "PDFAnnotation_SKExtensions.h" @@ -50,7 +49,6 @@ #import "SKStringConstants.h" #import "NSUserDefaults_SKExtensions.h" #import "SKReadingBar.h" -#import "SKTransitionController.h" #import "SKTextNoteEditor.h" #import "SKSyncDot.h" #import "SKLineInspector.h" @@ -107,9 +105,6 @@ #define SMALL_MAGNIFICATION 1.5 #define LARGE_MAGNIFICATION 4.0 -#define AUTO_HIDE_DELAY 3.0 -#define SHOW_NAV_DELAY 0.25 - // based on: reading speed: 240 words/min // layout: 10 words/line, 40 line/page, 600 points/page #define DEFAULT_PACER_SPEED 6.0 @@ -138,10 +133,6 @@ #define SKUseToolModeCursorsKey @"SKUseToolModeCursors" #define SKMagnifyWithMousePressedKey @"SKMagnifyWithMousePressed" #define SKPacerSpeedKey @"SKPacerSpeed" -#define SKUseArrowCursorInPresentationKey @"SKUseArrowCursorInPresentation" -#define SKLaserPointerColorKey @"SKLaserPointerColor" -#define SKRemoveLaserPointerShadowKey @"SKRemoveLaserPointerShadows" -#define SKDisableDrawingInPresentationKey @"SKDisableDrawingInPresentation" #define SKAnnotationKey @"SKAnnotation" @@ -157,12 +148,6 @@ static inline NSSize SKFitTextNoteSize(NSString *string, NSFont *font, CGFloat width); enum { - SKNavigationNone, - SKNavigationBottom, - SKNavigationEverywhere, -}; - -enum { SKLayerNone, SKLayerUse, SKLayerAdd, @@ -206,15 +191,9 @@ - (void)beginNewUndoGroupIfNeededWithCommit:(BOOL)commit; -- (void)enableNavigation; -- (void)disableNavigation; - - (void)stopPacer; - (void)updatePacer; -- (void)doAutoHide; -- (void)showNavWindow; - - (void)setNeedsDisplayForReadingBarBounds:(NSRect)rect onPage:(PDFPage *)page; - (void)doMoveCurrentAnnotationForKey:(unichar)eventChar byAmount:(CGFloat)delta; @@ -236,7 +215,6 @@ - (void)doMarqueeZoomWithEvent:(NSEvent *)theEvent; - (BOOL)doDragMouseWithEvent:(NSEvent *)theEvent; - (BOOL)doDragTextWithEvent:(NSEvent *)theEvent; -- (void)doDragWindowWithEvent:(NSEvent *)theEvent; - (void)setCursorForMouse:(NSEvent *)theEvent; - (void)showHelpMenu; @@ -253,8 +231,8 @@ @implementation SKPDFView -@synthesize toolMode, annotationMode, temporaryToolMode, currentAnnotation, readingBar, pacerSpeed, transitionController, typeSelectHelper, syncDot; -@dynamic extendedDisplayMode, presentationMode, displaysHorizontally, hideNotes, canSelectNote, hasReadingBar, hasPacer, currentSelectionPage, currentSelectionRect, currentMagnification, needsRewind, editing, zooming; +@synthesize toolMode, annotationMode, temporaryToolMode, currentAnnotation, readingBar, pacerSpeed, typeSelectHelper, syncDot, hideNotes, zooming; +@dynamic extendedDisplayMode, displaysHorizontally, canSelectNote, hasReadingBar, hasPacer, currentSelectionPage, currentSelectionRect, currentMagnification, needsRewind, editing; + (void)initialize { SKINITIALIZE; @@ -283,26 +261,14 @@ toolMode = [[NSUserDefaults standardUserDefaults] integerForKey:SKLastToolModeKey]; annotationMode = [[NSUserDefaults standardUserDefaults] integerForKey:SKLastAnnotationModeKey]; - transitionController = nil; - typeSelectHelper = nil; spellingTag = [NSSpellChecker uniqueSpellDocumentTag]; - pdfvFlags.presentationMode = 0; - pdfvFlags.hideNotes = 0; - pdfvFlags.wantsNewUndoGroup = 0; - pdfvFlags.cursorHidden = 0; - pdfvFlags.useArrowCursorInPresentation = [[NSUserDefaults standardUserDefaults] boolForKey:SKUseArrowCursorInPresentationKey]; - pdfvFlags.removeLaserPointerShadow = [[NSUserDefaults standardUserDefaults] boolForKey:SKRemoveLaserPointerShadowKey]; - pdfvFlags.drawInPresentation = NO == [[NSUserDefaults standardUserDefaults] boolForKey:SKDisableDrawingInPresentationKey]; + hideNotes = NO; + wantsNewUndoGroup = NO; inKeyWindow = NO; - laserPointerColor = [[NSUserDefaults standardUserDefaults] integerForKey:SKLaserPointer... [truncated message content] |