holding_space_tray_bubble.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_HOLDING_SPACE_HOLDING_SPACE_TRAY_BUBBLE_H_
  5. #define ASH_SYSTEM_HOLDING_SPACE_HOLDING_SPACE_TRAY_BUBBLE_H_
  6. #include <memory>
  7. #include <vector>
  8. #include "ash/ash_export.h"
  9. #include "ash/public/cpp/tablet_mode_observer.h"
  10. #include "ash/shelf/shelf.h"
  11. #include "ash/shelf/shelf_observer.h"
  12. #include "ash/system/holding_space/holding_space_view_delegate.h"
  13. #include "ash/system/screen_layout_observer.h"
  14. #include "ash/system/tray/tray_bubble_wrapper.h"
  15. #include "ash/wm/tablet_mode/tablet_mode_controller.h"
  16. #include "base/scoped_observation.h"
  17. namespace ash {
  18. class HoldingSpaceTray;
  19. class HoldingSpaceTrayChildBubble;
  20. // The bubble associated with the `HoldingSpaceTray`.
  21. class ASH_EXPORT HoldingSpaceTrayBubble : public ScreenLayoutObserver,
  22. public ShelfObserver,
  23. public TabletModeObserver {
  24. public:
  25. explicit HoldingSpaceTrayBubble(HoldingSpaceTray* holding_space_tray);
  26. HoldingSpaceTrayBubble(const HoldingSpaceTrayBubble&) = delete;
  27. HoldingSpaceTrayBubble& operator=(const HoldingSpaceTrayBubble&) = delete;
  28. ~HoldingSpaceTrayBubble() override;
  29. void AnchorUpdated();
  30. TrayBubbleView* GetBubbleView();
  31. views::Widget* GetBubbleWidget();
  32. // Returns all holding space item views in the bubble. Views are returned in
  33. // top-to-bottom, left-to-right order (or mirrored for RTL).
  34. std::vector<HoldingSpaceItemView*> GetHoldingSpaceItemViews();
  35. // Returns the `holding_space_tray_` associated with this bubble.
  36. HoldingSpaceTray* tray() { return holding_space_tray_; }
  37. private:
  38. class ChildBubbleContainer;
  39. // Return the maximum height available for the holding space bubble.
  40. int CalculateMaxHeight() const;
  41. void UpdateBubbleBounds();
  42. // ScreenLayoutObserver:
  43. void OnDisplayConfigurationChanged() override;
  44. // ShelfObserver:
  45. void OnAutoHideStateChanged(ShelfAutoHideState new_state) override;
  46. // TabletModeObserver:
  47. void OnTabletModeStarted() override;
  48. void OnTabletModeEnded() override;
  49. // The owner of this class.
  50. HoldingSpaceTray* const holding_space_tray_;
  51. // The singleton delegate for holding space views that implements support
  52. // for context menu, drag-and-drop, and multiple selection.
  53. HoldingSpaceViewDelegate delegate_{this};
  54. // Views owned by view hierarchy.
  55. ChildBubbleContainer* child_bubble_container_;
  56. std::vector<HoldingSpaceTrayChildBubble*> child_bubbles_;
  57. std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_;
  58. std::unique_ptr<ui::EventHandler> event_handler_;
  59. base::ScopedObservation<Shelf, ShelfObserver> shelf_observation_{this};
  60. base::ScopedObservation<TabletModeController, TabletModeObserver>
  61. tablet_mode_observation_{this};
  62. };
  63. } // namespace ash
  64. #endif // ASH_SYSTEM_HOLDING_SPACE_HOLDING_SPACE_TRAY_BUBBLE_H_