Add multi-windows support (#12243)

Co-authored-by: bofeng.song <bofeng.song@chukong-inc.com>
This commit is contained in:
林玮
2022-09-15 14:55:44 +08:00
committed by GitHub
parent 2afd02e711
commit 785fd91511
83 changed files with 1906 additions and 381 deletions
@@ -34,53 +34,67 @@
#include "sdl2/SDL_clipboard.h"
namespace cc {
SystemWindow::SystemWindow(IEventDispatch *delegate)
: _sdl(std::make_unique<SDLHelper>(delegate)) {
SystemWindow::SystemWindow(uint32_t windowId, void *externalHandle)
: _windowId(windowId) {
if (externalHandle) {
_windowHandle = reinterpret_cast<uintptr_t>(externalHandle);
}
}
SystemWindow::~SystemWindow() {
}
int SystemWindow::init() {
return _sdl->init();
}
void SystemWindow::pollEvent(bool *quit) {
return _sdl->pollEvent(quit);
_windowHandle = 0;
_windowId = 0;
}
void SystemWindow::swapWindow() {
_sdl->swapWindow();
SDLHelper::swapWindow(_window);
}
bool SystemWindow::createWindow(const char *title,
int w, int h, int flags) {
_sdl->createWindow(title, w, h, flags);
_window = SDLHelper::createWindow(title, w, h, flags);
if (!_window) {
return false;
}
_width = w;
_height = h;
_windowHandle = SDLHelper::getWindowHandle(_window);
return true;
}
bool SystemWindow::createWindow(const char *title,
int x, int y, int w,
int h, int flags) {
_sdl->createWindow(title, x, y, w, h, flags);
_width = w;
_window = SDLHelper::createWindow(title, x, y, w, h, flags);
if (!_window) {
return false;
}
_width = w;
_height = h;
_windowHandle = SDLHelper::getWindowHandle(_window);
return true;
}
void SystemWindow::closeWindow() {
HWND windowHandle = reinterpret_cast<HWND>(getWindowHandle());
if (windowHandle != 0) {
::SendMessageA(windowHandle, WM_CLOSE, 0, 0);
}
}
uint32_t SystemWindow::getWindowId() const {
return _windowId;
}
uintptr_t SystemWindow::getWindowHandle() const {
return _sdl->getWindowHandle();
return _windowHandle;
}
void SystemWindow::setCursorEnabled(bool value) {
_sdl->setCursorEnabled(value);
SDLHelper::setCursorEnabled(value);
}
void SystemWindow::copyTextToClipboard(const ccstd::string &text) {