1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
ash / system / tray / tray_detailed_view.h [blame]
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_TRAY_TRAY_DETAILED_VIEW_H_
#define ASH_SYSTEM_TRAY_TRAY_DETAILED_VIEW_H_
#include <memory>
#include "ash/ash_export.h"
#include "ash/system/tray/view_click_listener.h"
#include "ash/system/tray/zero_state_view.h"
#include "base/memory/raw_ptr.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/view.h"
namespace gfx {
struct VectorIcon;
} // namespace gfx
namespace views {
class BoxLayout;
class Button;
class ProgressBar;
class ScrollView;
} // namespace views
namespace ash {
class DetailedViewDelegate;
class HoverHighlightView;
class TriView;
class ASH_EXPORT TrayDetailedView : public views::View,
public ViewClickListener {
METADATA_HEADER(TrayDetailedView, views::View)
public:
explicit TrayDetailedView(DetailedViewDelegate* delegate);
TrayDetailedView(const TrayDetailedView&) = delete;
TrayDetailedView& operator=(const TrayDetailedView&) = delete;
~TrayDetailedView() override;
// views::View:
void Layout(PassKey) override;
gfx::Size CalculatePreferredSize(
const views::SizeBounds& available_size) const override;
// ViewClickListener:
// Don't override this --- override HandleViewClicked.
void OnViewClicked(views::View* sender) final;
// Setter for `progress_bar_` accessibility label.
void OverrideProgressBarAccessibleName(const std::u16string& name);
views::ScrollView* scroll_view_for_testing() { return scroller_; }
ZeroStateView* zero_state_view_for_testing() { return zero_state_view_; }
// Adds a targetable row to `container` containing `icon`, `text`, and a
// checkbox. `checked` determines whether the checkbox is checked or not.
// `enterprise_managed` determines whether or not there will be an enterprise
// managed icon for that item.
// The `container` should be a RoundedContainer.
HoverHighlightView* AddScrollListCheckableItem(
views::View* container,
const gfx::VectorIcon& icon,
const std::u16string& text,
bool checked,
bool enterprise_managed = false);
protected:
// Exposes the layout manager of this view to give control to subclasses.
views::BoxLayout* box_layout() { return box_layout_; }
// Creates the row containing the back button and title.
void CreateTitleRow(int string_id);
// Creates a scrollable list. The list has a border at the bottom if there is
// any other view between the list and the footer row at the bottom.
void CreateScrollableList();
// Creates a zero state view.
void CreateZeroStateView(std::unique_ptr<ZeroStateView> view);
// Adds a targetable row to `container` containing `icon` and `text`.
// The `container` should be a RoundedContainer.
HoverHighlightView* AddScrollListItem(views::View* container,
const gfx::VectorIcon& icon,
const std::u16string& text);
// Removes (and destroys) all child views.
void Reset();
// Shows or hides the progress bar below the title row. It occupies the same
// space as the created placeholder. If `progress_bar_` doesn't already exist
// it will be created.
void ShowProgress(double value, bool visible);
// Sets the visibility of the zero state view.
void SetZeroStateViewVisibility(bool visible);
// Helper functions which create and return the settings and help buttons,
// respectively, used in the material design top-most header row. The caller
// assumes ownership of the returned buttons.
virtual views::Button* CreateInfoButton(
views::Button::PressedCallback callback,
int info_accessible_name_id);
views::Button* CreateSettingsButton(views::Button::PressedCallback callback,
int setting_accessible_name_id);
views::Button* CreateHelpButton(views::Button::PressedCallback callback);
// Closes the bubble that contains the detailed view.
void CloseBubble();
TriView* tri_view() { return tri_view_; }
views::ScrollView* scroller() const { return scroller_; }
views::View* scroll_content() const { return scroll_content_; }
views::View* zero_state_view() const { return zero_state_view_; }
private:
friend class TrayDetailedViewTest;
// Overridden to handle clicks on subclass-specific views.
virtual void HandleViewClicked(views::View* view);
// Returns the TriView used for the title row. A label with `string_id` is
// added to the CENTER view. Left aligns the label contained in the CENTER
// view.
std::unique_ptr<TriView> CreateTitleTriView(int string_id);
// Creates and adds subclass-specific buttons to the title row.
virtual void CreateExtraTitleRowButtons();
// Transition to main view from detailed view.
void TransitionToMainView();
const raw_ptr<DetailedViewDelegate, DanglingUntriaged> delegate_;
raw_ptr<views::BoxLayout, DanglingUntriaged> box_layout_ = nullptr;
raw_ptr<views::ScrollView, DanglingUntriaged> scroller_ = nullptr;
raw_ptr<views::View, DanglingUntriaged> scroll_content_ = nullptr;
raw_ptr<views::ProgressBar> progress_bar_ = nullptr;
raw_ptr<ZeroStateView> zero_state_view_ = nullptr;
// The container view for the top-most title row. Owned by views hierarchy.
raw_ptr<TriView, DanglingUntriaged> tri_view_ = nullptr;
// The back button that appears in the title row. Owned by views hierarchy.
raw_ptr<views::Button, DanglingUntriaged> back_button_ = nullptr;
// The accessible name for the `progress_bar_`.
std::optional<std::u16string> progress_bar_accessible_name_;
};
} // namespace ash
#endif // ASH_SYSTEM_TRAY_TRAY_DETAILED_VIEW_H_