| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/mac/sdk_forward_declarations.h" | 8 #include "base/mac/sdk_forward_declarations.h" |
| 9 #import "chrome/browser/ui/cocoa/image_button_cell.h" | 9 #import "chrome/browser/ui/cocoa/image_button_cell.h" |
| 10 #import "chrome/browser/ui/cocoa/view_id_util.h" | 10 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| 11 #include "skia/ext/skia_utils_mac.h" | 11 #include "skia/ext/skia_utils_mac.h" |
| 12 #import "ui/base/cocoa/nsview_additions.h" | 12 #import "ui/base/cocoa/nsview_additions.h" |
| 13 #include "ui/base/material_design/material_design_controller.h" | 13 #include "ui/base/material_design/material_design_controller.h" |
| 14 #include "ui/base/theme_provider.h" | 14 #include "ui/base/theme_provider.h" |
| 15 #include "ui/gfx/image/image_skia_util_mac.h" | 15 #include "ui/gfx/image/image_skia_util_mac.h" |
| 16 #include "ui/gfx/paint_vector_icon.h" | 16 #include "ui/gfx/paint_vector_icon.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // The bounds of toolbar buttons in Material Design. | 20 // Toolbar buttons are 24x24 in Material Design. |
| 21 const NSRect kMDButtonBounds = NSMakeRect(0, 0, 28, 28); | 21 const NSRect kMDButtonBounds = NSMakeRect(0, 0, 24, 24); |
| 22 | 22 |
| 23 // The size of a toolbar button icon in Material Design. A toolbar button image | 23 // The size of a toolbar button icon in Material Design. A toolbar button image |
| 24 // consists of a border and background, with a centered icon. | 24 // consists of a border and background, with a centered icon. |
| 25 const NSSize kMDButtonIconSize = NSMakeSize(16, 16); | 25 const NSSize kMDButtonIconSize = NSMakeSize(16, 16); |
| 26 | 26 |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| 29 // An NSCustomImageRep subclass that creates the "three dots" image of the | 29 // An NSCustomImageRep subclass that creates the "three dots" image of the |
| 30 // Material Design browser tools icon. | 30 // Material Design browser tools icon. |
| 31 @interface BrowserToolsImageRep : NSCustomImageRep | 31 @interface BrowserToolsImageRep : NSCustomImageRep |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 @synthesize icon = icon_; | 72 @synthesize icon = icon_; |
| 73 @synthesize style = style_; | 73 @synthesize style = style_; |
| 74 | 74 |
| 75 - (void)dealloc { | 75 - (void)dealloc { |
| 76 [icon_ release]; | 76 [icon_ release]; |
| 77 [super dealloc]; | 77 [super dealloc]; |
| 78 } | 78 } |
| 79 | 79 |
| 80 + (void)drawImage:(ToolbarButtonImageRep*)imageRep { | 80 + (void)drawImage:(ToolbarButtonImageRep*)imageRep { |
| 81 // Create the path used for the background fill. | 81 // Create the path used for the background fill. |
| 82 NSRect destRect = NSInsetRect(kMDButtonBounds, 2, 2); | |
| 83 NSBezierPath* roundedRectPath = | 82 NSBezierPath* roundedRectPath = |
| 84 [NSBezierPath bezierPathWithRoundedRect:destRect xRadius:2 yRadius:2]; | 83 [NSBezierPath bezierPathWithRoundedRect:kMDButtonBounds |
| 84 xRadius:2 |
| 85 yRadius:2]; |
| 85 | 86 |
| 86 // Determine the fill color. | 87 // Determine the fill color. |
| 87 NSColor* fillColor = nil; | 88 NSColor* fillColor = nil; |
| 88 switch (imageRep.style) { | 89 switch (imageRep.style) { |
| 89 case ToolbarButtonImageBackgroundStyle::HOVER: | 90 case ToolbarButtonImageBackgroundStyle::HOVER: |
| 90 fillColor = [NSColor colorWithCalibratedWhite:0 alpha:0.08]; | 91 fillColor = [NSColor colorWithCalibratedWhite:0 alpha:0.08]; |
| 91 break; | 92 break; |
| 92 case ToolbarButtonImageBackgroundStyle::HOVER_THEMED: | 93 case ToolbarButtonImageBackgroundStyle::HOVER_THEMED: |
| 93 fillColor = [NSColor colorWithCalibratedWhite:1 alpha:0.08]; | 94 fillColor = [NSColor colorWithCalibratedWhite:1 alpha:0.08]; |
| 94 break; | 95 break; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 // Update the hover and pressed image backgrounds to match the current theme. | 352 // Update the hover and pressed image backgrounds to match the current theme. |
| 352 if (ui::MaterialDesignController::IsModeMaterial()) { | 353 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 353 [self resetButtonStateImages]; | 354 [self resetButtonStateImages]; |
| 354 } | 355 } |
| 355 } | 356 } |
| 356 | 357 |
| 357 - (void)windowDidChangeActive { | 358 - (void)windowDidChangeActive { |
| 358 } | 359 } |
| 359 | 360 |
| 360 @end | 361 @end |
| OLD | NEW |