graph_page_view_base.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_HUD_DISPLAY_GRAPH_PAGE_VIEW_BASE_H_
  5. #define ASH_HUD_DISPLAY_GRAPH_PAGE_VIEW_BASE_H_
  6. #include "ash/hud_display/data_source.h"
  7. #include "ash/hud_display/legend.h"
  8. #include "base/sequence_checker.h"
  9. #include "ui/views/view.h"
  10. namespace views {
  11. class ImageButton;
  12. }
  13. namespace ash {
  14. namespace hud_display {
  15. class Legend;
  16. class ReferenceLines;
  17. // Interface for a single graph page.
  18. class GraphPageViewBase : public views::View {
  19. public:
  20. METADATA_HEADER(GraphPageViewBase);
  21. GraphPageViewBase();
  22. GraphPageViewBase(const GraphPageViewBase&) = delete;
  23. GraphPageViewBase& operator=(const GraphPageViewBase&) = delete;
  24. ~GraphPageViewBase() override;
  25. // Update page data from the new snapshot.
  26. virtual void UpdateData(const DataSource::Snapshot& snapshot) = 0;
  27. // Adds default legend.
  28. void CreateLegend(const std::vector<Legend::Entry>& entries);
  29. // Put the |ReferenceLines| object in its dedicated container. See
  30. // |ReferenceLines| for details.
  31. ReferenceLines* CreateReferenceLines(float left,
  32. float top,
  33. float right,
  34. float bottom,
  35. const std::u16string& x_unit,
  36. const std::u16string& y_unit,
  37. int horizontal_points_number,
  38. int horizontal_ticks_interval,
  39. float vertical_ticks_interval);
  40. protected:
  41. void RefreshLegendValues();
  42. private:
  43. void OnButtonPressed();
  44. // Container for the |ReferenceLines| object.
  45. views::View* reference_lines_container_ = nullptr; // not owned
  46. // Container for the legend object.
  47. views::View* legend_container_ = nullptr; // not owned
  48. views::ImageButton* legend_min_max_button_ = nullptr; // not owned
  49. Legend* legend_ = nullptr; // not owned
  50. SEQUENCE_CHECKER(ui_sequence_checker_);
  51. };
  52. } // namespace hud_display
  53. } // namespace ash
  54. #endif // ASH_HUD_DISPLAY_GRAPH_PAGE_VIEW_BASE_H_