quick_action_item.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright 2020 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_PHONEHUB_QUICK_ACTION_ITEM_H_
  5. #define ASH_SYSTEM_PHONEHUB_QUICK_ACTION_ITEM_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/system/unified/feature_pod_button.h"
  8. namespace views {
  9. class Label;
  10. }
  11. namespace ash {
  12. // A toggle button with labels used in the quick action view.
  13. class ASH_EXPORT QuickActionItem : public views::View {
  14. public:
  15. class Delegate {
  16. public:
  17. // Called when the button of the quick action item is clicked.
  18. virtual void OnButtonPressed(bool is_now_enabled) = 0;
  19. };
  20. // If only one icon is supplied, it will be used in both cases.
  21. QuickActionItem(Delegate* delegate,
  22. int label_id,
  23. const gfx::VectorIcon& icon);
  24. ~QuickActionItem() override;
  25. QuickActionItem(QuickActionItem&) = delete;
  26. QuickActionItem operator=(QuickActionItem&) = delete;
  27. // Set the text of sub-label shown below the label.
  28. void SetSubLabel(const std::u16string& sub_label);
  29. // Set the color of sub-label shown below the label.
  30. void SetSubLabelColor(SkColor color);
  31. // Set the tooltip text of the icon button.
  32. void SetTooltip(const std::u16string& text);
  33. // Change the toggled state. If toggled, the background color of the circle
  34. // will change.
  35. void SetToggled(bool toggled);
  36. bool IsToggled() const;
  37. // Get the title/label text of the item.
  38. const std::u16string& GetItemLabel() const;
  39. // Set the item to be enabled or disabled. When disabled, the button cannot be
  40. // clicked and the labels are greyed out.
  41. void SetEnabled(bool enabled);
  42. // views::View:
  43. bool HasFocus() const override;
  44. void RequestFocus() override;
  45. const char* GetClassName() const override;
  46. FeaturePodIconButton* icon_button() const { return icon_button_; }
  47. private:
  48. // Owned by views hierarchy.
  49. FeaturePodIconButton* icon_button_ = nullptr;
  50. views::Label* label_ = nullptr;
  51. views::Label* sub_label_ = nullptr;
  52. // Enabled color of the sub label.
  53. SkColor sub_label_color_;
  54. };
  55. } // namespace ash
  56. #endif // ASH_SYSTEM_PHONEHUB_QUICK_ACTION_ITEM_H_