detailed_view_delegate.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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_SYSTEM_TRAY_DETAILED_VIEW_DELEGATE_H_
  5. #define ASH_SYSTEM_TRAY_DETAILED_VIEW_DELEGATE_H_
  6. #include <string>
  7. #include "ash/ash_export.h"
  8. #include "third_party/abseil-cpp/absl/types/optional.h"
  9. #include "third_party/skia/include/core/SkColor.h"
  10. #include "ui/views/controls/button/button.h"
  11. namespace gfx {
  12. struct VectorIcon;
  13. } // namespace gfx
  14. namespace views {
  15. class Label;
  16. class Separator;
  17. class View;
  18. } // namespace views
  19. namespace ash {
  20. class HoverHighlightView;
  21. class TriView;
  22. class UnifiedSystemTrayController;
  23. class ViewClickListener;
  24. // A delegate of TrayDetailedView that handles bubble related actions e.g.
  25. // transition to the main view, closing the bubble, etc.
  26. class ASH_EXPORT DetailedViewDelegate {
  27. public:
  28. explicit DetailedViewDelegate(UnifiedSystemTrayController* tray_controller);
  29. DetailedViewDelegate(const DetailedViewDelegate&) = delete;
  30. DetailedViewDelegate& operator=(const DetailedViewDelegate&) = delete;
  31. virtual ~DetailedViewDelegate();
  32. // Transition to the main view from the detailed view. |restore_focus| is true
  33. // if the title row has keyboard focus before transition. If so, the main view
  34. // should focus on the corresponding element of the detailed view.
  35. virtual void TransitionToMainView(bool restore_focus);
  36. // Close the bubble that contains the detailed view.
  37. virtual void CloseBubble();
  38. // Get the background color of the detailed view.
  39. virtual absl::optional<SkColor> GetBackgroundColor();
  40. // Return true if overflow indicator of ScrollView is enabled.
  41. virtual bool IsOverflowIndicatorEnabled() const;
  42. // Return TriView used for the title row. It should have title label of
  43. // |string_id| in CENTER. TrayDetailedView will calls CreateBackButton() and
  44. // adds the returned view to START.
  45. virtual TriView* CreateTitleRow(int string_id);
  46. // Return the separator used between the title row and the contents. Caller
  47. // takes ownership of the returned view.
  48. virtual views::View* CreateTitleSeparator();
  49. // Configure a |view| to have a visible separator below.
  50. virtual void ShowStickyHeaderSeparator(views::View* view,
  51. bool show_separator);
  52. // Return a targetable row containing |icon| and |text|. Caller takes
  53. // ownership of the returned view.
  54. virtual HoverHighlightView* CreateScrollListItem(ViewClickListener* listener,
  55. const gfx::VectorIcon& icon,
  56. const std::u16string& text);
  57. // Return the back button used in the title row. Caller takes ownership of the
  58. // returned view.
  59. virtual views::Button* CreateBackButton(
  60. views::Button::PressedCallback callback);
  61. // Return the info button used in the title row. Caller takes ownership of the
  62. // returned view.
  63. virtual views::Button* CreateInfoButton(
  64. views::Button::PressedCallback callback,
  65. int info_accessible_name_id);
  66. // Return the settings button used in the title row. Caller takes ownership of
  67. // the returned view.
  68. virtual views::Button* CreateSettingsButton(
  69. views::Button::PressedCallback callback,
  70. int setting_accessible_name_id);
  71. // Return the help button used in the title row. Caller takes ownership of the
  72. // returned view.
  73. virtual views::Button* CreateHelpButton(
  74. views::Button::PressedCallback callback);
  75. // Update the colors that need to be updated while switching between dark and
  76. // light mode.
  77. virtual void UpdateColors();
  78. private:
  79. UnifiedSystemTrayController* const tray_controller_;
  80. views::Label* title_label_ = nullptr;
  81. views::Separator* title_separator_ = nullptr;
  82. };
  83. } // namespace ash
  84. #endif // ASH_SYSTEM_TRAY_DETAILED_VIEW_DELEGATE_H_