37 checkbox_ = Checkbox(checkbox);
38 radiobox_ = Radiobox(radiobox);
40 Add(Container::Vertical({
42 Maybe(radiobox_, checkbox.checked),
48 util::clamp(radiobox.selected(), 0,
int(radiobox.entries.size()) - 1);
49 selected_ = util::clamp(selected_(), 0,
int(radiobox.entries.size()) - 1);
51 if (selected_() >= 0 && selected_() <
int(radiobox.entries.size())) {
52 title_ = radiobox.entries[selected_()];
55 return transform(*open_, checkbox_->Render(), radiobox_->Render());
60 const bool open_old = open_();
61 const int selected_old = selected_();
62 bool handled = ComponentBase::OnEvent(event);
65 if (!open_old && open_()) {
66 radiobox_->TakeFocus();
70 if (open_old && open_()) {
71 const bool should_close =
72 (selected_() != selected_old) ||
73 (event == Event::Return) ||
74 (
event == Event::Character(
' ')) ||
75 (event == Event::Escape) ||
76 (
event.is_mouse() && event.
mouse().
button == Mouse::Left &&
80 checkbox_->TakeFocus();
90 open_ = checkbox.checked;
91 selected_ = radiobox.selected;
92 checkbox.checked = &*open_;
93 radiobox.selected = &*selected_;
94 checkbox.label = &title_;
96 if (!checkbox.transform) {
98 auto prefix = text(s.state ?
"↓ " :
"→ ");
99 auto t = text(s.label);
106 return hbox({prefix, t});
111 transform = [](
bool is_open,
Element checkbox_element,
114 const int max_height = 12;
116 std::move(checkbox_element),
118 std::move(radiobox_element) | vscroll_indicator | frame |
123 return vbox({std::move(checkbox_element), filler()}) | border;
|ButtonOption|、|CheckboxOption|、|RadioboxOption|、|MenuEntryOption|、|MenuOption|からの変換の引数。