make the progress bar in compact view take up essentially the entire cell

This commit is contained in:
Mitchell Livingston 2010-03-20 05:09:34 +00:00
parent 9c87f67f9b
commit a075653c67
3 changed files with 74 additions and 73 deletions

View File

@ -28,7 +28,7 @@
+ (NSGradient *) progressGradientForRed: (CGFloat) redComponent green: (CGFloat) greenComponent blue: (CGFloat) blueComponent
{
const CGFloat alpha = [[NSUserDefaults standardUserDefaults] boolForKey: @"SmallView"] ? 0.085 : 1.0;
const CGFloat alpha = [[NSUserDefaults standardUserDefaults] boolForKey: @"SmallView"] ? 0.2 : 1.0;
NSColor * baseColor = [NSColor colorWithCalibratedRed: redComponent green: greenComponent blue: blueComponent alpha: alpha];

View File

@ -325,6 +325,9 @@
const BOOL minimal = [fDefaults boolForKey: @"SmallView"];
//bar
[self drawBar: [self barRectForBounds: cellFrame]];
//group coloring
const NSRect iconRect = [self iconRectForBounds: cellFrame];
@ -374,9 +377,6 @@
[self drawImage: [NSImage imageNamed: [NSApp isOnSnowLeopardOrBetter] ? NSImageNameCaution : @"Error.png"] inRect: errorRect];
}
//bar
[self drawBar: [self barRectForBounds: cellFrame]];
//text color
NSColor * titleColor, * statusColor;
if ([self backgroundStyle] == NSBackgroundStyleDark)
@ -710,25 +710,23 @@
- (NSRect) barRectForBounds: (NSRect) bounds
{
const BOOL minimal = [fDefaults boolForKey: @"SmallView"];
NSRect result;
result.size.height = BAR_HEIGHT;
result.origin.x = NSMinX(bounds) + (minimal ? IMAGE_SIZE_MIN : IMAGE_SIZE_REG) + PADDING_BETWEEN_IMAGE_AND_BAR;
result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE;
if (minimal)
#warning make const
result.origin.y += 2.0;
if ([fDefaults boolForKey: @"SmallView"])
return NSInsetRect(bounds, 2.0, 2.0);
else
result.origin.y += HEIGHT_TITLE + PADDING_BETWEEN_TITLE_AND_PROGRESS + HEIGHT_STATUS + PADDING_BETWEEN_PROGRESS_AND_BAR;
result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONTAL;
if (!minimal)
result.size.width -= 2.0 * (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH);
result.size.width = floor(NSWidth(result));
return result;
{
NSRect result;
result.size.height = BAR_HEIGHT;
result.origin.x = NSMinX(bounds) + IMAGE_SIZE_REG + PADDING_BETWEEN_IMAGE_AND_BAR;
result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE + PADDING_BETWEEN_TITLE_AND_PROGRESS
+ HEIGHT_STATUS + PADDING_BETWEEN_PROGRESS_AND_BAR;
result.size.width = floor(NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONTAL
- 2.0 * (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH));
return result;
}
}
- (NSRect) controlButtonRectForBounds: (NSRect) bounds

View File

@ -682,71 +682,74 @@
//alternating rows - first row after group row is white
- (void) highlightSelectionInClipRect: (NSRect) clipRect
{
NSRect visibleRect = clipRect;
NSRange rows = [self rowsInRect: visibleRect];
BOOL start = YES;
const CGFloat totalRowHeight = [self rowHeight] + [self intercellSpacing].height;
NSRect gridRects[(NSInteger)(ceil(visibleRect.size.height / totalRowHeight / 2.0)) + 1]; //add one if partial rows at top and bottom
NSInteger rectNum = 0;
if (rows.length > 0)
if (![fDefaults boolForKey: @"SmallView"])
{
//determine what the first row color should be
if ([[self itemAtRow: rows.location] isKindOfClass: [Torrent class]])
NSRect visibleRect = clipRect;
NSRange rows = [self rowsInRect: visibleRect];
BOOL start = YES;
const CGFloat totalRowHeight = [self rowHeight] + [self intercellSpacing].height;
NSRect gridRects[(NSInteger)(ceil(visibleRect.size.height / totalRowHeight / 2.0)) + 1]; //add one if partial rows at top and bottom
NSInteger rectNum = 0;
if (rows.length > 0)
{
for (NSInteger i = rows.location-1; i>=0; i--)
//determine what the first row color should be
if ([[self itemAtRow: rows.location] isKindOfClass: [Torrent class]])
{
for (NSInteger i = rows.location-1; i>=0; i--)
{
if (![[self itemAtRow: i] isKindOfClass: [Torrent class]])
break;
start = !start;
}
}
else
{
rows.location++;
rows.length--;
}
NSInteger i;
for (i = rows.location; i < NSMaxRange(rows); i++)
{
if (![[self itemAtRow: i] isKindOfClass: [Torrent class]])
break;
{
start = YES;
continue;
}
if (!start && ![self isRowSelected: i])
gridRects[rectNum++] = [self rectOfRow: i];
start = !start;
}
}
else
{
rows.location++;
rows.length--;
const CGFloat newY = NSMaxY([self rectOfRow: i-1]);
visibleRect.size.height -= newY - visibleRect.origin.y;
visibleRect.origin.y = newY;
}
NSInteger i;
for (i = rows.location; i < NSMaxRange(rows); i++)
const NSInteger numberBlankRows = ceil(visibleRect.size.height / totalRowHeight);
//remaining visible rows continue alternating
visibleRect.size.height = totalRowHeight;
if (start)
visibleRect.origin.y += totalRowHeight;
for (NSInteger i = start ? 1 : 0; i < numberBlankRows; i += 2)
{
if (![[self itemAtRow: i] isKindOfClass: [Torrent class]])
{
start = YES;
continue;
}
if (!start && ![self isRowSelected: i])
gridRects[rectNum++] = [self rectOfRow: i];
start = !start;
gridRects[rectNum++] = visibleRect;
visibleRect.origin.y += 2.0 * totalRowHeight;
}
const CGFloat newY = NSMaxY([self rectOfRow: i-1]);
visibleRect.size.height -= newY - visibleRect.origin.y;
visibleRect.origin.y = newY;
NSAssert([[NSColor controlAlternatingRowBackgroundColors] count] >= 2, @"There should be 2 alternating row colors");
[[[NSColor controlAlternatingRowBackgroundColors] objectAtIndex: 1] set];
NSRectFillList(gridRects, rectNum);
}
const NSInteger numberBlankRows = ceil(visibleRect.size.height / totalRowHeight);
//remaining visible rows continue alternating
visibleRect.size.height = totalRowHeight;
if (start)
visibleRect.origin.y += totalRowHeight;
for (NSInteger i = start ? 1 : 0; i < numberBlankRows; i += 2)
{
gridRects[rectNum++] = visibleRect;
visibleRect.origin.y += 2.0 * totalRowHeight;
}
NSAssert([[NSColor controlAlternatingRowBackgroundColors] count] >= 2, @"There should be 2 alternating row colors");
[[[NSColor controlAlternatingRowBackgroundColors] objectAtIndex: 1] set];
NSRectFillList(gridRects, rectNum);
[super highlightSelectionInClipRect: clipRect];
}