mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +02:00
move subImage recalculation to it's own method
This commit is contained in:
parent
f9bcd23463
commit
787127b149
1 changed files with 16 additions and 12 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue