]> granicus.if.org Git - transmission/commitdiff
#3788 Adjust the status and filter bars' colors; make status bar draggable (again)
authorMitchell Livingston <livings124@transmissionbt.com>
Thu, 9 Dec 2010 23:30:35 +0000 (23:30 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Thu, 9 Dec 2010 23:30:35 +0000 (23:30 +0000)
macosx/Controller.m
macosx/StatusBarView.h
macosx/StatusBarView.m

index 83d68fdd61ab38ab30cc7a81a3f98f8e8e37138a..46ae19c759254e6a82ab744e139114438096dffd 100644 (file)
@@ -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];
index fb7ed0fef606d59ec1262cbf2b5e1218307047bf..7c25ff63d0e738a79ae2e54bc1f233f43ffe8eaf 100644 (file)
 
 @interface StatusBarView : NSView
 {
+    BOOL fIsFilter;
+    NSGradient * fInactiveGradient, * fStatusGradient, * fFilterGradient;
     NSColor * fGrayBorderColor;
 }
 
+- (void) setIsFilter: (BOOL) isFilter;
+
 @end
index 377190cb63810433f6ab693005e73bb8451c671e..e5cc78067767d27e4bb768ef33de9c14168a3db1 100644 (file)
 
 #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;
 }
 - (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