mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Switch to generated properties
This commit is contained in:
@@ -1,30 +1,15 @@
|
||||
#import <OakAppKit/OakImageAndTextCell.h>
|
||||
#import <oak/debug.h>
|
||||
|
||||
@class OakTimer;
|
||||
|
||||
enum {
|
||||
OFBPathInfoCellHitCloseButton = (12 << 1),
|
||||
};
|
||||
|
||||
@interface OFBPathInfoCell : OakImageAndTextCell
|
||||
{
|
||||
OBJC_WATCH_LEAKS(OFBPathInfoCell);
|
||||
NSUInteger labelIndex;
|
||||
BOOL mouseDownInCloseButton;
|
||||
BOOL isOpen;
|
||||
BOOL isVisible;
|
||||
BOOL isLoading;
|
||||
double spinnerValue;
|
||||
OakTimer* spinTimer;
|
||||
}
|
||||
@property (nonatomic, assign) NSUInteger labelIndex;
|
||||
|
||||
@property (nonatomic, assign) BOOL isOpen;
|
||||
@property (nonatomic, assign) BOOL isVisible;
|
||||
@property (nonatomic, assign) BOOL isLoading;
|
||||
@property (nonatomic, assign) BOOL mouseDownInCloseButton;
|
||||
|
||||
- (NSRect)closeButtonRectInFrame:(NSRect)cellFrame;
|
||||
- (BOOL)isMouseInCloseButtonInFrame:(NSRect)cellFrame controlView:(NSView*)controlView;
|
||||
@end
|
||||
|
||||
@@ -5,59 +5,6 @@
|
||||
#import <OakFoundation/OakTimer.h>
|
||||
#import <oak/debug.h>
|
||||
|
||||
@interface OFBPathInfoCell ()
|
||||
@property (nonatomic, retain) OakTimer* spinTimer;
|
||||
@end
|
||||
|
||||
@implementation OFBPathInfoCell
|
||||
@synthesize isOpen, isVisible, labelIndex, isLoading, spinTimer, mouseDownInCloseButton;
|
||||
|
||||
- (id)copyWithZone:(NSZone*)aZone
|
||||
{
|
||||
OFBPathInfoCell* res = [super copyWithZone:aZone];
|
||||
DB(new(&res->_instance_counter_helper) watch_leaks_OFBPathInfoCell(_instance_counter_helper));
|
||||
res->spinTimer = nil;
|
||||
return res;
|
||||
}
|
||||
|
||||
- (void)drawLabelIndex:(NSUInteger)labelColorIndex inFrame:(NSRect)cellFrame
|
||||
{
|
||||
if(labelColorIndex == 0)
|
||||
return;
|
||||
ASSERT(labelColorIndex < 8)
|
||||
|
||||
// color names: Gray, Green, Purple, Blue, Yellow, Red, Orange
|
||||
static NSString* const startCol[] = { @"#CFCFCF", @"#D4EE9C", @"#DDBDEA", @"#ACD0FE", @"#F8F79C", @"#B2B2B2", @"#F9D194" };
|
||||
static NSString* const stopCol[] = { @"#A8A8A8", @"#AFDC49", @"#C186D7", @"#5B9CFE", @"#ECDF4A", @"#FC605C", @"#F6AC46" };
|
||||
|
||||
NSRect r = NSIntegralRect(NSInsetRect(cellFrame, 2, 0));
|
||||
if([self isHighlighted])
|
||||
r.size.height = r.size.width = 16;
|
||||
|
||||
NSGradient* gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithString:startCol[labelColorIndex-1]] endingColor:[NSColor colorWithString:stopCol[labelColorIndex-1]]];
|
||||
NSBezierPath* path = [NSBezierPath bezierPathWithRoundedRect:r xRadius:8.0 yRadius:8.0];
|
||||
[gradient drawInBezierPath:path angle:90];
|
||||
}
|
||||
|
||||
- (NSImage*)closeIcon
|
||||
{
|
||||
return self.isOpen ? [NSImage imageNamed:@"CloseFile" inSameBundleAsClass:[self class]] : nil;
|
||||
}
|
||||
|
||||
- (NSRect)closeButtonRectInFrame:(NSRect)cellFrame
|
||||
{
|
||||
if(!self.isOpen)
|
||||
return NSZeroRect;
|
||||
return NSMakeRect(NSMaxX(cellFrame) - self.closeIcon.size.width, NSMaxY(cellFrame) - (cellFrame.size.height + self.closeIcon.size.height) / 2, self.closeIcon.size.width, self.closeIcon.size.height);
|
||||
}
|
||||
|
||||
- (void)redrawFrame:(OakTimer*)timer
|
||||
{
|
||||
[timer.userInfo setNeedsDisplay:YES];
|
||||
spinnerValue += 0.1;
|
||||
self.spinTimer = nil;
|
||||
}
|
||||
|
||||
static void DrawSpinner (NSRect cellFrame, BOOL isFlipped, NSColor* color, double value)
|
||||
{
|
||||
static const CGFloat deg2rad = 0.017453292519943295;
|
||||
@@ -83,6 +30,63 @@ static void DrawSpinner (NSRect cellFrame, BOOL isFlipped, NSColor* color, doubl
|
||||
}
|
||||
}
|
||||
|
||||
@interface OFBPathInfoCell ()
|
||||
{
|
||||
OBJC_WATCH_LEAKS(OFBPathInfoCell);
|
||||
double spinnerValue;
|
||||
}
|
||||
@property (nonatomic, retain) OakTimer* spinTimer;
|
||||
@property (nonatomic, assign) BOOL mouseDownInCloseButton;
|
||||
- (BOOL)isMouseInCloseButtonInFrame:(NSRect)cellFrame controlView:(NSView*)controlView;
|
||||
@end
|
||||
|
||||
@implementation OFBPathInfoCell
|
||||
- (id)copyWithZone:(NSZone*)aZone
|
||||
{
|
||||
OFBPathInfoCell* res = [super copyWithZone:aZone];
|
||||
DB(new(&res->_instance_counter_helper) watch_leaks_OFBPathInfoCell(_instance_counter_helper));
|
||||
res.spinTimer = nil;
|
||||
return res;
|
||||
}
|
||||
|
||||
- (void)drawLabelIndex:(NSUInteger)labelColorIndex inFrame:(NSRect)cellFrame
|
||||
{
|
||||
if(labelColorIndex == 0)
|
||||
return;
|
||||
ASSERT(labelColorIndex < 8)
|
||||
|
||||
// color names: Gray, Green, Purple, Blue, Yellow, Red, Orange
|
||||
static NSString* const startCol[] = { @"#CFCFCF", @"#D4EE9C", @"#DDBDEA", @"#ACD0FE", @"#F8F79C", @"#B2B2B2", @"#F9D194" };
|
||||
static NSString* const stopCol[] = { @"#A8A8A8", @"#AFDC49", @"#C186D7", @"#5B9CFE", @"#ECDF4A", @"#FC605C", @"#F6AC46" };
|
||||
|
||||
NSRect r = NSIntegralRect(NSInsetRect(cellFrame, 2, 0));
|
||||
if([self isHighlighted])
|
||||
r.size.height = r.size.width = 16;
|
||||
|
||||
NSGradient* gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithString:startCol[labelColorIndex-1]] endingColor:[NSColor colorWithString:stopCol[labelColorIndex-1]]];
|
||||
NSBezierPath* path = [NSBezierPath bezierPathWithRoundedRect:r xRadius:8.0 yRadius:8.0];
|
||||
[gradient drawInBezierPath:path angle:90];
|
||||
}
|
||||
|
||||
- (NSImage*)closeIcon
|
||||
{
|
||||
return self.isOpen ? [NSImage imageNamed:@"CloseFile" inSameBundleAsClass:[OFBPathInfoCell class]] : nil;
|
||||
}
|
||||
|
||||
- (NSRect)closeButtonRectInFrame:(NSRect)cellFrame
|
||||
{
|
||||
if(!self.isOpen)
|
||||
return NSZeroRect;
|
||||
return NSMakeRect(NSMaxX(cellFrame) - self.closeIcon.size.width, NSMaxY(cellFrame) - (cellFrame.size.height + self.closeIcon.size.height) / 2, self.closeIcon.size.width, self.closeIcon.size.height);
|
||||
}
|
||||
|
||||
- (void)redrawFrame:(OakTimer*)timer
|
||||
{
|
||||
[timer.userInfo setNeedsDisplay:YES];
|
||||
spinnerValue += 0.1;
|
||||
self.spinTimer = nil;
|
||||
}
|
||||
|
||||
- (BOOL)isMouseInCloseButtonInFrame:(NSRect)cellFrame controlView:(NSView*)controlView
|
||||
{
|
||||
NSPoint mousePoint = [controlView convertPoint:[controlView.window mouseLocationOutsideOfEventStream] fromView:nil];
|
||||
@@ -97,7 +101,7 @@ static void DrawSpinner (NSRect cellFrame, BOOL isFlipped, NSColor* color, doubl
|
||||
NSRect labelFrame = cellFrame;
|
||||
labelFrame.origin.x -= extra;
|
||||
labelFrame.size.width += extra;
|
||||
[self drawLabelIndex:labelIndex inFrame:labelFrame];
|
||||
[self drawLabelIndex:_labelIndex inFrame:labelFrame];
|
||||
}
|
||||
|
||||
if(self.isLoading)
|
||||
@@ -113,14 +117,10 @@ static void DrawSpinner (NSRect cellFrame, BOOL isFlipped, NSColor* color, doubl
|
||||
else if(self.isOpen)
|
||||
{
|
||||
NSImage* closeIcon = self.closeIcon;
|
||||
if(mouseDownInCloseButton)
|
||||
{
|
||||
closeIcon = [NSImage imageNamed:@"CloseFilePressed" inSameBundleAsClass:[self class]];
|
||||
}
|
||||
if(_mouseDownInCloseButton)
|
||||
closeIcon = [NSImage imageNamed:@"CloseFilePressed" inSameBundleAsClass:[OFBPathInfoCell class]];
|
||||
else if([self isMouseInCloseButtonInFrame:cellFrame controlView:controlView] && [[controlView window] isKeyWindow])
|
||||
{
|
||||
closeIcon = [NSImage imageNamed:@"CloseFileOver" inSameBundleAsClass:[self class]];
|
||||
}
|
||||
closeIcon = [NSImage imageNamed:@"CloseFileOver" inSameBundleAsClass:[OFBPathInfoCell class]];
|
||||
[closeIcon drawInRect:[self closeButtonRectInFrame:cellFrame] fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1];
|
||||
cellFrame.size.width -= self.closeIcon.size.width;
|
||||
}
|
||||
@@ -167,15 +167,15 @@ static void DrawSpinner (NSRect cellFrame, BOOL isFlipped, NSColor* color, doubl
|
||||
while([theEvent type] != NSLeftMouseUp)
|
||||
{
|
||||
mousePos = [controlView convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||
if(NSMouseInRect(mousePos, [self closeButtonRectInFrame:cellFrame], [controlView isFlipped]) != mouseDownInCloseButton)
|
||||
if(NSMouseInRect(mousePos, [self closeButtonRectInFrame:cellFrame], [controlView isFlipped]) != _mouseDownInCloseButton)
|
||||
{
|
||||
mouseDownInCloseButton = !mouseDownInCloseButton;
|
||||
_mouseDownInCloseButton = !_mouseDownInCloseButton;
|
||||
[controlView setNeedsDisplayInRect:[self closeButtonRectInFrame:cellFrame]];
|
||||
}
|
||||
theEvent = [NSApp nextEventMatchingMask:(NSLeftMouseDraggedMask|NSMouseMovedMask|NSLeftMouseUpMask) untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YES];
|
||||
}
|
||||
|
||||
mouseDownInCloseButton = NO;
|
||||
_mouseDownInCloseButton = NO;
|
||||
[controlView setNeedsDisplayInRect:[self closeButtonRectInFrame:cellFrame]];
|
||||
return YES;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user