From 850a561a83b5da4a620b5bba1812919d58600c56 Mon Sep 17 00:00:00 2001 From: Patrick Burke Date: Wed, 16 Nov 2011 13:13:57 +1000 Subject: ModelTweaker: viewport transitions implemented Change-Id: If2169810994418a08eed4cb2aa53200eb65d55c2 Reviewed-by: Sarah Jane Smith --- util/qt3d/modeltweak/qml/BlenderValueSlider.qml | 1 - util/qt3d/modeltweak/qml/ModelTweak.qml | 44 ++++++++++++++++++++----- util/qt3d/modeltweak/qml/ModelViewport.qml | 24 ++++++++++---- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/util/qt3d/modeltweak/qml/BlenderValueSlider.qml b/util/qt3d/modeltweak/qml/BlenderValueSlider.qml index 9895a354..67e77506 100644 --- a/util/qt3d/modeltweak/qml/BlenderValueSlider.qml +++ b/util/qt3d/modeltweak/qml/BlenderValueSlider.qml @@ -18,7 +18,6 @@ Item { Rectangle { id: rect - anchors.right: parent.right radius: 8 border.width: 1 border.color: "#191919" diff --git a/util/qt3d/modeltweak/qml/ModelTweak.qml b/util/qt3d/modeltweak/qml/ModelTweak.qml index 63dd8daa..d4426d4f 100644 --- a/util/qt3d/modeltweak/qml/ModelTweak.qml +++ b/util/qt3d/modeltweak/qml/ModelTweak.qml @@ -94,10 +94,10 @@ Rectangle { ModelViewport { id: mvpZY - visible: !mvpXY.isBig && !mvpXZ.isBig ? true : false - x: isBig ? 0 : 0; - y: isBig ? 0 : 0; + x: 0; + y: 0; camera.eye: Qt.vector3d(10, 0, 0); + stateName: "ZYMaximised" function translateMouseX(mouse) { transformTranslate.translate = @@ -133,10 +133,10 @@ Rectangle { ModelViewport { id: mvpXY - visible: !mvpZY.isBig && !mvpXZ.isBig ? true : false - x: isBig ? 0 : parent.width/2 - y: isBig ? 0 : 0; + x: parent.width/2 + y: 0; camera.eye: Qt.vector3d(0, 0, 10); + stateName: "XYMaximised" function translateMouseX(mouse) { transformTranslate.translate = @@ -172,11 +172,11 @@ Rectangle { ModelViewport { id: mvpXZ - visible: !mvpZY.isBig && !mvpXY.isBig ? true : false - x: isBig ? 0 : parent.width/2; - y: isBig ? 0 : parent.height/2; + x: parent.width/2; + y: parent.height/2; camera.eye: Qt.vector3d(0, 10, 0); camera.upVector: Qt.vector3d(0, 0, -1); + stateName: "XZMaximised" function translateMouseX(mouse) { transformTranslate.translate = @@ -236,4 +236,30 @@ Rectangle { id: helpOverlay visible: false } + + states: [ + State { + name: "3Views" + }, + State { + name: "ZYMaximised" + PropertyChanges { target: mvpZY; x: 0; y: 0; width: mainwindow.width; height: mainwindow.height; } + PropertyChanges { target: mvpXY; x: mainwindow.width; y: 0; width: 0; height: mainwindow.height/2; } + PropertyChanges { target: mvpXZ; x: mainwindow.width; y: mainwindow.height; width: 0; height: 0; } + }, + State { + name: "XYMaximised" + PropertyChanges { target: mvpZY; x: 0; y: 0; width: 0; height: mainwindow.height/2; } + PropertyChanges { target: mvpXY; x: 0; y: 0; width: mainwindow.width; height: mainwindow.height; } + PropertyChanges { target: mvpXZ; x: mainwindow.width/2; y: mainwindow.height; width: mainwindow.width/2; height: 0; } + }, + State { + name: "XZMaximised" + PropertyChanges { target: mvpZY; x: 0; y: 0; width: 0; height: 0; } + PropertyChanges { target: mvpXY; x: mainwindow.width/2; y: 0; width: mainwindow.width/2; height: 0; } + PropertyChanges { target: mvpXZ; x: 0; y: 0; width: mainwindow.width; height: mainwindow.height; } + } + ] + + state: "3Views" } diff --git a/util/qt3d/modeltweak/qml/ModelViewport.qml b/util/qt3d/modeltweak/qml/ModelViewport.qml index 3a812cb9..c633898e 100644 --- a/util/qt3d/modeltweak/qml/ModelViewport.qml +++ b/util/qt3d/modeltweak/qml/ModelViewport.qml @@ -3,14 +3,12 @@ import Qt3D 1.0 Rectangle { id: view - width: isBig ? parent.width : parent.width/2; - height: isBig ? parent.height : parent.height/2 + width: parent.width/2; + height: parent.height/2 color: parent.color border.color: parent.border.color - property bool isBig: false; - property alias itemPosition: mainItem.position; property alias itemScale: mainItem.scale; property alias camera: viewport.camera @@ -45,6 +43,13 @@ Rectangle { property double rotateSensitivity: 8; property double scaleSensitivity: 32; + property string stateName + + Behavior on x { NumberAnimation { duration: 300 } } + Behavior on y { NumberAnimation { duration: 300 } } + Behavior on width { NumberAnimation { duration: 300 } } + Behavior on height { NumberAnimation { duration: 300 } } + Viewport { id: viewport anchors.fill: parent @@ -140,12 +145,19 @@ Rectangle { Image { id: img - source: view.isBig ? "images/shrink.png" : "images/grow.png" + source: mainwindow.state !== "3Views" ? "images/shrink.png" : "images/grow.png" x: 2 y: 2 MouseArea { anchors.fill: parent - onClicked: isBig = !isBig + onClicked: { + if (view.stateName) { + if(mainwindow.state !== "3Views") + mainwindow.state = "3Views" + else + mainwindow.state = view.stateName + } + } } } } -- cgit v1.2.3