V3.5.0 create window (#10481)

* 1. Modify the parameters of the creation window
2. Modify the relationship between platform and interface
3. Rename vibrate to vibrator in linux and QNX

* Fix empty platform implementation

* Fix empty platform implementation

* Modify mac and ios createwindow interface

* Create a centered window by default

* Mobile platforms do not require window creation
This commit is contained in:
qiuguohua
2022-03-25 18:43:17 +08:00
committed by GitHub
parent 1f11536a1f
commit b6af1ada02
62 changed files with 419 additions and 762 deletions
@@ -35,41 +35,57 @@
#include "SDL2/SDL_syswm.h"
#include "bindings/event/EventDispatcher.h"
#include "platform/IEventDispatch.h"
#include "platform/linux/LinuxPlatform.h"
namespace {
} // namespace
#include "platform/SDLHelper.h"
namespace cc {
SystemWindow::SystemWindow() {
SystemWindow::SystemWindow(IEventDispatch *delegate)
: _sdl(std::make_unique<SDLHelper>(delegate)) {
}
SystemWindow::~SystemWindow() {
}
int SystemWindow::init() {
return _sdl->init();
}
void SystemWindow::pollEvent(bool *quit) {
return _sdl->pollEvent(quit);
}
void SystemWindow::swapWindow() {
_sdl->swapWindow();
}
bool SystemWindow::createWindow(const char *title,
int w, int h, int flags) {
_sdl->createWindow(title, w, h, flags);
_width = w;
_height = h;
return true;
}
bool SystemWindow::createWindow(const char *title,
int x, int y, int w,
int h, int flags) {
// Create window
LinuxPlatform *platform = dynamic_cast<LinuxPlatform *>(BasePlatform::getPlatform());
CCASSERT(platform != nullptr, "Platform pointer can't be null");
platform->createWindow(title, x, y, w, h, flags);
_sdl->createWindow(title, x, y, w, h, flags);
_width = w;
_height = h;
return true;
}
uintptr_t SystemWindow::getWindowHandler() const {
//return _handle;
LinuxPlatform *platform = dynamic_cast<LinuxPlatform *>(BasePlatform::getPlatform());
CCASSERT(platform != nullptr, "Platform pointer can't be null");
return platform->getWindowHandler();
return _sdl->getWindowHandler();
}
uintptr_t SystemWindow::getDisplay() const {
return _sdl->getDisplay();
}
void SystemWindow::setCursorEnabled(bool value) {
SDL_SetRelativeMouseMode(value ? SDL_FALSE : SDL_TRUE);
_sdl->setCursorEnabled(value);
}
void SystemWindow::copyTextToClipboard(const std::string &text) {