system_menu_button.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef ASH_SYSTEM_TRAY_SYSTEM_MENU_BUTTON_H_
  5. #define ASH_SYSTEM_TRAY_SYSTEM_MENU_BUTTON_H_
  6. #include "ash/resources/vector_icons/vector_icons.h"
  7. #include "ui/base/metadata/metadata_header_macros.h"
  8. #include "ui/gfx/image/image_skia.h"
  9. #include "ui/views/controls/button/button.h"
  10. #include "ui/views/controls/button/image_button.h"
  11. namespace ash {
  12. // A 48x48 image button with a material design ripple effect, which can be
  13. // used across Ash material design native UI menus.
  14. class SystemMenuButton : public views::ImageButton {
  15. public:
  16. METADATA_HEADER(SystemMenuButton);
  17. // Constructs the button with |callback| and a centered icon corresponding to
  18. // |normal_icon| when button is enabled and |disabled_icon| when it is
  19. // disabled. |accessible_name_id| corresponds to the string in
  20. // ui::ResourceBundle to use for the button's accessible and tooltip text.
  21. SystemMenuButton(PressedCallback callback,
  22. const gfx::ImageSkia& normal_icon,
  23. const gfx::ImageSkia& disabled_icon,
  24. int accessible_name_id);
  25. // Similar to the above constructor. Just gets a single vector icon and
  26. // creates the normal and disabled icons based on that using default menu icon
  27. // colors.
  28. SystemMenuButton(PressedCallback callback,
  29. const gfx::VectorIcon& icon,
  30. int accessible_name_id);
  31. SystemMenuButton(const SystemMenuButton&) = delete;
  32. SystemMenuButton& operator=(const SystemMenuButton&) = delete;
  33. ~SystemMenuButton() override;
  34. // Sets the normal and disabled icons based on that using default menu icon
  35. // colors.
  36. void SetVectorIcon(const gfx::VectorIcon& icon);
  37. private:
  38. // Returns the size that the ink drop should be constructed with.
  39. gfx::Size GetInkDropSize() const;
  40. };
  41. } // namespace ash
  42. #endif // ASH_SYSTEM_TRAY_SYSTEM_MENU_BUTTON_H_