Revision: 28615
http://sourceforge.net/p/bibdesk/svn/28615
Author: hofman
Date: 2024-01-15 18:22:58 +0000 (Mon, 15 Jan 2024)
Log Message:
-----------
use system methid to draw an image in a flipped view
Modified Paths:
--------------
trunk/bibdesk/BDSKLineNumberView.m
trunk/bibdesk/NSArray_BDSKExtensions.h
trunk/bibdesk/NSArray_BDSKExtensions.m
trunk/bibdesk/NSImage_BDSKExtensions.h
trunk/bibdesk/NSImage_BDSKExtensions.m
Modified: trunk/bibdesk/BDSKLineNumberView.m
===================================================================
--- trunk/bibdesk/BDSKLineNumberView.m 2024-01-15 17:26:18 UTC (rev 28614)
+++ trunk/bibdesk/BDSKLineNumberView.m 2024-01-15 18:22:58 UTC (rev 28615)
@@ -37,7 +37,6 @@
*/
#import "BDSKLineNumberView.h"
-#import "NSImage_BDSKExtensions.h"
#import "BDSKErrorObject.h"
#import "NSColor_BDSKExtensions.h"
@@ -217,7 +216,7 @@
if (rectCount > 0) {
if (errorMarkers && (marker = (__bridge
id)NSMapGet(errorMarkers, (const void *)line))) {
markerRect.origin.y = offsetY + NSMidY(rects[0]) - 0.5
* MARKER_THICKNESS;
- [[marker image] drawFlipped:[self isFlipped]
inRect:markerRect fromRect:NSZeroRect
operation:NSCompositingOperationSourceOver fraction:1.0];
+ [[marker image] drawInRect:markerRect
fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0
respectFlipped:YES hints:nil];
[self addToolTipRect:markerRect owner:self
userData:(void *)line];
}
label = [NSString stringWithFormat:@"%lu", (unsigned
long)(line + 1)];
Modified: trunk/bibdesk/NSArray_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSArray_BDSKExtensions.h 2024-01-15 17:26:18 UTC (rev
28614)
+++ trunk/bibdesk/NSArray_BDSKExtensions.h 2024-01-15 18:22:58 UTC (rev
28615)
@@ -93,7 +93,6 @@
- (NSArray *)arrayByRemovingObject:(id)anObject;
-- (NSIndexSet *)indexesOfObjects:(NSArray *)objects;
- (NSIndexSet *)indexesOfObjectsIdenticalTo:(NSArray *)objects;
- (NSArray *)objectsAtIndexSpecifiers:(NSArray *)indexes;
Modified: trunk/bibdesk/NSArray_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSArray_BDSKExtensions.m 2024-01-15 17:26:18 UTC (rev
28614)
+++ trunk/bibdesk/NSArray_BDSKExtensions.m 2024-01-15 18:22:58 UTC (rev
28615)
@@ -320,53 +320,20 @@
[array addObject:[self objectAtIndex:[is index]]];
return array;
}
-
-/* theSelector should be either indexOfObject:inRange: or
indexOfObjectIdenticalTo:inRange */
-static inline
-NSIndexSet *__BDIndexesOfObjectsUsingSelector(NSArray *arrayToSearch, NSArray
*objectsToFind, SEL theSelector)
+
+- (NSIndexSet *)indexesOfObjectsIdenticalTo:(NSArray *)objects;
{
+ // assume objects exist at most once in self, which is how we use it
NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet];
NSUInteger idx;
- NSUInteger count = [arrayToSearch count];
-
- NSRange range = NSMakeRange(0, count);
-
- typedef NSUInteger (*indexIMP)(id, SEL, id, NSRange);
- indexIMP indexOfObjectInRange = (indexIMP)[arrayToSearch
methodForSelector:theSelector];
-
- for (id obj in objectsToFind) {
-
- // see if we have the first occurrence of this object
- idx = indexOfObjectInRange(arrayToSearch, theSelector, obj, range);
-
- while(idx != NSNotFound){
+ for (id obj in objects) {
+ idx = [self indexOfObjectIdenticalTo:obj];
+ if(idx != NSNotFound)
[indexes addIndex:idx];
-
- // shift search range to the right
- range.location = idx + 1;
- range.length = count - idx - 1;
-
- // NSArray seems to handle out-of-range here, but we'll be careful
anyway
- idx = NSMaxRange(range) < count ?
indexOfObjectInRange(arrayToSearch, theSelector, obj, range) : NSNotFound;
- }
-
- // resetting to max range is always valid
- range.location = 0;
- range.length = count;
}
- return indexes;
+ return indexes;
}
-- (NSIndexSet *)indexesOfObjects:(NSArray *)objects;
-{
- return __BDIndexesOfObjectsUsingSelector(self, objects,
@selector(indexOfObject:inRange:));
-}
-
-- (NSIndexSet *)indexesOfObjectsIdenticalTo:(NSArray *)objects;
-{
- return __BDIndexesOfObjectsUsingSelector(self, objects,
@selector(indexOfObjectIdenticalTo:inRange:));
-}
-
- (id)sortedArrayUsingMergesortWithDescriptors:(NSArray *)sortDescriptors;
{
NSMutableArray *array = [self mutableCopy];
Modified: trunk/bibdesk/NSImage_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSImage_BDSKExtensions.h 2024-01-15 17:26:18 UTC (rev
28614)
+++ trunk/bibdesk/NSImage_BDSKExtensions.h 2024-01-15 18:22:58 UTC (rev
28615)
@@ -77,8 +77,6 @@
- (NSImage *)dragImageWithCount:(NSInteger)count;
- (NSImage *)dragImageWithCount:(NSInteger)count inside:(BOOL)inside
size:(NSSize)size;
-- (void)drawFlipped:(BOOL)isFlipped inRect:(NSRect)dstRect
fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op
fraction:(CGFloat)delta;
-
// creates an image with a single bitmap image rep of the given size and scale
- (id)initBitmapWithSize:(NSSize)size scale:(CGFloat)scale
drawingHandler:(void (^)(NSRect dstRect))drawingHandler;
// creates an image with a two bitmap image reps of the given size and scales
1 and 2
Modified: trunk/bibdesk/NSImage_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSImage_BDSKExtensions.m 2024-01-15 17:26:18 UTC (rev
28614)
+++ trunk/bibdesk/NSImage_BDSKExtensions.m 2024-01-15 18:22:58 UTC (rev
28615)
@@ -738,21 +738,6 @@
return dragImage;
}
-- (void)drawFlipped:(BOOL)isFlipped inRect:(NSRect)dstRect
fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op
fraction:(CGFloat)delta {
- if (isFlipped) {
- [NSGraphicsContext saveGraphicsState];
- NSAffineTransform *transform = [NSAffineTransform transform];
- [transform translateXBy:0.0 yBy:NSMaxY(dstRect)];
- [transform scaleXBy:1.0 yBy:-1.0];
- [transform translateXBy:0.0 yBy:-NSMinY(dstRect)];
- [transform concat];
- [self drawInRect:dstRect fromRect:srcRect operation:op fraction:delta];
- [NSGraphicsContext restoreGraphicsState];
- } else {
- [self drawInRect:dstRect fromRect:srcRect operation:op fraction:delta];
- }
-}
-
- (id)initBitmapWithSize:(NSSize)size scale:(CGFloat)scale
drawingHandler:(void (^)(NSRect dstRect))drawingHandler {
self = [self initWithSize:size];
if (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