aboutsummaryrefslogtreecommitdiff
path: root/src/ui/window.cpp
blob: 7c0683af3a1fd2fce9dbccf582330d62910a2dd7 (plain)
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
#include "cru/ui/window.hpp"

#include "cru/ui/render/window_render_object.hpp"
#include "cru/ui/ui_host.hpp"

namespace cru::ui {
Window* Window::CreateOverlapped() {
  return new Window(tag_overlapped_constructor{});
}

Window::Window(tag_overlapped_constructor) {
  managed_ui_host_ = std::make_unique<UiHost>(this);
}

Window::~Window() {
  // explicit destroy ui host first.
  managed_ui_host_.reset();
}

std::string_view Window::GetControlType() const { return control_type; }

render::RenderObject* Window::GetRenderObject() const { return render_object_; }

void Window::OnChildChanged(Control* old_child, Control* new_child) {
  if (old_child) render_object_->RemoveChild(0);
  if (new_child) render_object_->AddChild(new_child->GetRenderObject(), 0);
}
}  // namespace cru::ui