| 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 "ash/system/tray/tray_popup_header_button.h" | 5 #include "ash/system/tray/tray_popup_header_button.h" |
| 6 | 6 |
| 7 #include "ash/ash_constants.h" | 7 #include "ash/ash_constants.h" |
| 8 #include "ash/system/tray/tray_constants.h" | 8 #include "ash/system/tray/tray_constants.h" |
| 9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/views/background.h" | 10 #include "ui/views/background.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 bundle.GetImageNamed(enabled_resource_id).ToImageSkia()); | 28 bundle.GetImageNamed(enabled_resource_id).ToImageSkia()); |
| 29 SetToggledImage(views::Button::STATE_NORMAL, | 29 SetToggledImage(views::Button::STATE_NORMAL, |
| 30 bundle.GetImageNamed(disabled_resource_id).ToImageSkia()); | 30 bundle.GetImageNamed(disabled_resource_id).ToImageSkia()); |
| 31 SetImage(views::Button::STATE_HOVERED, | 31 SetImage(views::Button::STATE_HOVERED, |
| 32 bundle.GetImageNamed(enabled_resource_id_hover).ToImageSkia()); | 32 bundle.GetImageNamed(enabled_resource_id_hover).ToImageSkia()); |
| 33 SetToggledImage(views::Button::STATE_HOVERED, | 33 SetToggledImage(views::Button::STATE_HOVERED, |
| 34 bundle.GetImageNamed(disabled_resource_id_hover).ToImageSkia()); | 34 bundle.GetImageNamed(disabled_resource_id_hover).ToImageSkia()); |
| 35 SetImageAlignment(views::ImageButton::ALIGN_CENTER, | 35 SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
| 36 views::ImageButton::ALIGN_MIDDLE); | 36 views::ImageButton::ALIGN_MIDDLE); |
| 37 SetAccessibleName(bundle.GetLocalizedString(accessible_name_id)); | 37 SetAccessibleName(bundle.GetLocalizedString(accessible_name_id)); |
| 38 SetFocusBehavior(FocusBehavior::ALWAYS); | 38 Button::ConfigureDefaultFocus(this); |
| 39 set_request_focus_on_press(false); | 39 set_request_focus_on_press(false); |
| 40 | 40 |
| 41 SetFocusPainter(views::Painter::CreateSolidFocusPainter( | 41 SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
| 42 kFocusBorderColor, | 42 kFocusBorderColor, |
| 43 gfx::Insets(1, 2, 2, 3))); | 43 gfx::Insets(1, 2, 2, 3))); |
| 44 } | 44 } |
| 45 | 45 |
| 46 TrayPopupHeaderButton::~TrayPopupHeaderButton() {} | 46 TrayPopupHeaderButton::~TrayPopupHeaderButton() {} |
| 47 | 47 |
| 48 const char* TrayPopupHeaderButton::GetClassName() const { | 48 const char* TrayPopupHeaderButton::GetClassName() const { |
| 49 return kViewClassName; | 49 return kViewClassName; |
| 50 } | 50 } |
| 51 | 51 |
| 52 gfx::Size TrayPopupHeaderButton::GetPreferredSize() const { | 52 gfx::Size TrayPopupHeaderButton::GetPreferredSize() const { |
| 53 return gfx::Size(ash::kTrayPopupItemHeight, ash::kTrayPopupItemHeight); | 53 return gfx::Size(ash::kTrayPopupItemHeight, ash::kTrayPopupItemHeight); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void TrayPopupHeaderButton::StateChanged() { | 56 void TrayPopupHeaderButton::StateChanged() { |
| 57 if (state() == STATE_HOVERED || state() == STATE_PRESSED) { | 57 if (state() == STATE_HOVERED || state() == STATE_PRESSED) { |
| 58 set_background(views::Background::CreateSolidBackground( | 58 set_background(views::Background::CreateSolidBackground( |
| 59 kTrayPopupHoverBackgroundColor)); | 59 kTrayPopupHoverBackgroundColor)); |
| 60 } else { | 60 } else { |
| 61 set_background(nullptr); | 61 set_background(nullptr); |
| 62 } | 62 } |
| 63 SchedulePaint(); | 63 SchedulePaint(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace ash | 66 } // namespace ash |
| OLD | NEW |