OLD | NEW |
(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 "ui/base/resource/resource_bundle.h" |
| 11 #include "ui/gfx/paint_vector_icon.h" |
| 12 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| 13 #include "ui/views/animation/ink_drop_highlight.h" |
| 14 #include "ui/views/border.h" |
| 15 #include "ui/views/painter.h" |
| 16 |
| 17 namespace ash { |
| 18 |
| 19 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, |
| 20 const gfx::VectorIcon& icon, |
| 21 int accessible_name_id) |
| 22 : views::ImageButton(listener) { |
| 23 gfx::ImageSkia image = gfx::CreateVectorIcon(icon, kMenuIconColor); |
| 24 SetImage(views::Button::STATE_NORMAL, &image); |
| 25 const int horizontal_padding = (kMenuButtonSize - image.width()) / 2; |
| 26 const int vertical_padding = (kMenuButtonSize - image.height()) / 2; |
| 27 SetBorder( |
| 28 views::Border::CreateEmptyBorder(vertical_padding, horizontal_padding, |
| 29 vertical_padding, horizontal_padding)); |
| 30 |
| 31 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 32 SetTooltipText(bundle.GetLocalizedString(accessible_name_id)); |
| 33 |
| 34 // TODO(tdanderson): Update the focus rect color, border thickness, and |
| 35 // location for material design. |
| 36 SetFocusForPlatform(); |
| 37 SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
| 38 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); |
| 39 |
| 40 SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); |
| 41 set_has_ink_drop_action_on_click(true); |
| 42 set_ink_drop_base_color(kMenuIconColor); |
| 43 } |
| 44 |
| 45 SystemMenuButton::~SystemMenuButton() {} |
| 46 |
| 47 std::unique_ptr<views::InkDropRipple> SystemMenuButton::CreateInkDropRipple() |
| 48 const { |
| 49 return base::MakeUnique<views::FloodFillInkDropRipple>( |
| 50 GetLocalBounds(), GetInkDropCenterBasedOnLastEvent(), |
| 51 GetInkDropBaseColor(), ink_drop_visible_opacity()); |
| 52 } |
| 53 |
| 54 std::unique_ptr<views::InkDropHighlight> |
| 55 SystemMenuButton::CreateInkDropHighlight() const { |
| 56 gfx::Size size = GetLocalBounds().size(); |
| 57 return base::MakeUnique<views::InkDropHighlight>( |
| 58 size, kInkDropSmallCornerRadius, |
| 59 gfx::RectF(gfx::SizeF(size)).CenterPoint(), kMenuIconColor); |
| 60 } |
| 61 |
| 62 bool SystemMenuButton::ShouldShowInkDropForFocus() const { |
| 63 return false; |
| 64 } |
| 65 |
| 66 } // namespace ash |
OLD | NEW |