diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-07 20:59:00 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-07 20:59:00 +0000 |
commit | 875f8f9b0757f2029b21cead7822db116ea525e0 (patch) | |
tree | 2e5007bd2cbfed52d50080205ae62d37a58fc375 /chrome/browser/cocoa | |
parent | 248e1623b3943775a94ca3cee125f02788549e3e (diff) | |
download | chromium_src-875f8f9b0757f2029b21cead7822db116ea525e0.zip chromium_src-875f8f9b0757f2029b21cead7822db116ea525e0.tar.gz chromium_src-875f8f9b0757f2029b21cead7822db116ea525e0.tar.bz2 |
[Mac] Fix themes drawing code to properly position the theme in fullscreen windows and to properly blend transparent themes with black. Also adds a way to pass an offset in to the theme drawing code.
BUG=40213
TEST=Android robot theme should draw properly, not be pure black.
Review URL: http://codereview.chromium.org/1527020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43875 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/browser_frame_view.h | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_frame_view.mm | 34 | ||||
-rw-r--r-- | chrome/browser/cocoa/floating_bar_backing_view.mm | 6 |
3 files changed, 35 insertions, 9 deletions
diff --git a/chrome/browser/cocoa/browser_frame_view.h b/chrome/browser/cocoa/browser_frame_view.h index 6505dfb..42faa9b 100644 --- a/chrome/browser/cocoa/browser_frame_view.h +++ b/chrome/browser/cocoa/browser_frame_view.h @@ -55,7 +55,9 @@ // count). + (BOOL)drawWindowThemeInDirtyRect:(NSRect)dirtyRect forView:(NSView*)view - bounds:(NSRect)bounds; + bounds:(NSRect)bounds + offset:(NSPoint)offset + forceBlackBackground:(BOOL)forceBlackBackground; // Gets the color to draw title text. + (NSColor*)titleColorForThemeView:(NSView*)view; diff --git a/chrome/browser/cocoa/browser_frame_view.mm b/chrome/browser/cocoa/browser_frame_view.mm index 3937cc2..dfc8003 100644 --- a/chrome/browser/cocoa/browser_frame_view.mm +++ b/chrome/browser/cocoa/browser_frame_view.mm @@ -151,7 +151,9 @@ static BOOL gCanGetCornerRadius = NO; // Do the theming. BOOL themed = [BrowserFrameView drawWindowThemeInDirtyRect:rect forView:self - bounds:windowRect]; + bounds:windowRect + offset:NSZeroPoint + forceBlackBackground:NO]; // If the window needs a title and we painted over the title as drawn by the // default window paint, paint it ourselves. @@ -180,7 +182,9 @@ static BOOL gCanGetCornerRadius = NO; + (BOOL)drawWindowThemeInDirtyRect:(NSRect)dirtyRect forView:(NSView*)view - bounds:(NSRect)bounds { + bounds:(NSRect)bounds + offset:(NSPoint)offset + forceBlackBackground:(BOOL)forceBlackBackground { ThemeProvider* themeProvider = [[view window] themeProvider]; if (!themeProvider) return NO; @@ -231,19 +235,34 @@ static BOOL gCanGetCornerRadius = NO; // This will make the themes look slightly different than in Windows/Linux // because of the differing heights between window top and tab top, but this // has been approved by UI. + NSView* frameView = [[[view window] contentView] superview]; + NSPoint topLeft = NSMakePoint(NSMinX(bounds), NSMaxY(bounds)); + NSPoint topLeftInFrameCoordinates = + [view convertPoint:topLeft toView:frameView]; + NSPoint phase = kBrowserFrameViewPatternPhaseOffset; - phase.y += NSHeight(bounds); + phase.x += (offset.x + topLeftInFrameCoordinates.x); + phase.y += (offset.y + topLeftInFrameCoordinates.y); // Align the phase to physical pixels so resizing the window under HiDPI // doesn't cause wiggling of the theme. - phase = [view convertPointToBase:phase]; + phase = [frameView convertPointToBase:phase]; phase.x = floor(phase.x); phase.y = floor(phase.y); - phase = [view convertPointFromBase:phase]; + phase = [frameView convertPointFromBase:phase]; + + // Default to replacing any existing pixels with the theme image, but if + // asked paint black first and blend the theme with black. + NSCompositingOperation operation = NSCompositeCopy; + if (forceBlackBackground) { + [[NSColor blackColor] set]; + NSRectFill(dirtyRect); + operation = NSCompositeSourceOver; + } [[NSGraphicsContext currentContext] setPatternPhase:phase]; [themeImageColor set]; - NSRectFill(dirtyRect); + NSRectFillUsingOperation(dirtyRect, operation); themed = YES; } else if (gradient) { NSPoint startPoint = NSMakePoint(NSMinX(bounds), NSMaxY(bounds)); @@ -266,7 +285,8 @@ static BOOL gCanGetCornerRadius = NO; // Anchor to top-left and don't scale. NSSize overlaySize = [overlayImage size]; NSRect imageFrame = NSMakeRect(0, 0, overlaySize.width, overlaySize.height); - [overlayImage drawAtPoint:NSMakePoint(0, NSHeight(bounds) - + [overlayImage drawAtPoint:NSMakePoint(offset.x, + NSHeight(bounds) + offset.y - overlaySize.height) fromRect:imageFrame operation:NSCompositeSourceOver diff --git a/chrome/browser/cocoa/floating_bar_backing_view.mm b/chrome/browser/cocoa/floating_bar_backing_view.mm index 5d67e47..a3c1b0f 100644 --- a/chrome/browser/cocoa/floating_bar_backing_view.mm +++ b/chrome/browser/cocoa/floating_bar_backing_view.mm @@ -19,9 +19,13 @@ [[NSColor windowBackgroundColor] set]; NSRectFill(rect); + // TODO(rohitrao): Don't assume -22 here. [BrowserFrameView drawWindowThemeInDirtyRect:rect forView:self - bounds:[self bounds]]; + bounds:[self bounds] + offset:NSMakePoint(0, -22) + forceBlackBackground:YES]; + } // Eat all mouse events (and do *not* pass them on to the next responder!). |