Changeset 11453


Ignore:
Timestamp:
Dec 4, 2010, 3:55:36 AM (11 years ago)
Author:
livings124
Message:

experiment for #3788 Adjust the status and filter bars' colors; make main window draggable

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r11441 r11453  
    392392- (void) awakeFromNib
    393393{
     394    [fFilterBar setIsFilter: YES];
     395   
    394396    NSToolbar * toolbar = [[NSToolbar alloc] initWithIdentifier: @"TRMainToolbar"];
    395397    [toolbar setDelegate: self];
     
    421423    [fWindow setContentMinSize: contentMinSize];
    422424    [fWindow setContentBorderThickness: NSMinY([[fTableView enclosingScrollView] frame]) forEdge: NSMinYEdge];
     425    [fWindow setMovableByWindowBackground: YES];
    423426   
    424427    [[fTotalDLField cell] setBackgroundStyle: NSBackgroundStyleRaised];
  • trunk/macosx/StatusBarView.h

    r9844 r11453  
    2727@interface StatusBarView : NSView
    2828{
     29    BOOL fIsFilter;
     30    NSGradient * fInactiveGradient, * fFilterGradient;
    2931    NSColor * fGrayBorderColor;
    3032}
    3133
     34- (void) setIsFilter: (BOOL) isFilter;
     35
    3236@end
  • trunk/macosx/StatusBarView.m

    r9844 r11453  
    2525#import "StatusBarView.h"
    2626
     27@interface StatusBarView (Private)
     28
     29- (void) reload;
     30
     31@end
     32
    2733@implementation StatusBarView
    2834
     
    3137    if ((self = [super initWithFrame: rect]))
    3238    {
     39        fIsFilter = NO;
    3340        fGrayBorderColor = [[NSColor colorWithCalibratedRed: 171.0/255.0 green: 171.0/255.0 blue: 171.0/255.0 alpha: 1.0] retain];
     41       
     42        NSColor * lightColor = [NSColor colorWithCalibratedRed: 230.0/255.0 green: 230.0/255.0 blue: 230.0/255.0 alpha: 1.0];
     43        NSColor * darkColor = [NSColor colorWithCalibratedRed: 220.0/255.0 green: 220.0/255.0 blue: 220.0/255.0 alpha: 1.0];
     44        fInactiveGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
     45       
     46        lightColor = [NSColor colorWithCalibratedRed: 235.0/255.0 green: 235.0/255.0 blue: 235.0/255.0 alpha: 1.0];
     47        darkColor = [NSColor colorWithCalibratedRed: 205.0/255.0 green: 205.0/255.0 blue: 205.0/255.0 alpha: 1.0];
     48        fFilterGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
     49       
     50        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reload)
     51            name: NSWindowDidBecomeMainNotification object: [self window]];
     52        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reload)
     53            name: NSWindowDidResignMainNotification object: [self window]];
    3454    }
    3555    return self;
     
    3959{
    4060    [fGrayBorderColor release];
     61    [fInactiveGradient release];
     62    [fFilterGradient release];
    4163    [super dealloc];
     64}
     65
     66- (BOOL) mouseDownCanMoveWindow
     67{
     68    return !fIsFilter;
     69}
     70
     71#warning get rid of asap
     72- (void) setIsFilter: (BOOL) isFilter
     73{
     74    fIsFilter = isFilter;
    4275}
    4376
    4477- (void) drawRect: (NSRect) rect
    4578{
    46     NSInteger count = 0;
    47     NSRect gridRects[3];
    48     NSColor * colorRects[3];
    49    
    50     NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0);
    51     if (NSIntersectsRect(lineBorderRect, rect))
     79    if (fIsFilter)
    5280    {
    53         gridRects[count] = lineBorderRect;
    54         colorRects[count] = [NSColor whiteColor];
    55         ++count;
     81        NSInteger count = 0;
     82        NSRect gridRects[2];
     83        NSColor * colorRects[2];
    5684       
    57         rect.size.height -= 1.0;
     85        NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0);
     86        if ([[self window] isMainWindow])
     87        {
     88            if (NSIntersectsRect(lineBorderRect, rect))
     89            {
     90                gridRects[count] = lineBorderRect;
     91                colorRects[count] = [NSColor whiteColor];
     92                ++count;
     93               
     94                rect.size.height -= 1.0;
     95            }
     96        }
     97       
     98        lineBorderRect.origin.y = 0.0;
     99        if (NSIntersectsRect(lineBorderRect, rect))
     100        {
     101            gridRects[count] = lineBorderRect;
     102            colorRects[count] = fGrayBorderColor;
     103            ++count;
     104           
     105            rect.origin.y += 1.0;
     106            rect.size.height -= 1.0;
     107        }
     108       
     109        NSRectFillListWithColors(gridRects, colorRects, count);
     110       
     111        [fFilterGradient drawInRect: rect angle: 270.0];
    58112    }
    59    
    60     lineBorderRect.origin.y = 0.0;
    61     if (NSIntersectsRect(lineBorderRect, rect))
     113    else
    62114    {
    63         gridRects[count] = lineBorderRect;
    64         colorRects[count] = fGrayBorderColor;
    65         ++count;
     115        const BOOL active = [[self window] isMainWindow];
    66116       
    67         rect.origin.y += 1.0;
    68         rect.size.height -= 1.0;
     117        NSInteger count = 0;
     118        NSRect gridRects[active ? 3 : 2];
     119        NSColor * colorRects[active ? 3 : 2];
     120       
     121        NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0);
     122        if (active)
     123        {
     124            if (NSIntersectsRect(lineBorderRect, rect))
     125            {
     126                gridRects[count] = lineBorderRect;
     127                colorRects[count] = [NSColor colorWithCalibratedWhite: 0.75 alpha: 1.0];
     128                ++count;
     129               
     130                rect.size.height -= 1.0;
     131            }
     132        }
     133       
     134        lineBorderRect.origin.y = 0.0;
     135        if (NSIntersectsRect(lineBorderRect, rect))
     136        {
     137            gridRects[count] = lineBorderRect;
     138            colorRects[count] = [[self window] isMainWindow] ? [NSColor colorWithCalibratedWhite: 0.25 alpha: 1.0]
     139                                    : [NSColor colorWithCalibratedWhite: 0.5 alpha: 1.0];
     140            ++count;
     141           
     142            rect.origin.y += 1.0;
     143            rect.size.height -= 1.0;
     144        }
     145       
     146        if (active)
     147        {
     148            gridRects[count] = rect;
     149            colorRects[count] = [NSColor colorWithCalibratedWhite: 0.59 alpha: 1.0];
     150            ++count;
     151        }
     152        else
     153            [fInactiveGradient drawInRect: rect angle: 270.0];
     154       
     155        NSRectFillListWithColors(gridRects, colorRects, count);
    69156    }
    70    
    71     gridRects[count] = rect;
    72     colorRects[count] = [NSColor controlColor];
    73     ++count;
    74    
    75     NSRectFillListWithColors(gridRects, colorRects, count);
    76157}
    77158
    78159@end
     160
     161@implementation StatusBarView (Private)
     162
     163- (void) reload
     164{
     165    [self setNeedsDisplay: YES];
     166}
     167
     168@end
Note: See TracChangeset for help on using the changeset viewer.