diff options
Diffstat (limited to 'src/ui/window.cpp')
-rw-r--r-- | src/ui/window.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/ui/window.cpp b/src/ui/window.cpp index e426bc78..349b78ff 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -31,7 +31,7 @@ namespace cru::ui } LRESULT __stdcall GeneralWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { - auto window = Application::GetInstance()->GetWindowManager()->FromHandle(hWnd); + auto window = WindowManager::GetInstance()->FromHandle(hWnd); LRESULT result; if (window != nullptr && window->HandleWindowMessage(hWnd, Msg, wParam, lParam, result)) @@ -40,6 +40,14 @@ namespace cru::ui return DefWindowProc(hWnd, Msg, wParam, lParam); } + WindowManager* WindowManager::GetInstance() + { + return Application::GetInstance()->ResolveSingleton<WindowManager>([](auto) + { + return new WindowManager{}; + }); + } + WindowManager::WindowManager() { general_window_class_ = std::make_unique<WindowClass>( L"CruUIWindowClass", @@ -106,20 +114,20 @@ namespace cru::ui } Window::Window() : Control(WindowConstructorTag{}, this), control_list_({ this }) { - const auto app = Application::GetInstance(); + const auto window_manager = WindowManager::GetInstance(); hwnd_ = CreateWindowEx(0, - app->GetWindowManager()->GetGeneralWindowClass()->GetName(), + window_manager->GetGeneralWindowClass()->GetName(), L"", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - nullptr, nullptr, app->GetInstanceHandle(), nullptr + nullptr, nullptr, Application::GetInstance()->GetInstanceHandle(), nullptr ); if (hwnd_ == nullptr) throw std::runtime_error("Failed to create window."); - app->GetWindowManager()->RegisterWindow(hwnd_, this); + window_manager->RegisterWindow(hwnd_, this); - render_target_ = app->GetGraphManager()->CreateWindowRenderTarget(hwnd_); + render_target_ = graph::GraphManager::GetInstance()->CreateWindowRenderTarget(hwnd_); SetCursor(cursors::arrow); } @@ -511,7 +519,7 @@ namespace cru::ui } void Window::OnDestroyInternal() { - Application::GetInstance()->GetWindowManager()->UnregisterWindow(hwnd_); + WindowManager::GetInstance()->UnregisterWindow(hwnd_); hwnd_ = nullptr; } |