From: Mitchell Livingston Date: Thu, 9 Dec 2010 23:30:35 +0000 (+0000) Subject: #3788 Adjust the status and filter bars' colors; make status bar draggable (again) X-Git-Tag: 2.20b1~217 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0371e8bc80e2ce9d0f06729a5848ba8694670bcc;p=transmission #3788 Adjust the status and filter bars' colors; make status bar draggable (again) --- diff --git a/macosx/Controller.m b/macosx/Controller.m index 83d68fdd6..46ae19c75 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -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]; diff --git a/macosx/StatusBarView.h b/macosx/StatusBarView.h index fb7ed0fef..7c25ff63d 100644 --- a/macosx/StatusBarView.h +++ b/macosx/StatusBarView.h @@ -26,7 +26,11 @@ @interface StatusBarView : NSView { + BOOL fIsFilter; + NSGradient * fInactiveGradient, * fStatusGradient, * fFilterGradient; NSColor * fGrayBorderColor; } +- (void) setIsFilter: (BOOL) isFilter; + @end diff --git a/macosx/StatusBarView.m b/macosx/StatusBarView.m index 377190cb6..e5cc78067 100644 --- a/macosx/StatusBarView.m +++ b/macosx/StatusBarView.m @@ -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]; + + 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]; - rect.origin.y += 1.0; - rect.size.height -= 1.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