shelf_bubble.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_SHELF_SHELF_BUBBLE_H_
  5. #define ASH_SHELF_SHELF_BUBBLE_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/public/cpp/shelf_types.h"
  8. #include "ash/shelf/shelf_background_animator.h"
  9. #include "ash/shelf/shelf_background_animator_observer.h"
  10. #include "ash/shell.h"
  11. #include "ui/views/bubble/bubble_dialog_delegate_view.h"
  12. namespace views {
  13. class View;
  14. } // namespace views
  15. namespace ash {
  16. // A base class for all shelf tooltip bubbles.
  17. class ASH_EXPORT ShelfBubble : public views::BubbleDialogDelegateView,
  18. public ShelfBackgroundAnimatorObserver {
  19. public:
  20. ShelfBubble(views::View* anchor, ShelfAlignment alignment);
  21. ShelfBubble(const ShelfBubble&) = delete;
  22. ShelfBubble& operator=(const ShelfBubble&) = delete;
  23. ~ShelfBubble() override;
  24. // Returns true if we should close when we get a press down event within our
  25. // bounds.
  26. virtual bool ShouldCloseOnPressDown() = 0;
  27. // Returns true if we should disappear when the mouse leaves the anchor's
  28. // bounds.
  29. virtual bool ShouldCloseOnMouseExit() = 0;
  30. protected:
  31. void set_border_radius(int radius) { border_radius_ = radius; }
  32. // Performs the actual bubble creation.
  33. void CreateBubble();
  34. private:
  35. // ShelfBackgroundAnimatorObserver:
  36. void UpdateShelfBackground(SkColor color) override;
  37. int border_radius_ = 0;
  38. ShelfBackgroundAnimator background_animator_;
  39. };
  40. } // namespace ash
  41. #endif // ASH_SHELF_SHELF_BUBBLE_H_