Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 969 vs 970 for /trunk/Source Code/Editor/Widgets/ImWindowDivide.cpp

Diff revisions: vs.
  @@ -17,12 +17,16 @@
17 17 , _isMainWindow(false)
18 18 , _windowGUID(-1)
19 19 {
20 - Attorney::WindowManagerWindow::registerWindow(_parent, this);
20 + Attorney::WindowManagerWindow::onCreateWindow(_parent, this);
21 21 }
22 22
23 23 ImwWindowDivide::~ImwWindowDivide()
24 24 {
25 - Attorney::WindowManagerWindow::unregisterWindow(_parent, this);
25 + Attorney::WindowManagerWindow::onDestroyWindow(_parent, this);
26 + }
27 +
28 + void ImwWindowDivide::onDestroyPlatformWindow() {
29 + _pWindow = nullptr;
26 30 }
27 31
28 32 bool ImwWindowDivide::Init(ImwPlatformWindow* parent)
  @@ -31,10 +35,17 @@
31 35
32 36 if (pMainDivide != nullptr) {
33 37 WindowDescriptor descriptor;
34 - descriptor.fullscreen = false;
35 38 descriptor.title = "ImWindow";
36 39 descriptor.targetDisplay = 0;
37 40 descriptor.dimensions.set(_context.config().runtime.resolution);
41 + descriptor.clearColour.set(DefaultColours::RED);
42 + SetBit(descriptor.flags, to_base(WindowDescriptor::Flags::HIDDEN));
43 +
44 + if (GetType() != ImWindow::E_PLATFORM_WINDOW_TYPE_MAIN &&
45 + GetType() != ImWindow::E_PLATFORM_WINDOW_TYPE_SECONDARY)
46 + {
47 + ClearBit(descriptor.flags, to_base(WindowDescriptor::Flags::DECORATED));
48 + }
38 49
39 50 ErrorCode err = ErrorCode::NO_ERR;
40 51 U32 idx = _context.app().windowManager().createWindow(descriptor, err);
  @@ -47,6 +58,8 @@
47 58 _pWindow = &_context.app().windowManager().getWindow(0u);
48 59 _isMainWindow = true;
49 60 }
61 + _pWindow->destroyCbk([this]() { onDestroyPlatformWindow();} );
62 +
50 63 SetState();
51 64 ImGuiIO& io = ImGui::GetIO();
52 65 io.RenderDrawListsFn = nullptr;
  @@ -63,14 +76,19 @@
63 76 _pWindow->addEventListener(WindowEvent::MOUSE_WHEEL, [this](const DisplayWindow::WindowEventArgs& args) { OnMouseWheel(args._mod);});
64 77 _pWindow->addEventListener(WindowEvent::KEY_PRESS, [this](const DisplayWindow::WindowEventArgs& args) { OnKey(args._key, args._flag);});
65 78 _pWindow->addEventListener(WindowEvent::TEXT, [this](const DisplayWindow::WindowEventArgs& args) { OnUTF8(args._text);});
66 - // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime.
79 + if (GetType() == ImWindow::E_PLATFORM_WINDOW_TYPE_DRAG_PREVIEW) {
80 + //_pWindow->opacity(128);
81 + }
67 82
68 83 return true;
69 84 }
70 85
71 86 ImVec2 ImwWindowDivide::GetPosition() const
72 87 {
73 - return ImVec2(_pWindow->getPosition());
88 + if (_pWindow != nullptr) {
89 + return ImVec2(_pWindow->getPosition());
90 + }
91 + return ImVec2(1.0f, 1.0f);
74 92 }
75 93
76 94 ImVec2 ImwWindowDivide::GetSize() const
  @@ -85,40 +103,59 @@
85 103
86 104 bool ImwWindowDivide::IsWindowMaximized() const
87 105 {
88 - return _pWindow->maximized();
106 + if (_pWindow != nullptr) {
107 + return _pWindow->maximized();
108 + }
109 + return false;
89 110 }
90 111
91 112 bool ImwWindowDivide::IsWindowMinimized() const {
92 - return _pWindow->minimized();
113 + if (_pWindow != nullptr) {
114 + return _pWindow->minimized();
115 + }
116 +
117 + return false;
93 118 }
94 119
95 120 void ImwWindowDivide::Show(bool bShow) {
96 - _pWindow->hidden(!bShow);
121 + if (_pWindow != nullptr) {
122 + _pWindow->hidden(!bShow);
123 + }
97 124 }
98 125
99 126 void ImwWindowDivide::SetSize(int iWidth, int iHeight)
100 127 {
101 - _pWindow->setDimensions(to_U16(iWidth), to_U16(iHeight));
128 + if (_pWindow != nullptr) {
129 + _pWindow->setDimensions(to_U16(iWidth), to_U16(iHeight));
130 + }
102 131 }
103 132
104 133 void ImwWindowDivide::SetPosition(int iX, int iY)
105 134 {
106 - _pWindow->setPosition(iX, iY);
135 + if (_pWindow != nullptr) {
136 + _pWindow->setPosition(iX, iY);
137 + }
107 138 }
108 139
109 140 void ImwWindowDivide::SetWindowMaximized(bool bMaximized)
110 141 {
111 - _pWindow->maximized(bMaximized);
142 + if (_pWindow != nullptr) {
143 + _pWindow->maximized(bMaximized);
144 + }
112 145 }
113 146
114 147 void ImwWindowDivide::SetWindowMinimized()
115 148 {
116 - _pWindow->minimized(true);
149 + if (_pWindow != nullptr) {
150 + _pWindow->minimized(true);
151 + }
117 152 }
118 153
119 154 void ImwWindowDivide::SetTitle(const char* pTitle)
120 155 {
121 - _pWindow->title(pTitle);
156 + if (_pWindow != nullptr) {
157 + _pWindow->title(pTitle);
158 + }
122 159 }
123 160
124 161 void ImwWindowDivide::PreUpdate()
  @@ -157,9 +194,11 @@
157 194 {
158 195 ACKNOWLEDGE_UNUSED(iWidth);
159 196 ACKNOWLEDGE_UNUSED(iHeight);
160 - _size = ImVec2(_pWindow->getDimensions());
161 - vec2<U16> display_size = _pWindow->getDrawableSize();
162 - _drawableSize = ImVec2(_size.x > 0 ? ((float)display_size.w / _size.x) : 0, _size.y > 0 ? ((float)display_size.h / _size.y) : 0);
197 + if (_pWindow != nullptr) {
198 + _size = ImVec2(_pWindow->getDimensions());
199 + vec2<U16> display_size = _pWindow->getDrawableSize();
200 + _drawableSize = ImVec2(_size.x > 0 ? ((float)display_size.w / _size.x) : 0, _size.y > 0 ? ((float)display_size.h / _size.y) : 0);
201 + }
163 202 }
164 203
165 204 void ImwWindowDivide::OnMouseButton(int iButton, bool bDown)