Expose device-pixel-ratio to properties.
This allows scaling of the UI accordingly, to keep things usable on HiDPi screens. (Note this is not fixed yet, but this is a step)
This commit is contained in:
parent
4d900a5c26
commit
09972be25a
3 changed files with 22 additions and 9 deletions
|
@ -141,6 +141,12 @@ void GLWindow::onScreenChanged()
|
|||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
|
||||
_devicePixelRatio = screen()->devicePixelRatio();
|
||||
#endif
|
||||
|
||||
if (_isPrimaryWindow) {
|
||||
// allow PUI and Canvas to be scaled
|
||||
fgSetDouble("/sim/rendering/gui-pixel-ratio", _devicePixelRatio);
|
||||
}
|
||||
|
||||
syncGeometryWithOSG();
|
||||
}
|
||||
|
||||
|
@ -355,8 +361,6 @@ void GLWindow::wheelEvent( QWheelEvent* event )
|
|||
}
|
||||
|
||||
GraphicsWindowQt5::GraphicsWindowQt5(osg::GraphicsContext::Traits* traits)
|
||||
: _realized(false)
|
||||
, _updateContextNeeded(false)
|
||||
{
|
||||
_traits = traits;
|
||||
init(0);
|
||||
|
@ -385,14 +389,12 @@ bool GraphicsWindowQt5::init( Qt::WindowFlags f )
|
|||
//flags |= Qt::MaximizeUsingFullscreenGeometryHint;
|
||||
}
|
||||
|
||||
// create widget
|
||||
// create window
|
||||
_window.reset(new GLWindow);
|
||||
_window->setFlags(flags);
|
||||
_window->setSurfaceType(QSurface::OpenGLSurface);
|
||||
_window->setFormat(traits2qSurfaceFormat(_traits.get()));
|
||||
_window->create();
|
||||
|
||||
|
||||
_window->setTitle( _traits->windowName.c_str() );
|
||||
|
||||
// to get OS-dependant default positioning of the window (which is desirable),
|
||||
|
@ -418,6 +420,10 @@ bool GraphicsWindowQt5::init( Qt::WindowFlags f )
|
|||
}
|
||||
|
||||
_window->_isPrimaryWindow = windowData->isPrimaryWindow;
|
||||
if (_window->_isPrimaryWindow) {
|
||||
fgSetDouble("/sim/rendering/gui-pixel-ratio", _window->_devicePixelRatio);
|
||||
}
|
||||
|
||||
_window->setGraphicsWindow( this );
|
||||
useCursor( _traits->useCursor );
|
||||
|
||||
|
@ -760,7 +766,11 @@ void GraphicsWindowQt5::requestRedraw()
|
|||
|
||||
void GraphicsWindowQt5::requestContinuousUpdate(bool needed)
|
||||
{
|
||||
_continousUpdate = needed;
|
||||
GraphicsWindow::requestContinuousUpdate(needed);
|
||||
if (_continousUpdate) {
|
||||
_window->requestUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsWindowQt5::setFullscreen(bool isFullscreen)
|
||||
|
|
|
@ -112,7 +112,7 @@ protected:
|
|||
QSet<QEvent::Type> _eventCompressor;
|
||||
|
||||
bool _forwardKeyEvents = false;
|
||||
qreal _devicePixelRatio;
|
||||
qreal _devicePixelRatio = 1.0;
|
||||
|
||||
// is this the primary (GUI) window
|
||||
bool _isPrimaryWindow = false;
|
||||
|
@ -198,8 +198,9 @@ protected:
|
|||
QOpenGLContext* _shareContext = nullptr;
|
||||
bool _ownsWidget;
|
||||
QCursor _currentCursor;
|
||||
bool _realized;
|
||||
bool _updateContextNeeded;
|
||||
bool _realized = false;
|
||||
bool _updateContextNeeded = false;
|
||||
bool _continousUpdate = false;
|
||||
osg::observer_ptr< osgViewer::ViewerBase > _viewer;
|
||||
|
||||
// if true, we will generate a resize event on the next
|
||||
|
|
|
@ -372,6 +372,8 @@ void fgOSInit(int* argc, char** argv)
|
|||
SG_LOG(SG_GL, SG_INFO, "Using Qt implementation of GraphicsWindow");
|
||||
flightgear::initQtWindowingSystem();
|
||||
} else {
|
||||
// stock OSG windows are not Hi-DPI aware
|
||||
fgSetDouble("/sim/rendering/gui-pixel-ratio", 1.0);
|
||||
SG_LOG(SG_GL, SG_INFO, "Using stock OSG implementation of GraphicsWindow");
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue