OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/system_menu_button.h" | 5 #include "ash/system/tray/system_menu_button.h" |
6 | 6 |
7 #include "ash/ash_constants.h" | 7 #include "ash/ash_constants.h" |
8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
9 #include "ash/system/tray/tray_constants.h" | 9 #include "ash/system/tray/tray_constants.h" |
10 #include "ash/system/tray/tray_popup_utils.h" | 10 #include "ash/system/tray/tray_popup_utils.h" |
11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
12 #include "ui/gfx/paint_vector_icon.h" | 12 #include "ui/gfx/paint_vector_icon.h" |
13 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 13 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
14 #include "ui/views/animation/ink_drop_highlight.h" | 14 #include "ui/views/animation/ink_drop_highlight.h" |
15 #include "ui/views/animation/ink_drop_impl.h" | 15 #include "ui/views/animation/ink_drop_impl.h" |
16 #include "ui/views/animation/ink_drop_mask.h" | 16 #include "ui/views/animation/ink_drop_mask.h" |
17 #include "ui/views/animation/square_ink_drop_ripple.h" | 17 #include "ui/views/animation/square_ink_drop_ripple.h" |
18 #include "ui/views/border.h" | |
19 #include "ui/views/painter.h" | 18 #include "ui/views/painter.h" |
20 | 19 |
21 namespace ash { | 20 namespace ash { |
22 | 21 |
23 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, | 22 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, |
24 TrayPopupInkDropStyle ink_drop_style, | 23 TrayPopupInkDropStyle ink_drop_style, |
25 gfx::ImageSkia normal_icon, | 24 gfx::ImageSkia normal_icon, |
26 gfx::ImageSkia disabled_icon, | 25 gfx::ImageSkia disabled_icon, |
27 int accessible_name_id) | 26 int accessible_name_id) |
28 : views::ImageButton(listener), ink_drop_style_(ink_drop_style) { | 27 : views::ImageButton(listener), ink_drop_style_(ink_drop_style) { |
29 DCHECK_EQ(normal_icon.width(), disabled_icon.width()); | 28 DCHECK_EQ(normal_icon.width(), disabled_icon.width()); |
30 DCHECK_EQ(normal_icon.height(), disabled_icon.height()); | 29 DCHECK_EQ(normal_icon.height(), disabled_icon.height()); |
31 | 30 |
32 SetImage(views::Button::STATE_NORMAL, &normal_icon); | 31 SetImage(views::Button::STATE_NORMAL, &normal_icon); |
33 SetImage(views::Button::STATE_DISABLED, &disabled_icon); | 32 SetImage(views::Button::STATE_DISABLED, &disabled_icon); |
34 | 33 |
35 const int horizontal_padding = (kMenuButtonSize - normal_icon.width()) / 2; | 34 set_preferred_size(gfx::Size(kMenuButtonSize, kMenuButtonSize)); |
36 const int vertical_padding = (kMenuButtonSize - normal_icon.height()) / 2; | |
37 SetBorder(views::CreateEmptyBorder(vertical_padding, horizontal_padding, | |
38 vertical_padding, horizontal_padding)); | |
39 | 35 |
40 SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id)); | 36 SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id)); |
41 | 37 |
42 SetFocusPainter(TrayPopupUtils::CreateFocusPainter()); | 38 SetFocusPainter(TrayPopupUtils::CreateFocusPainter()); |
43 TrayPopupUtils::ConfigureTrayPopupButton(this); | 39 TrayPopupUtils::ConfigureTrayPopupButton(this); |
44 } | 40 } |
45 | 41 |
46 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, | 42 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, |
47 TrayPopupInkDropStyle ink_drop_style, | 43 TrayPopupInkDropStyle ink_drop_style, |
48 const gfx::VectorIcon& icon, | 44 const gfx::VectorIcon& icon, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 : TrayPopupUtils::CreateInkDropHighlight(ink_drop_style_, this, | 76 : TrayPopupUtils::CreateInkDropHighlight(ink_drop_style_, this, |
81 ink_drop_color_.value()); | 77 ink_drop_color_.value()); |
82 } | 78 } |
83 | 79 |
84 std::unique_ptr<views::InkDropMask> SystemMenuButton::CreateInkDropMask() | 80 std::unique_ptr<views::InkDropMask> SystemMenuButton::CreateInkDropMask() |
85 const { | 81 const { |
86 return TrayPopupUtils::CreateInkDropMask(ink_drop_style_, this); | 82 return TrayPopupUtils::CreateInkDropMask(ink_drop_style_, this); |
87 } | 83 } |
88 | 84 |
89 } // namespace ash | 85 } // namespace ash |
OLD | NEW |