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

Unified Diff: ash/common/system/tray/tray_popup_header_button.cc

Issue 2264383002: More closely align palette to spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tool-magnifier
Patch Set: Add fs to icon numbers Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/tray/tray_popup_header_button.h ('k') | ui/gfx/vector_icons/help.icon » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/tray/tray_popup_header_button.cc
diff --git a/ash/common/system/tray/tray_popup_header_button.cc b/ash/common/system/tray/tray_popup_header_button.cc
index bb15d503600002a69ca0f4375af118ccb5f9873b..213a0a0cea7b8a47a5cae5c7f97aaf529daee682 100644
--- a/ash/common/system/tray/tray_popup_header_button.cc
+++ b/ash/common/system/tray/tray_popup_header_button.cc
@@ -12,24 +12,24 @@
namespace ash {
+namespace {
+
+const gfx::ImageSkia* GetImageForResourceId(int resource_id) {
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ return bundle.GetImageNamed(resource_id).ToImageSkia();
+}
+
+} // namespace
+
// static
const char TrayPopupHeaderButton::kViewClassName[] =
"tray/TrayPopupHeaderButton";
TrayPopupHeaderButton::TrayPopupHeaderButton(views::ButtonListener* listener,
- int icon_resource_id,
+ const gfx::ImageSkia& icon,
int accessible_name_id)
: views::ToggleImageButton(listener) {
- ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
- SetImage(views::Button::STATE_NORMAL,
- bundle.GetImageNamed(icon_resource_id).ToImageSkia());
- SetImageAlignment(views::ImageButton::ALIGN_CENTER,
- views::ImageButton::ALIGN_MIDDLE);
- SetAccessibleName(bundle.GetLocalizedString(accessible_name_id));
- SetFocusForPlatform();
-
- SetFocusPainter(views::Painter::CreateSolidFocusPainter(
- kFocusBorderColor, gfx::Insets(1, 2, 2, 3)));
+ Initialize(icon, accessible_name_id);
}
TrayPopupHeaderButton::TrayPopupHeaderButton(views::ButtonListener* listener,
@@ -38,7 +38,8 @@ TrayPopupHeaderButton::TrayPopupHeaderButton(views::ButtonListener* listener,
int enabled_resource_id_hover,
int disabled_resource_id_hover,
int accessible_name_id)
- : TrayPopupHeaderButton(listener, enabled_resource_id, accessible_name_id) {
+ : views::ToggleImageButton(listener) {
+ Initialize(*GetImageForResourceId(enabled_resource_id), accessible_name_id);
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
SetToggledImage(views::Button::STATE_NORMAL,
bundle.GetImageNamed(disabled_resource_id).ToImageSkia());
@@ -70,4 +71,17 @@ void TrayPopupHeaderButton::StateChanged() {
SchedulePaint();
}
+void TrayPopupHeaderButton::Initialize(const gfx::ImageSkia& icon,
+ int accessible_name_id) {
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ SetImage(views::Button::STATE_NORMAL, &icon);
+ SetImageAlignment(views::ImageButton::ALIGN_CENTER,
+ views::ImageButton::ALIGN_MIDDLE);
+ SetAccessibleName(bundle.GetLocalizedString(accessible_name_id));
+ SetFocusForPlatform();
+
+ SetFocusPainter(views::Painter::CreateSolidFocusPainter(
+ kFocusBorderColor, gfx::Insets(1, 2, 2, 3)));
+}
+
} // namespace ash
« no previous file with comments | « ash/common/system/tray/tray_popup_header_button.h ('k') | ui/gfx/vector_icons/help.icon » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698