UI: Give views a pointer to their parent group

Set by ViewGroup when a view is added, inserted or swapped in. Lets a view
find the scroll view it's in, for example.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-22 15:34:51 +02:00
1 parent 729047d449
commit 5d8db2a22d
3 files changed
+13 -2

No files matched your search

+2 -2
View File
@@ -164,6 +164,7 @@ bool ViewGroup::ReplaceSubview(View *view, View *newView) {
for (int i = 0; i < (int)views_.size(); i++) {
if (views_[i] == view) {
views_[i] = newView;
SetParentOf(newView);
delete view;
return true;
}
@@ -1042,8 +1043,7 @@ CollapsibleSection::CollapsibleSection(std::string_view title, LayoutParams *lay
open_ = &localOpen_;
SetSpacing(0.0f);
header_ = new CollapsibleHeader(open_, title);
views_.push_back(header_);
header_ = Add(new CollapsibleHeader(open_, title));
header_->OnClick.Add([=](UI::EventParams &) {
// Change the visibility of all children except the first one.
// Later maybe try something more ambitious.