diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-09-05 13:39:21 +0200 |
---|---|---|
committer | Antti Kokko <antti.kokko@qt.io> | 2018-09-07 06:51:53 +0000 |
commit | e9ca04e5f821e07153245854783a34eff3848bf3 (patch) | |
tree | 61ffcd95c4faf74b4f72e5b24ffae3fe6fcd259d | |
parent | d4455dba8adae02bdfcebc6c328c33cdbbb1241d (diff) |
Change origin for Right and Bottom calculations
Right and Bottom are pixels or percentage from the right or bottom side of
the output. Until now we treated them as values with the top-left as the
origin. Correct this to stay compatible with 3DS1.
Task-number: QT3DS-2200
Change-Id: I5ffa1444f2e5b545ff194c4b418c0536765393e9
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r-- | src/runtime/q3dsscenemanager.cpp | 48 | ||||
-rw-r--r-- | tests/scenes/layersizepos/sizingmodes.uip | 53 |
2 files changed, 89 insertions, 12 deletions
diff --git a/src/runtime/q3dsscenemanager.cpp b/src/runtime/q3dsscenemanager.cpp index f09efb6..8def542 100644 --- a/src/runtime/q3dsscenemanager.cpp +++ b/src/runtime/q3dsscenemanager.cpp @@ -1586,14 +1586,20 @@ QSize Q3DSSceneManager::calculateLayerSize(Q3DSLayerNode *layer3DS, const QSize Q_FALLTHROUGH(); case Q3DSLayerNode::WidthRight: { - int width = qRound(layer3DS->widthUnits() == Q3DSLayerNode::Percent ? layer3DS->width() * 0.01f * parentSize.width() : layer3DS->width()); + int width = qRound(layer3DS->widthUnits() == Q3DSLayerNode::Percent + ? layer3DS->width() * 0.01f * parentSize.width() + : layer3DS->width()); w = width; } break; case Q3DSLayerNode::LeftRight: { - float left = layer3DS->leftUnits() == Q3DSLayerNode::Percent ? layer3DS->left() * 0.01f * parentSize.width() : layer3DS->left(); - float right = layer3DS->rightUnits() == Q3DSLayerNode::Percent ? parentSize.width() - (layer3DS->right() * 0.01f * parentSize.width()) : layer3DS->right(); + float left = layer3DS->leftUnits() == Q3DSLayerNode::Percent + ? layer3DS->left() * 0.01f * parentSize.width() + : layer3DS->left(); + float right = layer3DS->rightUnits() == Q3DSLayerNode::Percent + ? parentSize.width() - (layer3DS->right() * 0.01f * parentSize.width()) + : parentSize.width() - layer3DS->right(); w = qRound(right - left) + 1; } break; @@ -1608,14 +1614,20 @@ QSize Q3DSSceneManager::calculateLayerSize(Q3DSLayerNode *layer3DS, const QSize Q_FALLTHROUGH(); case Q3DSLayerNode::HeightBottom: { - int height = qRound(layer3DS->heightUnits() == Q3DSLayerNode::Percent ? layer3DS->height() * 0.01f * parentSize.height() : layer3DS->height()); + int height = qRound(layer3DS->heightUnits() == Q3DSLayerNode::Percent + ? layer3DS->height() * 0.01f * parentSize.height() + : layer3DS->height()); h = height; } break; case Q3DSLayerNode::TopBottom: { - float top = layer3DS->topUnits() == Q3DSLayerNode::Percent ? layer3DS->top() * 0.01f * parentSize.height() : layer3DS->top(); - float bottom = layer3DS->bottomUnits() == Q3DSLayerNode::Percent ? parentSize.height() - (layer3DS->bottom() * 0.01f * parentSize.height()) : layer3DS->bottom(); + float top = layer3DS->topUnits() == Q3DSLayerNode::Percent + ? layer3DS->top() * 0.01f * parentSize.height() + : layer3DS->top(); + float bottom = layer3DS->bottomUnits() == Q3DSLayerNode::Percent + ? parentSize.height() - (layer3DS->bottom() * 0.01f * parentSize.height()) + : parentSize.height() - layer3DS->bottom(); h = qRound(bottom - top) + 1; } break; @@ -1635,14 +1647,20 @@ QPointF Q3DSSceneManager::calculateLayerPos(Q3DSLayerNode *layer3DS, const QSize Q_FALLTHROUGH(); case Q3DSLayerNode::LeftRight: { - float left = layer3DS->leftUnits() == Q3DSLayerNode::Percent ? layer3DS->left() * 0.01f * parentSize.width() : layer3DS->left(); + float left = layer3DS->leftUnits() == Q3DSLayerNode::Percent + ? layer3DS->left() * 0.01f * parentSize.width() + : layer3DS->left(); x = left; } break; case Q3DSLayerNode::WidthRight: { - float right = layer3DS->rightUnits() == Q3DSLayerNode::Percent ? parentSize.width() - (layer3DS->right() * 0.01f * parentSize.width()) : layer3DS->right(); - float width = layer3DS->widthUnits() == Q3DSLayerNode::Percent ? layer3DS->width() * 0.01f * parentSize.width() : layer3DS->width(); + float right = layer3DS->rightUnits() == Q3DSLayerNode::Percent + ? parentSize.width() - (layer3DS->right() * 0.01f * parentSize.width()) + : parentSize.width() - layer3DS->right(); + float width = layer3DS->widthUnits() == Q3DSLayerNode::Percent + ? layer3DS->width() * 0.01f * parentSize.width() + : layer3DS->width(); x = right - width + 1; } break; @@ -1657,14 +1675,20 @@ QPointF Q3DSSceneManager::calculateLayerPos(Q3DSLayerNode *layer3DS, const QSize Q_FALLTHROUGH(); case Q3DSLayerNode::TopBottom: { - float top = layer3DS->topUnits() == Q3DSLayerNode::Percent ? layer3DS->top() * 0.01f * parentSize.height() : layer3DS->top(); + float top = layer3DS->topUnits() == Q3DSLayerNode::Percent + ? layer3DS->top() * 0.01f * parentSize.height() + : layer3DS->top(); y = top; } break; case Q3DSLayerNode::HeightBottom: { - float bottom = layer3DS->bottomUnits() == Q3DSLayerNode::Percent ? parentSize.height() - (layer3DS->bottom() * 0.01f * parentSize.height()) : layer3DS->bottom(); - float height = layer3DS->heightUnits() == Q3DSLayerNode::Percent ? layer3DS->height() * 0.01f * parentSize.height() : layer3DS->height(); + float bottom = layer3DS->bottomUnits() == Q3DSLayerNode::Percent + ? parentSize.height() - (layer3DS->bottom() * 0.01f * parentSize.height()) + : parentSize.height() - layer3DS->bottom(); + float height = layer3DS->heightUnits() == Q3DSLayerNode::Percent + ? layer3DS->height() * 0.01f * parentSize.height() + : layer3DS->height(); y = bottom - height + 1; } break; diff --git a/tests/scenes/layersizepos/sizingmodes.uip b/tests/scenes/layersizepos/sizingmodes.uip new file mode 100644 index 0000000..8282e12 --- /dev/null +++ b/tests/scenes/layersizepos/sizingmodes.uip @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<UIP version="4" > + <Project > + <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="600" maintainAspect="False" > + <CustomColors count="16" >#ffffff #1e1e1e #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #646464</CustomColors> + </ProjectSettings> + <Graph > + <Scene id="Scene" > + <Layer id="Layer3" > + <Camera id="Camera_002" /> + <Light id="Light_002" /> + </Layer> + <Layer id="Layer2" > + <Camera id="Camera_001" /> + <Light id="Light_001" /> + </Layer> + <Layer id="Layer4" > + <Camera id="Camera_003" /> + <Light id="Light_003" /> + </Layer> + <Layer id="Layer5" > + <Camera id="Camera_004" /> + <Light id="Light_004" /> + </Layer> + <Layer id="Layer" > + <Camera id="Camera" /> + <Light id="Light" /> + </Layer> + </Scene> + </Graph> + <Logic > + <State name="Master Slide" component="#Scene" > + <Add ref="#Layer" background="SolidColor" backgroundcolor="0.541176 0.137255 0.211765" /> + <Add ref="#Camera" /> + <Add ref="#Light" /> + <State id="Scene-Slide1" name="Slide1" > + <Add ref="#Layer3" name="Layer3" background="SolidColor" backgroundcolor="0.0745098 0.0745098 0.839216" height="150" heightunits="pixels" left="200" leftunits="pixels" top="250" topunits="pixels" width="300" widthunits="pixels" /> + <Add ref="#Camera_002" /> + <Add ref="#Light_002" /> + <Add ref="#Layer2" name="Layer2" background="SolidColor" backgroundcolor="0.133333 0.513726 0.192157" bottom="80" bottomunits="pixels" heightunits="pixels" left="100" leftunits="pixels" top="100" topunits="pixels" vertfields="Height/Bottom" width="200" widthunits="pixels" /> + <Add ref="#Camera_001" /> + <Add ref="#Light_001" /> + <Add ref="#Layer4" name="Layer4" background="SolidColor" backgroundcolor="0.513726 0.462745 0.0666667" bottom="200" bottomunits="pixels" heightunits="pixels" horzfields="Width/Right" left="100" leftunits="pixels" right="10" top="50" topunits="pixels" vertfields="Top/Bottom" width="200" widthunits="pixels" /> + <Add ref="#Camera_003" /> + <Add ref="#Light_003" /> + <Add ref="#Layer5" name="Layer5" background="SolidColor" backgroundcolor="0.337255 0.482353 0.513726" bottom="10" bottomunits="percent" heightunits="pixels" horzfields="Width/Right" left="100" leftunits="pixels" right="20" rightunits="pixels" top="70" topunits="percent" vertfields="Top/Bottom" width="200" widthunits="pixels" /> + <Add ref="#Camera_004" /> + <Add ref="#Light_004" /> + </State> + </State> + </Logic> + </Project> +</UIP> |