aboutsummaryrefslogtreecommitdiff
path: root/src/ui/render/SingleChildRenderObject.cpp
blob: 7b10b34353c556006d7e82cc593f533ba1378193 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "cru/ui/render/SingleChildRenderObject.h"

namespace cru::ui::render {
void SingleChildRenderObject::SetChild(RenderObject *new_child) {
  assert(new_child->GetParent() == nullptr);
  if (child_ == new_child) return;
  auto old_child = child_;
  if (child_) {
    child_->SetParent(nullptr);
  }
  child_ = new_child;
  if (child_) {
    child_->SetParent(this);
  }
  OnChildChanged(old_child, new_child);
}

void SingleChildRenderObject::OnChildChanged(RenderObject *old_child,
                                             RenderObject *new_child) {
  InvalidateLayout();
}
}  // namespace cru::ui::render