From f9bcd23463bc7dfa2cfb0041e22339087d7b6a8b Mon Sep 17 00:00:00 2001 From: WolfGang Date: Wed, 4 Apr 2018 17:28:55 +0100 Subject: [PATCH 1/2] make subimage update the image anchors --- interface/resources/qml/hifi/overlays/ImageOverlay.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/resources/qml/hifi/overlays/ImageOverlay.qml b/interface/resources/qml/hifi/overlays/ImageOverlay.qml index cbcf6c7910..0171ac7b2c 100644 --- a/interface/resources/qml/hifi/overlays/ImageOverlay.qml +++ b/interface/resources/qml/hifi/overlays/ImageOverlay.qml @@ -62,6 +62,7 @@ Overlay { case "height": image.ySize = value; break; } } + image.resizer.start(); } function updatePropertiesFromScript(properties) { From 787127b149d35cae3565b87ca3e94e47c7a7149e Mon Sep 17 00:00:00 2001 From: WolfGang Date: Wed, 4 Apr 2018 22:10:54 +0100 Subject: [PATCH 2/2] move subImage recalculation to it's own method --- .../qml/hifi/overlays/ImageOverlay.qml | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/interface/resources/qml/hifi/overlays/ImageOverlay.qml b/interface/resources/qml/hifi/overlays/ImageOverlay.qml index 0171ac7b2c..c1ed166769 100644 --- a/interface/resources/qml/hifi/overlays/ImageOverlay.qml +++ b/interface/resources/qml/hifi/overlays/ImageOverlay.qml @@ -20,17 +20,7 @@ Overlay { repeat: false running: false onTriggered: { - if (image.xSize === 0) { - image.xSize = image.sourceSize.width - image.xStart; - } - if (image.ySize === 0) { - image.ySize = image.sourceSize.height - image.yStart; - } - - image.anchors.leftMargin = -image.xStart * root.width / image.xSize; - image.anchors.topMargin = -image.yStart * root.height / image.ySize; - image.anchors.rightMargin = (image.xStart + image.xSize - image.sourceSize.width) * root.width / image.xSize; - image.anchors.bottomMargin = (image.yStart + image.ySize - image.sourceSize.height) * root.height / image.ySize; + recalculateMargins(); } } @@ -44,6 +34,20 @@ Overlay { anchors.fill: parent } + function recalculateMargins() { + if (image.xSize === 0) { + image.xSize = image.sourceSize.width - image.xStart; + } + if (image.ySize === 0) { + image.ySize = image.sourceSize.height - image.yStart; + } + + image.anchors.leftMargin = -image.xStart * root.width / image.xSize; + image.anchors.topMargin = -image.yStart * root.height / image.ySize; + image.anchors.rightMargin = (image.xStart + image.xSize - image.sourceSize.width) * root.width / image.xSize; + image.anchors.bottomMargin = (image.yStart + image.ySize - image.sourceSize.height) * root.height / image.ySize; + } + ColorOverlay { id: color anchors.fill: image @@ -62,7 +66,7 @@ Overlay { case "height": image.ySize = value; break; } } - image.resizer.start(); + recalculateMargins(); } function updatePropertiesFromScript(properties) {