• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: darken grey NSToolbar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: darken grey NSToolbar


  • Subject: Re: darken grey NSToolbar
  • From: John Pannell <email@hidden>
  • Date: Thu, 6 Jul 2006 17:13:21 -0600

Hi Yorh-

I used a technique popularized by Matt Gemmell shortly after the release of the new iTunes appearance. I was unable to locate his post about it, however, so I'm pasting in the method I use to custom paint the window - the code below will use two images and compose them into the "color pattern" used to draw a textured window. Note that the window *must* be textured.

Also of note: the dark color used in the iTunes background is not really appropriate if any of your toolbar items are disabled at any time - a greyed-out icon looks very muddled against the dark background. I ended up modifying the iTunes background in photoshop to have roughly the same "brightness" as the new unified look, but retaining the more metalized appearance of iTunes. You can see the results in my app: http://www.positivespinmedia.com/shareware/Pandora/

Note that all this is just ripped out - you'll need to sub in the proper references to your window, images, etc.

- (void)paintWindow
{
NSColor *bgColor = [[self window] backgroundColor];
NSImage *bg = [[NSImage alloc] initWithSize:[[self window] frame].size];


    [bg lockFocus];

    // Composite current background color into bg
    [bgColor set];
    NSRectFill(NSMakeRect(0, 0, [bg size].width, [bg size].height));

// Composite top "pattern"
NSImage *topMiddleImage = [NSImage imageNamed:@"top_middle2"];
NSColor *topMiddle = [NSColor colorWithPatternImage:topMiddleImage];
[topMiddle set];
[[NSGraphicsContext currentContext] setPatternPhase:NSMakePoint ([bg size].width, [bg size].height)];
NSRectFill(NSMakeRect(0, [bg size].height - [topMiddleImage size].height, [bg size].width, [topMiddleImage size].height));


// Composite bottom-middle "pattern"
NSImage *bottomMiddleImage = [NSImage imageNamed:@"bottom_middle2"];
NSColor *bottomMiddle = [NSColor colorWithPatternImage:bottomMiddleImage];
[bottomMiddle set];
[[NSGraphicsContext currentContext] setPatternPhase:NSMakePoint (0, [bottomMiddleImage size].height)];
NSRectFill(NSMakeRect(0, 0, [bg size].width, [bottomMiddleImage size].height));


    [bg unlockFocus];

[[self window] setBackgroundColor:[NSColor colorWithPatternImage:bg]];

    [bg release];
}

On Jul 6, 2006, at 4:21 AM, Yorh wrote:

Hi to all,

I built an NSToolbar programmatically with the standard methods.
Now I would like to use a background image on it (is a darken grey image like iTunes).
Anyone knows how can I do?

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >darken grey NSToolbar (From: Yorh <email@hidden>)

  • Prev by Date: Re: iTunes-like progress bar
  • Next by Date: My revisions to DragAndDropOutlineEdit
  • Previous by thread: darken grey NSToolbar
  • Next by thread: Re: darken grey NSToolbar
  • Index(es):
    • Date
    • Thread