Revision: 12685
          http://sourceforge.net/p/skim-app/code/12685
Author:   hofman
Date:     2022-01-04 23:50:03 +0000 (Tue, 04 Jan 2022)
Log Message:
-----------
Derive wether to draw active selections from passed pdfview

Modified Paths:
--------------
    trunk/PDFAnnotationInk_SKExtensions.m
    trunk/PDFAnnotationLine_SKExtensions.m
    trunk/PDFAnnotationMarkup_SKExtensions.m
    trunk/PDFAnnotation_SKExtensions.h
    trunk/PDFAnnotation_SKExtensions.m
    trunk/PDFView_SKExtensions.h
    trunk/PDFView_SKExtensions.m
    trunk/SKPDFView.m

Modified: trunk/PDFAnnotationInk_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationInk_SKExtensions.m       2022-01-04 23:41:09 UTC (rev 
12684)
+++ trunk/PDFAnnotationInk_SKExtensions.m       2022-01-04 23:50:03 UTC (rev 
12685)
@@ -240,8 +240,8 @@
     return NSUnionRect([super displayRectForBounds:bounds 
lineWidth:lineWidth], NSIntegralRect(rect));
 }
 
-- (void)drawSelectionHighlightForView:(PDFView *)pdfView 
inContext:(CGContextRef)context active:(BOOL)active {
-    [super drawSelectionHighlightForView:pdfView inContext:context 
active:active];
+- (void)drawSelectionHighlightForView:(PDFView *)pdfView 
inContext:(CGContextRef)context {
+    [super drawSelectionHighlightForView:pdfView inContext:context];
     if (NSIsEmptyRect([self bounds]) == NO && [self isSkimNote]) {
         CGFloat scale = ceil(1.0 / [pdfView unitWidthOnPage:[self page]]);
         NSRect b = [self bounds];

Modified: trunk/PDFAnnotationLine_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationLine_SKExtensions.m      2022-01-04 23:41:09 UTC (rev 
12684)
+++ trunk/PDFAnnotationLine_SKExtensions.m      2022-01-04 23:50:03 UTC (rev 
12685)
@@ -266,12 +266,13 @@
         return 0;
 }
 
-- (void)drawSelectionHighlightForView:(PDFView *)pdfView 
inContext:(CGContextRef)context active:(BOOL)active {
+- (void)drawSelectionHighlightForView:(PDFView *)pdfView 
inContext:(CGContextRef)context {
     if (NSIsEmptyRect([self bounds]))
         return;
     NSPoint origin = [self bounds].origin;
     NSPoint point = SKAddPoints(origin, [self startPoint]);
     CGFloat delta = [pdfView unitWidthOnPage:[self page]];
+    BOOL active = [pdfView drawsActiveSelections];
     SKDrawResizeHandle(context, point, delta, active);
     point = SKAddPoints(origin, [self endPoint]);
     SKDrawResizeHandle(context, point, delta, active);

Modified: trunk/PDFAnnotationMarkup_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationMarkup_SKExtensions.m    2022-01-04 23:41:09 UTC (rev 
12684)
+++ trunk/PDFAnnotationMarkup_SKExtensions.m    2022-01-04 23:50:03 UTC (rev 
12685)
@@ -327,7 +327,7 @@
     return bounds;
 }
 
-- (void)drawSelectionHighlightForView:(PDFView *)pdfView 
inContext:(CGContextRef)context active:(BOOL)active {
+- (void)drawSelectionHighlightForView:(PDFView *)pdfView 
inContext:(CGContextRef)context {
     if (NSIsEmptyRect([self bounds]))
         return;
     
@@ -335,7 +335,7 @@
     NSUInteger i, iMax = [lines count];
     PDFPage *page = [self page];
     CGFloat lineWidth = [pdfView unitWidthOnPage:page];
-    CGColorRef color = [[NSColor selectionHighlightColor:active] CGColor];
+    CGColorRef color = [[NSColor selectionHighlightColor:[pdfView 
drawsActiveSelections]] CGColor];
     
     CGContextSaveGState(context);
     CGContextSetStrokeColorWithColor(context, color);

Modified: trunk/PDFAnnotation_SKExtensions.h
===================================================================
--- trunk/PDFAnnotation_SKExtensions.h  2022-01-04 23:41:09 UTC (rev 12684)
+++ trunk/PDFAnnotation_SKExtensions.h  2022-01-04 23:50:03 UTC (rev 12685)
@@ -106,7 +106,7 @@
 
 - (SKRectEdges)resizeHandleForPoint:(NSPoint)point 
scaleFactor:(CGFloat)scaleFactor;
 
-- (void)drawSelectionHighlightForView:(PDFView *)pdfView 
inContext:(CGContextRef)context active:(BOOL)active;
+- (void)drawSelectionHighlightForView:(PDFView *)pdfView 
inContext:(CGContextRef)context;
 
 - (void)registerUserName;
 

Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m  2022-01-04 23:41:09 UTC (rev 12684)
+++ trunk/PDFAnnotation_SKExtensions.m  2022-01-04 23:50:03 UTC (rev 12685)
@@ -406,12 +406,13 @@
     return [self isResizable] ? SKResizeHandleForPointFromRect(point, [self 
bounds], 4.0 / scaleFactor) : 0;
 }
 
-- (void)drawSelectionHighlightForView:(PDFView *)pdfView 
inContext:(CGContextRef)context active:(BOOL)active {
+- (void)drawSelectionHighlightForView:(PDFView *)pdfView 
inContext:(CGContextRef)context {
     if (NSIsEmptyRect([self bounds]))
         return;
     if ([self isSkimNote]) {
         NSRect rect = [pdfView backingAlignedRect:[self bounds] onPage:[self 
page]];
         CGFloat lineWidth = [pdfView unitWidthOnPage:[self page]];
+        BOOL active = [pdfView drawsActiveSelections];
         CGContextSaveGState(context);
         if ([self isResizable]) {
             SKDrawResizeHandles(context, rect, lineWidth, YES, active);

Modified: trunk/PDFView_SKExtensions.h
===================================================================
--- trunk/PDFView_SKExtensions.h        2022-01-04 23:41:09 UTC (rev 12684)
+++ trunk/PDFView_SKExtensions.h        2022-01-04 23:50:03 UTC (rev 12685)
@@ -66,6 +66,8 @@
 - (CGFloat)unitWidthOnPage:(PDFPage *)page;
 - (NSRect)backingAlignedRect:(NSRect)rect onPage:(PDFPage *)page;
 
+@property (nonatomic, readonly) BOOL drawsActiveSelections;
+
 + (NSColor *)defaultBackgroundColor;
 + (NSColor *)defaultFullScreenBackgroundColor;
 

Modified: trunk/PDFView_SKExtensions.m
===================================================================
--- trunk/PDFView_SKExtensions.m        2022-01-04 23:41:09 UTC (rev 12684)
+++ trunk/PDFView_SKExtensions.m        2022-01-04 23:50:03 UTC (rev 12685)
@@ -50,6 +50,7 @@
 #import "SKApplication.h"
 #import "NSView_SKExtensions.h"
 #import "NSImage_SKExtensions.h"
+#import "NSResponder_SKExtensions.h"
 
 
 #if SDK_BEFORE(10_13)
@@ -70,7 +71,7 @@
 
 @implementation PDFView (SKExtensions)
 
-@dynamic physicalScaleFactor, scrollView, displayedPages, minimumScaleFactor, 
maximumScaleFactor;
+@dynamic physicalScaleFactor, scrollView, displayedPages, minimumScaleFactor, 
maximumScaleFactor, drawsActiveSelections;
 
 static inline CGFloat physicalScaleFactorForView(NSView *view) {
     NSScreen *screen = [[view window] screen];
@@ -279,6 +280,15 @@
     return RUNNING_AFTER(10_11) ? rect : [self convertRect:[self 
backingAlignedRect:[self convertRect:rect fromPage:page] 
options:NSAlignAllEdgesOutward] toPage:page];
 }
 
+- (BOOL)drawsActiveSelections {
+    if (RUNNING_AFTER(10_14))
+        return [[self window] isKeyWindow];
+    else if (RUNNING_AFTER(10_11))
+        return YES;
+    else
+        return ([[self window] isKeyWindow] && [[[self window] firstResponder] 
isDescendantOf:self]);
+}
+
 static NSColor *defaultBackgroundColor(NSString *backgroundColorKey, NSString 
*darkBackgroundColorKey) {
     NSColor *color = nil;
     if (SKHasDarkAppearance(NSApp))

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2022-01-04 23:41:09 UTC (rev 12684)
+++ trunk/SKPDFView.m   2022-01-04 23:50:03 UTC (rev 12685)
@@ -487,7 +487,7 @@
     }
     
     if ([[annotation page] isEqual:pdfPage])
-        [annotation drawSelectionHighlightForView:self inContext:context 
active:[self drawsActiveSelections]];
+        [annotation drawSelectionHighlightForView:self inContext:context];
     
     [self drawSelectionForPage:pdfPage inContext:context];
     

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

Reply via email to