Revision: 15190 http://sourceforge.net/p/skim-app/code/15190 Author: hofman Date: 2025-05-12 08:50:43 +0000 (Mon, 12 May 2025) Log Message: ----------- Implement all page navigation methods in page view class as well as validation methods
Modified Paths: -------------- trunk/SKPresentationView.h trunk/SKPresentationView.m Modified: trunk/SKPresentationView.h =================================================================== --- trunk/SKPresentationView.h 2025-05-11 21:24:30 UTC (rev 15189) +++ trunk/SKPresentationView.h 2025-05-12 08:50:43 UTC (rev 15190) @@ -55,8 +55,15 @@ @property (nonatomic, nullable, strong) SKTransitionController *transitionController; +@property (nonatomic) BOOL canGoToNextPage; +@property (nonatomic) BOOL canGoToPreviousPage; +@property (nonatomic) BOOL canGoToFirstPage; +@property (nonatomic) BOOL canGoToLastPage; + - (void)goToNextPage:(nullable id)sender; - (void)goToPreviousPage:(nullable id)sender; +- (void)goToFirstPage:(nullable id)sender; +- (void)goToLastPage:(nullable id)sender; - (void)displayPage:(PDFPage *)page completionHandler:(void (^ _Nullable)(void))completionHandler; - (void)animateToNextPage:(void (^)(void))completionHandler; @@ -85,11 +92,6 @@ @property (nonatomic) BOOL autoScales; -@property (nonatomic) BOOL canGoToNextPage; -@property (nonatomic) BOOL canGoToPreviousPage; -@property (nonatomic) BOOL canGoToFirstPage; -@property (nonatomic) BOOL canGoToLastPage; - @property (nonatomic) BOOL hasBlackout; @property (nonatomic) NSInteger cursorStyle; @@ -96,9 +98,6 @@ @property (nonatomic) BOOL removeCursorShadow; @property (nonatomic) BOOL drawInPresentation; -- (void)goToFirstPage:(nullable id)sender; -- (void)goToLastPage:(nullable id)sender; - - (void)toggleAutoActualSize:(nullable id)sender; - (void)toggleBlackout:(nullable id)sender; Modified: trunk/SKPresentationView.m =================================================================== --- trunk/SKPresentationView.m 2025-05-11 21:24:30 UTC (rev 15189) +++ trunk/SKPresentationView.m 2025-05-12 08:50:43 UTC (rev 15190) @@ -85,7 +85,7 @@ @implementation SKPDFPageView -@synthesize page, transitionController; +@synthesize page, transitionController, canGoToNextPage, canGoToPreviousPage, canGoToFirstPage, canGoToLastPage; static inline NSArray *defaultKeysToObserve() { if (@available(macOS 10.14, *)) @@ -202,6 +202,22 @@ - (BOOL)autoScales { return YES; } +- (BOOL)canGoToNextPage { + return [page pageIndex] + 1 < [[page document] pageCount]; +} + +- (BOOL)canGoToPreviousPage { + return [page pageIndex] > 0; +} + +- (BOOL)canGoToFirstPage { + return [page pageIndex] > 0; +} + +- (BOOL)canGoToLastPage { + return [page pageIndex] + 1 < [[page document] pageCount]; +} + #pragma mark Action - (void)goToNextPage:(id)sender { @@ -224,6 +240,20 @@ } } +- (void)goToFirstPage:(id)sender { + PDFDocument *pdfDoc = [page document]; + NSUInteger idx = [page pageIndex]; + if (idx > 0) + [self setPage:[pdfDoc pageAtIndex:0]]; +} + +- (void)goToLastPage:(id)sender { + PDFDocument *pdfDoc = [page document]; + NSUInteger idx = [page pageIndex]; + if (idx + 1 < [pdfDoc pageCount]) + [self setPage:[pdfDoc pageAtIndex:[pdfDoc pageCount] - 1]]; +} + #pragma mark Drawing - (void)displayPage:(void (^)(void))completionHandler { @@ -317,7 +347,7 @@ @implementation SKPresentationView -@dynamic autoScales, canGoToNextPage, canGoToPreviousPage, canGoToFirstPage, canGoToLastPage, cursorStyle, hasBlackout, removeCursorShadow, drawInPresentation; +@dynamic autoScales, cursorStyle, hasBlackout, removeCursorShadow, drawInPresentation; + (void)initialize { SKINITIALIZE; @@ -373,22 +403,6 @@ return [pageView alphaValue] <= 0.0; } -- (BOOL)canGoToNextPage { - return [page pageIndex] + 1 < [[page document] pageCount]; -} - -- (BOOL)canGoToPreviousPage { - return [page pageIndex] > 0; -} - -- (BOOL)canGoToFirstPage { - return [page pageIndex] > 0; -} - -- (BOOL)canGoToLastPage { - return [page pageIndex] + 1 < [[page document] pageCount]; -} - - (NSInteger)cursorStyle { return pvFlags.useArrowCursor ? -1 : laserPointerColor; } @@ -403,20 +417,6 @@ #pragma mark Actions -- (void)goToFirstPage:(id)sender { - PDFDocument *pdfDoc = [page document]; - NSUInteger idx = [page pageIndex]; - if (idx > 0) - [self setPage:[pdfDoc pageAtIndex:0]]; -} - -- (void)goToLastPage:(id)sender { - PDFDocument *pdfDoc = [page document]; - NSUInteger idx = [page pageIndex]; - if (idx + 1 < [pdfDoc pageCount]) - [self setPage:[pdfDoc pageAtIndex:[pdfDoc pageCount] - 1]]; -} - - (void)toggleAutoActualSize:(id)sender { [self setAutoScales:[self autoScales] == NO]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit