aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/controls/Window.h
blob: a2ae01f9e61afcdcb13d3674b5e18386c9f24309 (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
#pragma once
#include "../render/StackLayoutRenderObject.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>

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 std::string_view kControlType = "Window";

  Window();

  static Window* CreatePopup();

  std::string GetControlType() const override;

  void SetAttachedControl(Control* control);

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

  void SetGainFocusOnCreateAndDestroyWhenLoseFocus(bool value);

 private:
  std::shared_ptr<ControlHost> control_host_;

  Control* attached_control_;

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