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

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: Removed 'badge' icons and added color and new path to existing icons Created 4 years, 6 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/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "chrome/browser/themes/theme_properties.h" 12 #include "chrome/browser/themes/theme_properties.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_otr_state.h"
14 #include "chrome/browser/ui/layout_constants.h" 15 #include "chrome/browser/ui/layout_constants.h"
15 #include "chrome/browser/ui/toolbar/app_menu_model.h" 16 #include "chrome/browser/ui/toolbar/app_menu_model.h"
16 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" 17 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h"
17 #include "chrome/browser/ui/views/toolbar/app_menu.h" 18 #include "chrome/browser/ui/views/toolbar/app_menu.h"
18 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 19 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
19 #include "extensions/common/feature_switch.h" 20 #include "extensions/common/feature_switch.h"
20 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
21 #include "ui/base/material_design/material_design_controller.h" 22 #include "ui/base/material_design/material_design_controller.h"
22 #include "ui/base/resource/resource_bundle.h" 23 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/base/theme_provider.h" 24 #include "ui/base/theme_provider.h"
(...skipping 20 matching lines...) Expand all
44 weak_factory_(this) { 45 weak_factory_(this) {
45 set_ink_drop_delegate( 46 set_ink_drop_delegate(
46 base::WrapUnique(new views::ButtonInkDropDelegate(this, this))); 47 base::WrapUnique(new views::ButtonInkDropDelegate(this, this)));
47 if (!ui::MaterialDesignController::IsModeMaterial()) 48 if (!ui::MaterialDesignController::IsModeMaterial())
48 icon_painter_.reset(new AppMenuIconPainter(this)); 49 icon_painter_.reset(new AppMenuIconPainter(this));
49 } 50 }
50 51
51 AppMenuButton::~AppMenuButton() {} 52 AppMenuButton::~AppMenuButton() {}
52 53
53 void AppMenuButton::SetSeverity(AppMenuIconPainter::Severity severity, 54 void AppMenuButton::SetSeverity(AppMenuIconPainter::Severity severity,
55 AppMenuBadgeController::BadgeType type,
54 bool animate) { 56 bool animate) {
55 if (ui::MaterialDesignController::IsModeMaterial()) { 57 if (ui::MaterialDesignController::IsModeMaterial()) {
56 severity_ = severity; 58 severity_ = severity;
59 type_ = type;
57 UpdateIcon(); 60 UpdateIcon();
58 return; 61 return;
59 } 62 }
60 63
61 icon_painter_->SetSeverity(severity, animate); 64 icon_painter_->SetSeverity(severity, animate);
62 SchedulePaint(); 65 SchedulePaint();
63 } 66 }
64 67
65 void AppMenuButton::ShowMenu(bool for_drop) { 68 void AppMenuButton::ShowMenu(bool for_drop) {
66 if (menu_ && menu_->IsShowing()) 69 if (menu_ && menu_->IsShowing())
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 129
127 return ResourceBundle::GetSharedInstance(). 130 return ResourceBundle::GetSharedInstance().
128 GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size(); 131 GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size();
129 } 132 }
130 133
131 void AppMenuButton::ScheduleAppMenuIconPaint() { 134 void AppMenuButton::ScheduleAppMenuIconPaint() {
132 SchedulePaint(); 135 SchedulePaint();
133 } 136 }
134 137
135 void AppMenuButton::UpdateIcon() { 138 void AppMenuButton::UpdateIcon() {
139 using BadgeType = AppMenuBadgeController::BadgeType;
136 DCHECK(ui::MaterialDesignController::IsModeMaterial()); 140 DCHECK(ui::MaterialDesignController::IsModeMaterial());
141 gfx::VectorIconId icon_id = gfx::VectorIconId::BROWSER_TOOLS;
137 SkColor color = gfx::kPlaceholderColor; 142 SkColor color = gfx::kPlaceholderColor;
138 switch (severity_) { 143 switch (severity_) {
139 case AppMenuIconPainter::SEVERITY_NONE: 144 case AppMenuIconPainter::SEVERITY_NONE:
140 color = GetThemeProvider()->GetColor( 145 color = GetThemeProvider()->GetColor(
141 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); 146 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
142 break; 147 break;
143 case AppMenuIconPainter::SEVERITY_LOW: 148 case AppMenuIconPainter::SEVERITY_LOW:
144 color = gfx::kGoogleGreen700; 149 color = gfx::kGoogleGreen700;
150 icon_id = gfx::VectorIconId::UPDATE_MENU_SEVERITY_LOW_MEDIUM_HIGH;
145 break; 151 break;
146 case AppMenuIconPainter::SEVERITY_MEDIUM: 152 case AppMenuIconPainter::SEVERITY_MEDIUM:
147 color = gfx::kGoogleYellow700; 153 color = gfx::kGoogleYellow700;
154 if (type_ == BadgeType::GLOBAL_ERROR)
155 icon_id = gfx::VectorIconId::UPDATE_MENU_FAILED;
156 else if (type_ == BadgeType::INCOMPATIBILITY_WARNING)
157 icon_id = gfx::VectorIconId::UPDATE_MENU_SEVERITY_WARNING;
158 else
159 icon_id = gfx::VectorIconId::UPDATE_MENU_SEVERITY_LOW_MEDIUM_HIGH;
Evan Stade 2016/06/03 18:58:14 it seems like icon id and color should be orthogon
kylix_rd 2016/06/03 19:27:14 Done.
148 break; 160 break;
149 case AppMenuIconPainter::SEVERITY_HIGH: 161 case AppMenuIconPainter::SEVERITY_HIGH:
150 color = gfx::kGoogleRed700; 162 color = gfx::kGoogleRed700;
163 icon_id = gfx::VectorIconId::UPDATE_MENU_SEVERITY_LOW_MEDIUM_HIGH;
151 break; 164 break;
152 } 165 }
153 166
154 SetImage(views::Button::STATE_NORMAL, 167 SetImage(views::Button::STATE_NORMAL,
155 gfx::CreateVectorIcon(gfx::VectorIconId::BROWSER_TOOLS, color)); 168 gfx::CreateVectorIcon(icon_id, 16, color));
156 } 169 }
157 170
158 void AppMenuButton::SetTrailingMargin(int margin) { 171 void AppMenuButton::SetTrailingMargin(int margin) {
159 margin_trailing_ = margin; 172 margin_trailing_ = margin;
160 173
161 UpdateThemedBorder(); 174 UpdateThemedBorder();
162 175
163 if (!ui::MaterialDesignController::IsModeMaterial()) { 176 if (!ui::MaterialDesignController::IsModeMaterial()) {
164 const int inset = LabelButton::kFocusRectInset; 177 const int inset = LabelButton::kFocusRectInset;
165 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( 178 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets(
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 views::MenuButton::OnPaint(canvas); 260 views::MenuButton::OnPaint(canvas);
248 if (ui::MaterialDesignController::IsModeMaterial()) 261 if (ui::MaterialDesignController::IsModeMaterial())
249 return; 262 return;
250 // Use GetPreferredSize() to center the icon inside the visible bounds rather 263 // Use GetPreferredSize() to center the icon inside the visible bounds rather
251 // than the whole size() (which may refer to hit test region extended to the 264 // than the whole size() (which may refer to hit test region extended to the
252 // end of the toolbar in maximized mode). 265 // end of the toolbar in maximized mode).
253 icon_painter_->Paint(canvas, GetThemeProvider(), 266 icon_painter_->Paint(canvas, GetThemeProvider(),
254 gfx::Rect(GetPreferredSize()), 267 gfx::Rect(GetPreferredSize()),
255 AppMenuIconPainter::BEZEL_NONE); 268 AppMenuIconPainter::BEZEL_NONE);
256 } 269 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698