on xenial help sign in
more work
commit7c3c9c74cf5edf2f919d3bd16151627367d60786 authorMichael Zanetti <michael.zanetti@canonical.com> dateSat 2 Jul 2016, 04:02 (10 years ago) parentaafcc29
5 files changed+105−66
qml/Stages/ApplicationWindow.qml−11 qml/Stages/DecoratedWindow.qml+65−31 qml/Stages/DesktopStage.qml+37−24 qml/Stages/SpreadMaths.qml+2 tests/qmltests/CMakeLists.txt+1
qml/Stages/ApplicationWindow.qml−11
@@ -28,17 +28,6 @@ FocusScope {
2828 property bool orientationChangesEnabled: d.supportsSurfaceResize ? d.surfaceOldEnoughToBeResized : true
2929 readonly property string title: surface && surface.name !== "" ? surface.name : d.name
3030
31− // overridable from outside
32− property bool fullscreen: {
33− if (surface) {
34− return surface.state === Mir.FullscreenState;
35− } else if (application) {
36− return application.fullscreen;
37− } else {
38− return false;
39− }
40− }
41−
4231 // to be set from outside
4332 property QtObject surface
4433 property QtObject application
qml/Stages/DecoratedWindow.qml+65−31
@@ -22,31 +22,32 @@ FocusScope {
2222 id: root
2323
2424 implicitWidth: !counterRotate ? applicationWindow.implicitWidth : applicationWindow.implicitHeight
25− implicitHeight: visibleDecorationHeight + (!counterRotate ? applicationWindow.implicitHeight : applicationWindow.implicitWidth)
25+ implicitHeight: decorationHeight + (!counterRotate ? applicationWindow.implicitHeight : applicationWindow.implicitWidth)
2626
2727 property alias application: applicationWindow.application
2828 property alias surface: applicationWindow.surface
2929 property alias active: decoration.active
3030 readonly property alias title: applicationWindow.title
31− property alias fullscreen: applicationWindow.fullscreen
3231 property alias maximizeButtonShown: decoration.maximizeButtonShown
3332
34− // Whether we want it to sho in general
33+ // Changing this will actually add/remove a decoration, meaning, requestedHeight will take the decoration into account.
34+ property bool hasDecoration: true
35+ // This will temporarily show/hide the decoration without actually changing the surface's dimensions
3536 property bool showDecoration: true
36− // Whether it is actually shown. Even if showDecoration is true, this might be false for other reasons (e.g. app is fullscreened)
37− readonly property bool decorationShown: showDecoration && !fullscreen
38− property bool highlightShown: false
37+ property bool showHighlight: false
3938 property real shadowOpacity: 1
4039
4140 property real requestedWidth
4241 property real requestedHeight
42+ property bool scaleToPreview
43+ property int scaleToPreviewSize: units.gu(30)
4344
4445 property alias surfaceOrientationAngle: applicationWindow.surfaceOrientationAngle
45− readonly property real visibleDecorationHeight: root.decorationShown ? decoration.height : 0
46+ readonly property real decorationHeight: Math.min(d.visibleDecorationHeight, d.requestedDecorationHeight)
4647 readonly property bool counterRotate: surfaceOrientationAngle != 0 && surfaceOrientationAngle != 180
4748
4849 readonly property int minimumWidth: !counterRotate ? applicationWindow.minimumWidth : applicationWindow.minimumHeight
49− readonly property int minimumHeight: visibleDecorationHeight + (!counterRotate ? applicationWindow.minimumHeight : applicationWindow.minimumWidth)
50+ readonly property int minimumHeight: decorationHeight + (!counterRotate ? applicationWindow.minimumHeight : applicationWindow.minimumWidth)
5051 readonly property int maximumWidth: !counterRotate ? applicationWindow.maximumWidth : applicationWindow.maximumHeight
5152 readonly property int maximumHeight: (root.decorationShown && applicationWindow.maximumHeight > 0 ? decoration.height : 0)
5253 + (!counterRotate ? applicationWindow.maximumHeight : applicationWindow.maximumWidth)
@@ -62,29 +63,28 @@ FocusScope {
6263 signal minimizeClicked()
6364 signal decorationPressed()
6465
66+ QtObject {
67+ id: d
68+ property int requestedDecorationHeight: root.hasDecoration && root.hasDecoration ? decoration.height : 0
69+ Behavior on requestedDecorationHeight { UbuntuNumberAnimation { duration: priv.animationDuration } }
70+
71+ property int visibleDecorationHeight: root.showDecoration && root.hasDecoration ? decoration.height : 0
72+ Behavior on visibleDecorationHeight { UbuntuNumberAnimation { duration: priv.animationDuration } }
73+ }
74+
6575 Rectangle {
6676 id: selectionHighlight
6777 anchors.fill: parent
6878 anchors.margins: -units.gu(1)
6979 color: "white"
70− opacity: highlightShown ? 0.15 : 0
80+ opacity: showHighlight ? 0.15 : 0
7181 }
7282
7383 Rectangle {
7484 anchors { left: selectionHighlight.left; right: selectionHighlight.right; bottom: selectionHighlight.bottom; }
7585 height: units.dp(2)
7686 color: theme.palette.normal.focus
77− visible: highlightShown
78− }
79−
80− BorderImage {
81− anchors {
82− fill: root
83− margins: active ? -units.gu(2) : -units.gu(1.5)
84− }
85− source: "graphics/dropshadow2gu.sci"
86− opacity: root.shadowOpacity * .3
87− visible: !fullscreen
87+ visible: showHighlight
8888 }
8989
9090 WindowDecoration {
@@ -95,7 +95,10 @@ FocusScope {
9595 height: units.gu(3)
9696 width: root.width
9797 title: applicationWindow.title
98− visible: root.decorationShown
98+ opacity: root.hasDecoration && root.showDecoration ? 1 : 0
99+
100+ // FIXME: priv.animationDuration reaches out of context... neads cleanup before landing
101+ Behavior on opacity { UbuntuNumberAnimation { duration: priv.animationDuration } }
99102
100103 onCloseClicked: root.closeClicked();
101104 onMaximizeClicked: { root.decorationPressed(); root.maximizeClicked(); }
@@ -109,21 +112,44 @@ FocusScope {
109112 id: applicationWindow
110113 objectName: "appWindow"
111114 anchors.top: parent.top
112− anchors.topMargin: root.decorationShown ? decoration.height : 0
115+ anchors.topMargin: root.decorationHeight
113116 anchors.left: parent.left
114117 width: root.width
115118 height: root.height - anchors.topMargin
116− readonly property real requestedHeightMinusDecoration: root.requestedHeight - root.visibleDecorationHeight
117− requestedHeight: !counterRotate ? requestedHeightMinusDecoration : root.requestedWidth
118− requestedWidth: !counterRotate ? root.requestedWidth : requestedHeightMinusDecoration
119+ requestedHeight: !counterRotate ? root.requestedHeight - d.requestedDecorationHeight : root.requestedWidth
120+ requestedWidth: !counterRotate ? root.requestedWidth : root.requestedHeight - d.requestedDecorationHeight
121+ property int oldRequestedWidth: requestedWidth
122+ property int oldRequestedHeight: requestedHeight
123+ onRequestedWidthChanged: oldRequestedWidth = requestedWidth
124+ onRequestedHeightChanged: oldRequestedHeight = requestedHeight
119125 interactive: true
120126 focus: true
121127
122− Behavior on anchors.topMargin {
123− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
124− }
125−
126− transform: Rotation {
128+ property real itemScale: 1
129+ states: [
130+ State {
131+ name: "preview"; when: root.scaleToPreview
132+ PropertyChanges {
133+ target: applicationWindow;
134+ requestedWidth: applicationWindow.oldRequestedWidth
135+ requestedHeight: applicationWindow.oldRequestedHeight
136+ implicitWidth: root.scaleToPreviewSize
137+ implicitHeight: root.scaleToPreviewSize
138+ width: Math.min(root.scaleToPreviewSize, Math.min(applicationWindow.requestedHeight, applicationWindow.requestedWidth))
139+ height: Math.min(root.scaleToPreviewSize, Math.min(applicationWindow.requestedHeight, applicationWindow.requestedWidth))
140+ itemScale: 1.0 * root.scaleToPreviewSize / applicationWindow.width
141+ }
142+ }
143+ ]
144+ transitions: [
145+ Transition {
146+ from: "*"; to: "*"
147+ UbuntuNumberAnimation { properties: "width,height,implicitWidth,implicitHeight"; duration: priv.animationDuration }
148+ }
149+ ]
150+
151+ transform: [
152+ Rotation {
127153 readonly property int rotationAngle: applicationWindow.application &&
128154 applicationWindow.application.rotatesWindowContents
129155 ? ((360 - applicationWindow.surfaceOrientationAngle) % 360) : 0
@@ -140,6 +166,14 @@ FocusScope {
140166 else return 0;
141167 }
142168 angle: rotationAngle
143− }
169+ },
170+ Scale {
171+ xScale: applicationWindow.itemScale
172+ yScale: applicationWindow.itemScale
173+ }
174+
175+ ]
144176 }
177+
178+ Rectangle { anchors.fill: parent; color: "blue"; opacity: .3 }
145179}
qml/Stages/DesktopStage.qml+37−24
@@ -128,7 +128,7 @@ AbstractStage {
128128 property var foregroundMaximizedAppDelegate: null // for stuff like drop shadow and focusing maximized app by clicking panel
129129
130130 property bool goneToSpread: false
131− property int animationDuration: UbuntuAnimation.FastDuration// 4000//UbuntuAnimation.SleepyDuration
131+ property int animationDuration: /*UbuntuAnimation.FastDuration//*/ 4000//UbuntuAnimation.SleepyDuration
132132
133133 function updateForegroundMaximizedApp() {
134134 var found = false;
@@ -350,7 +350,7 @@ AbstractStage {
350350 readonly property bool maximizedHorizontally: windowState & WindowStateStorage.WindowStateMaximizedHorizontally
351351 readonly property bool maximizedVertically: windowState & WindowStateStorage.WindowStateMaximizedVertically
352352 readonly property bool minimized: windowState & WindowStateStorage.WindowStateMinimized
353− readonly property alias fullscreen: decoratedWindow.fullscreen
353+ readonly property bool fullscreen: state == "fullscreen"
354354
355355 property int windowState: WindowStateStorage.WindowStateNormal
356356 property bool animationsEnabled: true
@@ -569,16 +569,15 @@ AbstractStage {
569569 x: spreadMaths.animatedX
570570 y: spreadMaths.animatedY
571571 z: index
572− height: decoratedWindow.height + windowInfoItem.height + units.gu(2)
572+ height: spreadMaths.tileSize + windowInfoItem.height + units.gu(2)
573573 requestedWidth: decoratedWindow.oldRequestedWidth
574574 requestedHeight: decoratedWindow.oldRequestedHeight
575575 }
576576 PropertyChanges {
577577 target: decoratedWindow;
578578 showDecoration: false;
579− height: units.gu(40)
580− width: units.gu(40)
581579 angle: spreadMaths.animatedAngle
580+ scaleToPreview: true
582581 }
583582 PropertyChanges { target: inputBlocker; enabled: true }
584583 PropertyChanges { target: windowInfoItem; opacity: 1 }
@@ -618,7 +617,7 @@ AbstractStage {
618617 }
619618 PropertyChanges {
620619 target: decoratedWindow
621− showDecoration: false
620+ hasDecoration: false
622621 }
623622 PropertyChanges {
624623 target: resizeArea
@@ -638,14 +637,18 @@ AbstractStage {
638637 }
639638 },
640639 State {
641− name: "fullscreen"; when: decoratedWindow.fullscreen && !appDelegate.minimized
640+ name: "fullscreen"; when: surface ? surface.state === Mir.FullscreenState : application.fullscreen && !appDelegate.minimized
642641 PropertyChanges {
643642 target: appDelegate;
644− x: rotation == 0 ? 0 : (parent.width - width) / 2 + (shellOrientationAngle == 90 ? -PanelState.panelHeight : PanelState.panelHeight)
645− y: rotation == 0 ? -PanelState.panelHeight : (parent.height - height) / 2
643+ x: rotation == 0 ? 0 : (parent.width - width) / 2 + (shellOrientationAngle == 90 ? 0 : PanelState.panelHeight)
644+ y: rotation == 0 ? 0 : (parent.height - height) / 2
646645 requestedWidth: appContainer.width;
647646 requestedHeight: appContainer.height;
648647 }
648+ PropertyChanges {
649+ target: decoratedWindow
650+ hasDecoration: false
651+ }
649652 },
650653 State {
651654 name: "normal";
@@ -745,22 +748,22 @@ AbstractStage {
745748 },
746749 Transition {
747750 to: "spread"
748− PropertyAnimation { target: appDelegate; properties: "x,y,height"; duration: priv.animationDuration }
749− PropertyAnimation { target: decoratedWindow; properties: "width,height,angle"; duration: priv.animationDuration }
751+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,height"; duration: priv.animationDuration }
752+ UbuntuNumberAnimation { target: decoratedWindow; properties: "width,height,angle,baseScale"; duration: priv.animationDuration }
750753 },
751754 Transition {
752755 from: "spread"; to: "staged,normal"
753− PropertyAnimation { target: appDelegate; properties: "x,y,height"; duration: priv.animationDuration }
754− PropertyAnimation { target: decoratedWindow; properties: "angle,width,height"; duration: priv.animationDuration }
756+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,height"; duration: priv.animationDuration }
757+ UbuntuNumberAnimation { target: decoratedWindow; properties: "angle,width,height,baseScale"; duration: priv.animationDuration }
755758 },
756759 Transition {
757760 from: "normal"; to: "staged";
758− PropertyAnimation { target: appDelegate; properties: "x,y,requestedWidth,requestedHeight"; duration: priv.animationDuration }
761+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,requestedWidth,requestedHeight"; duration: priv.animationDuration }
759762 },
760763 Transition {
761764 to: "staged"
762− PropertyAnimation { target: appDelegate; properties: "x,y"; duration: priv.animationDuration }
763− PropertyAnimation { target: appDelegate; properties: "requestedWidth,requestedHeight"; duration: priv.animationDuration }
765+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y"; duration: priv.animationDuration }
766+ UbuntuNumberAnimation { target: appDelegate; properties: "requestedWidth,requestedHeight"; duration: priv.animationDuration }
764767 }
765768
766769 ]
@@ -857,19 +860,29 @@ AbstractStage {
857860 property real angle: 0
858861 property real itemScale: 1
859862 transform: [
860−// Scale {
861−// origin.x: itemScaleOriginX
862−// origin.y: itemScaleOriginY
863−// xScale: itemScale
864−// yScale: itemScale
865−// },
863+ Scale {
864+ origin.x: itemScaleOriginX
865+ origin.y: itemScaleOriginY
866+ xScale: decoratedWindow.itemScale
867+ yScale: decoratedWindow.itemScale
868+ },
866869 Rotation {
867− origin { x: 0; y: (decoratedWindow.height - (decoratedWindow.height * decoratedWindow.itemScale / 2)) }
870+ origin { x: 0; y: (decoratedWindow.height * decoratedWindow.itemScale / 2) }
868871 axis { x: 0; y: 1; z: 0 }
869872 angle: decoratedWindow.angle
870873 }
871874 ]
872875 }
876+ BorderImage {
877+ anchors {
878+ fill: decoratedWindow
879+ margins: /*active ? -units.gu(2) : */-units.gu(1.5)
880+ }
881+ source: "graphics/dropshadow2gu.sci"
882+ opacity: root.shadowOpacity * .3
883+ visible: false
884+ }
885+
873886
874887 WindowControlsOverlay {
875888 id: touchControls
@@ -902,7 +915,7 @@ AbstractStage {
902915
903916 WindowInfoItem {
904917 id: windowInfoItem
905− anchors { left: parent.left; bottom: parent.bottom }
918+ anchors { left: parent.left; top: decoratedWindow.bottom; topMargin: units.gu(1) }
906919 title: decoratedWindow.title
907920 iconSource: model.application.icon
908921 opacity: 0
qml/Stages/SpreadMaths.qml+2
@@ -67,6 +67,8 @@ Item {
6767 readonly property real middleSectionProgress: (linearX - margins - foldingAreaWidth) / (flickableWidth - (margins + foldingAreaWidth) * 2)
6868
6969 // Output
70+ readonly property int tileSize: units.gu(40)
71+
7072 readonly property int animatedX: {
7173 if (itemIndex == 0) print("leftFoldingAreaProgress", leftFoldingAreaProgress, "rightFoldingAreaProgress", rightFoldingAreaProgress)
7274 if (leftFoldingAreaProgress > 4) { // Stop it at the edge
tests/qmltests/CMakeLists.txt+1
@@ -94,6 +94,7 @@ add_unity8_qmltest(Stages SurfaceContainer)
9494add_unity8_qmltest(Stages TabletStage)
9595add_unity8_qmltest(Stages WindowResizeArea)
9696add_unity8_qmltest(Stages Splash)
97+add_unity8_qmltest(Stages DecoratedWindow)
9798add_unity8_qmltest(Tutorial Tutorial LIGHTDM)
9899add_unity8_qmltest(Wizard Wizard ENVIRONMENT "OXIDE_NO_SANDBOX=1")
99100add_unity8_qmltest(utils/Unity/Test UnityTest)