UI: CollapsibleHeader no longer shows the open/close icon if there are no items

This commit is contained in:
Henrik Rydgård committed 2023-07-23 11:11:44 +02:00
1 parent 18ac95a107
commit aa46d3aae3
4 files changed
+20 -4

No files matched your search

+8 -3
View File
@@ -1183,9 +1183,9 @@ StickyChoice *ChoiceStrip::Choice(int index) {
CollapsibleSection::CollapsibleSection(const std::string &title, LayoutParams *layoutParams) : LinearLayout(ORIENT_VERTICAL, layoutParams) {
SetSpacing(0.0f);
CollapsibleHeader *heading = new CollapsibleHeader(&open_, title);
views_.push_back(heading);
heading->OnClick.Add([=](UI::EventParams &) {
heading_ = new CollapsibleHeader(&open_, title);
views_.push_back(heading_);
heading_->OnClick.Add([=](UI::EventParams &) {
// Change the visibility of all children except the first one.
// Later maybe try something more ambitious.
for (size_t i = 1; i < views_.size(); i++) {
@@ -1195,4 +1195,9 @@ CollapsibleSection::CollapsibleSection(const std::string &title, LayoutParams *l
});
}
void CollapsibleSection::Update() {
ViewGroup::Update();
heading_->SetHasSubitems(views_.size() > 1);
}
} // namespace UI