aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/Window.cpp
blob: b302cb629d23a2f218b8e97861fb086f4b1068df (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
29
30
31
32
33
#include "cru/ui/controls/Window.hpp"

#include "cru/common/Base.hpp"
#include "cru/platform/gui/Base.hpp"
#include "cru/ui/host/WindowHost.hpp"
#include "cru/ui/render/Base.hpp"
#include "cru/ui/render/StackLayoutRenderObject.hpp"

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

Window::Window() : render_object_(new render::StackLayoutRenderObject()) {
  render_object_->SetAttachedControl(this);
  SetContainerRenderObject(render_object_.get());
  window_host_ = std::make_unique<host::WindowHost>(this);
}

Window::~Window() {}

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

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

void Window::Show(bool create) {
  platform::gui::INativeWindow* native_window =
      create ? window_host_->CreateNativeWindow().get()
             : window_host_->GetNativeWindow();
  if (!native_window) return;
  native_window->SetVisible(true);
}
}  // namespace cru::ui::controls