2 * Copyright (C) 2014-2016 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import Ubuntu.Components 1.3
19 import Unity.Application 0.1
24 width: !counterRotate ? applicationWindow.width : applicationWindow.height
25 height: visibleDecorationHeight + (!counterRotate ? applicationWindow.height : applicationWindow.width)
27 property alias application: applicationWindow.application
28 property alias surface: applicationWindow.surface
29 property alias active: decoration.active
30 readonly property alias title: applicationWindow.title
31 property alias fullscreen: applicationWindow.fullscreen
32 property alias maximizeButtonShown: decoration.maximizeButtonShown
34 readonly property bool decorationShown: !fullscreen
35 property bool highlightShown: false
36 property real shadowOpacity: 1
38 property real requestedWidth
39 property real requestedHeight
41 property alias surfaceOrientationAngle: applicationWindow.surfaceOrientationAngle
42 readonly property real visibleDecorationHeight: root.decorationShown ? decoration.height : 0
43 readonly property bool counterRotate: surfaceOrientationAngle != 0 && surfaceOrientationAngle != 180
45 readonly property int minimumWidth: !counterRotate ? applicationWindow.minimumWidth : applicationWindow.minimumHeight
46 readonly property int minimumHeight: visibleDecorationHeight + (!counterRotate ? applicationWindow.minimumHeight : applicationWindow.minimumWidth)
47 readonly property int maximumWidth: !counterRotate ? applicationWindow.maximumWidth : applicationWindow.maximumHeight
48 readonly property int maximumHeight: (root.decorationShown && applicationWindow.maximumHeight > 0 ? decoration.height : 0)
49 + (!counterRotate ? applicationWindow.maximumHeight : applicationWindow.maximumWidth)
50 readonly property int widthIncrement: !counterRotate ? applicationWindow.widthIncrement : applicationWindow.heightIncrement
51 readonly property int heightIncrement: !counterRotate ? applicationWindow.heightIncrement : applicationWindow.widthIncrement
53 property alias overlayShown: decoration.overlayShown
56 signal maximizeClicked()
57 signal maximizeHorizontallyClicked()
58 signal maximizeVerticallyClicked()
59 signal minimizeClicked()
60 signal decorationPressed()
63 id: selectionHighlight
65 anchors.margins: -units.gu(1)
67 opacity: highlightShown ? 0.15 : 0
71 anchors { left: selectionHighlight.left; right: selectionHighlight.right; bottom: selectionHighlight.bottom; }
73 color: theme.palette.normal.focus
74 visible: highlightShown
80 margins: active ? -units.gu(2) : -units.gu(1.5)
82 source: "graphics/dropshadow2gu.sci"
83 opacity: root.shadowOpacity * .3
90 objectName: "appWindowDecoration"
91 anchors { left: parent.left; top: parent.top; right: parent.right }
94 title: applicationWindow.title
95 visible: root.decorationShown
97 onCloseClicked: root.closeClicked();
98 onMaximizeClicked: { root.decorationPressed(); root.maximizeClicked(); }
99 onMaximizeHorizontallyClicked: { root.decorationPressed(); root.maximizeHorizontallyClicked(); }
100 onMaximizeVerticallyClicked: { root.decorationPressed(); root.maximizeVerticallyClicked(); }
101 onMinimizeClicked: root.minimizeClicked();
102 onPressed: root.decorationPressed();
106 id: applicationWindow
107 objectName: "appWindow"
108 anchors.top: parent.top
109 anchors.topMargin: decoration.height
110 anchors.left: parent.left
111 readonly property real requestedHeightMinusDecoration: root.requestedHeight - root.visibleDecorationHeight
112 requestedHeight: !counterRotate ? requestedHeightMinusDecoration : root.requestedWidth
113 requestedWidth: !counterRotate ? root.requestedWidth : requestedHeightMinusDecoration
117 transform: Rotation {
118 readonly property int rotationAngle: applicationWindow.application &&
119 applicationWindow.application.rotatesWindowContents
120 ? ((360 - applicationWindow.surfaceOrientationAngle) % 360) : 0
122 if (rotationAngle == 90) return applicationWindow.height / 2;
123 else if (rotationAngle == 270) return applicationWindow.width / 2;
124 else if (rotationAngle == 180) return applicationWindow.width / 2;
128 if (rotationAngle == 90) return applicationWindow.height / 2;
129 else if (rotationAngle == 270) return applicationWindow.width / 2;
130 else if (rotationAngle == 180) return applicationWindow.height / 2;