mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 18:41:10 +02:00
Working on getting the offscreen UI working on retina
This commit is contained in:
parent
a624ff43c4
commit
759acfa175
2 changed files with 21 additions and 9 deletions
|
@ -764,6 +764,16 @@ void Application::initializeUi() {
|
||||||
return QPointF(p);
|
return QPointF(p);
|
||||||
});
|
});
|
||||||
offscreenUi->resume();
|
offscreenUi->resume();
|
||||||
|
connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect & r){
|
||||||
|
static qreal oldDevicePixelRatio = 0;
|
||||||
|
qreal devicePixelRatio = _glWidget->devicePixelRatio();
|
||||||
|
if (devicePixelRatio != oldDevicePixelRatio) {
|
||||||
|
oldDevicePixelRatio = devicePixelRatio;
|
||||||
|
qDebug() << "Device pixel ratio changed, triggering GL resize";
|
||||||
|
resizeGL(_glWidget->width(),
|
||||||
|
_glWidget->height());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::paintGL() {
|
void Application::paintGL() {
|
||||||
|
@ -906,7 +916,7 @@ void Application::resizeGL(int width, int height) {
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
offscreenUi->resize(QSize(width, height));
|
offscreenUi->resize(_glWidget->size());
|
||||||
|
|
||||||
// update Stats width
|
// update Stats width
|
||||||
// let's set horizontal offset to give stats some margin to mirror
|
// let's set horizontal offset to give stats some margin to mirror
|
||||||
|
|
|
@ -79,7 +79,8 @@ void OffscreenUi::resize(const QSize & newSize) {
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
|
|
||||||
// Clear out any fbos with the old size
|
// Clear out any fbos with the old size
|
||||||
_fboCache.setSize(newSize);
|
qreal pixelRatio = _renderControl->_renderWindow ? _renderControl->_renderWindow->devicePixelRatio() : 1.0;
|
||||||
|
_fboCache.setSize(newSize * pixelRatio);
|
||||||
|
|
||||||
// Update our members
|
// Update our members
|
||||||
if (_rootItem) {
|
if (_rootItem) {
|
||||||
|
@ -203,7 +204,7 @@ QPointF OffscreenUi::mapWindowToUi(const QPointF & p, QObject * dest) {
|
||||||
}
|
}
|
||||||
vec2 pos = toGlm(p);
|
vec2 pos = toGlm(p);
|
||||||
pos /= sourceSize;
|
pos /= sourceSize;
|
||||||
pos *= vec2(toGlm(_quickWindow->renderTargetSize()));
|
pos *= vec2(toGlm(_quickWindow->size()));
|
||||||
return QPointF(pos.x, pos.y);
|
return QPointF(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,11 +301,13 @@ void OffscreenUi::setProxyWindow(QWindow * window) {
|
||||||
|
|
||||||
void OffscreenUi::show(const QUrl & url, const QString & name) {
|
void OffscreenUi::show(const QUrl & url, const QString & name) {
|
||||||
QQuickItem * item = _rootItem->findChild<QQuickItem*>(name);
|
QQuickItem * item = _rootItem->findChild<QQuickItem*>(name);
|
||||||
|
if (nullptr == item) {
|
||||||
|
load(url);
|
||||||
|
item = _rootItem->findChild<QQuickItem*>(name);
|
||||||
|
}
|
||||||
|
|
||||||
if (nullptr != item) {
|
if (nullptr != item) {
|
||||||
item->setEnabled(true);
|
item->setEnabled(true);
|
||||||
item->setVisible(true);
|
|
||||||
} else {
|
|
||||||
load(url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +315,7 @@ void OffscreenUi::toggle(const QUrl & url, const QString & name) {
|
||||||
QQuickItem * item = _rootItem->findChild<QQuickItem*>(name);
|
QQuickItem * item = _rootItem->findChild<QQuickItem*>(name);
|
||||||
// First load?
|
// First load?
|
||||||
if (nullptr == item) {
|
if (nullptr == item) {
|
||||||
load(url);
|
show(url, name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,12 +323,11 @@ void OffscreenUi::toggle(const QUrl & url, const QString & name) {
|
||||||
// dialogs can still swallow keyboard input)
|
// dialogs can still swallow keyboard input)
|
||||||
bool newFlag = !item->isEnabled();
|
bool newFlag = !item->isEnabled();
|
||||||
item->setEnabled(newFlag);
|
item->setEnabled(newFlag);
|
||||||
// item->setVisible(newFlag);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OffscreenUi::load(const QUrl & url) {
|
void OffscreenUi::load(const QUrl & url) {
|
||||||
|
qDebug() << "Loading from url: " << url;
|
||||||
QVariant returnedValue;
|
QVariant returnedValue;
|
||||||
QVariant msg = url;
|
QVariant msg = url;
|
||||||
QMetaObject::invokeMethod(_rootItem, "loadChild",
|
QMetaObject::invokeMethod(_rootItem, "loadChild",
|
||||||
|
|
Loading…
Reference in a new issue