mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
#3788 Adjust the status and filter bars' colors; make status bar draggable (again)
This commit is contained in:
parent
43ed57b278
commit
0371e8bc80
3 changed files with 123 additions and 24 deletions
|
@ -391,6 +391,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
[fFilterBar setIsFilter: YES];
|
||||
|
||||
NSToolbar * toolbar = [[NSToolbar alloc] initWithIdentifier: @"TRMainToolbar"];
|
||||
[toolbar setDelegate: self];
|
||||
[toolbar setAllowsUserCustomization: YES];
|
||||
|
@ -420,6 +422,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
+ [fTableView rowHeight] + [fTableView intercellSpacing].height;
|
||||
[fWindow setContentMinSize: contentMinSize];
|
||||
[fWindow setContentBorderThickness: NSMinY([[fTableView enclosingScrollView] frame]) forEdge: NSMinYEdge];
|
||||
[fWindow setMovableByWindowBackground: YES];
|
||||
|
||||
[[fTotalDLField cell] setBackgroundStyle: NSBackgroundStyleRaised];
|
||||
[[fTotalULField cell] setBackgroundStyle: NSBackgroundStyleRaised];
|
||||
|
|
|
@ -26,7 +26,11 @@
|
|||
|
||||
@interface StatusBarView : NSView
|
||||
{
|
||||
BOOL fIsFilter;
|
||||
NSGradient * fInactiveGradient, * fStatusGradient, * fFilterGradient;
|
||||
NSColor * fGrayBorderColor;
|
||||
}
|
||||
|
||||
- (void) setIsFilter: (BOOL) isFilter;
|
||||
|
||||
@end
|
||||
|
|
|
@ -24,13 +24,37 @@
|
|||
|
||||
#import "StatusBarView.h"
|
||||
|
||||
@interface StatusBarView (Private)
|
||||
|
||||
- (void) reload;
|
||||
|
||||
@end
|
||||
|
||||
@implementation StatusBarView
|
||||
|
||||
- (id) initWithFrame: (NSRect) rect
|
||||
{
|
||||
if ((self = [super initWithFrame: rect]))
|
||||
{
|
||||
fIsFilter = NO;
|
||||
fGrayBorderColor = [[NSColor colorWithCalibratedRed: 171.0/255.0 green: 171.0/255.0 blue: 171.0/255.0 alpha: 1.0] retain];
|
||||
|
||||
NSColor * lightColor = [NSColor colorWithCalibratedRed: 230.0/255.0 green: 230.0/255.0 blue: 230.0/255.0 alpha: 1.0];
|
||||
NSColor * darkColor = [NSColor colorWithCalibratedRed: 220.0/255.0 green: 220.0/255.0 blue: 220.0/255.0 alpha: 1.0];
|
||||
fInactiveGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
|
||||
|
||||
lightColor = [NSColor colorWithCalibratedRed: 160.0/255.0 green: 160.0/255.0 blue: 160.0/255.0 alpha: 1.0];
|
||||
darkColor = [NSColor colorWithCalibratedRed: 155.0/255.0 green: 155.0/255.0 blue: 155.0/255.0 alpha: 1.0];
|
||||
fStatusGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
|
||||
|
||||
lightColor = [NSColor colorWithCalibratedRed: 235.0/255.0 green: 235.0/255.0 blue: 235.0/255.0 alpha: 1.0];
|
||||
darkColor = [NSColor colorWithCalibratedRed: 205.0/255.0 green: 205.0/255.0 blue: 205.0/255.0 alpha: 1.0];
|
||||
fFilterGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reload)
|
||||
name: NSWindowDidBecomeMainNotification object: [self window]];
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reload)
|
||||
name: NSWindowDidResignMainNotification object: [self window]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -38,41 +62,109 @@
|
|||
- (void) dealloc
|
||||
{
|
||||
[fGrayBorderColor release];
|
||||
[fStatusGradient release];
|
||||
[fInactiveGradient release];
|
||||
[fFilterGradient release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL) mouseDownCanMoveWindow
|
||||
{
|
||||
return !fIsFilter;
|
||||
}
|
||||
|
||||
#warning get rid of asap
|
||||
- (void) setIsFilter: (BOOL) isFilter
|
||||
{
|
||||
fIsFilter = isFilter;
|
||||
}
|
||||
|
||||
- (void) drawRect: (NSRect) rect
|
||||
{
|
||||
NSInteger count = 0;
|
||||
NSRect gridRects[3];
|
||||
NSColor * colorRects[3];
|
||||
|
||||
NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0);
|
||||
if (NSIntersectsRect(lineBorderRect, rect))
|
||||
if (fIsFilter)
|
||||
{
|
||||
gridRects[count] = lineBorderRect;
|
||||
colorRects[count] = [NSColor whiteColor];
|
||||
++count;
|
||||
NSInteger count = 0;
|
||||
NSRect gridRects[2];
|
||||
NSColor * colorRects[2];
|
||||
|
||||
rect.size.height -= 1.0;
|
||||
NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0);
|
||||
if ([[self window] isMainWindow])
|
||||
{
|
||||
if (NSIntersectsRect(lineBorderRect, rect))
|
||||
{
|
||||
gridRects[count] = lineBorderRect;
|
||||
colorRects[count] = [NSColor whiteColor];
|
||||
++count;
|
||||
|
||||
rect.size.height -= 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
lineBorderRect.origin.y = 0.0;
|
||||
if (NSIntersectsRect(lineBorderRect, rect))
|
||||
{
|
||||
gridRects[count] = lineBorderRect;
|
||||
colorRects[count] = [[self window] isMainWindow] ? [NSColor colorWithCalibratedWhite: 0.25 alpha: 1.0]
|
||||
: [NSColor colorWithCalibratedWhite: 0.5 alpha: 1.0];
|
||||
++count;
|
||||
|
||||
rect.origin.y += 1.0;
|
||||
rect.size.height -= 1.0;
|
||||
}
|
||||
|
||||
NSRectFillListWithColors(gridRects, colorRects, count);
|
||||
|
||||
[fFilterGradient drawInRect: rect angle: 270.0];
|
||||
}
|
||||
|
||||
lineBorderRect.origin.y = 0.0;
|
||||
if (NSIntersectsRect(lineBorderRect, rect))
|
||||
else
|
||||
{
|
||||
gridRects[count] = lineBorderRect;
|
||||
colorRects[count] = fGrayBorderColor;
|
||||
++count;
|
||||
const BOOL active = [[self window] isMainWindow];
|
||||
|
||||
rect.origin.y += 1.0;
|
||||
rect.size.height -= 1.0;
|
||||
NSInteger count = 0;
|
||||
NSRect gridRects[2];
|
||||
NSColor * colorRects[2];
|
||||
|
||||
NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0);
|
||||
if (active)
|
||||
{
|
||||
if (NSIntersectsRect(lineBorderRect, rect))
|
||||
{
|
||||
gridRects[count] = lineBorderRect;
|
||||
colorRects[count] = [NSColor colorWithCalibratedWhite: 0.75 alpha: 1.0];
|
||||
++count;
|
||||
|
||||
rect.size.height -= 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
lineBorderRect.origin.y = 0.0;
|
||||
if (NSIntersectsRect(lineBorderRect, rect))
|
||||
{
|
||||
gridRects[count] = lineBorderRect;
|
||||
colorRects[count] = [[self window] isMainWindow] ? [NSColor colorWithCalibratedWhite: 0.25 alpha: 1.0]
|
||||
: [NSColor colorWithCalibratedWhite: 0.5 alpha: 1.0];
|
||||
++count;
|
||||
|
||||
rect.origin.y += 1.0;
|
||||
rect.size.height -= 1.0;
|
||||
}
|
||||
|
||||
if (active)
|
||||
[fStatusGradient drawInRect: rect angle: 270.0];
|
||||
else
|
||||
[fInactiveGradient drawInRect: rect angle: 270.0];
|
||||
|
||||
NSRectFillListWithColors(gridRects, colorRects, count);
|
||||
}
|
||||
|
||||
gridRects[count] = rect;
|
||||
colorRects[count] = [NSColor controlColor];
|
||||
++count;
|
||||
|
||||
NSRectFillListWithColors(gridRects, colorRects, count);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation StatusBarView (Private)
|
||||
|
||||
- (void) reload
|
||||
{
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue