bubble_utils.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2021 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_BUBBLE_BUBBLE_UTILS_H_
  5. #define ASH_BUBBLE_BUBBLE_UTILS_H_
  6. #include <memory>
  7. #include <string>
  8. #include "ash/ash_export.h"
  9. namespace ui {
  10. class LocatedEvent;
  11. } // namespace ui
  12. namespace views {
  13. class Label;
  14. } // namespace views
  15. namespace ash {
  16. namespace bubble_utils {
  17. // Returns false if `event` should not close a bubble. Returns true if `event`
  18. // should close a bubble, or if more processing is required. Callers may also
  19. // need to check for a click on the view that spawned the bubble (otherwise the
  20. // bubble will close and immediately reopen).
  21. ASH_EXPORT bool ShouldCloseBubbleForEvent(const ui::LocatedEvent& event);
  22. // Enumeration of supported label styles.
  23. enum class LabelStyle {
  24. kBadge,
  25. kBody,
  26. kChipBody,
  27. kChipTitle,
  28. kHeader,
  29. kSubtitle,
  30. };
  31. // Applies the specified `style` to the given `label`.
  32. ASH_EXPORT void ApplyStyle(views::Label* label, LabelStyle style);
  33. // Creates a label with optional `text` matching the specified `style`. The
  34. // label will paint correctly even if it is not added to the view hierarchy.
  35. std::unique_ptr<views::Label> CreateLabel(
  36. LabelStyle style,
  37. const std::u16string& text = std::u16string());
  38. } // namespace bubble_utils
  39. } // namespace ash
  40. #endif // ASH_BUBBLE_BUBBLE_UTILS_H_