@@ -22,31 +22,32 @@ FocusScope {
24 implicitWidth: !counterRotate ? applicationWindow.implicitWidth : applicationWindow.implicitHeight
24 implicitWidth: !counterRotate ? applicationWindow.implicitWidth : applicationWindow.implicitHeight
25− implicitHeight: visibleDecorationHeight + (!counterRotate ? applicationWindow.implicitHeight : applicationWindow.implicitWidth)
25+ implicitHeight: decorationHeight + (!counterRotate ? applicationWindow.implicitHeight : applicationWindow.implicitWidth)
27 property alias application: applicationWindow.application
27 property alias application: applicationWindow.application
28 property alias surface: applicationWindow.surface
28 property alias surface: applicationWindow.surface
29 property alias active: decoration.active
29 property alias active: decoration.active
30 readonly property alias title: applicationWindow.title
30 readonly property alias title: applicationWindow.title
31− property alias fullscreen: applicationWindow.fullscreen
32 property alias maximizeButtonShown: decoration.maximizeButtonShown
31 property alias maximizeButtonShown: decoration.maximizeButtonShown
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
35 property bool showDecoration: true
36 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+ property bool showHighlight: false
37− readonly property bool decorationShown: showDecoration && !fullscreen
38− property bool highlightShown: false
39 property real shadowOpacity: 1
38 property real shadowOpacity: 1
41 property real requestedWidth
40 property real requestedWidth
42 property real requestedHeight
41 property real requestedHeight
42+ property bool scaleToPreview
43+ property int scaleToPreviewSize: units.gu(30)
44 property alias surfaceOrientationAngle: applicationWindow.surfaceOrientationAngle
45 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)
46 readonly property bool counterRotate: surfaceOrientationAngle != 0 && surfaceOrientationAngle != 180
47 readonly property bool counterRotate: surfaceOrientationAngle != 0 && surfaceOrientationAngle != 180
48 readonly property int minimumWidth: !counterRotate ? applicationWindow.minimumWidth : applicationWindow.minimumHeight
49 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)
50 readonly property int maximumWidth: !counterRotate ? applicationWindow.maximumWidth : applicationWindow.maximumHeight
51 readonly property int maximumWidth: !counterRotate ? applicationWindow.maximumWidth : applicationWindow.maximumHeight
51 readonly property int maximumHeight: (root.decorationShown && applicationWindow.maximumHeight > 0 ? decoration.height : 0)
52 readonly property int maximumHeight: (root.decorationShown && applicationWindow.maximumHeight > 0 ? decoration.height : 0)
52 + (!counterRotate ? applicationWindow.maximumHeight : applicationWindow.maximumWidth)
53 + (!counterRotate ? applicationWindow.maximumHeight : applicationWindow.maximumWidth)
@@ -62,29 +63,28 @@ FocusScope {
62 signal minimizeClicked()
63 signal minimizeClicked()
63 signal decorationPressed()
64 signal decorationPressed()
68+ property int requestedDecorationHeight: root.hasDecoration && root.hasDecoration ? decoration.height : 0
69+ Behavior on requestedDecorationHeight { UbuntuNumberAnimation { duration: priv.animationDuration } }
71+ property int visibleDecorationHeight: root.showDecoration && root.hasDecoration ? decoration.height : 0
72+ Behavior on visibleDecorationHeight { UbuntuNumberAnimation { duration: priv.animationDuration } }
65 Rectangle {
75 Rectangle {
66 id: selectionHighlight
76 id: selectionHighlight
67 anchors.fill: parent
77 anchors.fill: parent
68 anchors.margins: -units.gu(1)
78 anchors.margins: -units.gu(1)
69 color: "white"
79 color: "white"
70− opacity: highlightShown ? 0.15 : 0
80+ opacity: showHighlight ? 0.15 : 0
73 Rectangle {
83 Rectangle {
74 anchors { left: selectionHighlight.left; right: selectionHighlight.right; bottom: selectionHighlight.bottom; }
84 anchors { left: selectionHighlight.left; right: selectionHighlight.right; bottom: selectionHighlight.bottom; }
75 height: units.dp(2)
85 height: units.dp(2)
76 color: theme.palette.normal.focus
86 color: theme.palette.normal.focus
77− visible: highlightShown
87+ visible: showHighlight
83− margins: active ? -units.gu(2) : -units.gu(1.5)
85− source: "graphics/dropshadow2gu.sci"
86− opacity: root.shadowOpacity * .3
90 WindowDecoration {
90 WindowDecoration {
@@ -95,7 +95,10 @@ FocusScope {
95 height: units.gu(3)
95 height: units.gu(3)
96 width: root.width
96 width: root.width
97 title: applicationWindow.title
97 title: applicationWindow.title
98− visible: root.decorationShown
98+ opacity: root.hasDecoration && root.showDecoration ? 1 : 0
100+ // FIXME: priv.animationDuration reaches out of context... neads cleanup before landing
101+ Behavior on opacity { UbuntuNumberAnimation { duration: priv.animationDuration } }
100 onCloseClicked: root.closeClicked();
103 onCloseClicked: root.closeClicked();
101 onMaximizeClicked: { root.decorationPressed(); root.maximizeClicked(); }
104 onMaximizeClicked: { root.decorationPressed(); root.maximizeClicked(); }
@@ -109,21 +112,44 @@ FocusScope {
109 id: applicationWindow
112 id: applicationWindow
110 objectName: "appWindow"
113 objectName: "appWindow"
111 anchors.top: parent.top
114 anchors.top: parent.top
112− anchors.topMargin: root.decorationShown ? decoration.height : 0
115+ anchors.topMargin: root.decorationHeight
113 anchors.left: parent.left
116 anchors.left: parent.left
114 width: root.width
117 width: root.width
115 height: root.height - anchors.topMargin
118 height: root.height - anchors.topMargin
116− readonly property real requestedHeightMinusDecoration: root.requestedHeight - root.visibleDecorationHeight
119+ requestedHeight: !counterRotate ? root.requestedHeight - d.requestedDecorationHeight : root.requestedWidth
117− requestedHeight: !counterRotate ? requestedHeightMinusDecoration : root.requestedWidth
120+ requestedWidth: !counterRotate ? root.requestedWidth : root.requestedHeight - d.requestedDecorationHeight
118− requestedWidth: !counterRotate ? root.requestedWidth : requestedHeightMinusDecoration
121+ property int oldRequestedWidth: requestedWidth
122+ property int oldRequestedHeight: requestedHeight
123+ onRequestedWidthChanged: oldRequestedWidth = requestedWidth
124+ onRequestedHeightChanged: oldRequestedHeight = requestedHeight
119 interactive: true
125 interactive: true
120 focus: true
126 focus: true
122− Behavior on anchors.topMargin {
128+ property real itemScale: 1
123− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
129+ states: [
131+ name: "preview"; when: root.scaleToPreview
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
147+ UbuntuNumberAnimation { properties: "width,height,implicitWidth,implicitHeight"; duration: priv.animationDuration }
126− transform: Rotation {
151+ transform: [
127 readonly property int rotationAngle: applicationWindow.application &&
153 readonly property int rotationAngle: applicationWindow.application &&
128 applicationWindow.application.rotatesWindowContents
154 applicationWindow.application.rotatesWindowContents
129 ? ((360 - applicationWindow.surfaceOrientationAngle) % 360) : 0
155 ? ((360 - applicationWindow.surfaceOrientationAngle) % 360) : 0
@@ -140,6 +166,14 @@ FocusScope {
140 else return 0;
166 else return 0;
142 angle: rotationAngle
168 angle: rotationAngle
171+ xScale: applicationWindow.itemScale
172+ yScale: applicationWindow.itemScale
178+ Rectangle { anchors.fill: parent; color: "blue"; opacity: .3 }