diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-13 13:24:05 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-13 13:24:05 +0000 |
commit | 9bc8295aefb56b29672e9cf7e6326a7133524195 (patch) | |
tree | 8e5b836550673ca083fd9a063b34808be4700636 | |
parent | d647e280bba804d4589e952015122ff4bd8d3463 (diff) | |
download | chromium_src-9bc8295aefb56b29672e9cf7e6326a7133524195.zip chromium_src-9bc8295aefb56b29672e9cf7e6326a7133524195.tar.gz chromium_src-9bc8295aefb56b29672e9cf7e6326a7133524195.tar.bz2 |
mac: Switch browser action backgrounds from vectors to bitmaps
Based on a patch from Andrew Bonventre <andybons@chromium.org>
BUG=111101
TEST=hover a browser action. highlight looks like the highlight on
the reload button.
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/10907212
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156539 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/cocoa/extensions/browser_action_button.h | 4 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/extensions/browser_action_button.mm | 29 |
2 files changed, 23 insertions, 10 deletions
diff --git a/chrome/browser/ui/cocoa/extensions/browser_action_button.h b/chrome/browser/ui/cocoa/extensions/browser_action_button.h index 4ee5231..359ec7a 100644 --- a/chrome/browser/ui/cocoa/extensions/browser_action_button.h +++ b/chrome/browser/ui/cocoa/extensions/browser_action_button.h @@ -9,7 +9,7 @@ #import "base/memory/scoped_nsobject.h" #include "base/memory/scoped_ptr.h" -#import "chrome/browser/ui/cocoa/gradient_button_cell.h" +#import "chrome/browser/ui/cocoa/image_button_cell.h" class Browser; class ExtensionAction; @@ -69,7 +69,7 @@ extern NSString* const kBrowserActionButtonDragEndNotification; @end -@interface BrowserActionCell : GradientButtonCell { +@interface BrowserActionCell : ImageButtonCell { @private // The current tab ID used when drawing the cell. int tabId_; diff --git a/chrome/browser/ui/cocoa/extensions/browser_action_button.mm b/chrome/browser/ui/cocoa/extensions/browser_action_button.mm index a2d31c3..14fe67e 100644 --- a/chrome/browser/ui/cocoa/extensions/browser_action_button.mm +++ b/chrome/browser/ui/cocoa/extensions/browser_action_button.mm @@ -36,11 +36,8 @@ NSString* const kBrowserActionButtonDraggingNotification = NSString* const kBrowserActionButtonDragEndNotification = @"BrowserActionButtonDragEndNotification"; -static const CGFloat kBrowserActionBadgeOriginYOffset = 5; - -namespace { +const CGFloat kBrowserActionBadgeOriginYOffset = 5; const CGFloat kAnimationDuration = 0.2; -} // anonymous namespace // A helper class to bridge the asynchronous Skia bitmap loading mechanism to // the extension's button. @@ -137,6 +134,12 @@ class ExtensionImageTrackerBridge : public content::NotificationObserver, [cell accessibilitySetOverrideValue:base::SysUTF8ToNSString(extension->name()) forAttribute:NSAccessibilityDescriptionAttribute]; + [cell setImageID:IDR_BROWSER_ACTION + forButtonState:image_button_cell::kDefaultState]; + [cell setImageID:IDR_BROWSER_ACTION_H + forButtonState:image_button_cell::kHoverState]; + [cell setImageID:IDR_BROWSER_ACTION_P + forButtonState:image_button_cell::kPressedState]; [self setTitle:@""]; [self setButtonType:NSMomentaryChangeButton]; @@ -214,8 +217,7 @@ class ExtensionImageTrackerBridge : public content::NotificationObserver, - (void)endDrag { isBeingDragged_ = NO; [[NSNotificationCenter defaultCenter] - postNotificationName:kBrowserActionButtonDragEndNotification - object:self]; + postNotificationName:kBrowserActionButtonDragEndNotification object:self]; [[self cell] setHighlighted:NO]; } @@ -306,9 +308,20 @@ class ExtensionImageTrackerBridge : public content::NotificationObserver, extensionAction_->PaintBadge(&canvas, boundingRect, tabId_); } -- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { +- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { gfx::ScopedNSGraphicsContextSaveGState scopedGState; - [super drawInteriorWithFrame:cellFrame inView:controlView]; + [super drawWithFrame:cellFrame inView:controlView]; + const NSSize imageSize = self.image.size; + const NSRect imageRect = + NSMakeRect(std::floor((NSWidth(cellFrame) - imageSize.width) / 2.0), + std::floor((NSHeight(cellFrame) - imageSize.height) / 2.0), + imageSize.width, imageSize.height); + [self.image drawInRect:imageRect + fromRect:NSZeroRect + operation:NSCompositeSourceOver + fraction:1.0 + neverFlipped:YES]; + cellFrame.origin.y += kBrowserActionBadgeOriginYOffset; [self drawBadgeWithinFrame:cellFrame]; } |