18
18
import Ubuntu.Components 1.3
19
19
import Unity.Application 0.1
20
import "Spread/MathUtils.js" as MathUtils
24
width: !counterRotate ? applicationWindow.width : applicationWindow.height
25
height: visibleDecorationHeight + (!counterRotate ? applicationWindow.height : applicationWindow.width)
25
// The DecoratedWindow takes requestedWidth/requestedHeight and asks its surface to be resized to that
26
// (minus the window decoration size in case hasDecoration and showDecoration are true)
27
// The surface might not be able to resize to the requested values. It will return its actual size
28
// in implicitWidth/implicitHeight.
27
30
property alias application: applicationWindow.application
28
31
property alias surface: applicationWindow.surface
29
32
readonly property alias focusedSurface: applicationWindow.focusedSurface
30
33
property alias active: decoration.active
31
34
readonly property alias title: applicationWindow.title
32
property alias fullscreen: applicationWindow.fullscreen
33
35
property alias maximizeButtonShown: decoration.maximizeButtonShown
36
property alias interactive: applicationWindow.interactive
37
readonly property alias orientationChangesEnabled: applicationWindow.orientationChangesEnabled
35
readonly property bool decorationShown: !fullscreen
36
property bool highlightShown: false
37
property real shadowOpacity: 1
39
// Changing this will actually add/remove a decoration, meaning, requestedHeight will take the decoration into account.
40
property bool hasDecoration: true
41
// This will temporarily show/hide the decoration without actually changing the surface's dimensions
42
property real showDecoration: 1
43
property bool animateDecoration: false
44
property bool showHighlight: false
45
property int highlightSize: units.gu(1)
46
property real shadowOpacity: 0
47
property bool darkening: false
39
49
property real requestedWidth
40
50
property real requestedHeight
51
property real scaleToPreviewProgress: 0
52
property int scaleToPreviewSize: units.gu(30)
42
54
property alias surfaceOrientationAngle: applicationWindow.surfaceOrientationAngle
43
readonly property real visibleDecorationHeight: root.decorationShown ? decoration.height : 0
55
readonly property real decorationHeight: Math.min(d.visibleDecorationHeight, d.requestedDecorationHeight)
44
56
readonly property bool counterRotate: surfaceOrientationAngle != 0 && surfaceOrientationAngle != 180
46
58
readonly property int minimumWidth: !counterRotate ? applicationWindow.minimumWidth : applicationWindow.minimumHeight
47
readonly property int minimumHeight: visibleDecorationHeight + (!counterRotate ? applicationWindow.minimumHeight : applicationWindow.minimumWidth)
59
readonly property int minimumHeight: decorationHeight + (!counterRotate ? applicationWindow.minimumHeight : applicationWindow.minimumWidth)
48
60
readonly property int maximumWidth: !counterRotate ? applicationWindow.maximumWidth : applicationWindow.maximumHeight
49
61
readonly property int maximumHeight: (root.decorationShown && applicationWindow.maximumHeight > 0 ? decoration.height : 0)
50
62
+ (!counterRotate ? applicationWindow.maximumHeight : applicationWindow.maximumWidth)
66
78
signal decorationPressed()
67
79
signal decorationReleased()
83
property int requestedDecorationHeight: root.hasDecoration ? decoration.height : 0
84
Behavior on requestedDecorationHeight { enabled: root.animateDecoration; UbuntuNumberAnimation { } }
86
property int visibleDecorationHeight: root.hasDecoration ? root.showDecoration * decoration.height : 0
87
Behavior on visibleDecorationHeight { enabled: root.animateDecoration; UbuntuNumberAnimation { } }
93
name: "normal"; when: root.scaleToPreviewProgress <= 0 && root.application.state === ApplicationInfoInterface.Running
96
implicitWidth: counterRotate ? applicationWindow.implicitHeight : applicationWindow.implicitWidth
97
implicitHeight: root.decorationHeight + (counterRotate ? applicationWindow.implicitWidth: applicationWindow.implicitHeight)
101
name: "normalSuspended"; when: root.scaleToPreviewProgress <= 0 && root.application.state !== ApplicationInfoInterface.Running
105
implicitWidth: counterRotate ? applicationWindow.requestedHeight : applicationWindow.requestedWidth
106
implicitHeight: root.decorationHeight + (counterRotate ? applicationWindow.requestedWidth: applicationWindow.requestedHeight)
110
name: "preview"; when: root.scaleToPreviewProgress > 0
113
implicitWidth: MathUtils.linearAnimation(0, 1, applicationWindow.oldRequestedWidth, root.scaleToPreviewSize, root.scaleToPreviewProgress)
114
implicitHeight: MathUtils.linearAnimation(0, 1, applicationWindow.oldRequestedHeight, root.scaleToPreviewSize, root.scaleToPreviewProgress)
117
target: applicationWindow;
118
requestedWidth: applicationWindow.oldRequestedWidth
119
requestedHeight: applicationWindow.oldRequestedHeight
120
width: MathUtils.linearAnimation(0, 1, applicationWindow.oldRequestedWidth, applicationWindow.minSize, root.scaleToPreviewProgress)
121
height: MathUtils.linearAnimation(0, 1, applicationWindow.oldRequestedHeight, applicationWindow.minSize, root.scaleToPreviewProgress)
122
itemScale: root.implicitWidth / width
70
129
id: selectionHighlight
130
objectName: "selectionHighlight"
71
131
anchors.fill: parent
72
anchors.margins: -units.gu(1)
132
anchors.margins: -root.highlightSize
74
opacity: highlightShown ? 0.15 : 0
78
anchors { left: selectionHighlight.left; right: selectionHighlight.right; bottom: selectionHighlight.bottom; }
80
color: theme.palette.normal.focus
81
visible: highlightShown
134
opacity: showHighlight ? 0.55 : 0
141
left: parent.left; top: parent.top; right: parent.right
87
142
margins: active ? -units.gu(2) : -units.gu(1.5)
89
source: "graphics/dropshadow2gu.sci"
90
opacity: root.shadowOpacity * .3
144
height: Math.min(applicationWindow.implicitHeight, applicationWindow.height) * applicationWindow.itemScale
145
+ root.decorationHeight * Math.min(1, root.showDecoration) + (active ? units.gu(4) : units.gu(3))
146
source: "../graphics/dropshadow2gu.sci"
147
opacity: root.shadowOpacity
94
150
WindowDecoration {
152
target: root.parent || null
97
153
objectName: "appWindowDecoration"
98
154
anchors { left: parent.left; top: parent.top; right: parent.right }
99
155
height: units.gu(3)
100
156
width: root.width
101
157
title: applicationWindow.title
102
visible: root.decorationShown
158
opacity: root.hasDecoration ? Math.min(1, root.showDecoration) : 0
160
Behavior on opacity { UbuntuNumberAnimation { } }
104
162
onCloseClicked: root.closeClicked();
105
163
onMaximizeClicked: { root.decorationPressed(); root.maximizeClicked(); }
126
184
ApplicationWindow {
127
185
id: applicationWindow
128
186
objectName: "appWindow"
187
anchors.left: parent.left
129
188
anchors.top: parent.top
130
anchors.topMargin: decoration.height
131
anchors.left: parent.left
132
readonly property real requestedHeightMinusDecoration: root.requestedHeight - root.visibleDecorationHeight
133
requestedHeight: !counterRotate ? requestedHeightMinusDecoration : root.requestedWidth
134
requestedWidth: !counterRotate ? root.requestedWidth : requestedHeightMinusDecoration
189
anchors.topMargin: root.decorationHeight * Math.min(1, root.showDecoration)
191
height: implicitHeight
192
requestedHeight: !counterRotate ? root.requestedHeight - d.requestedDecorationHeight : root.requestedWidth
193
requestedWidth: !counterRotate ? root.requestedWidth : root.requestedHeight - d.requestedDecorationHeight
194
property int oldRequestedWidth: requestedWidth
195
property int oldRequestedHeight: requestedHeight
196
onRequestedWidthChanged: oldRequestedWidth = requestedWidth
197
onRequestedHeightChanged: oldRequestedHeight = requestedHeight
138
transform: Rotation {
200
property real itemScale: 1
201
property real minSize: Math.min(root.scaleToPreviewSize, Math.min(requestedHeight, Math.min(requestedWidth, Math.min(implicitHeight, implicitWidth))))
205
id: rotationTransform
139
206
readonly property int rotationAngle: applicationWindow.application &&
140
207
applicationWindow.application.rotatesWindowContents
141
208
? ((360 - applicationWindow.surfaceOrientationAngle) % 360) : 0