[ui] CameraController: avoid allocating new objects on bindings

Change existing objects values instead of re-creating point/size objects, on bindings that can be evaluated very often.
This commit is contained in:
Yann Lanthony 2019-02-07 18:14:16 +01:00
parent 1793a30861
commit 829aa24a4a
2 changed files with 7 additions and 3 deletions

View file

@ -44,7 +44,8 @@ Entity {
sourceDevice: mouseSourceDevice
onPressed: {
_pressed = true;
currentPosition = lastPosition = Qt.point(mouse.x, mouse.y);
currentPosition.x = lastPosition.x = mouse.x;
currentPosition.y = lastPosition.y = mouse.y;
mousePressed(mouse);
}
onReleased: {
@ -52,7 +53,7 @@ Entity {
mouseReleased(mouse);
}
onClicked: mouseClicked(mouse)
onPositionChanged: { currentPosition = Qt.point(mouse.x, mouse.y) }
onPositionChanged: { currentPosition.x = mouse.x; currentPosition.y = mouse.y }
onDoubleClicked: mouseDoubleClicked(mouse)
onWheel: {
var d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.2;