Revision: 28667
http://sourceforge.net/p/bibdesk/svn/28667
Author: hofman
Date: 2024-01-24 15:56:33 +0000 (Wed, 24 Jan 2024)
Log Message:
-----------
use subview to draw rubber band
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
10:39:04 UTC (rev 28666)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h 2024-01-24
15:56:33 UTC (rev 28667)
@@ -222,7 +222,7 @@
CGLayerRef _selectionOverlay;
NSUInteger _lastClickedIndex;
NSUInteger _dropIndex;
- NSRect _rubberBandRect;
+ NSView *_rubberBandView;
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
10:39:04 UTC (rev 28666)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2024-01-24
15:56:33 UTC (rev 28667)
@@ -141,6 +141,13 @@
static void FVFillBackgroundColorOrGradient(NSColor *backgroundColor, NSRect
rect, NSRect bounds, NSWindow *window);
+#pragma mark -
+
+@interface FVRubberBandView : NSView
+@end
+
+static void FVFillBackgroundColorOrGradient(NSColor *backgroundColor, NSRect
rect, NSRect bounds, NSWindow *window);
+
#import <Quartz/Quartz.h>
@interface FVFileView (FVDelegateDeclarations) <FVDownloadDelegate,
QLPreviewPanelDataSource, QLPreviewPanelDelegate>
@@ -323,7 +330,7 @@
_fvFlags.controllingQLPreviewPanel = NO;
_selectionIndexes = [[NSIndexSet alloc] init];
_lastClickedIndex = NSNotFound;
- _rubberBandRect = NSZeroRect;
+ _rubberBandView = nil;
_fvFlags.isMouseDown = NO;
_fvFlags.isEditable = NO;
[self setBackgroundColor:[[self class] defaultBackgroundColor]];
@@ -2115,17 +2122,6 @@
CGContextRestoreGState(drawingContext);
}
-- (void)_drawRubberbandRect
-{
- // @@ Dark mode
- [[NSColor colorWithCalibratedWhite:1.0 alpha:0.3] setFill];
- NSRect r = [self centerScanRect:NSInsetRect(_rubberBandRect, 0.5, 0.5)];
- NSRectFillUsingOperation(r, NSCompositingOperationSourceOver);
- // NSFrameRect doesn't respect setStroke
- [[NSColor lightGrayColor] setFill];
- NSFrameRectWithWidth(r, 1.0);
-}
-
#define DROP_MESSAGE_MIN_FONTSIZE ((CGFloat) 8.0)
#define DROP_MESSAGE_MAX_INSET ((CGFloat) 20.0)
@@ -2598,9 +2594,6 @@
if (_dropIndex != NSNotFound || _fvFlags.dropOperation == FVDropOn) {
[self _drawDropHighlight];
}
- else if (NSIsEmptyRect(_rubberBandRect) == NO) {
- [self _drawRubberbandRect];
- }
}
#if DEBUG_GRID
[[NSColor grayColor] set];
@@ -3335,13 +3328,13 @@
return rect;
}
-- (NSIndexSet *)_allIndexesInRubberBandRect
+- (NSIndexSet *)_allIndexesInRubberBandRect:(NSRect)rect
{
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
// do a fast check to avoid hit testing every icon in the grid
NSRange rowRange, columnRange;
- [self _getRangeOfRows:&rowRange columns:&columnRange
inRect:_rubberBandRect];
+ [self _getRangeOfRows:&rowRange columns:&columnRange inRect:rect];
// this is a useful test to see exactly what
_getRangeOfRows:columns:inRect: is giving us
/*
@@ -3368,7 +3361,7 @@
{
for (c = columnRange.location; c < cMax; c++)
{
- if (NSIntersectsRect([self _rectOfIconInRow:r column:c],
_rubberBandRect)) {
+ if (NSIntersectsRect([self _rectOfIconInRow:r column:c], rect)) {
idx = [self _indexForGridRow:r column:c];
if (NSNotFound != idx)
[indexSet addIndex:idx];
@@ -3382,9 +3375,9 @@
- (void)mouseUp:(NSEvent *)event
{
_fvFlags.isMouseDown = NO;
- if (NO == NSIsEmptyRect(_rubberBandRect)) {
- [self setNeedsDisplayInRect:_rubberBandRect];
- _rubberBandRect = NSZeroRect;
+ if (_rubberBandView) {
+ [_rubberBandView removeFromSuperview];
+ _rubberBandView = nil;
}
}
@@ -3397,7 +3390,7 @@
// _fvFlags.isMouseDown tells us if the mouseDown: event originated in
this view; if not, just ignore it
- if (NSEqualRects(_rubberBandRect, NSZeroRect) && NSNotFound != i &&
_fvFlags.isMouseDown) {
+ if (nil == _rubberBandView && NSNotFound != i && _fvFlags.isMouseDown) {
// No previous rubber band selection, so check to see if we're
dragging an icon at this point.
// The condition is also false when we're getting a repeated call to
mouseDragged: for rubber band drawing.
@@ -3432,9 +3425,12 @@
else if (_fvFlags.isMouseDown) {
// no icons to drag, so we must draw the rubber band rectangle
- _rubberBandRect =
NSIntersectionRect(_rectWithCorners(_lastMouseDownLocInView, p), [self bounds]);
- [self _setSelectionIndexes:[self _allIndexesInRubberBandRect]];
- [self setNeedsDisplayInRect:_rubberBandRect];
+ NSRect rubberBandRect =
NSIntersectionRect(_rectWithCorners(_lastMouseDownLocInView, p), [self bounds]);
+ [self _setSelectionIndexes:[self
_allIndexesInRubberBandRect:rubberBandRect]];
+ if (_rubberBandView == nil)
+ _rubberBandView = [[FVRubberBandView alloc]
initWithFrame:NSZeroRect];
+ [_rubberBandView setFrame:[self
centerScanRect:NSInsetRect(rubberBandRect, 0.5, 0.5)]];
+ [self addSubview:_rubberBandView];
[self autoscroll:event];
[super mouseDragged:event];
}
@@ -5004,3 +5000,22 @@
CGColorSpaceRelease(cspace);
}
}
+
+#pragma mark
+
+@implementation FVRubberBandView
+
+- (BOOL)isFlipped {
+ return YES;
+}
+
+- (void)drawRect:(NSRect)dirtyRect {
+ NSRect rect = [self bounds];
+ [[NSColor colorWithCalibratedWhite:1.0 alpha:0.3] setFill];
+ NSRect r = [self centerScanRect:NSInsetRect(rect, 1.0, 1.0)];
+ NSRectFillUsingOperation(r, NSCompositingOperationSourceOver);
+ // NSFrameRect doesn't respect setStroke
+ [[NSColor lightGrayColor] setFill];
+ NSFrameRectWithWidth(r, 1.0);}
+
+@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