| 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 #ifndef ASH_COMMON_SYSTEM_TRAY_SYSTEM_MENU_BUTTON_H_ | |
| 6 #define ASH_COMMON_SYSTEM_TRAY_SYSTEM_MENU_BUTTON_H_ | |
| 7 | |
| 8 #include "ash/common/system/tray/tray_popup_ink_drop_style.h" | |
| 9 #include "ash/resources/vector_icons/vector_icons.h" | |
| 10 #include "base/macros.h" | |
| 11 #include "base/optional.h" | |
| 12 #include "ui/gfx/image/image_skia.h" | |
| 13 #include "ui/views/controls/button/button.h" | |
| 14 #include "ui/views/controls/button/image_button.h" | |
| 15 | |
| 16 namespace ash { | |
| 17 | |
| 18 // A 48x48 image button with a material design ripple effect, which can be | |
| 19 // used across Ash material design native UI menus. | |
| 20 // TODO(tdanderson): Deprecate TrayPopupHeaderButton in favor of | |
| 21 // SystemMenuButton once material design is enabled by default. See | |
| 22 // crbug.com/614453. | |
| 23 class SystemMenuButton : public views::ImageButton { | |
| 24 public: | |
| 25 // Constructs the button with |listener| and a centered icon corresponding to | |
| 26 // |normal_icon| when button is enabled and |disabled_icon| when it is | |
| 27 // disabled. |ink_drop_style| specifies which flavor of the ink drop should be | |
| 28 // used. |accessible_name_id| corresponds to the string in ui::ResourceBundle | |
| 29 // to use for the button's accessible and tooltip text. | |
| 30 SystemMenuButton(views::ButtonListener* listener, | |
| 31 TrayPopupInkDropStyle ink_drop_style, | |
| 32 gfx::ImageSkia normal_icon, | |
| 33 gfx::ImageSkia disabled_icon, | |
| 34 int accessible_name_id); | |
| 35 | |
| 36 // Similar to the above constructor. Just gets a single vector icon and | |
| 37 // creates the normal and disabled icons based on that using default menu icon | |
| 38 // colors. | |
| 39 SystemMenuButton(views::ButtonListener* listener, | |
| 40 TrayPopupInkDropStyle ink_drop_style, | |
| 41 const gfx::VectorIcon& icon, | |
| 42 int accessible_name_id); | |
| 43 ~SystemMenuButton() override; | |
| 44 | |
| 45 // Explicity sets the ink drop color. Otherwise the default value will be used | |
| 46 // by TrayPopupUtils::CreateInkDropRipple() and | |
| 47 // TrayPopupUtils::CreateInkDropHighlight(). | |
| 48 void SetInkDropColor(SkColor color); | |
| 49 | |
| 50 // views::ImageButton: | |
| 51 std::unique_ptr<views::InkDrop> CreateInkDrop() override; | |
| 52 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; | |
| 53 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() | |
| 54 const override; | |
| 55 std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override; | |
| 56 | |
| 57 private: | |
| 58 // Returns the size that the ink drop should be constructed with. | |
| 59 gfx::Size GetInkDropSize() const; | |
| 60 | |
| 61 // Defines the flavor of ink drop ripple/highlight that should be constructed. | |
| 62 TrayPopupInkDropStyle ink_drop_style_; | |
| 63 | |
| 64 // The color to use when creating the ink drop. If null the default color is | |
| 65 // used as defined by TrayPopupUtils::CreateInkDropRipple() and | |
| 66 // TrayPopupUtils::CreateInkDropHighlight(). | |
| 67 base::Optional<SkColor> ink_drop_color_; | |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(SystemMenuButton); | |
| 70 }; | |
| 71 | |
| 72 } // namespace ash | |
| 73 | |
| 74 #endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_MENU_BUTTON_H_ | |
| OLD | NEW |