Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 return ResourceBundle::GetSharedInstance(). | 127 return ResourceBundle::GetSharedInstance(). |
| 128 GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size(); | 128 GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void AppMenuButton::ScheduleAppMenuIconPaint() { | 131 void AppMenuButton::ScheduleAppMenuIconPaint() { |
| 132 SchedulePaint(); | 132 SchedulePaint(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void AppMenuButton::UpdateIcon() { | 135 void AppMenuButton::UpdateIcon() { |
| 136 DCHECK(ui::MaterialDesignController::IsModeMaterial()); | 136 DCHECK(ui::MaterialDesignController::IsModeMaterial()); |
| 137 gfx::VectorIconId icon_id = gfx::VectorIconId::BROWSER_TOOLS; | |
| 137 SkColor color = gfx::kPlaceholderColor; | 138 SkColor color = gfx::kPlaceholderColor; |
| 138 switch (severity_) { | 139 switch (severity_) { |
| 139 case AppMenuIconPainter::SEVERITY_NONE: | 140 case AppMenuIconPainter::SEVERITY_NONE: |
| 140 color = GetThemeProvider()->GetColor( | 141 color = GetThemeProvider()->GetColor( |
| 141 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); | 142 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); |
| 142 break; | 143 break; |
| 143 case AppMenuIconPainter::SEVERITY_LOW: | 144 case AppMenuIconPainter::SEVERITY_LOW: |
| 144 color = gfx::kGoogleGreen700; | 145 color = gfx::kGoogleGreen700; |
| 146 icon_id = gfx::VectorIconId::UPDATE_MENU_SEVERITY_LOW; | |
| 145 break; | 147 break; |
| 146 case AppMenuIconPainter::SEVERITY_MEDIUM: | 148 case AppMenuIconPainter::SEVERITY_MEDIUM: |
| 147 color = gfx::kGoogleYellow700; | 149 color = gfx::kGoogleYellow700; |
| 150 icon_id = gfx::VectorIconId::UPDATE_MENU_SEVERITY_MEDIUM; | |
| 148 break; | 151 break; |
| 149 case AppMenuIconPainter::SEVERITY_HIGH: | 152 case AppMenuIconPainter::SEVERITY_HIGH: |
| 150 color = gfx::kGoogleRed700; | 153 color = gfx::kGoogleRed700; |
| 154 icon_id = gfx::VectorIconId::UPDATE_MENU_SEVERITY_HIGH; | |
| 151 break; | 155 break; |
| 152 } | 156 } |
|
kylix_rd
2016/05/10 14:20:10
TODO: Determine other state information to select
Evan Stade
2016/05/10 16:48:14
You're assuming the menu is changing color due to
kylix_rd
2016/05/10 17:49:01
The AppMenuBadgeController doesn't update the Badg
Evan Stade
2016/05/10 18:04:13
I suppose it must, or the logic of mapping state t
kylix_rd
2016/05/10 18:10:51
I've arrived at the same conclusion. A subsequent
Evan Stade
2016/05/10 18:48:39
no. First step would be to see if designers actual
kylix_rd
2016/05/10 19:17:02
Ah, so the question was more rhetorical and specul
| |
| 153 | 157 |
| 154 SetImage(views::Button::STATE_NORMAL, | 158 SetImage(views::Button::STATE_NORMAL, gfx::CreateVectorIcon(icon_id, color)); |
|
kylix_rd
2016/05/10 16:23:47
In seems that calling this gfx::CreateVectorIcon()
Evan Stade
2016/05/10 16:48:14
hardcode a value (16)
kylix_rd
2016/05/10 17:49:01
Done.
| |
| 155 gfx::CreateVectorIcon(gfx::VectorIconId::BROWSER_TOOLS, color)); | |
| 156 } | 159 } |
| 157 | 160 |
| 158 void AppMenuButton::SetTrailingMargin(int margin) { | 161 void AppMenuButton::SetTrailingMargin(int margin) { |
| 159 margin_trailing_ = margin; | 162 margin_trailing_ = margin; |
| 160 | 163 |
| 161 UpdateThemedBorder(); | 164 UpdateThemedBorder(); |
| 162 | 165 |
| 163 const int inset = LabelButton::kFocusRectInset; | 166 const int inset = LabelButton::kFocusRectInset; |
| 164 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( | 167 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( |
| 165 gfx::Insets(inset, inset, inset, inset + margin))); | 168 gfx::Insets(inset, inset, inset, inset + margin))); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 views::MenuButton::OnPaint(canvas); | 247 views::MenuButton::OnPaint(canvas); |
| 245 if (ui::MaterialDesignController::IsModeMaterial()) | 248 if (ui::MaterialDesignController::IsModeMaterial()) |
| 246 return; | 249 return; |
| 247 // Use GetPreferredSize() to center the icon inside the visible bounds rather | 250 // 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 | 251 // than the whole size() (which may refer to hit test region extended to the |
| 249 // end of the toolbar in maximized mode). | 252 // end of the toolbar in maximized mode). |
| 250 icon_painter_->Paint(canvas, GetThemeProvider(), | 253 icon_painter_->Paint(canvas, GetThemeProvider(), |
| 251 gfx::Rect(GetPreferredSize()), | 254 gfx::Rect(GetPreferredSize()), |
| 252 AppMenuIconPainter::BEZEL_NONE); | 255 AppMenuIconPainter::BEZEL_NONE); |
| 253 } | 256 } |
| OLD | NEW |