aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/controls/Window.h
blob: 2c650c414972856c9b5129681930c95f867b0e95 (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
34
35
36
37
38
39
40
41
42
#pragma once
#include "../render/StackLayoutRenderObject.h"
#include "ControlHost.h"
#include "LayoutControl.h"

#include <cru/base/Base.h>
#include <cru/base/Event.h>
#include <cru/base/Guard.h>
#include <cru/base/log/Logger.h>
#include <cru/platform/gui/UiApplication.h>
#include <cru/platform/gui/Window.h>

#include <memory>

namespace cru::ui::controls {
class CRU_UI_API Window
    : public LayoutControl<render::StackLayoutRenderObject> {
  CRU_DEFINE_CLASS_LOG_TAG("cru::ui::controls::Window")
  friend Control;

 public:
  static constexpr auto kControlName = "Window";

  Window();

  static Window* CreatePopup();

  void SetAttachedControl(Control* control);

  platform::gui::INativeWindow* GetNativeWindow();

  void SetGainFocusOnCreateAndDestroyWhenLoseFocus(bool value);

 private:
  std::unique_ptr<ControlHost> control_host_;

  Control* attached_control_;

  EventHandlerRevokerListGuard
      gain_focus_on_create_and_destroy_when_lose_focus_event_guard_;
};
}  // namespace cru::ui::controls