Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3464)

Unified Diff: chrome/browser/ui/cocoa/extensions/browser_action_button.mm

Issue 10907212: mac: Switch browser action backgrounds from vectors to bitmaps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/browser_action_button.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/extensions/browser_action_button.mm
diff --git a/chrome/browser/ui/cocoa/extensions/browser_action_button.mm b/chrome/browser/ui/cocoa/extensions/browser_action_button.mm
index a2d31c39a4acf592091d48d5701ac242876f58e6..14fe67ee6b3dc00581c8204019bbbb40162cb967 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];
}
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/browser_action_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698