Revision: 11544
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=11544&view=rev
Author: hofman
Date: 2007-11-11 10:51:39 -0800 (Sun, 11 Nov 2007)
Log Message:
-----------
Improvements to arrow buttons in file icons.
Modified Paths:
--------------
branches/TRY_ARM_FILE_INTERFACE/bibdesk_vendorsrc/amaxwell/FileView/FVArrowButton.h
branches/TRY_ARM_FILE_INTERFACE/bibdesk_vendorsrc/amaxwell/FileView/FVArrowButton.m
branches/TRY_ARM_FILE_INTERFACE/bibdesk_vendorsrc/amaxwell/FileView/FileView.m
Modified:
branches/TRY_ARM_FILE_INTERFACE/bibdesk_vendorsrc/amaxwell/FileView/FVArrowButton.h
===================================================================
---
branches/TRY_ARM_FILE_INTERFACE/bibdesk_vendorsrc/amaxwell/FileView/FVArrowButton.h
2007-11-11 17:42:20 UTC (rev 11543)
+++
branches/TRY_ARM_FILE_INTERFACE/bibdesk_vendorsrc/amaxwell/FileView/FVArrowButton.h
2007-11-11 18:51:39 UTC (rev 11544)
@@ -44,7 +44,7 @@
NSUInteger _arrowDirection;
}
-+ (id)newLeftArrowWithSize:(NSSize)size;
-+ (id)newRightArrowWithSize:(NSSize)size;
+- (id)initLeftArrowWithFrame:(NSRect)frameRect;
+- (id)initRightArrowWithFrame:(NSRect)frameRect;
@end
Modified:
branches/TRY_ARM_FILE_INTERFACE/bibdesk_vendorsrc/amaxwell/FileView/FVArrowButton.m
===================================================================
---
branches/TRY_ARM_FILE_INTERFACE/bibdesk_vendorsrc/amaxwell/FileView/FVArrowButton.m
2007-11-11 17:42:20 UTC (rev 11543)
+++
branches/TRY_ARM_FILE_INTERFACE/bibdesk_vendorsrc/amaxwell/FileView/FVArrowButton.m
2007-11-11 18:51:39 UTC (rev 11544)
@@ -49,75 +49,28 @@
@end
@implementation FVArrowButtonCell
-
-- (id)init
-{
- self = [super init];
- // handle highlight drawing manually, since NSButtonCell draws a
rectangular background mask
- [self setHighlightsBy:NSNoCellMask];
- return self;
-}
-
-- (void)drawImage:(NSImage *)image withFrame:(NSRect)frame inView:(NSView
*)controlView;
-{
- if ([self isHighlighted]) {
- // could check to see if [controlView isFlipped], but the icon is
symmetric
- [image drawInRect:frame fromRect:NSZeroRect
operation:NSCompositeSourceOver fraction:1.0];
- [[NSColor colorWithCalibratedWhite:0.5 alpha:0.5] setFill];
- [[NSBezierPath bezierPathWithOvalInRect:frame] fill];
- }
- else {
- [super drawImage:image withFrame:frame inView:controlView];
-
- if ([self isEnabled] == NO) {
- [NSGraphicsContext saveGraphicsState];
- [[NSColor colorWithCalibratedWhite:1.0 alpha:0.5] setFill];
- [[NSBezierPath bezierPathWithOvalInRect:frame] fill];
- [NSGraphicsContext restoreGraphicsState];
- }
- }
-}
-
@end
@implementation FVArrowButton
+ (Class)cellClass { return [FVArrowButtonCell class]; }
-- (NSImage *)rightArrowImage;
+- (NSImage *)arrowImage;
{
NSSize size = [self frame].size;
NSImage *image = [[NSImage alloc] initWithSize:size];
- [image lockFocus];
-
+ NSLog(@"%@",NSStringFromSize(size));
NSRect arrowRect = NSZeroRect;
arrowRect.size = size;
- NSBezierPath *circle = [NSBezierPath bezierPathWithOvalInRect:arrowRect];
- [[NSColor colorWithCalibratedWhite:0.0 alpha:0.3] setFill];
- [circle fill];
-
- [[NSColor colorWithCalibratedWhite:1.0 alpha:0.7] setFill];
- [rightArrowBezierPathWithSize(size) fill];
-
- [image unlockFocus];
- return [image autorelease];
-}
-
-- (NSImage *)leftArrowImage;
-{
- NSSize size = [self frame].size;
- NSImage *image = [[NSImage alloc] initWithSize:size];
-
- NSRect arrowRect = NSZeroRect;
- arrowRect.size = size;
-
[image lockFocus];
// reverse the CTM so the arrow points left
- CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicsPort];
- CGContextTranslateCTM(ctxt, size.width, 0);
- CGContextScaleCTM(ctxt, -1, 1);
+ if (FVArrowLeft == _arrowDirection) {
+ CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicsPort];
+ CGContextTranslateCTM(ctxt, size.width, 0);
+ CGContextScaleCTM(ctxt, -1, 1);
+ }
NSBezierPath *circle = [NSBezierPath bezierPathWithOvalInRect:arrowRect];
[[NSColor colorWithCalibratedWhite:0.0 alpha:0.3] setFill];
@@ -131,33 +84,51 @@
return [image autorelease];
}
-+ (id)newLeftArrowWithSize:(NSSize)size;
+- (id)initLeftArrowWithFrame:(NSRect)frameRect
{
- FVArrowButton *button = [[self allocWithZone:[self zone]]
initWithFrame:NSMakeRect(0,0,size.width,size.height)];
- [button setImage:[button leftArrowImage]];
- [button setImagePosition:NSImageOnly];
- [button setBordered:NO];
- button->_arrowDirection = FVArrowLeft;
- return button;
+ if (self = [super initWithFrame:frameRect]) {
+ _arrowDirection = FVArrowLeft;
+ [self setImage:[self arrowImage]];
+ [self setImagePosition:NSImageOnly];
+ [self setBezelStyle:NSRegularSquareBezelStyle];
+ [self setBordered:NO];
+ [[self cell] setHighlightsBy:NSContentsCellMask];
+ }
+ return self;
}
-+ (id)newRightArrowWithSize:(NSSize)size;
+- (id)initRightArrowWithFrame:(NSRect)frameRect
{
- FVArrowButton *button = [[self allocWithZone:[self zone]]
initWithFrame:NSMakeRect(0,0,size.width,size.height)];
- [button setImage:[button rightArrowImage]];
- [button setImagePosition:NSImageOnly];
- [button setBordered:NO];
- button->_arrowDirection = FVArrowRight;
- return button;
+ if (self = [super initWithFrame:frameRect]) {
+ _arrowDirection = FVArrowRight;
+ [self setImage:[self arrowImage]];
+ [self setImagePosition:NSImageOnly];
+ [self setBezelStyle:NSRegularSquareBezelStyle];
+ [self setBordered:NO];
+ [[self cell] setHighlightsBy:NSContentsCellMask];
+ }
+ return self;
}
+- (id)initWithFrame:(NSRect)frameRect {
+ return [self initRightArrowWithFrame:frameRect];
+}
+
// any time the frame changes, create a new image at the correct size
- (void)setFrame:(NSRect)aFrame
{
[super setFrame:aFrame];
- [self setImage:(FVArrowLeft == _arrowDirection ? [self leftArrowImage] :
[self rightArrowImage])];
+ if (NSEqualSizes(aFrame.size, [[self image] size]) == NO)
+ [self setImage:[self arrowImage]];
}
+- (void)setFrameSize:(NSSize)aSize
+{
+ [super setFrameSize:aSize];
+ if (NSEqualSizes(aSize, [[self image] size]) == NO)
+ [self setImage:[self arrowImage]];
+}
+
// Modify mouseDown: behavior slightly. Wince this control is superimposed on
another pseudo-control (the FileView), we want to avoid passing some events to
the next responder.
- (void)mouseDown:(NSEvent *)event
{
Modified:
branches/TRY_ARM_FILE_INTERFACE/bibdesk_vendorsrc/amaxwell/FileView/FileView.m
===================================================================
---
branches/TRY_ARM_FILE_INTERFACE/bibdesk_vendorsrc/amaxwell/FileView/FileView.m
2007-11-11 17:42:20 UTC (rev 11543)
+++
branches/TRY_ARM_FILE_INTERFACE/bibdesk_vendorsrc/amaxwell/FileView/FileView.m
2007-11-11 18:51:39 UTC (rev 11544)
@@ -152,11 +152,11 @@
const CFDictionaryValueCallBacks integerValueCallBacks = { 0, NULL, NULL,
intDesc, intEqual };
_trackingRectMap = CFDictionaryCreateMutable(alloc, 0,
&integerKeyCallBacks, &integerValueCallBacks);
- _leftArrow = [FVArrowButton newLeftArrowWithSize:NSMakeSize(16, 16)];
+ _leftArrow = [[FVArrowButton alloc] initLeftArrowWithFrame:NSMakeRect(0.0,
0.0, 16.0, 16.0)];
[_leftArrow setTarget:self];
[_leftArrow setAction:@selector(leftArrowAction:)];
- _rightArrow = [FVArrowButton newRightArrowWithSize:NSMakeSize(16, 16)];
+ _rightArrow = [[FVArrowButton alloc]
initRightArrowWithFrame:NSMakeRect(0.0, 0.0, 16.0, 16.0)];
[_rightArrow setTarget:self];
[_rightArrow setAction:@selector(rightArrowAction:)];
@@ -1212,7 +1212,7 @@
NSRect leftRect = NSZeroRect, rightRect = NSZeroRect;
// determine a min/max size for the arrow buttons
- CGFloat side = NSHeight(iconRect) / 5;
+ CGFloat side = roundf(NSHeight(iconRect) / 5);
side = MIN(side, 32);
side = MAX(side, 10);
leftRect.size = NSMakeSize(side, side);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit