summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Render/StudioRenderer.cpp
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2018-05-15 11:49:01 +0300
committerJanne Kangas <janne.kangas@qt.io>2018-05-30 09:22:27 +0000
commit013735c73b0f6b2f32d4c39425884fa86dc2ded5 (patch)
treea34ea2e57d2af737967e59e99a3f7d106c5b5c35 /src/Authoring/Studio/Render/StudioRenderer.cpp
parent22c412cc609330d05b99beec11e0201ff99a3002 (diff)
Update scene renderer display scaling factor when GL view rect changes
Get current display scaling factor when render rectangle changes size. Fixes incorrect mouse click coordinate mapping after rescaling (Studio window moved from one monitor to another, for example). Change-Id: Id9d82775e9c11fac308085b0a7891dfa610e8d05 Task-Id: QT3DS-1673 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Render/StudioRenderer.cpp')
-rw-r--r--src/Authoring/Studio/Render/StudioRenderer.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Authoring/Studio/Render/StudioRenderer.cpp b/src/Authoring/Studio/Render/StudioRenderer.cpp
index 8265be69..be0bdf8c 100644
--- a/src/Authoring/Studio/Render/StudioRenderer.cpp
+++ b/src/Authoring/Studio/Render/StudioRenderer.cpp
@@ -94,6 +94,7 @@ struct SRendererImpl : public IStudioRenderer,
int m_LastToolMode;
bool m_GuidesEnabled;
qt3dsdm::TSignalConnectionPtr m_SelectionSignal;
+ float m_pixelRatio;
SRendererImpl()
: m_Dispatch(*g_StudioApp.GetCore()->GetDispatch())
@@ -107,6 +108,7 @@ struct SRendererImpl : public IStudioRenderer,
, m_RenderRequested(false)
, m_LastToolMode(0)
, m_GuidesEnabled(true)
+ , m_pixelRatio(0.0)
{
m_Dispatch.AddReloadListener(this);
m_Dispatch.AddDataModelListener(this);
@@ -223,6 +225,7 @@ struct SRendererImpl : public IStudioRenderer,
m_Rect = inRect;
if (IsInitialized()) {
+ m_pixelRatio = devicePixelRatio();
m_RenderContext->BeginRender();
NVRenderContext &theContext = m_RenderContext->GetRenderContext();
theContext.SetViewport(qt3ds::render::NVRenderRect(0, 0, inRect.width(),
@@ -568,8 +571,8 @@ struct SRendererImpl : public IStudioRenderer,
if (m_Translation == NULL)
return;
- inPoint.setX(inPoint.x() * devicePixelRatio());
- inPoint.setY(inPoint.y() * devicePixelRatio());
+ inPoint.setX(inPoint.x() * m_pixelRatio);
+ inPoint.setY(inPoint.y() * m_pixelRatio);
m_PickResult = SStudioPickValue();
TranslationSelectMode::Enum theSelectMode = TranslationSelectMode::Group;
@@ -634,8 +637,8 @@ struct SRendererImpl : public IStudioRenderer,
if (m_Translation == NULL)
return;
- inPoint.setX(inPoint.x() * devicePixelRatio());
- inPoint.setY(inPoint.y() * devicePixelRatio());
+ inPoint.setX(inPoint.x() * m_pixelRatio);
+ inPoint.setY(inPoint.y() * m_pixelRatio);
if (m_MaybeDragStart) {
// Dragging in the first 5 pixels will be ignored to avoid unconsciously accidental
@@ -837,8 +840,8 @@ struct SRendererImpl : public IStudioRenderer,
void OnSceneMouseDblClick(SceneDragSenderType::Enum inSenderType, QPoint inPoint) override
{
if (inSenderType == SceneDragSenderType::SceneWindow && m_Translation) {
- inPoint.setX(inPoint.x() * devicePixelRatio());
- inPoint.setY(inPoint.y() * devicePixelRatio());
+ inPoint.setX(inPoint.x() * m_pixelRatio);
+ inPoint.setY(inPoint.y() * m_pixelRatio);
m_RenderContext->BeginRender();
SStudioPickValue theResult(
m_Translation->Pick(inPoint, TranslationSelectMode::NestedComponentSingle));