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

Side by Side Diff: ash/common/system/tray/system_menu_button.cc

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 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
« no previous file with comments | « ash/common/system/tray/system_menu_button.h ('k') | ash/common/system/tray/system_tray.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/common/system/tray/system_menu_button.h"
6
7 #include "ash/common/ash_constants.h"
8 #include "ash/common/system/tray/system_tray.h"
9 #include "ash/common/system/tray/tray_constants.h"
10 #include "ash/common/system/tray/tray_popup_utils.h"
11 #include "ui/base/l10n/l10n_util.h"
12 #include "ui/gfx/paint_vector_icon.h"
13 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
14 #include "ui/views/animation/ink_drop_highlight.h"
15 #include "ui/views/animation/ink_drop_impl.h"
16 #include "ui/views/animation/ink_drop_mask.h"
17 #include "ui/views/animation/square_ink_drop_ripple.h"
18 #include "ui/views/border.h"
19 #include "ui/views/painter.h"
20
21 namespace ash {
22
23 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener,
24 TrayPopupInkDropStyle ink_drop_style,
25 gfx::ImageSkia normal_icon,
26 gfx::ImageSkia disabled_icon,
27 int accessible_name_id)
28 : views::ImageButton(listener), ink_drop_style_(ink_drop_style) {
29 DCHECK_EQ(normal_icon.width(), disabled_icon.width());
30 DCHECK_EQ(normal_icon.height(), disabled_icon.height());
31
32 SetImage(views::Button::STATE_NORMAL, &normal_icon);
33 SetImage(views::Button::STATE_DISABLED, &disabled_icon);
34
35 const int horizontal_padding = (kMenuButtonSize - normal_icon.width()) / 2;
36 const int vertical_padding = (kMenuButtonSize - normal_icon.height()) / 2;
37 SetBorder(views::CreateEmptyBorder(vertical_padding, horizontal_padding,
38 vertical_padding, horizontal_padding));
39
40 SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id));
41
42 SetFocusPainter(TrayPopupUtils::CreateFocusPainter());
43 TrayPopupUtils::ConfigureTrayPopupButton(this);
44 }
45
46 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener,
47 TrayPopupInkDropStyle ink_drop_style,
48 const gfx::VectorIcon& icon,
49 int accessible_name_id)
50 : SystemMenuButton(listener,
51 ink_drop_style,
52 gfx::CreateVectorIcon(icon, kMenuIconColor),
53 gfx::CreateVectorIcon(icon, kMenuIconColorDisabled),
54 accessible_name_id) {}
55
56 SystemMenuButton::~SystemMenuButton() {}
57
58 void SystemMenuButton::SetInkDropColor(SkColor color) {
59 ink_drop_color_ = color;
60 }
61
62 std::unique_ptr<views::InkDrop> SystemMenuButton::CreateInkDrop() {
63 return TrayPopupUtils::CreateInkDrop(ink_drop_style_, this);
64 }
65
66 std::unique_ptr<views::InkDropRipple> SystemMenuButton::CreateInkDropRipple()
67 const {
68 return ink_drop_color_ == base::nullopt
69 ? TrayPopupUtils::CreateInkDropRipple(
70 ink_drop_style_, this, GetInkDropCenterBasedOnLastEvent())
71 : TrayPopupUtils::CreateInkDropRipple(
72 ink_drop_style_, this, GetInkDropCenterBasedOnLastEvent(),
73 ink_drop_color_.value());
74 }
75
76 std::unique_ptr<views::InkDropHighlight>
77 SystemMenuButton::CreateInkDropHighlight() const {
78 return ink_drop_color_ == base::nullopt
79 ? TrayPopupUtils::CreateInkDropHighlight(ink_drop_style_, this)
80 : TrayPopupUtils::CreateInkDropHighlight(ink_drop_style_, this,
81 ink_drop_color_.value());
82 }
83
84 std::unique_ptr<views::InkDropMask> SystemMenuButton::CreateInkDropMask()
85 const {
86 return TrayPopupUtils::CreateInkDropMask(ink_drop_style_, this);
87 }
88
89 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/system_menu_button.h ('k') | ash/common/system/tray/system_tray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698