power_button_menu_item_view.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright 2018 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_POWER_POWER_BUTTON_MENU_ITEM_VIEW_H_
  5. #define ASH_SYSTEM_POWER_POWER_BUTTON_MENU_ITEM_VIEW_H_
  6. #include <string>
  7. #include "ash/ash_export.h"
  8. #include "ui/views/controls/button/image_button.h"
  9. namespace views {
  10. class ImageView;
  11. class Label;
  12. } // namespace views
  13. namespace gfx {
  14. struct VectorIcon;
  15. } // namespace gfx
  16. namespace ash {
  17. // PowerButtonMenuItemView represents an item of the power button menu. It
  18. // includes an icon and title.
  19. class ASH_EXPORT PowerButtonMenuItemView : public views::ImageButton {
  20. public:
  21. // Height of the menu item in pixels.
  22. static constexpr int kMenuItemHeight = 84;
  23. // Width of the menu item in pixels.
  24. static constexpr int kMenuItemWidth = 84;
  25. // Thickness of the menu item's border in pixels.
  26. static constexpr int kItemBorderThickness = 2;
  27. PowerButtonMenuItemView(PressedCallback callback,
  28. const gfx::VectorIcon& icon,
  29. const std::u16string& title_text);
  30. PowerButtonMenuItemView(const PowerButtonMenuItemView&) = delete;
  31. PowerButtonMenuItemView& operator=(const PowerButtonMenuItemView&) = delete;
  32. ~PowerButtonMenuItemView() override;
  33. // views::View:
  34. const char* GetClassName() const override;
  35. private:
  36. // views::View:
  37. void Layout() override;
  38. gfx::Size CalculatePreferredSize() const override;
  39. void OnFocus() override;
  40. void OnBlur() override;
  41. void OnThemeChanged() override;
  42. // views::ImageButton:
  43. void PaintButtonContents(gfx::Canvas* canvas) override;
  44. // Owned by views hierarchy.
  45. views::ImageView* icon_view_ = nullptr;
  46. views::Label* title_ = nullptr;
  47. const gfx::VectorIcon& icon_;
  48. };
  49. } // namespace ash
  50. #endif // ASH_SYSTEM_POWER_POWER_BUTTON_MENU_ITEM_VIEW_H_