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

Side by Side Diff: chrome/browser/ui/views/toolbar/app_menu_button.cc

Issue 1966643002: Integrate new MD update menu icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Uses the BadgeType to select the severity-warning icon. Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" 5 #include "chrome/browser/ui/views/toolbar/app_menu_button.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 ink_drop_delegate_(new views::ButtonInkDropDelegate(this, this)), 44 ink_drop_delegate_(new views::ButtonInkDropDelegate(this, this)),
45 weak_factory_(this) { 45 weak_factory_(this) {
46 set_ink_drop_delegate(ink_drop_delegate_.get()); 46 set_ink_drop_delegate(ink_drop_delegate_.get());
47 if (!ui::MaterialDesignController::IsModeMaterial()) 47 if (!ui::MaterialDesignController::IsModeMaterial())
48 icon_painter_.reset(new AppMenuIconPainter(this)); 48 icon_painter_.reset(new AppMenuIconPainter(this));
49 } 49 }
50 50
51 AppMenuButton::~AppMenuButton() {} 51 AppMenuButton::~AppMenuButton() {}
52 52
53 void AppMenuButton::SetSeverity(AppMenuIconPainter::Severity severity, 53 void AppMenuButton::SetSeverity(AppMenuIconPainter::Severity severity,
54 AppMenuBadgeController::BadgeType type,
54 bool animate) { 55 bool animate) {
55 if (ui::MaterialDesignController::IsModeMaterial()) { 56 if (ui::MaterialDesignController::IsModeMaterial()) {
56 severity_ = severity; 57 severity_ = severity;
58 type_ = type;
57 UpdateIcon(); 59 UpdateIcon();
58 return; 60 return;
59 } 61 }
60 62
61 icon_painter_->SetSeverity(severity, animate); 63 icon_painter_->SetSeverity(severity, animate);
62 SchedulePaint(); 64 SchedulePaint();
63 } 65 }
64 66
65 void AppMenuButton::ShowMenu(bool for_drop) { 67 void AppMenuButton::ShowMenu(bool for_drop) {
66 if (menu_ && menu_->IsShowing()) 68 if (menu_ && menu_->IsShowing())
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 return ResourceBundle::GetSharedInstance(). 129 return ResourceBundle::GetSharedInstance().
128 GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size(); 130 GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size();
129 } 131 }
130 132
131 void AppMenuButton::ScheduleAppMenuIconPaint() { 133 void AppMenuButton::ScheduleAppMenuIconPaint() {
132 SchedulePaint(); 134 SchedulePaint();
133 } 135 }
134 136
135 void AppMenuButton::UpdateIcon() { 137 void AppMenuButton::UpdateIcon() {
136 DCHECK(ui::MaterialDesignController::IsModeMaterial()); 138 DCHECK(ui::MaterialDesignController::IsModeMaterial());
139 gfx::VectorIconId icon_id = gfx::VectorIconId::BROWSER_TOOLS;
137 SkColor color = gfx::kPlaceholderColor; 140 SkColor color = gfx::kPlaceholderColor;
138 switch (severity_) { 141 switch (severity_) {
139 case AppMenuIconPainter::SEVERITY_NONE: 142 case AppMenuIconPainter::SEVERITY_NONE:
140 color = GetThemeProvider()->GetColor( 143 color = GetThemeProvider()->GetColor(
141 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); 144 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
142 break; 145 break;
143 case AppMenuIconPainter::SEVERITY_LOW: 146 case AppMenuIconPainter::SEVERITY_LOW:
144 color = gfx::kGoogleGreen700; 147 color = gfx::kGoogleGreen700;
148 icon_id = gfx::VectorIconId::UPDATE_MENU_SEVERITY_LOW;
145 break; 149 break;
146 case AppMenuIconPainter::SEVERITY_MEDIUM: 150 case AppMenuIconPainter::SEVERITY_MEDIUM:
147 color = gfx::kGoogleYellow700; 151 color = gfx::kGoogleYellow700;
152 if (type_ == AppMenuBadgeController::BADGE_TYPE_GLOBAL_ERROR)
153 icon_id = gfx::VectorIconId::UPDATE_MENU_FAILED;
154 else if (type_ ==
155 AppMenuBadgeController::BADGE_TYPE_INCOMPATIBILITY_WARNING)
Peter Kasting 2016/05/11 19:16:46 The long names for the enum values are causing str
kylix_rd 2016/05/11 19:54:43 Should this kind of refactoring work be a separate
Peter Kasting 2016/05/11 19:57:48 There's no formal rule, it's basically a judgment
156 icon_id = gfx::VectorIconId::UPDATE_MENU_SEVERITY_WARNING;
157 else
158 icon_id = gfx::VectorIconId::UPDATE_MENU_SEVERITY_MEDIUM;
148 break; 159 break;
149 case AppMenuIconPainter::SEVERITY_HIGH: 160 case AppMenuIconPainter::SEVERITY_HIGH:
150 color = gfx::kGoogleRed700; 161 color = gfx::kGoogleRed700;
162 icon_id = gfx::VectorIconId::UPDATE_MENU_SEVERITY_HIGH;
151 break; 163 break;
152 } 164 }
153 165
154 SetImage(views::Button::STATE_NORMAL, 166 SetImage(views::Button::STATE_NORMAL,
155 gfx::CreateVectorIcon(gfx::VectorIconId::BROWSER_TOOLS, color)); 167 gfx::CreateVectorIcon(icon_id, 16, color));
156 } 168 }
157 169
158 void AppMenuButton::SetTrailingMargin(int margin) { 170 void AppMenuButton::SetTrailingMargin(int margin) {
159 margin_trailing_ = margin; 171 margin_trailing_ = margin;
160 172
161 UpdateThemedBorder(); 173 UpdateThemedBorder();
162 174
163 const int inset = LabelButton::kFocusRectInset; 175 const int inset = LabelButton::kFocusRectInset;
164 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( 176 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets(
165 gfx::Insets(inset, inset, inset, inset + margin))); 177 gfx::Insets(inset, inset, inset, inset + margin)));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 views::MenuButton::OnPaint(canvas); 256 views::MenuButton::OnPaint(canvas);
245 if (ui::MaterialDesignController::IsModeMaterial()) 257 if (ui::MaterialDesignController::IsModeMaterial())
246 return; 258 return;
247 // Use GetPreferredSize() to center the icon inside the visible bounds rather 259 // Use GetPreferredSize() to center the icon inside the visible bounds rather
248 // than the whole size() (which may refer to hit test region extended to the 260 // than the whole size() (which may refer to hit test region extended to the
249 // end of the toolbar in maximized mode). 261 // end of the toolbar in maximized mode).
250 icon_painter_->Paint(canvas, GetThemeProvider(), 262 icon_painter_->Paint(canvas, GetThemeProvider(),
251 gfx::Rect(GetPreferredSize()), 263 gfx::Rect(GetPreferredSize()),
252 AppMenuIconPainter::BEZEL_NONE); 264 AppMenuIconPainter::BEZEL_NONE);
253 } 265 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698