| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "chrome/browser/ui/cocoa/toolbar/app_toolbar_button.h" |
| 6 |
| 7 #include "base/macros.h" |
| 8 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 9 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| 10 |
| 11 class AppMenuButtonIconPainterDelegateMac : |
| 12 public AppMenuIconPainter::Delegate { |
| 13 public: |
| 14 explicit AppMenuButtonIconPainterDelegateMac(NSButton* button) : |
| 15 button_(button) {} |
| 16 ~AppMenuButtonIconPainterDelegateMac() override {} |
| 17 |
| 18 void ScheduleAppMenuIconPaint() override { |
| 19 [button_ setNeedsDisplay:YES]; |
| 20 } |
| 21 |
| 22 private: |
| 23 NSButton* button_; |
| 24 |
| 25 DISALLOW_COPY_AND_ASSIGN(AppMenuButtonIconPainterDelegateMac); |
| 26 }; |
| 27 |
| 28 @interface AppToolbarButton () |
| 29 - (void)commonInit; |
| 30 @end |
| 31 |
| 32 @implementation AppToolbarButton |
| 33 |
| 34 - (instancetype)initWithFrame:(NSRect)frame { |
| 35 if ((self = [super initWithFrame:frame])) { |
| 36 [self commonInit]; |
| 37 } |
| 38 return self; |
| 39 } |
| 40 |
| 41 - (void)awakeFromNib { |
| 42 [self commonInit]; |
| 43 } |
| 44 |
| 45 - (void)commonInit { |
| 46 view_id_util::SetID(self, VIEW_ID_APP_MENU); |
| 47 delegate_.reset(new AppMenuButtonIconPainterDelegateMac(self)); |
| 48 severity_ = AppMenuIconPainter::Severity::SEVERITY_NONE; |
| 49 } |
| 50 |
| 51 - (SkColor)iconColor:(BOOL)themeIsDark { |
| 52 const SkColor normalColor = SkColorSetRGB(0x5A, 0x5A, 0x5A); |
| 53 const SkColor normalIncognitoColor = SkColorSetRGB(0xFF, 0xFF, 0xFF); |
| 54 const SkColor severityMedColor = SkColorSetRGB(0xF0, 0x93, 0x00); |
| 55 const SkColor severityMedIncognitoColor = SkColorSetRGB(0xF7, 0xCB, 0x4D); |
| 56 const SkColor severityHighColor = SkColorSetRGB(0xC5, 0x39, 0x29); |
| 57 const SkColor severityHighIncognitoColor = SkColorSetRGB(0xE6, 0x73, 0x7C); |
| 58 |
| 59 switch (severity_) { |
| 60 case AppMenuIconPainter::Severity::SEVERITY_NONE: |
| 61 case AppMenuIconPainter::Severity::SEVERITY_LOW: |
| 62 return themeIsDark ? normalIncognitoColor : normalColor; |
| 63 break; |
| 64 |
| 65 case AppMenuIconPainter::Severity::SEVERITY_MEDIUM: |
| 66 return themeIsDark ? severityMedIncognitoColor : severityMedColor; |
| 67 break; |
| 68 |
| 69 case AppMenuIconPainter::Severity::SEVERITY_HIGH: |
| 70 return themeIsDark ? severityHighIncognitoColor : severityHighColor; |
| 71 break; |
| 72 |
| 73 default: |
| 74 break; |
| 75 } |
| 76 } |
| 77 |
| 78 - (void)setSeverity:(AppMenuIconPainter::Severity)severity |
| 79 shouldAnimate:(BOOL)shouldAnimate { |
| 80 if (severity != severity_) { |
| 81 severity_ = severity; |
| 82 [self setImagesFromIconId:gfx::VectorIconId::BROWSER_TOOLS]; |
| 83 [self setNeedsDisplay:YES]; |
| 84 } |
| 85 } |
| 86 |
| 87 @end |
| OLD | NEW |