Revision: 28668
          http://sourceforge.net/p/bibdesk/svn/28668
Author:   hofman
Date:     2024-01-24 16:15:44 +0000 (Wed, 24 Jan 2024)
Log Message:
-----------
draw drop highlights in subview, avoids redrawing the icons

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h      2024-01-24 
15:56:33 UTC (rev 28667)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h      2024-01-24 
16:15:44 UTC (rev 28668)
@@ -223,6 +223,7 @@
     NSUInteger                      _lastClickedIndex;
     NSUInteger                      _dropIndex;
     NSView                         *_rubberBandView;
+    NSView                         *_dropHighlightView;
     struct __fvFlags {
         unsigned int displayMode:2;
         unsigned int dropOperation:2;

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2024-01-24 
15:56:33 UTC (rev 28667)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2024-01-24 
16:15:44 UTC (rev 28668)
@@ -53,6 +53,8 @@
 #import "FVColorMenuView.h"
 #import "FVAccessibilityIconElement.h"
 
+#import <Quartz/Quartz.h>
+
 #import <sys/stat.h>
 #import <sys/time.h>
 #import <pthread.h>
@@ -146,13 +148,23 @@
 @interface FVRubberBandView : NSView
 @end
 
-static void FVFillBackgroundColorOrGradient(NSColor *backgroundColor, NSRect 
rect, NSRect bounds, NSWindow *window);
+#pragma mark -
 
-#import <Quartz/Quartz.h>
+@protocol FVDropHighlightViewDelegate
+- (void)drawDropHighlightInView:(NSView *)view;
+@end
 
-@interface FVFileView (FVDelegateDeclarations) <FVDownloadDelegate, 
QLPreviewPanelDataSource, QLPreviewPanelDelegate>
+@interface FVDropHighlightView : NSView {
+    __weak id<FVDropHighlightViewDelegate> _delegate;
+}
+@property (nonatomic, weak) id<FVDropHighlightViewDelegate> delegate;
 @end
 
+#pragma mark -
+
+@interface FVFileView (FVDelegateDeclarations) <FVDownloadDelegate, 
QLPreviewPanelDataSource, QLPreviewPanelDelegate, FVDropHighlightViewDelegate>
+@end
+
 #if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < 
MAC_OS_X_VERSION_10_7
 
 typedef NS_ENUM(NSInteger, NSScrollerStyle) {
@@ -1991,7 +2003,7 @@
 
 // no save/restore needed because of when these are called in -drawRect: (this 
is why they're private)
 
-- (void)_drawDropHighlight;
+- (void)drawDropHighlightInView:(NSView *)view;
 {
     CGFloat lineWidth = 2.0;
     NSBezierPath *p;
@@ -2552,9 +2564,7 @@
 
 - (void)drawRect:(NSRect)rect;
 {
-    BOOL isDrawingToScreen = [[NSGraphicsContext currentContext] 
isDrawingToScreen];
-    
-    if (isDrawingToScreen && _backgroundView == nil) {
+    if (_backgroundView == nil && [[NSGraphicsContext currentContext] 
isDrawingToScreen]) {
         // otherwise we see a blocky transition, which fades on the redraw 
when scrolling stops
         if (_backgroundColor == nil && [[[self enclosingScrollView] 
contentView] copiesOnScroll])
             [[[self enclosingScrollView] contentView] setCopiesOnScroll:NO];
@@ -2588,14 +2598,7 @@
         [self _drawDropMessage];
     }
     
-    if (isDrawingToScreen) {
-        
-        // drop highlight and rubber band are mutually exclusive
-        if (_dropIndex != NSNotFound || _fvFlags.dropOperation == FVDropOn) {
-            [self _drawDropHighlight];
-        }
-    }
-#if DEBUG_GRID 
+#if DEBUG_GRID
     [[NSColor grayColor] set];
     NSRect r = NSInsetRect([self bounds], [self _leftMargin], [self 
_topMargin]);
     r.size.height += [self _topMargin] - [self _bottomMargin];
@@ -2851,7 +2854,12 @@
         _fvFlags.dropOperation = FVDropBefore;
     }
     
-    [self setNeedsDisplay:YES];
+    if (_dropHighlightView == nil) {
+        _dropHighlightView = [[FVDropHighlightView alloc] initWithFrame:[self 
bounds]];
+        [(FVDropHighlightView *)_dropHighlightView setDelegate:self];
+        [self addSubview:_dropHighlightView];
+    }
+    [_dropHighlightView setNeedsDisplay:YES];
     return dragOp;
 }
 
@@ -2867,8 +2875,10 @@
     _fvFlags.dropOperation = FVDropBefore;
     if (_fvFlags.needsReload)
         [self reloadIcons];
-    else
-        [self setNeedsDisplay:YES];
+    //else
+      //  [self setNeedsDisplay:YES];
+    [_dropHighlightView removeFromSuperview];
+    _dropHighlightView = nil;
 }
 
 // only invoked if performDragOperation returned YES
@@ -2877,6 +2887,8 @@
     _dropIndex = NSNotFound;
     _fvFlags.dropOperation = FVDropBefore;
     [self reloadIcons];
+    [_dropHighlightView removeFromSuperview];
+    _dropHighlightView = nil;
 }
 
 static NSURL *makeCopyOfFileAtURL(NSURL *fileURL) {
@@ -5005,10 +5017,6 @@
 
 @implementation FVRubberBandView
 
-- (BOOL)isFlipped {
-    return YES;
-}
-
 - (void)drawRect:(NSRect)dirtyRect {
     NSRect rect = [self bounds];
     [[NSColor colorWithCalibratedWhite:1.0 alpha:0.3] setFill];
@@ -5019,3 +5027,19 @@
     NSFrameRectWithWidth(r, 1.0);}
 
 @end
+
+#pragma mark -
+
+@implementation FVDropHighlightView
+
+@synthesize delegate=_delegate;
+
+- (BOOL)isFlipped {
+    return YES;
+}
+
+- (void)drawRect:(NSRect)dirtyRect {
+    [[self delegate] drawDropHighlightInView:self];
+}
+
+@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