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
ash / style / style_viewer / radio_button_instances_grid_view_factory.cc [blame]
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/style/style_viewer/system_ui_components_grid_view_factories.h"
#include "ash/style/radio_button.h"
#include "ash/style/style_viewer/system_ui_components_grid_view.h"
namespace ash {
namespace {
// Conigure of grid view for `RadioButton` instances. We have 4* 4 instances
// divided into 4 column groups.
constexpr size_t kGridViewRowNum = 4;
constexpr size_t kGridViewColNum = 4;
constexpr size_t kGridViewRowGroupSize = 4;
constexpr size_t kGirdViewColGroupSize = 1;
constexpr int kRadioButtonWidth = 218;
constexpr auto kRadioButtonPadding = gfx::Insets::TLBR(8, 12, 8, 12);
} // namespace
std::unique_ptr<SystemUIComponentsGridView>
CreateRadioButtonInstancesGridView() {
auto grid_view = std::make_unique<SystemUIComponentsGridView>(
kGridViewRowNum, kGridViewColNum, kGridViewRowGroupSize,
kGirdViewColGroupSize);
grid_view->AddInstance(
u"", std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Default CircleRight",
RadioButton::IconDirection::kLeading,
RadioButton::IconType::kCircle, kRadioButtonPadding));
grid_view->AddInstance(
u"", std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Default CircleRight",
RadioButton::IconDirection::kFollowing,
RadioButton::IconType::kCircle, kRadioButtonPadding));
grid_view->AddInstance(
u"",
std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Default CheckRight", RadioButton::IconDirection::kLeading,
RadioButton::IconType::kCheck, kRadioButtonPadding));
grid_view->AddInstance(
u"", std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Default CheckRight",
RadioButton::IconDirection::kFollowing,
RadioButton::IconType::kCheck, kRadioButtonPadding));
auto selected_circle_left = std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Selected CircleRight", RadioButton::IconDirection::kLeading,
RadioButton::IconType::kCircle, kRadioButtonPadding);
selected_circle_left->SetSelected(true);
grid_view->AddInstance(u"", std::move(selected_circle_left));
auto selected_circle_right = std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Selected CircleRight", RadioButton::IconDirection::kFollowing,
RadioButton::IconType::kCircle, kRadioButtonPadding);
selected_circle_right->SetSelected(true);
grid_view->AddInstance(u"", std::move(selected_circle_right));
auto selected_check_left = std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Selected CheckRight", RadioButton::IconDirection::kLeading,
RadioButton::IconType::kCheck, kRadioButtonPadding);
selected_check_left->SetSelected(true);
grid_view->AddInstance(u"", std::move(selected_check_left));
auto selected_check_right = std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Selected CheckRight", RadioButton::IconDirection::kFollowing,
RadioButton::IconType::kCheck, kRadioButtonPadding);
selected_check_right->SetSelected(true);
grid_view->AddInstance(u"", std::move(selected_check_right));
auto disable_circle_left = std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Disabled CircleRight", RadioButton::IconDirection::kLeading,
RadioButton::IconType::kCircle, kRadioButtonPadding);
disable_circle_left->SetEnabled(false);
grid_view->AddInstance(u"", std::move(disable_circle_left));
auto disable_circle_right = std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Disabled CircleRight", RadioButton::IconDirection::kFollowing,
RadioButton::IconType::kCircle, kRadioButtonPadding);
disable_circle_right->SetEnabled(false);
grid_view->AddInstance(u"", std::move(disable_circle_right));
auto disable_check_left = std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Disabled CheckRight", RadioButton::IconDirection::kLeading,
RadioButton::IconType::kCheck, kRadioButtonPadding);
disable_check_left->SetEnabled(false);
grid_view->AddInstance(u"", std::move(disable_check_left));
auto disable_check_right = std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Disabled CheckRight", RadioButton::IconDirection::kFollowing,
RadioButton::IconType::kCheck, kRadioButtonPadding);
disable_check_right->SetEnabled(false);
grid_view->AddInstance(u"", std::move(disable_check_right));
auto disable_selected_circle_left = std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Disabled Selected CircleRight",
RadioButton::IconDirection::kLeading, RadioButton::IconType::kCircle,
kRadioButtonPadding);
disable_selected_circle_left->SetSelected(true);
disable_selected_circle_left->SetEnabled(false);
grid_view->AddInstance(u"", std::move(disable_selected_circle_left));
auto disable_selected_circle_right = std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Disabled SelectedCircleRight",
RadioButton::IconDirection::kFollowing, RadioButton::IconType::kCircle,
kRadioButtonPadding);
disable_selected_circle_right->SetSelected(true);
disable_selected_circle_right->SetEnabled(false);
grid_view->AddInstance(u"", std::move(disable_selected_circle_right));
auto disable_selected_check_left = std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Disabled Selected CheckRight",
RadioButton::IconDirection::kLeading, RadioButton::IconType::kCheck,
kRadioButtonPadding);
disable_selected_check_left->SetSelected(true);
disable_selected_check_left->SetEnabled(false);
grid_view->AddInstance(u"", std::move(disable_selected_check_left));
auto disable_selected_check_right = std::make_unique<RadioButton>(
kRadioButtonWidth, RadioButton::PressedCallback(),
/*label=*/u"Disabled Selected CheckRight",
RadioButton::IconDirection::kFollowing, RadioButton::IconType::kCheck,
kRadioButtonPadding);
disable_selected_check_right->SetSelected(true);
disable_selected_check_right->SetEnabled(false);
grid_view->AddInstance(u"", std::move(disable_selected_check_right));
return grid_view;
}
} // namespace ash