Revision: 27832
          http://sourceforge.net/p/bibdesk/svn/27832
Author:   hofman
Date:     2022-08-23 16:42:19 +0000 (Tue, 23 Aug 2022)
Log Message:
-----------
add a gray edge above zommable pdfview popup with legacy scrollers

Modified Paths:
--------------
    trunk/bibdesk/BDSKZoomablePDFView.h
    trunk/bibdesk/BDSKZoomablePDFView.m

Modified: trunk/bibdesk/BDSKZoomablePDFView.h
===================================================================
--- trunk/bibdesk/BDSKZoomablePDFView.h 2022-08-23 16:14:57 UTC (rev 27831)
+++ trunk/bibdesk/BDSKZoomablePDFView.h 2022-08-23 16:42:19 UTC (rev 27832)
@@ -39,11 +39,11 @@
 #import <Cocoa/Cocoa.h>
 #import <Quartz/Quartz.h>
 
-@class BDSKColoredView;
+@class BDSKBackgroundView;
 
 @interface BDSKZoomablePDFView : PDFView {
     NSPopUpButton *scalePopUpButton;
-    BDSKColoredView *backgroundView;
+    BDSKBackgroundView *backgroundView;
     CGFloat startScale;
 }
 

Modified: trunk/bibdesk/BDSKZoomablePDFView.m
===================================================================
--- trunk/bibdesk/BDSKZoomablePDFView.m 2022-08-23 16:14:57 UTC (rev 27831)
+++ trunk/bibdesk/BDSKZoomablePDFView.m 2022-08-23 16:42:19 UTC (rev 27832)
@@ -40,7 +40,6 @@
 #import "NSString_BDSKExtensions.h"
 #import "NSURL_BDSKExtensions.h"
 #import "NSView_BDSKExtensions.h"
-#import "BDSKColoredView.h"
 #import "NSColor_BDSKExtensions.h"
 #import "NSGeometry_BDSKExtensions.h"
 #import "NSObject_BDSKExtensions.h"
@@ -52,6 +51,16 @@
 @end
 #endif
 
+
+@interface BDSKBackgroundView : NSView {
+    NSColor *backgroundColor;
+    NSColor *edgeColor;
+}
+@property (nonatomic, retain) NSColor *backgroundColor;
+@property (nonatomic, retain) NSColor *edgeColor;
+@end
+
+
 @interface BDSKZoomablePDFView (BDSKPrivate)
 
 - (void)makeScalePopUpButton;
@@ -220,10 +229,13 @@
 }
 
 - (void)handleScrollerStyleDidChange:(NSNotification *)notification {
-    if ([NSScroller preferredScrollerStyle] == NSScrollerStyleLegacy)
+    if ([NSScroller preferredScrollerStyle] == NSScrollerStyleLegacy) {
         [backgroundView setBackgroundColor:[NSColor 
colorWithGenericGamma22White:0.98 alpha:1.0]];
-    else
+        [backgroundView setEdgeColor:[NSColor 
colorWithGenericGamma22White:0.905 alpha:1.0]];
+    } else {
         [backgroundView setBackgroundColor:[NSColor whiteColor]];
+        [backgroundView setEdgeColor:nil];
+    }
     [self updateColorFilters];
     [backgroundView setNeedsDisplay:YES];
 }
@@ -282,7 +294,7 @@
         [scalePopUpButton setAction:@selector(scalePopUpAction:)];
         
         NSView *containerView = [[[NSView alloc] 
initWithFrame:[scalePopUpButton frame]] autorelease];
-        backgroundView = [[BDSKColoredView alloc] 
initWithFrame:[scalePopUpButton frame]];
+        backgroundView = [[BDSKBackgroundView alloc] 
initWithFrame:[scalePopUpButton frame]];
         [backgroundView setTranslatesAutoresizingMaskIntoConstraints:NO];
         [containerView addSubview:backgroundView];
         [scalePopUpButton setTranslatesAutoresizingMaskIntoConstraints:NO];
@@ -478,3 +490,38 @@
 }
 
 @end
+
+
+@implementation BDSKBackgroundView
+
+@synthesize backgroundColor, edgeColor;
+
+- (id)initWithFrame:(NSRect)frame {
+    self = [super initWithFrame:frame];
+    if (self) {
+        backgroundColor = nil;
+    }
+    return self;
+}
+
+- (void)dealloc {
+    BDSKDESTROY(backgroundColor);
+    [super dealloc];
+}
+
+- (void)drawRect:(NSRect)rect {
+    if ([self backgroundColor]) {
+        [NSGraphicsContext saveGraphicsState];
+        [[self backgroundColor] setFill];
+        [NSBezierPath fillRect:rect];
+        if (edgeColor) {
+            [[self edgeColor] setFill];
+            [NSBezierPath fillRect:BDSKSliceRect(rect, 1.0, NSMaxYEdge)];
+        }
+        [NSGraphicsContext restoreGraphicsState];
+    }
+    [super drawRect:rect];
+}
+
+@end
+

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to