Revision: 28677
http://sourceforge.net/p/bibdesk/svn/28677
Author: hofman
Date: 2024-01-25 17:49:23 +0000 (Thu, 25 Jan 2024)
Log Message:
-----------
conveniencec method to get icon rect by index
Modified Paths:
--------------
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2024-01-25
17:22:33 UTC (rev 28676)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2024-01-25
17:49:23 UTC (rev 28677)
@@ -1181,6 +1181,14 @@
return rect;
}
+- (NSRect)_rectOfIconAtIndex:(NSUInteger)anIndex;
+{
+ NSUInteger r, c;
+ if ([self _getGridRow:&r column:&c ofIndex:anIndex])
+ return [self _rectOfIconInRow:r column:c];
+ return NSZeroRect;
+}
+
- (NSRect)_rectOfTextForIconRect:(NSRect)iconRect;
{
// add a couple of points between the icon and text, which is useful if
we're drawing a Finder label
@@ -1693,10 +1701,8 @@
- (NSRect)_rectOfProgressIndicatorForIconAtIndex:(NSUInteger)anIndex;
{
- NSUInteger r, c;
- NSRect frame = NSZeroRect;
- if ([self _getGridRow:&r column:&c ofIndex:anIndex]) {
- frame = [self _rectOfIconInRow:r column:c];
+ NSRect frame = [self _rectOfIconAtIndex:anIndex];
+ if (NSEqualRects(frame, NSZeroRect) == NO) {
NSPoint center = NSMakePoint(NSMidX(frame), NSMidY(frame));
CGFloat size = NSHeight(frame) / 2;
@@ -1942,10 +1948,8 @@
{
NSUInteger scrollIndex = [_selectionIndexes firstIndex];
if (NSNotFound != scrollIndex) {
- NSUInteger r, c;
- [self _getGridRow:&r column:&c ofIndex:scrollIndex];
// this won't necessarily trigger setNeedsDisplay:, which we need
unconditionally
- [self scrollRectToVisible:[self _rectOfIconInRow:r column:c]];
+ [self scrollRectToVisible:[self _rectOfIconAtIndex:scrollIndex]];
}
[_contentView setNeedsDisplay:YES];
_fvFlags.isRescaling = NO;
@@ -2037,7 +2041,6 @@
{
CGFloat lineWidth = 2.0;
NSBezierPath *p;
- NSUInteger r, c;
NSRect aRect = NSZeroRect;
BOOL isColumn = (_fvFlags.displayMode == FVDisplayModeColumn);
NSUInteger dropIndex = [_dropHighlightView dropIndex];
@@ -2048,13 +2051,11 @@
if (dropIndex == NSNotFound) {
aRect = [self visibleRect];
} else {
- [self _getGridRow:&r column:&c ofIndex:dropIndex];
- aRect = NSInsetRect([self _rectOfIconInRow:r column:c],
HIGHLIGHT_INSET, HIGHLIGHT_INSET);
+ aRect = NSInsetRect([self _rectOfIconAtIndex:dropIndex],
HIGHLIGHT_INSET, HIGHLIGHT_INSET);
}
break;
case FVDropBefore:
- [self _getGridRow:&r column:&c ofIndex:dropIndex];
- aRect = [self _rectOfIconInRow:r column:c];
+ aRect = [self _rectOfIconAtIndex:dropIndex];
// aRect size is 6, and should be centered between icons
if (isColumn) {
aRect.origin.y -= 6.0;
@@ -2065,8 +2066,7 @@
}
break;
case FVDropAfter:
- [self _getGridRow:&r column:&c ofIndex:dropIndex];
- aRect = [self _rectOfIconInRow:r column:c];
+ aRect = [self _rectOfIconAtIndex:dropIndex];
// aRect size is 6, and should be centered between icons
if (isColumn) {
aRect.origin.y += _iconSize.height + _padding.height - 6.0;
@@ -2581,9 +2581,9 @@
CGContextSetBlendMode(context, kCGBlendModeNormal);
[_selectionIndexes enumerateIndexesUsingBlock:^(NSUInteger i, BOOL
*stop){
- NSUInteger r, c;
- if ([self _getGridRow:&r column:&c ofIndex:i]) {
- NSRect highlightRect = NSInsetRect([self _rectOfIconInRow:r
column:c], HIGHLIGHT_INSET, HIGHLIGHT_INSET);
+ NSRect highlightRect = [self _rectOfIconAtIndex:i];
+ if (NSIsEmptyRect(highlightRect) == NO) {
+ highlightRect = NSInsetRect(highlightRect, HIGHLIGHT_INSET,
HIGHLIGHT_INSET);
if ([self needsToDrawRect:highlightRect])
[self _drawHighlightInRect:highlightRect
inContext:context];
}
@@ -3050,12 +3050,11 @@
- (void)_showArrowsForIconAtIndex:(NSUInteger)anIndex
{
- NSUInteger r, c;
-
// this can happen if we screwed up in managing cursor rects
NSParameterAssert(anIndex < [self numberOfIcons]);
+ NSRect iconRect = [self _rectOfIconAtIndex:anIndex];
- if ([self _getGridRow:&r column:&c ofIndex:anIndex]) {
+ if (NSIsEmptyRect(iconRect) == NO) {
FVIcon *anIcon = [self iconAtIndex:anIndex];
@@ -3068,8 +3067,6 @@
}
}
- NSRect iconRect = [self _rectOfIconInRow:r column:c];
-
// determine a min/max size for the arrow buttons
CGFloat side, sep;
side = round(0.2 * NSHeight(iconRect));
@@ -3465,9 +3462,9 @@
- (void)scrollItemAtIndexToVisible:(NSUInteger)anIndex
{
- NSUInteger r = 0, c = 0;
- if ([self _getGridRow:&r column:&c ofIndex:anIndex])
- [self scrollRectToVisible:[self _rectOfIconInRow:r column:c]];
+ NSRect rect = [self _rectOfIconAtIndex:anIndex];
+ if (NSIsEmptyRect(rect) == NO)
+ [self scrollRectToVisible:rect];
}
// override to select the first or last item when (back)tabbing into the file
view
@@ -3785,9 +3782,8 @@
[self _stopPreviewing];
}
else if ([_selectionIndexes count] == 1) {
- NSUInteger r, c;
- [self _getGridRow:&r column:&c ofIndex:[_selectionIndexes lastIndex]];
- [self _previewURL:[[self _selectedURLs] lastObject]
forIconInRect:[self _rectOfIconInRow:r column:c]];
+ NSRect rect = [self _rectOfIconAtIndex:[_selectionIndexes lastIndex]];
+ [self _previewURL:[[self _selectedURLs] lastObject]
forIconInRect:rect];
}
else {
[self _previewURLs:[self _selectedURLs]];
@@ -4317,9 +4313,9 @@
[self _stopPreviewing];
}
else if ([_selectionIndexes count] == 1) {
- NSUInteger r, c;
- if ([self _getGridRow:&r column:&c ofIndex:[_selectionIndexes
firstIndex]])
- [self _previewURL:[self URLAtIndex:[_selectionIndexes firstIndex]]
forIconInRect:[self _rectOfIconInRow:r column:c]];
+ NSRect rect = [self _rectOfIconAtIndex:[_selectionIndexes firstIndex]];
+ if (NSIsEmptyRect(rect) == NO)
+ [self _previewURL:[self URLAtIndex:[_selectionIndexes firstIndex]]
forIconInRect:rect];
}
else {
[self _previewURLs:[self _selectedURLs]];
@@ -4422,15 +4418,17 @@
- (NSRect)previewPanel:(QLPreviewPanel *)panel
sourceFrameOnScreenForPreviewItem:(id <QLPreviewItem>)item;
{
NSRect iconRect = NSZeroRect;
- NSUInteger r, c, i = [_orderedURLs indexOfObject:item];
- if (i != NSNotFound && [self _getGridRow:&r column:&c ofIndex:i]) {
- iconRect = [self _rectOfIconInRow:r column:c];
- iconRect = [self convertRect:iconRect toView:nil];
+ NSUInteger i = [_orderedURLs indexOfObject:item];
+ if (i != NSNotFound) {
+ iconRect = [self _rectOfIconAtIndex:i];
+ if (NSIsEmptyRect(iconRect) == NO) {
+ iconRect = [self convertRect:iconRect toView:nil];
#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >=
MAC_OS_X_VERSION_10_7
- iconRect = [[self window] convertRectToScreen:iconRect];
+ iconRect = [[self window] convertRectToScreen:iconRect];
#else
- iconRect.origin = [[self window] convertBaseToScreen:iconRect.origin];
+ iconRect.origin = [[self window]
convertBaseToScreen:iconRect.origin];
#endif
+ }
}
return iconRect;
}
@@ -4472,8 +4470,7 @@
NSRect visibleRect = [scrollView documentView] == self ? [scrollView
documentVisibleRect] : [self visibleRect];
NSUInteger i, count = [self numberOfIcons];
for (i = 0; i < count; i++) {
- NSUInteger r, c;
- if ([self _getGridRow:&r column:&c ofIndex:i] &&
NSIntersectsRect([self _rectOfIconInRow:r column:c], visibleRect))
+ if (NSIntersectsRect([self _rectOfIconAtIndex:i], visibleRect))
[children addObject:[_accessibilityIcons objectAtIndex:i]];
}
return NSAccessibilityUnignoredChildren(children);
@@ -4641,15 +4638,16 @@
- (NSRect)screenRectForIconElement:(FVAccessibilityIconElement *)element {
NSRect rect = NSZeroRect;
- NSUInteger r, c;
- if ([element index] < [_orderedURLs count] && [self _getGridRow:&r
column:&c ofIndex:[element index]]) {
- rect = [self _rectOfIconInRow:r column:c];
- rect = [self convertRect:rect toView:nil];
+ if ([element index] < [_orderedURLs count]) {
+ rect = [self _rectOfIconAtIndex:[element index]];
+ if (NSIsEmptyRect(rect) == NO) {
+ rect = [self convertRect:rect toView:nil];
#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >=
MAC_OS_X_VERSION_10_7
- rect = [[self window] convertRectToScreen:rect];
+ rect = [[self window] convertRectToScreen:rect];
#else
- rect.origin = [[self window] convertBaseToScreen:rect.origin];
+ rect.origin = [[self window] convertBaseToScreen:rect.origin];
#endif
+ }
}
return rect;
}
@@ -4679,9 +4677,7 @@
- (void)showMenuForIconElement:(FVAccessibilityIconElement *)element {
NSUInteger idx = [element index];
if (idx < [_orderedURLs count]) {
- NSUInteger r, c;
- [self _getGridRow:&r column:&c ofIndex:idx];
- NSRect rect = [self _rectOfIconInRow:r column:c];
+ NSRect rect = [self _rectOfIconAtIndex:idx];
NSPoint p = NSMakePoint(NSMidX(rect), fmin(NSMidY(rect), NSMinY(rect)
+ 10.0));
[self setSelectionIndexes:[NSIndexSet indexSetWithIndex:idx]];
[[self menuForIconAtIndex:idx] popUpMenuPositioningItem:nil
atLocation:p inView:self];
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