page_indicator_view.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright (c) 2019 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_UNIFIED_PAGE_INDICATOR_VIEW_H_
  5. #define ASH_SYSTEM_UNIFIED_PAGE_INDICATOR_VIEW_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/public/cpp/pagination/pagination_model_observer.h"
  8. #include "ui/views/view.h"
  9. namespace ash {
  10. class PaginationModel;
  11. class UnifiedSystemTrayController;
  12. // PageIndicatorView represents its underlying PaginationModel with a button
  13. // strip. Each page in the PaginationModel has a button in the strip and
  14. // when the button is clicked, the corresponding page becomes selected.
  15. class ASH_EXPORT PageIndicatorView : public views::View,
  16. public PaginationModelObserver {
  17. public:
  18. PageIndicatorView(UnifiedSystemTrayController* controller,
  19. bool initially_expanded);
  20. PageIndicatorView(const PageIndicatorView&) = delete;
  21. PageIndicatorView& operator=(const PageIndicatorView&) = delete;
  22. ~PageIndicatorView() override;
  23. // Change the expanded state. 0.0 if collapsed, and 1.0 if expanded.
  24. // Otherwise, it shows an intermediate state while animating.
  25. void SetExpandedAmount(double expanded_amount);
  26. // Returns the height of this view when the tray is fully expanded.
  27. int GetExpandedHeight();
  28. // views::View:
  29. gfx::Size CalculatePreferredSize() const override;
  30. void Layout() override;
  31. const char* GetClassName() const override;
  32. private:
  33. friend class PageIndicatorViewTest;
  34. class PageIndicatorButton;
  35. // PaginationModelObserver:
  36. void TotalPagesChanged(int previous_page_count, int new_page_count) override;
  37. void SelectedPageChanged(int old_selected, int new_selected) override;
  38. bool IsPageSelectedForTesting(int index);
  39. views::View* buttons_container() { return buttons_container_; }
  40. PageIndicatorButton* GetButtonByIndex(int index);
  41. UnifiedSystemTrayController* const controller_;
  42. // Owned by UnifiedSystemTrayModel.
  43. PaginationModel* const model_;
  44. double expanded_amount_;
  45. // Owned by views hierarchy.
  46. views::View* buttons_container_;
  47. };
  48. } // namespace ash
  49. #endif // ASH_SYSTEM_UNIFIED_PAGE_INDICATOR_VIEW_H_